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/)
-   -   Take fields from another folder (https://www.cfd-online.com/Forums/openfoam-programming-development/240314-take-fields-another-folder.html)

Mnuk December 26, 2021 16:23

Take fields from another folder
 
Hello to everyone!

I created a new solver and many volScalarFields are involved. In order to be clearer in the case to be simulated, I store them in different folders in 0 so:

0/Amplitudes
0/Fluxes
0/Properties
0/Weights

No problems, just change in createFields.H where I take variables like:

volScalarField fi1
(
IOobject
(
"Fluxes/fi1",
runTime.timeName(),
mesh_fi,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh_fi
);

However when I run the solver it gives me a problem: the fvSchemes is not able to find the variables!
It should do:

fvm::laplacian(DD1,fi1)

while in fvSchemes there is:

laplacian(DD1,fi1) Gauss linear corrected;

but it gives me this error:

Entry 'laplacian(Properties/DD1,Fluxes/fi1)' not found in dictionary "/mnt/c/users/hp/desktop/tesi/calcoli/Space_energy/RI1/system/fvSchemes.laplacianSchemes"

So I ask you: how to solve this? Is it possible to do what I want, so store the variables in subfolders in 0? Thanks to everyone :)

SHUBHAM9595 December 28, 2021 09:45

Hi Mnuk, what you are trying to do is possible. We just need to provide "consistent" naming conventions for the defined field variables.


1. A quick workaround should be to replace
Code:

laplacian(DD1,fi1) Gauss linear corrected;
with
Code:

laplacian(Properties/DD1,Fluxes/fi1) Gauss linear corrected;
Few remarks
2. I dont know why u r using multiple names to define the variable. Either fluxes or fi1 should do the job.
3. No idea about which specific constructor u r using but there is no need to use mesh_fi as all field variables are defined for a single common grid (which is just- mesh). You can also confirm this by looking at any createFields file.

Mnuk January 2, 2022 17:52

Hi Shunbam, thanks a lot for your answer!

I tried to do what you are suggesting in first bullet but it doesn't work because the "/" in "Fluxes/fi1" creates some problems.

Wrong token type - expected word, found on line 45: punctuation '/'

I come to an half solution. As it can be red from IOobject.H, at lines 250 and so on (https://www.openfoam.com/documentati...8H_source.html) there is the possibility to name the variable (in my case fi1) and below write the path where it is located, like:

volScalarField fi1
(
IOobject
(
"fi1",
runTime.timeName(),
"/Fluxes",
mesh_fi,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh_fi
);


where "fi1" is the name of the variable and "/Fluxes" the subfolder. This is below runTime.timeName() in such a way that the complete path is:

C:\folder\folder\folder\Case_study\0\Fluxes\fi1

where in "Case_study" are located also system and constant.

In this way there are no more problems with fvSchemes and fvSolution but when code saves variables it does it in subfolders in times folders like:

C:\folder\folder\folder\Case_study\0.002\Fluxes\fi 1

which can not be red by Paraview.

So now my question is how to save the variables in times folders and not in subfolders.

For the other two bullets:

2. Fluxes is the subfolder that contains fi1.
3. I am using two meshes so I need mesh and mesh_fi.


I wish to you an happy new year :)


All times are GMT -4. The time now is 14:09.