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/)
-   -   unable to use fvc::ddt correctly (https://www.cfd-online.com/Forums/openfoam-programming-development/107763-unable-use-fvc-ddt-correctly.html)

Rocky4 October 6, 2012 00:23

unable to use fvc::ddt correctly
 
i am working on melting problem of pure gallium based on enthalpy porosity technique.(Voller)
to start with i m neglecting fluid flow and using laplacian foam.
energy eqn requires a additional source term in the form of time derivative of latent heat content of each cell which inturn is based on temperature of each cell computed in previous time step. the problem is fvc:: ddt(DH) IS UNABLE RECOGNIZE oldtime step value of DH and sets it to zero ie
DHold=0,DHcurrent=DH.
I FOLLOWED the remarks on DDT in the thread
http://www.cfd-online.com/Forums/openfoam-solving/58580-ddt.html
ie i have defined DH OUTSIDE the timeloop
and used.oldtime() WHILE CREATING DH FIELD
but still the oldtime values of DH are set to zero while computing ddt(DH) rather than actual oldtime values .
I have tried a few things to make it work and got some different results
if the DH field in sources file is updated on a whole ,say arbitrarily as DH=DH+L
where L-latent heat
instead of cellwise updation.
then ddt(DH) uses the oldtime value of DH instead of setting to zero.however when updation of DH is made on cell by cell basis using forALL then
DHoldtime=0 is used for ddt(DH) COMPUTATION

ALSO if i dont use intermediate variable FT AND UPDATE DH directly using forALL the ddt(DH) is computed as zero meaning that DHoldtime is set to current value. the relevant portion of code is as follows
create fields
Info<< "Reading field T\n" << endl;
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

volScalarField lf
(
IOobject
(
"lf",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(
"lf", dimless, 0)
);

volScalarField ST
(
IOobject
(
"ST",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(
"ST", dimTemperature/dimTime, 0)
);
Info<<
"Reading field DH\n" << endl;
volScalarField DH
(
IOobject
(
"DH",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
DH.oldTime();
mesh,
dimensionedScalar(
"DH", dimLength*dimLength/(dimTime*dimTime), 0)
);
main code
#include"fvCFD.H"
#include"simpleControl.H"
#include"IFstream.H"
#include"OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include"setRootCase.H"
#include"createTime.H"
#include"createMesh.H"
#include"readProperties.H"
#include"createFields.H"
simpleControl simple(mesh);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCalculating temperature distribution\n" << endl;
while (simple.loop())
{
Info<<
"Time = " << runTime.timeName() << nl << endl;
while (simple.correctNonOrthogonal())
{
#include"sources.H"
# include"TEqn.H"
}
#include"write.H"
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<<
"End\n" << endl;
return 0;
}
sources
/cellwise updation of latent heat content for each time step
forAll(mesh.cells(),celli)
{
if (T[celli] > Tm.value())
{
FT[celli] = L.value();
}
if (T[celli] < Tm.value())
{
FT[celli] = 0;
}
};
DH=FT;
lf=DH/L;


ST = fvc::ddt(DH)/Cp;
// Solve energy equation


fvScalarMatrix TEqn
(
fvm::ddt(T)

- fvm::laplacian(DT, T)
==
- ST

);
TEqn.solve();
why the usage of forALL for updating cell value of FT/DH, affects the oldtime values while evaluating ddt(DH)? whereas as updation of the entire field on a whole does not cause any problem in oldtime values while evaluatng ddt(DH).Is there any other way to update field variable on cell by cell basis without affecting ddt(DH) evaluation? In nutshell why the use of forAll makes the object DH local thereby setting it to zero at the start of each new timestep and what's the remedy?

any kind of help is greatly appreciated. thanks in advance.sorry for such a long post but i wanted to express my point clearly.


Rocky4 October 10, 2012 20:39

sorry foamers
 
the DHold was becoming zero due to some other reason(related to algorithm of enthalpy method) and not due to usage of forAll .Sorry for troubling everyone.


All times are GMT -4. The time now is 18:26.