Difference between revisions of "HowTo Adding a new transport equation"
AntonChupin (Talk | contribs) |
|||
(29 intermediate revisions by 21 users not shown) | |||
Line 24: | Line 24: | ||
</cpp> | </cpp> | ||
− | In this example, the source term is | + | In this example, the source term is treated explicitly. To manage it implicitly, OpenFOAM provides the <tt>Sp</tt> and the <tt>SuSp</tt> functions. |
− | Suppose | + | Suppose we can write it as <math>S_k = \Kappa \psi </math>. The code lines to solve the same equation with an implicit treatment of the source term are: |
<cpp> | <cpp> | ||
Line 34: | Line 34: | ||
- fvm::laplacian(gamma, psi) | - fvm::laplacian(gamma, psi) | ||
== | == | ||
− | + | fvm::Sp(kappa, psi) | |
); | ); | ||
</cpp> | </cpp> | ||
<tt>SuSp(kappa, psi)</tt> can be used to discretise the source term implicitly or explicitly according to the sign of <tt>kappa</tt>. | <tt>SuSp(kappa, psi)</tt> can be used to discretise the source term implicitly or explicitly according to the sign of <tt>kappa</tt>. | ||
− | + | ||
+ | [[Category:Tutorials]] |
Latest revision as of 11:13, 21 October 2013
Suppose you want to solve and additional scalar transport equation for the scalar by adding it to an existing solver. The equation has the form
where and are defined as dimensionedScalar and are retrieved from a dictionary using the lookup member function. is the source term.
To implement the equation, just add the line:
dimensionedScalarField psi;
to the createFields.H file of the solver,
Then, solve the equation by adding the following lines in the point of the solver where you want the equation to be solved.
solve ( fvm::ddt(rho, psi) + fvm::div(phi, psi) - fvm::laplacian(gamma, psi) == S_psi );
In this example, the source term is treated explicitly. To manage it implicitly, OpenFOAM provides the Sp and the SuSp functions. Suppose we can write it as . The code lines to solve the same equation with an implicit treatment of the source term are:
solve ( fvm::ddt(rho, psi) + fvm::div(phi, psi) - fvm::laplacian(gamma, psi) == fvm::Sp(kappa, psi) );
SuSp(kappa, psi) can be used to discretise the source term implicitly or explicitly according to the sign of kappa.