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/)
-   -   double derivative with respect to time (https://www.cfd-online.com/Forums/openfoam-programming-development/150208-double-derivative-respect-time.html)

13msmemusman March 17, 2015 12:33

double derivative with respect to time
 
Hye i am new user of openFoam i need to calculate double derivative with respect to time of a scalar.
i have a scalar CoMx
i tried to find its double derivative by

scalar DDTCoMx = d2dt2(CoMx);

but i got error
error: ‘d2dt2’ was not declared in this scope
scalar DDTCoMx = d2dt2(CoMx);

please help me... is there any need to add some header file explaining d2dt2???? if yes then where this header file lies and how to add it in make/options???

kebsiali March 18, 2015 08:00

hi
the d2dt2 is defined within fvm, fvc,.........etc.
to call it you should write
fvc::d2dt2(CoMx) if you want to calculate ( which i think is your case)
fvm:d2dt2(CoMx) in case you want to generate the coefficient matrix to solve an equation

try this and tell me if it works or not.

13msmemusman March 18, 2015 10:22

There is still an error sir


myInterFoamDDT.C: In function ‘int main(int, char**)’:
myInterFoamDDT.C:121:34: error: no matching function for call to ‘d2dt2(Foam::scalar&)’
scalar DDTCoMx = fvc::d2dt2 (CoMx);

myInterFoamDDT.C:121:34: note: candidates are:
In file included from /opt/openfoam231/src/finiteVolume/lnInclude/fvcD2dt2.H:74:0,
from /opt/openfoam231/src/finiteVolume/lnInclude/fvc.H:46,
from /opt/openfoam231/src/finiteVolume/lnInclude/fvCFD.H:8,
from myInterFoamDDT.C:40:
/opt/openfoam231/src/finiteVolume/lnInclude/fvcD2dt2.C:44:1: note: template<class Type> Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> > Foam::fvc::d2dt2(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&)
d2dt2

/opt/openfoam231/src/finiteVolume/lnInclude/fvcD2dt2.C:44:1: note: template argument deduction/substitution failed:
myInterFoamDDT.C:121:34: note: mismatched types ‘const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>’ and ‘Foam::scalar {aka double}’
scalar DDTCoMx = fvc::d2dt2 (CoMx);

In file included from /opt/openfoam231/src/finiteVolume/lnInclude/fvcD2dt2.H:74:0,
from /opt/openfoam231/src/finiteVolume/lnInclude/fvc.H:46,
from /opt/openfoam231/src/finiteVolume/lnInclude/fvCFD.H:8,
from myInterFoamDDT.C:40:
/opt/openfoam231/src/finiteVolume/lnInclude/fvcD2dt2.C:59:1: note: template<class Type> Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> > Foam::fvc::d2dt2(const volScalarField&, const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&)
d2dt2

/opt/openfoam231/src/finiteVolume/lnInclude/fvcD2dt2.C:59:1: note: template argument deduction/substitution failed:
myInterFoamDDT.C:121:34: note: cannot convert ‘CoMx’ (type ‘Foam::scalar {aka double}’) to type ‘const volScalarField& {aka const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&}’
scalar DDTCoMx = fvc::d2dt2 (CoMx);

myInterFoamDDT.C:121:8: warning: unused variable ‘DDTCoMx’ [-Wunused-variable]
scalar DDTCoMx = fvc::d2dt2 (CoMx);

In file included from myInterFoamDDT.C:61:0:
/opt/openfoam231/src/finiteVolume/lnInclude/readTimeControls.H:38:8: warning: unused variable ‘maxDeltaT’ [-Wunused-variable]
scalar maxDeltaT =

kebsiali March 18, 2015 10:51

is CoMx a volScalarField?
could you specify how you define CoMx
The code is searching for a version of d2dt2 that matches the type of your CoMx ( I think) but couldn't find one.

13msmemusman March 18, 2015 11:06

sir here is code i have got center of mass and indivisual components of center of mass i want to get its time derivatives

CoM = sum(rho*mesh.V()*mesh.C().dimensionedInternalField ())/sum(rho*mesh.V());
Info << "Center of Mass " << CoM.dimensions() << " = " << CoM << nl << endl;

scalar CoMx = CoM.value().x();

Info << "Center of Mass x component = " << CoMx << nl << endl;

scalar CoMy = CoM.value().y();

Info << "Center of Mass y component = " << CoMy << nl << endl;
scalar CoMz = CoM.value().z();

Info << "Center of Mass z component = " << CoMz << nl << endl;



and for time derivative i used
scalar DDTCoMx = fvm::d2dt2 (CoMx);


but got error

13msmemusman March 18, 2015 11:08

i defined CoMx as scalar and got values but when i tried d2dt2 could not succeed

kebsiali March 18, 2015 11:18

Could you explain your case a little bit more???
what is it you are trying to model here?

13msmemusman March 18, 2015 11:25

i and just trying to calculate center of mass of fluid when fluid moves in damBreak tutorial and then find acceleration of center of mass. acceleration in x y and z direction.

kebsiali March 18, 2015 11:29

well the function called d2dt2 is not appropriate in this case my dear friend.
This function is used to discretize and not to calculate derivatives.
You should search for a utility that would do your task; i dont know if one exists or not.
but what you can do is simply
a=(Vnew-Vold)/dt
where V is done in the same manner

13msmemusman March 18, 2015 11:53

ohhh :mad: sir it means i will have to apply some numerical method to calculate derivative????


All times are GMT -4. The time now is 22:50.