|
[Sponsors] |
![]() |
![]() |
#1 |
Member
Shaun Cooper
Join Date: Mar 2009
Posts: 54
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 ![]() |
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?
|
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,906
Rep Power: 33 ![]() |
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
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 ![]() |
You learn something every day.
|
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,906
Rep Power: 33 ![]() |
:-) 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
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Member
Shaun Cooper
Join Date: Mar 2009
Posts: 54
Rep Power: 17 ![]() |
Thanks for all the help on the time derivative of magSqr( U ) field.
Shaun |
|
![]() |
![]() |
![]() |
![]() |
#7 |
Member
Shaun Cooper
Join Date: Mar 2009
Posts: 54
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#8 |
Member
David P. Schmidt
Join Date: Mar 2009
Posts: 72
Rep Power: 17 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Member
David P. Schmidt
Join Date: Mar 2009
Posts: 72
Rep Power: 17 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#10 |
Member
Shaun Cooper
Join Date: Mar 2009
Posts: 54
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#11 |
Senior Member
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#12 |
Member
David P. Schmidt
Join Date: Mar 2009
Posts: 72
Rep Power: 17 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#13 |
Member
David P. Schmidt
Join Date: Mar 2009
Posts: 72
Rep Power: 17 ![]() |
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) |
|
![]() |
![]() |
![]() |
![]() |
#14 |
Senior Member
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21 ![]() |
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
__________________
~ Daniel WEI ------------- Boeing Research & Technology - China Beijing, China |
|
![]() |
![]() |
![]() |
![]() |
#15 |
New Member
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 17 ![]() |
Hi there,
can anyone check the following equation: fvc: ![]() Is that right? Thanks |
|
![]() |
![]() |
![]() |
![]() |
#16 |
New Member
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#17 |
Member
Hamed Aghajani
Join Date: Mar 2009
Location: London, UK
Posts: 77
Rep Power: 17 ![]() |
According to http://www.cfd-online.com/Forums/ope...-enthalpy.html you are right.
fvc ![]() fvc::ddt(p) + fvc::div(p*U) - p * fvc::div(U) |
|
![]() |
![]() |
![]() |
![]() |
#18 |
New Member
Ali Sh
Join Date: Jun 2009
Location: London
Posts: 28
Rep Power: 17 ![]() |
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: ![]() //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: ![]() #1 Foam::sigFpe::sigFpeHandler(int) in "/home/ahajisha/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/libOpenFOAM.so" |
|
![]() |
![]() |
![]() |
![]() |
#19 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#20 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 ![]() |
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: ![]() Is it because of the interface compression, which affects the alpha1 and consequently the rho fields, but doesn't affect the fluxes phi? Last edited by linch; February 11, 2011 at 09:49. |
|
![]() |
![]() |
![]() |
Tags |
ddt, lagrangian derivative |
|
|