CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   DDt (https://www.cfd-online.com/Forums/openfoam-solving/58580-ddt.html)

coops August 14, 2006 19:49

Is it possible to take the tot
 
Is it possible to take the total derivative of a volVectorField and volScalarField (different equations of course). If not are there any suggestions as to how to overcome this? Also, is it possible to take the time derivative the magnitude of a vector dot product? (ie. ddt(magSqr(U)) where U is the velocity vector?)

Thanks in advance,

Shaun

eugene August 15, 2006 04:35

You can do fvc::ddt(magSqr(U))
 
You can do fvc::ddt(magSqr(U)), but not fvm::ddt(magSqr(U)), i.e. you can calculate the term explicitly. What are you ttrying to calculate anyway?

hjasak August 15, 2006 04:45

Beep! Not like that: think ab
 
Beep! Not like that: think about it.

In order to successfully evaluate the ddt term, you need to have stored the old-time level. This means the field of which you wish to evaluate the ddt must exist outside the time loop and rely on the oldTime() mechanism to correctly (and automatically) store the old-time level when time is incremented. In your case, magSqr(U) is a TEMPORARY, just created for you.

Thus, if you try to evaluate the ddt the way it is written, it will recognise that the field does not have the oldTime() level stored and will use the current value to initialise it. Basically, fvc::ddt(magSqr(U)) will always give you zero, which is wrong.

What you need to do is create a field magSqrU outside the time loop, set it to magSqr(U) in each time-step and then evaluate fvc::ddt(magSqrU).


The comment on fvc and fvm is, of course, correct. Thanks Eugene.

Hrv

eugene August 15, 2006 04:49

You learn something every day.
 
You learn something every day.

hjasak August 15, 2006 04:51

:-) Sounds good to me - I'll h
 
:-) Sounds good to me - I'll have a look at your stuff to learn how to get nice pictures out of my LES data. Hope I didn't upset you.

Hrv

coops August 15, 2006 18:06

Thanks for all the help on the
 
Thanks for all the help on the time derivative of magSqr( U ) field.

Shaun

coops August 15, 2006 18:13

Is it at all possible to take
 
Is it at all possible to take the Lagrangian (or Convective) derivative of a volScalarField (in one equation) and of a volVectorField (in another equation)? I wish to take the Lagrangian derivative of the velocity vector U and of Temperature T. However, when I try to use:

fvc::DDt(U) + ....

error: no matching function for call to 'DDt(Foam::volVectorField&)'

and for T:

fvc::DDt(T)+....

error: no matching function for call to 'DDt(Foam::volScalarField&)'

Is it possible to take the Lagrangian derivatives of these fields? If not, how does one overcome this? Do you need to code in the convective term?

Thanks once again,

Shaun

schmidt_d August 21, 2006 14:22

Shaun, The only way that I kn
 
Shaun,
The only way that I know to do this is by hand. Use the fact that DDt(T) is
fvc::ddt(T)+ (U & fvc::grad(T))
Note the extra parentheses with the dot product. The precedence of the & operator is not what you would expect, but is rather determined by the limitations of C++. Also keep in mind that this is not strongly conservative...you may run into trouble if this DDT is fed back into your numerical scheme. You also have the option of using the continuity equation, combined with the definition of DDT to reformulate this into strongly conservative form.

schmidt_d August 21, 2006 14:31

One other thing....if you use
 
One other thing....if you use the continuity equation and produce the conservative form, you have the option of doing this implicitly. For example, with constant density flow, you could get
fvm::ddt(T)+fvm::div(phi,T)
where phi is flux.

coops August 21, 2006 19:04

David, Thanks for your help
 
David,

Thanks for your help so far. However, I am new to both OpenFOAM and the FVM. Can you please explain a little more what you meant by
"Also keep in mind that this is not strongly conservative...you may run into trouble if this DDT is fed back into your numerical scheme. You also have the option of using the continuity equation, combined with the definition of DDT to reformulate this into strongly conservative form."

Thanks in advance,

Shaun

grtabor August 22, 2006 03:44

Its to do with the discretisat
 
Its to do with the discretisation of the

U & fvc::grad(T)

term. In the FVM we discretise this using Gauss theorem, converting it into fluxes into and out of the domain. If we discretise the term written like this then it is not guaranteed to preserve conservation of the quantity being advected (here essentially the energy); i.e. your derivative may be loosing or gaining energy. If you do some manipulation of the term to get it into the form

fvc::div(phi, T)

where phi is essentially the same as U, then when we apply Gauss we get something which preserves continuity at the _numerical_ level, rather than the mathematical level. This would be a strong conservative implementation.

Gavin

schmidt_d September 6, 2006 08:51

To add to Gavin's explanation
 
To add to Gavin's explanation and to address your question further, strong conservation is a property of an advection scheme; the concept of strong conservation is not specific to OpenFOAM. If a scheme is strongly conservative, then all the fluxes in the whole domain cancel out perfectly to give you the following result:
Change in quantity in domain = Inflow at boundaries - outflow at boundaries
Without the property of strong conservation, numerical error can generate or destroy small amounts of whatever quantity you are advecting.

This makes physical sense and is a very nice property to have for your scheme.

schmidt_d June 13, 2008 13:07

An addition to my previous com
 
An addition to my previous comments. Here is an example using OpenFOAM's built-in total derivative operator to find the total derivative of pressure.

volScalarField DpDt = fvc::DDt(phiv,p)

lakeat September 4, 2008 05:06

Hi, The different naming sy
 
Hi,

The different naming system of ddt in many textbooks and website makes me quite confused.

1. Could anyone help me out by telling me which ddt scheme is Adams-Bashforth method?

2. I am trying to solve a flow past square-cylinder case with LES, which ddt scheme is supposed to be better?

3. When should I use bounded-backward-differencing ddt, and when backward-differencing?

Please help! Thanks in advance.

Daniel

ICL November 23, 2009 07:47

Hi there,
can anyone check the following equation:
fvc::DDt(U, p) = fvc::ddt(p) + fvc::div(p*U) - p * fvc::div(U)

Is that right?

Thanks

ICL November 23, 2009 07:47

Hi there,
can anyone check the following equation:
fvc:: DDt(U, p) = fvc::ddt(p) + fvc::div(p*U) - p * fvc::div(U)

Is that right?

Thanks

haghajani December 2, 2009 10:36

What is DDt,
 
According to http://www.cfd-online.com/Forums/ope...-enthalpy.html you are right.

fvc:DDt(U, p) =
fvc::ddt(p)
+ fvc::div(p*U)
- p * fvc::div(U)

ICL December 2, 2009 10:43

The term (fvm::div(phi, h)) largely affects the solution of energy equation and the iteration has stopped after time steps. Any idea?
This is the energy equation file hEqn:

volTensorField tau =
- nu * (gradU + gradU.T())
+
(2.0/3.0 * nu * fvc::div(U)) * I;

volScalarField tauGradU = tau && gradU;


solve
(
//fvm::ddt(rho, h)
fvm::div(phi, h)
//- h * fvc::div(phi)
- fvm::laplacian(kl/Cp, h)
==
//fvc::DDt(phi, p)
//fvc::ddt(p)
fvc::div(phi/fvc::interpolate(rho) * fvc::interpolate(p))
//fvc::div(phi, p)
- p * fvc::div(phi/fvc::interpolate(rho))
- tauGradU
);

Courant Number mean: 0.0804511 max: 18829.1
GAMG: Solving for Ux, Initial residual = 0.20952, Final residual = 9.95384e-11, No Iterations 7
GAMG: Solving for Uy, Initial residual = 0.359518, Final residual = 2.31641e-11, No Iterations 8
GAMG: Solving for h, Initial residual = 0.228348, Final residual = 3.69123e+40, No Iterations 20
max(h): 3.22617e+46 min(h): -2.78718e+43
max(T): 1.54762e+43 min(T): -1.33703e+40
GAMG: Solving for p, Initial residual = 0.000963211, Final residual = 0.00317673, No Iterations 20
time step continuity errors : sum local = 0.00137243, global = -4.07819e-06, cumulative = -6.1801e-06
ExecutionTime = 4.55 s ClockTime = 4 s

Maximum Pressure = 0.41629, MPa

Time = 0.0003

Courant Number mean: 0.150658 max: 34559.5
GAMG: Solving for Ux, Initial residual = 0.109642, Final residual = 5.37149e-11, No Iterations 7
GAMG: Solving for Uy, Initial residual = 0.284941, Final residual = 2.12644e-11, No Iterations 8
#0 Foam::error::printStack(Foam::Ostream&) in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigFpe::sigFpeHandler(int) in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so"

linch February 10, 2011 11:00

DDt(U,x) DDt(phi,x) DDt (phi//fvc::interpolate(rho),x)?
 
So what's the correct implementation, if I'm looking for Langangian derivative for a scalar X (DxDt):

Code:

fvc::DDt(phi,x)
or
Code:

fvc::DDt(U,x)
?
And why in i.e. rhoPisoFoam there is an expression:
Code:

DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
Why is phi divided by rho?

DDt(U,x)? DDt(phi,x)? DDt (phi//fvc::interpolate(rho),x)?

Regards,
Ilya

linch February 11, 2011 06:25

I tried it out in OF 1.7.1:
DDt(U,x) can't be compiled, DDt(phi,x) can.

I still don't understand the meaning of DpDt = fvc:: DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p);
Edit: Got it: because phi isn't a volume but a mass flux in this case.

And as I computed DDt(phi,rho) or DDt(phi, alpha1) in interFoam after solving the convection of alpha1, I expected 0 to come out for entire flow because we are dealing with incompressible convective transport problem, but instead of this the result was different:

http://img819.imageshack.us/img819/5451/ddt.th.png

Is it because of the interface compression, which affects the alpha1 and consequently the rho fields, but doesn't affect the fluxes phi?

iamed18 June 12, 2012 09:51

Quote:

Originally Posted by grtabor (Post 196218)
Its to do with the discretisation of the

U & fvc::grad(T)

term. In the FVM we discretise this using Gauss theorem, converting it into fluxes into and out of the domain. If we discretise the term written like this then it is not guaranteed to preserve conservation of the quantity being advected (here essentially the energy); i.e. your derivative may be loosing or gaining energy. If you do some manipulation of the term to get it into the form

fvc::div(phi, T)

where phi is essentially the same as U, then when we apply Gauss we get something which preserves continuity at the _numerical_ level, rather than the mathematical level. This would be a strong conservative implementation.

Gavin

Forgive my lack of mathematical background, but is there someone that would be able to show the manipulation steps such that
\vec{U}\cdot\nabla\vec{U}=\nabla\cdot(\phi\vec{U}) where \phi=\vec{U}\cdot\vec{S}_f?
I've taken a few whacks at it and my lack of FVM, I think, is making me miss some obvious connection.

Many thanks to whomever is able to assist me!

Edit: Nevermind. Figured it out. Odd way, though it works.

Mohammad Jam September 9, 2016 03:03

.oldTime(); in chtMultiregionFoam
 
Hi

How to implement .oldTime(); after writing volScalarField in chtMultiregionFoam?

When i do that it gives this error:
class Foam::PtrList<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ has no member named ‘oldTime’

idrees khan January 19, 2021 05:10

Re: How to write material derivative of ln(T) in the consitutive equation
 
2 Attachment(s)
Hi Dear Former's
I'm going to Add temperature Equation to viscoelasticFluidFoam solver.
there is material derivative term of log(T)(screenshot attached) in the constitutive equation(I.e in this case Olroyd-B)

kindly any could guide me how to erite the that term in OldoydB.C file



I write it like fvm::ddt(tau_,logT) + fvc::div(phi()*tau_,logT)

Note:change to fvc and fvm respectively but getting same error's.(scrrenshot Attached)


regards
Idrees khan

idrees khan January 19, 2021 05:57

How to write material derivative of ln(T) in the consitutive equation
 
2 Attachment(s)
Hi Dear Former's
I'm going to Add temperature Equation to viscoelasticFluidFoam solver.
there is material derivative term of log(T)(screenshot attached) in the constitutive equation(I.e in this case Olroyd-B)

kindly any could guide me how to erite the that term in OldoydB.C file



I write it like fvm::ddt(tau_,logT) + fvc::div(phi()*tau_,logT)

Note:change to fvc and fvm respectively but getting same error's.(scrrenshot Attached)


regards
Idrees khan

idrees khan January 19, 2021 06:04

How to write material derivative of ln(T) in the consitutive equation
 
2 Attachment(s)
Hi Dear Former's
I'm going to Add temperature Equation to viscoelasticFluidFoam solver.
there is material derivative term of log(T)(screenshot attached) in the constitutive equation(I.e in this case Olroyd-B)

kindly any could guide me how to erite the that term in OldoydB.C file



I write it like fvm::ddt(tau_,logT) + fvc::div(phi()*tau_,logT)

Note:change to fvc and fvm respectively but getting same error's.(scrrenshot Attached)


regards
Idrees khan


All times are GMT -4. The time now is 13:43.