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/)
-   -   ddtSchemes, How Euler and CrankNicolson descritize? (https://www.cfd-online.com/Forums/openfoam-programming-development/129487-ddtschemes-how-euler-cranknicolson-descritize.html)

ooo February 6, 2014 06:12

ddtSchemes, How Euler and CrankNicolson descritize?
 
I want to solve( ddt(U) == F ) in which both U and F are volVectorField.
I get three different results when i use these three approaches!
I expect that all of them should be same

1) forAll(U, cellI) U[cellI] += runTime.deltaTValue()*F[cellI];
2) solve(fvm::ddt(U)==F); //Euler descritization
3) solve(fvm::ddt(U)==F); //CrankNicolson descritization

Do you know why they don't give same result? Because i think all of them do this : ( Unew = Uold + F*dt)

ooo February 10, 2014 11:41

I edited my above question completely to avoid posting a new thread.
I would appreciate if anyone helps about this new question.

wouter February 10, 2014 16:57

hello ooo,
I just followed a CFD course (on youTube) and found out there are a lot of ways to look at and use the meshdata. Every way has his own advantages and disadvantages. Your question is answered on this wiki link
http://en.wikipedia.org/wiki/Crank%E...icolson_method

hope this helps
Wouter
NB. as you can read in the first line I am an expert, because I read a book;).

ooo February 10, 2014 17:07

Quote:

Originally Posted by wouter (Post 474349)
hello ooo,
I just followed a CFD course (on youTube) and found out there are a lot of ways to look at and use the meshdata. Every way has his own advantages and disadvantages. Your question is answered on this wiki link
http://en.wikipedia.org/wiki/Crank%E...icolson_method

hope this helps
Wouter
NB. as you can read in the first line I am an expert, because I read a book;).

Thank you for your answer.
But the point is that in the right hand side of my equation, there is an independent value of U, therefore the time descritizations should not be different to each other in this equation.So i wonder why these three approaches give me different results.

lichmaster February 11, 2014 02:55

Euler and Crank-Nicholson must give different results if F is time dependent, as the first one basically should perform as your method 1 while the second one is a blend of Forward Euler and Backwards Euler.

As to why method 1 and 2 are not the same (I don't remember exactly and don't have time to check right now) it should be a dimensional issue: Euler should work with volume integrated fields, thus if you have a constant F field but different mesh volumes, your actual "F" term will be F*volume. Try to print the dimensions of U, F and ddt(U)...

ooo February 11, 2014 06:35

Quote:

Originally Posted by lichmaster (Post 474393)
Euler and Crank-Nicholson must give different results if F is time dependent, as the first one basically should perform as your method 1 while the second one is a blend of Forward Euler and Backwards Euler.

As to why method 1 and 2 are not the same (I don't remember exactly and don't have time to check right now) it should be a dimensional issue: Euler should work with volume integrated fields, thus if you have a constant F field but different mesh volumes, your actual "F" term will be F*volume. Try to print the dimensions of U, F and ddt(U)...

Thank you very much for your reply.

-About the dimension, my F field has the dimension of (m/s2).Also the dimension of the ddt(U) is (m/s2).Is there any problem here? because in both 1 and 2, the rhs and lhs seem have the same dimension.

-About the difference between euler and crankNicolson, i know their mathematical formula, but im confused with my algorithm :
In each time step :
*I solve the momentum equation
*use the computed velocity to compute F (by some formulas...),
*Solving (ddt(u)=F) to recompute U.
So, If it is descritized like this :
(Unew-Uold)/dt = Fnew (Implicit euler)
(Unew-Uold)/dt = 0.5*(Fnew+Fold) (crankNicolson)

The confusing part for me is the term (Fnew). Because in an implicit descritization, the RHS is descritized in the same time step, and in general we should not have Fnew! but the point is that i should use the value of F which was calculated in a line before of this equation in the same time step!
If it is going to use the known F, then it is not the implicit method anymore!
So again the same question comes up that how (ddt(U)=F) is descritized in my algorithm?


All times are GMT -4. The time now is 15:38.