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

How to define field in createFields.H fine in OF23x

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By T.D.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 15, 2015, 04:25
Default How to define field in createFields.H fine in OF23x
  #1
Member
 
Gitesh
Join Date: Jan 2010
Location: Finland
Posts: 73
Rep Power: 16
Gitesh P is on a distinguished road
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 is offline   Reply With Quote

Old   July 16, 2015, 07:37
Default
  #2
Senior Member
 
Join Date: Sep 2010
Posts: 226
Rep Power: 16
T.D. is on a distinguished road
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 View Post
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
tyting likes this.
T.D. is offline   Reply With Quote

Old   July 20, 2015, 04:22
Default
  #3
Member
 
Gitesh
Join Date: Jan 2010
Location: Finland
Posts: 73
Rep Power: 16
Gitesh P is on a distinguished road
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
Gitesh P is offline   Reply With Quote

Old   December 24, 2020, 12:01
Default
  #4
New Member
 
Pratik
Join Date: May 2020
Location: Oldenburg, Germany
Posts: 14
Rep Power: 5
Pratik_21 is on a distinguished road
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?
Pratik_21 is offline   Reply With Quote

Old   December 7, 2023, 09:46
Default
  #5
New Member
 
yingting tang
Join Date: Aug 2023
Posts: 7
Rep Power: 2
tyting is on a distinguished road
Quote:
Originally Posted by T.D. View Post
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!!
tyting is offline   Reply With Quote

Old   December 7, 2023, 12:30
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by tyting View Post
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).
olesen is offline   Reply With Quote

Old   December 8, 2023, 01:59
Default
  #7
New Member
 
yingting tang
Join Date: Aug 2023
Posts: 7
Rep Power: 2
tyting is on a distinguished road
Quote:
Originally Posted by olesen View Post
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!
tyting is offline   Reply With Quote

Old   December 8, 2023, 04:38
Default
  #8
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by tyting View Post
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.
olesen is offline   Reply With Quote

Reply


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
''unknown radialModelType type Gidaspow'' PROBLEM WITH THE BED TUTORIAL AndoniBM OpenFOAM Running, Solving & CFD 2 March 25, 2015 18:44
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51
How do I define a custom vector field? MHDWill FLUENT 0 September 29, 2007 17:04
ACCESS VIOLATION MHDWill FLUENT 1 September 23, 2007 02:51


All times are GMT -4. The time now is 11:38.