CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to define field in createFields.H fine in OF23x (https://www.cfd-online.com/Forums/openfoam-programming-development/156901-how-define-field-createfields-h-fine-of23x.html)

Gitesh P July 15, 2015 04:25

How to define field in createFields.H fine in OF23x
 
Hello,

I am trying to define heat transfer coefficient in createFields.H file in twoPhaseEulerFoam solver of OF23x. Can any suggest how I can do that?

Regrads,
GP

T.D. July 16, 2015 07:37

Hi,


Two methods: as a "dimensionedScalar" or as a "volScalarField"
1) First Method:

in the file createField.H add:

///////////////////////////////////////////////////
dimensionedScalar h
(
transportProperties.lookup("h")
);
///////////////////////////////////////////////////
and then you need to define its value with dimensions in
the "transportProperties" file in the case/constant folder

2) sencond Method:

in the file createField.H add:
///////////////////////////////////////////////////
volScalarField h
(
IOobject
(
"h",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("h",dimensionSet(......),scalar( "your value"))
);
///////////////////////////////////////////////////
Note that "NO_READ" must be changed to "MUSt_READ" based
on your requirements.

Don't Forget to recompile the solver with "wmake" command in terminal.

Have Fun :)

Regards,
T.D.

Quote:

Originally Posted by Gitesh P (Post 555521)
Hello,

I am trying to define heat transfer coefficient in createFields.H file in twoPhaseEulerFoam solver of OF23x. Can any suggest how I can do that?

Regrads,
GP


Gitesh P July 20, 2015 04:22

Hello,

Thank you very much for your help. Now I am able to print the fields what I want. Do you have any idea how I can get the total cell volumes where I have fluid interface?

I mean in my case I need to calculate the total interracial area of interface. So need the cell volumes where the interface is there.

Regards,
GP

Pratik_21 December 24, 2020 12:01

Hi,

I was trying the above-mentioned methods and they work. I get the file of the newly added field in the time steps folder but don't get the values in the timestep folders. It just shows the values that I mentioned in the 0 folder.

for curiosity, I used Info statement to print the values of the newly added variable on-screen, and there it shows the expected values. but then why I am not getting them in timestep folders?

tyting December 7, 2023 09:46

Quote:

Originally Posted by T.D. (Post 555709)
Hi,


Two methods: as a "dimensionedScalar" or as a "volScalarField"
1) First Method:

in the file createField.H add:

///////////////////////////////////////////////////
dimensionedScalar h
(
transportProperties.lookup("h")
);
///////////////////////////////////////////////////
and then you need to define its value with dimensions in
the "transportProperties" file in the case/constant folder

2) sencond Method:

in the file createField.H add:
///////////////////////////////////////////////////
volScalarField h
(
IOobject
(
"h",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("h",dimensionSet(......),scalar( "your value"))
);
///////////////////////////////////////////////////
Note that "NO_READ" must be changed to "MUSt_READ" based
on your requirements.

Don't Forget to recompile the solver with "wmake" command in terminal.

Have Fun :)

Regards,
T.D.

Hi,I got a problem when define a parameter used to store the max value of another scalarField:gradAlpha.My code is :
volScalarField maxG
(
IOobject
(
"maxG",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
gradAlpha.max()
);
when i run "wmake",the system display the following information:
error:no matching function for call to 'Foam::GeometricField<double,Foam::fvPatchField,Fo am::volMesh>::max()'
Does anyone know how to solve it?
Thanks for any help!!

olesen December 7, 2023 12:30

Quote:

Originally Posted by tyting (Post 861223)
Hi,I got a problem when define a parameter used to store the max value of another scalarField:gradAlpha.My code is :
volScalarField maxG
(
IOobject
(
"maxG",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
gradAlpha.max()
);
when i run "wmake",the system display the following information:
error:no matching function for call to 'Foam::GeometricField<double,Foam::fvPatchField,Fo am::volMesh>::max()'
Does anyone know how to solve it?
Thanks for any help!!


Please take a look at the documentation:
https://www.openfoam.com/documentati...tricField.html


From there you will see that max() as a method clamps the field - it certainly doesn't return anything. Have you tried with max(gradAlpha) as a free function? I think this delivers the right thing, but since it is one of many, many max() functions it is not particularly easy to find in the documentation (unless you have an idea what you are looking for).

tyting December 8, 2023 01:59

Quote:

Originally Posted by olesen (Post 861228)
Please take a look at the documentation:
https://www.openfoam.com/documentati...tricField.html


From there you will see that max() as a method clamps the field - it certainly doesn't return anything. Have you tried with max(gradAlpha) as a free function? I think this delivers the right thing, but since it is one of many, many max() functions it is not particularly easy to find in the documentation (unless you have an idea what you are looking for).

Thank you for your help! I'm not familiar with the code of OPENFOAM,so when I try to make some change in the present solver,lots of problem come up ...
For the problem I posed last night, I change my code into "scalar maxG=gMax(gradAlpha);" and then it can compile the solver sucessfully!

olesen December 8, 2023 04:38

Quote:

Originally Posted by tyting (Post 861251)
Thank you for your help! I'm not familiar with the code of OPENFOAM,so when I try to make some change in the present solver,lots of problem come up ...
For the problem I posed last night, I change my code into "scalar maxG=gMax(gradAlpha);" and then it can compile the solver sucessfully!


You may still also want to have some dimensions (eg, m/s, 1/m etc) on your new quantity. In which case you would initialize with a dimensionedScalar.
OpenFOAM has a lightweight dimension check for geometric fields - sometimes it is in the way, but most times it can help trace logic or programming errors when you put together equations.


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