CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

volScalarField to power of constant

Register Blogs Community New Posts Updated Threads Search

Like Tree8Likes
  • 7 Post By PicklER
  • 1 Post By ngj

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 13, 2014, 07:34
Default volScalarField to power of constant
  #1
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 11
PicklER is on a distinguished road
Hello (my first post)

I want to calculate:

rS=a0*P^rbn

in OpenFOAM, for a modified version of rhoCentralFoam. Where:

rS (0 1 -1 0 0 0 0) speed (m/s) volScalarField created by createFields

a0 (-1 2 1 0 0 0 0) read from thermophysicalProperties in test case as dimensionedScalar

P (1 -1 -2 0 0 0 0) pressure (kg/(ms^2)) created by createFields

rbn read from thermophysicalProperties in test case as dimensionedScalar, but is dimensionless and is some constant.

If I multiply a0 with P, then the dimensions change to (0 1 -1 0 0 0 0), which is correct for rS (0 1 -1 0 0 0 0) speed (m/s) volScalarField.

My problem is when I do P^rbn by using pow(P,rbn). Then the dimensions are altered.

My question: Is there a way to take a volScalarField such as P, to the power of a dimensionless scalar such as rbn without changing the dimensions??

Kind regards
PicklER is offline   Reply With Quote

Old   August 19, 2014, 03:11
Default
  #2
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 11
PicklER is on a distinguished road
I got a way to do this:

Store the dimensions of "p" as arDims
dimensionSet arDims(p.dimensions());

Make "p" dimensionless
p.dimensions().reset(dimless);

Perform calculation (resulting in desired dimension) (0 1 -1 0 0 0 0)
ar = a0*pow(p,rbn);

Restore the dimensions of "p".
p.dimensions().reset(arDims);

Hope this will help someone.
Vrede
PicklER is offline   Reply With Quote

Old   August 21, 2014, 08:42
Default
  #3
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
Have you tried to use: p.value()
This should give you the dimensionless values of the pressure field.
jherb is offline   Reply With Quote

Old   August 21, 2014, 13:59
Default
  #4
Member
 
Join Date: Jul 2014
Posts: 39
Rep Power: 11
PicklER is on a distinguished road
Hi jherb

Yes, I have tried "p.value()" (result below) and "p.val()", just to make sure.

Code:
srmFoamLam.C: In function ‘int main(int, char**)’:
srmFoamLam.C:88:23: error: ‘Foam::volScalarField’ has no member named ‘value’
  Info << "p.val "<< p.value() << endl;
                       ^
Thanks for idea though
Vrede
PicklER is offline   Reply With Quote

Old   August 21, 2014, 15:47
Default
  #5
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hallo,

One approach would be to do the following:

Code:
scalar exponent = 1.5;

// Perform on the internal part of the field
p.internalField() = Foam::pow(p.internalField(), exponent);

// Perform on the boundaries
forAll (p.boundaryField(), patchi)
{
    scalarField& pw = p.boundaryField()[patchi];
    pw = Foam::pow(pw, exponent);
}

p.correctBoundaryConditions();
Kind regards,

Niels
Luttappy likes this.
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   August 22, 2014, 15:44
Default
  #6
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
Ok, googling I found: http://www.cfd-online.com/Forums/ope...tml#post476693

The correct method seems to be field()
jherb is offline   Reply With Quote

Reply

Tags
constant), pow(volscalarfield


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
make a dimensionedScalar to be volScalarField sharonyue OpenFOAM Programming & Development 4 April 2, 2014 05:44
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 18:44
CGNS lib and Fortran compiler manaliac Main CFD Forum 2 November 29, 2010 06:25
Really big problems when creating own materials da Jop FLUENT 0 June 28, 2007 11:15


All times are GMT -4. The time now is 00:36.