[Solved] Read temperature dependent properties from a file and interpolate
2 Attachment(s)
Hello everyone,
I am trying to implement the following: - the thermophysical property "DT" shall be read from a data file and interpolated according to the temperature in the solution domain. Reading some posts here on cfd-online.com I got quite far, only the bounary values of the "DT" field are not calculated. ####### The Solver - based on icoFoam with TEqn according to wiki, but "DT" as volScalarField ####### The icoFileFoam.C file Code:
/*---------------------------------------------------------------------------*\ Code:
Info<< "Reading transportProperties\n" << endl; Code:
Info << "Reading DT property file and interpolate" << endl; ###### The test case ###### It is conduction only, a block 1 m long, 0.1 m high and 0.01 m in width with 100x10x1 cells. Every boundary is a wall (or empty), no velocity and the temperature is set to 273.15 K except for the right wall being 373.15 K. I used funkySetFields -time 0 -field T -keepPatches -expression "pos().x*50.0+273.15" to see the effect of interpolated "DT" field. As coded, the file "DT" is in the folder "constant". The test case is attached as zip, too. All this works fine. The "DT" field is written to the time directory as demanded and interpolated. Only, the boundary values of the "DT" stay 1e-3 as given in the createFields.H for initialisation (that's also why I chose this odd value). Therefore, the temperature does not build up to a linear slope from left to right, from 273.15 K to 373.15 K as it should. The written-out "DT" file gives sensible values in the internal field, but only "calculated 1e-3" for every boundary. This means, the boundary values of "DT" are not updated. Can anyone tell me, what line of coding is missing to interpolated these according to temperature, too ? Or maybe, anyone knows that the error is somewhere else? Thanks in advance Anja |
I got it.
The interpolateProperties.H has to look as follows to account for the boundary values as well: Code:
IFstream file_DT(runTime.path()/runTime.constant()/"DT"); Anja |
Thank you for sharing. Anja
|
Errors in parallel
When I run this interpolateProperties.H file in parallel, I get the following error (OF2.3.1):
error in IOstream "/path/to/case/directory/processor3/constant/DT" for operation operator >>(Istream&,List<T>&) from function IOstream::fatalCheck(const char*) . Has anyone else tried this code in parallel? Is there any way I can modify this code so that it runs in parallel? |
SOLVED - Parallel Read temperature dependent thermophysical properties from a file
I figured out what the problem was with doing this in parallel.
Apparently, when you run decomposePar, the solver will automatically look for the tabular files in the subfolders /path/to/case/directory/processor0/constant/ /path/to/case/directory//processor1/constant/ etc.., instead of just in the directory /path/to/case/directory/constant/ To resolve this issue, you need to copy the tabular file "DT" from /path/to/case/directory/constant/DT to /path/to/case/directory/processor0/constant/DT /path/to/case/directory/processor1/constant/DT etc... It may be helpful to do this in a loop within your script. |
Thanks for this discussion and it has proved quite helpful for me to define temperature dependent properties in OpenFOAM.
|
I recurrent it in OpenFOAM-v2306 and get the following error:
interpolateProperties.H:29:9: error: passing ‘const Foam::fvPatchField<double>’ as ‘this’ argument discards qualifiers [-fpermissive] 29 | ); | ^ which the error part is://Interpolation boundary field forAll(DT.boundaryField(), patchi) { DT.boundaryField()[patchi] = interpolateXY ( T.boundaryField()[patchi], DTGraph.x(), DTGraph.y() ); } Is there any way I can modify this part code so that it runs in OpenFOAM-v2306? |
All times are GMT -4. The time now is 07:03. |