|
[Sponsors] |
July 7, 2021, 11:37 |
How to translate code to formula?
|
#1 |
Senior Member
LT
Join Date: Dec 2010
Posts: 104
Rep Power: 15 |
sprayFoam had a member function called SU, which calculates the transfferd kinetic energy from the particles to the gas. This function returned value code is listed as follows.
const DimensionedField<scalar, volMesh> Vdt(mesh_.V()*this->db().time().deltaT()); ///////////////////////////////////////////////// UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U //If U is solved semiImplicitly ///////////////////////////////////////////////// tmp<fvVectorMatrix> tfvm(new fvVectorMatrix(U, dimForce)); fvVectorMatrix& fvm = tfvm.ref(); fvm.source() = -UTrans()/(this->db().time().deltaT()) //Other condition ///////////////////////////////////////////////// tmp<fvVectorMatrix>(new fvVectorMatrix(U, dimForce)) //Default value where :// Sources //- Momentum autoPtr<DimensionedField<vector, volMesh>> UTrans_; //- Coefficient for carrier phase U equation autoPtr<DimensionedField<scalar, volMesh>> UCoeff_; My question is how to translate the code to formula? Especially the first code. Thanks a lots! |
|
July 7, 2021, 12:29 |
|
#2 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 746
Rep Power: 14 |
It's almost impossible to understand the code you quoted ... partly because you didn't embed it using the code tags, and partly becaus you edited it leaving out the crucial parts that explain the context. Luckily I found the code that you are referring to in https://cpp.openfoam.org/v8/Kinemati...e.html#l00420:
Code:
template<class CloudType> inline Foam::tmp<Foam::fvVectorMatrix> Foam::KinematicCloud<CloudType>::SU(volVectorField& U) const { if (debug) { ... } if (solution_.coupled()) { if (solution_.semiImplicit("U")) { const volScalarField::Internal Vdt(mesh_.V()*this->db().time().deltaT()); return UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U; } else { tmp<fvVectorMatrix> tfvm(new fvVectorMatrix(U, dimForce)); fvVectorMatrix& fvm = tfvm.ref(); fvm.source() = -UTrans()/(this->db().time().deltaT()); return tfvm; } } return tmp<fvVectorMatrix>(new fvVectorMatrix(U, dimForce)); } Code:
tmp<fvVectorMatrix> tUEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) + MRF.DDt(rho, U) + turbulence->divDevTau(U) == rho()*g + parcels.SU(U) + fvOptions(rho, U) ); If the approach is not implicit, then it just calculates just an explicit source term. Hopefully that should be enough for you to dig down into the details. Good luck! |
|
July 7, 2021, 16:27 |
|
#3 |
Senior Member
LT
Join Date: Dec 2010
Posts: 104
Rep Power: 15 |
Thanks!
I have already read the code. What I expect is the PDE/ODE expression "translated" from the code. |
|
July 7, 2021, 16:30 |
|
#4 |
Senior Member
LT
Join Date: Dec 2010
Posts: 104
Rep Power: 15 |
By the way, I still use OpenFoam 4.X.
|
|
July 7, 2021, 17:12 |
|
#5 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 746
Rep Power: 14 |
||
July 8, 2021, 04:19 |
|
#6 |
Senior Member
LT
Join Date: Dec 2010
Posts: 104
Rep Power: 15 |
Thanks once again.
What I mean is the "translation" of those two sentences in the code. const volScalarField::Internal Vdt(mesh_.V()*this->db().time().deltaT()); return UTrans()/Vdt - fvm::Sp(UCoeff()/Vdt, U) + UCoeff()/Vdt*U; Especially the last senetence. Is it right? Su=Utrans/deltaT-UCoeff/Vdt*U + UCoeff/Vdt*U? where Vdt = V*deltaT, V is the droplet velocity? That's the point I want to know. Best regards! |
|
July 8, 2021, 04:59 |
|
#7 |
Senior Member
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14 |
Use CODE TAGS for these long stuff man.... It is impossible to read this...
No. mesh_.V() returns the cell volumes. So Vdt is the cell volume multiplied by the timestep. The velocity is usually called U everywhere. BTW: Code tags (You have to remove the spaces after first "CODE" !!! I just inserted so you can see the syntax): [CODE ] void thisIsADumbCode(int, int) {...} [/CODE] And it'll be: Code:
void thisIsADumbCode(int, int) {...} |
|
July 8, 2021, 06:01 |
|
#8 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 746
Rep Power: 14 |
If you really want to dig into the code and understand it, then first up - well done, that's the only way you will really understand how OpenFOAM works; secondly - buckle up, since you've got a heck of a ride in front of you! The lot's to get your head around. One bit of advice is that the Doxygen pages are REALLY useful for finding code, and tracking down variables etc ... there is a version for v4:
https://cpp.openfoam.org/v4/classFoa...20320c31fba00c the page I quoted has the class ref for V() - click on the metalink 186 to take you through to line 186 of the code etc. Also, read the header code in the associated .H files, and slowly you will start to build up the picture. Good luck again. |
|
Tags |
sprayfoam, su, utrans, ucoeff |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM] ParaView command in Foam-extend-4.1 | mitu_94 | ParaView | 0 | March 4, 2021 14:46 |
Fortran->Assembly : How to remove redundant non-vectorized code? | aerosayan | Main CFD Forum | 6 | November 20, 2020 06:37 |
The FOAM Documentation Project - SHUT-DOWN | holger_marschall | OpenFOAM | 242 | March 7, 2013 13:30 |
Error in CFX Solver | Leuchte | CFX | 5 | November 6, 2010 07:12 |
Small 3-D code | Zdravko Stojanovic | Main CFD Forum | 2 | July 19, 2010 11:11 |