CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Problems with own LES Model Implementation (http://www.cfd-online.com/Forums/openfoam/69026-problems-own-les-model-implementation.html)

fs82 October 9, 2009 10:10

Problems with own LES Model Implementation
 
I added a new subgrid scale model to my OpenFoam. Everything works fine except one thing. In detail it is a vegetation model, which adds a drag term to NS-Equation. So I modified the divDefBeff function with a additional term. Now I want to write out this term. Because the term is treat implicit I have to provide en explicit calculation right? So my current implementation looks like this:
I created a new field:
force_
(
IOobject
(
"force",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
a*mag(U)*U
)

and update it, everytime sgsModel->correct is called:
void myModel::correct(const tmp<volTensorField>& gradU)
{
GenEddyVisc::correct(gradU);
// Calculate force
force_=a*mag(U())*U();
// Calculate numeric viscosity
...
}
But this implementation sucks because if I make further changes on my force term, I have to remember 3 places (2 shown in the code above, 1 in divDevBeff) where I have to change the code. So may be anybody, with better C++ knowledge than me, could help me to find a more useful solution.

kind regards,

Fabian

fs82 October 9, 2009 10:31

Allright I had some luck and now I am able to reduce the occurance of the equation. If I initialize my volVectorField with zero:

force_
(
IOobject
(
"force",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedVector("force_",dimensionSet(0,1,-2,0,0,0,0),vector(0,0,0))
)

It looks much better. But may be there is still some room for futher improvments?

kind regards

Fabian


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