|
[Sponsors] |
August 13, 2014, 07:34 |
volScalarField to power of constant
|
#1 |
Member
Join Date: Jul 2014
Posts: 39
Rep Power: 11 |
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 |
|
August 19, 2014, 03:11 |
|
#2 |
Member
Join Date: Jul 2014
Posts: 39
Rep Power: 11 |
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 |
|
August 21, 2014, 08:42 |
|
#3 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Have you tried to use: p.value()
This should give you the dimensionless values of the pressure field. |
|
August 21, 2014, 13:59 |
|
#4 |
Member
Join Date: Jul 2014
Posts: 39
Rep Power: 11 |
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; ^ Vrede |
|
August 21, 2014, 15:47 |
|
#5 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
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(); Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
August 22, 2014, 15:44 |
|
#6 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Ok, googling I found: http://www.cfd-online.com/Forums/ope...tml#post476693
The correct method seems to be field() |
|
Tags |
constant), pow(volscalarfield |
|
|
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 |