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/)
-   -   Problem with reading field values into a costomized noundary condition (https://www.cfd-online.com/Forums/openfoam-programming-development/177447-problem-reading-field-values-into-costomized-noundary-condition.html)

Jung hoo September 14, 2016 02:55

Problem with reading field values into a costomized noundary condition
 
Hi, I have a trouble in reading field values.(like U or p, etc.)

I modified interFoam as below.

Quote:

Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
# include "readPIMPLEControls.H"
# include "readTimeControls.H"
# include "CourantNo.H"
# include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
// Pressure-velocity corrector
int oCorr = 0;
do
{
twoPhaseProperties.correct();
# include "alphaEqnSubCycle.H"
# include "UEqn.H"
// --- PISO loop
for (int corr = 0; corr < nCorr; corr++)
{
# include "pEqn.H"
}
# include "continuityErrs.H"
p = pd + rho*gh;
if (pd.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pdRefCell)
);
}
turbulence->correct();
//correction
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readSIMPLEControls.H"

volSymmTensorField Reff(turbulence->devReff());
volVectorField wallShearStress
(
IOobject
(
"wallShearStress",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector
(
"wallShearStress",
Reff.dimensions(),
vector::zero
)
);
forAll(wallShearStress.boundaryField(), patchi)
{
wallShearStress.boundaryField()[patchi] =
(
-mesh.Sf().boundaryField()[patchi]
/mesh.magSf().boundaryField()[patchi]
) & Reff.boundaryField()[patchi];
}
runTime.write();
It's quite similar with existing interFoam solver, but I added code to calculate 'wallShearStress' (bold writing).

This modified solver works well.

But when I tried to read the wallShearStress field into my new boundary condition using

Quote:

const volVectorField& wallShearStress = db().lookupObject<volVectorField>("wallShearStress ");
The compile is done with no trouble, but I get error message as below when I run application.

Quote:

--> FOAM FATAL ERROR:
request for volVectorField wallShearStress from objectRegistry region0 failed
available objects of type volVectorField are
3
(
U_0
U
T
)

From function objectRegistry::lookupObject<Type>(const word&) const
in file /home/lee/foam/foam-extend-3.1/src/foam/lnInclude/objectRegistryTemplates.C at line 139.
FOAM aborting
I guess probably the 'wallShearStress' on my own solver does not be resisted properly in the 'objectRegistry'.

How can I make a new field resisted in 'objectRegistry' properly like U or p?

Any comments will help me a lot. Thanks!

EhsanMh September 14, 2016 06:58

Hi,

substitute MUST_READ with NO_READ

Jung hoo September 14, 2016 21:15

Thank you for your fast reply Ehsan!

Actually, I already have tried that, but it didn't work.


With that code that I posted, the 'wallShearStress' files are made from the folder that is next time-step of 0 folder while other object files(like U or p) are made from 0 folder.


I think my problem can be solved if the 'wallShearStress' files can be made from 0 folder like U or p file.


Can you advise me about that please?


All times are GMT -4. The time now is 00:06.