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

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 oldtime 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 oldtime 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 timestep and then evaluate fvc::ddt(magSqrU). The comment on fvc and fvm is, of course, correct. Thanks Eugene. Hrv 
You learn something every day.
You learn something every day.

:) 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 
Thanks for all the help on the
Thanks for all the help on the time derivative of magSqr( U ) field.
Shaun 
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 
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. 
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. 
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 
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 
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. 
An addition to my previous com
An addition to my previous comments. Here is an example using OpenFOAM's builtin total derivative operator to find the total derivative of pressure.
volScalarField DpDt = fvc::DDt(phiv,p) 
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 AdamsBashforth method? 2. I am trying to solve a flow past squarecylinder case with LES, which ddt scheme is supposed to be better? 3. When should I use boundedbackwarddifferencing ddt, and when backwarddifferencing? Please help! Thanks in advance. Daniel 
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 
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 
What is DDt,
According to http://www.cfdonline.com/Forums/ope...enthalpy.html you are right.
fvc:DDt(U, p) = fvc::ddt(p) + fvc::div(p*U)  p * fvc::div(U) 
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.95384e11, No Iterations 7 GAMG: Solving for Uy, Initial residual = 0.359518, Final residual = 2.31641e11, 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.07819e06, cumulative = 6.1801e06 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.37149e11, No Iterations 7 GAMG: Solving for Uy, Initial residual = 0.284941, Final residual = 2.12644e11, No Iterations 8 #0 Foam::error::printStack(Foam::Ostream&) in "/home/ahajisha/OpenFOAM/OpenFOAM1.5/lib/linux64GccDPOpt/libOpenFOAM.so" #1 Foam::sigFpe::sigFpeHandler(int) in "/home/ahajisha/OpenFOAM/OpenFOAM1.5/lib/linux64GccDPOpt/libOpenFOAM.so" 
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) 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); DDt(U,x)? DDt(phi,x)? DDt (phi//fvc::interpolate(rho),x)? Regards, Ilya 
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? 
All times are GMT 4. The time now is 12:02. 