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!
|