CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Saving pressure field in simpleFoam (http://www.cfd-online.com/Forums/openfoam-solving/59150-saving-pressure-field-simplefoam.html)

cpplabs February 10, 2008 18:40

Hi, In simpleFoam.C, runTim
 
Hi,
In simpleFoam.C, runTime.Write() is used to write results, and simpleFoam p.storePrevIter() is called to store the pressure field of the previous iteration. Because the WOpt_ member in the copy constructor of GeometricField is always set to be NO_Write, and it seems that the write function always export the pressure field for the previous iteration (not p itself), pressue is always missing from the export.
Can someone tell me how to fix the problem or what part of my understanding is wrong?

Thanks.

============================================
// construct as copy
template<class> class PatchField, class GeoMesh>
Foam::GeometricField<type,>::GeometricField
(
const GeometricField<type,>& gf
)
:
DimensionedField<type,>(gf),
timeIndex_(gf.timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
boundaryField_(*this, gf.boundaryField_)
{
if (debug)
{
Info<<>::GeometricField : "
"constructing as copy"
<<>info() << endl;
}

if (gf.field0Ptr_)
{
field0Ptr_ = new GeometricField<type,>
(
*gf.field0Ptr_
);
}

this->writeOpt() = IOobject::NO_WRITE;
}

hjasak February 10, 2008 20:47

Nice one. Go to OpenFOAM-1
 
Nice one. Go to

OpenFOAM-1.4.1-dev/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricF ield.C

look for the function void Foam::GeometricField<type,>::storePrevIter() const

and in the second part do the following:

fieldPrevIterPtr_ =
new GeometricField<type,>
(
IOobject
(
this->name() + "_prev",
this->time().timeName(),
this->db()
),
*this
);


Hrv

cpplabs February 10, 2008 21:50

Hi, Thanks for the workaro
 
Hi,
Thanks for the workaround. I did further study into the code and found that "ConstructFromTmp" makes the difference because the following contructor. If ConstructFromTmp is turned on (defined), regIOobject(df) will be used instead of regIOobject(df, true), and the objectRegistry registration will not be transfered to the copy.
My further question is what is the purpose of ConstructFromTmp? It is used at several locations in the code, what different does this switch make?

Regards,

JT
================================================
template<class>
DimensionedField<type,>::DimensionedField
(
const DimensionedField<type,>& df
)
:
# ifdef ConstructFromTmp
regIOobject(df),
# else
regIOobject(df, true),
# endif
Field<type>(df),
mesh_(df.mesh_),
dimensions_(df.dimensions_)
{}


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