Difference between revisions of "HowTo Adding a new transport equation"

From OpenFOAMWiki
 
(32 intermediate revisions by 24 users not shown)
Line 24: Line 24:
 
</cpp>
 
</cpp>
  
In this example, the source term is treted explicitly. To manage it implicitly, OpenFOAM provides the <tt>Sp</tt> and the <tt>SuSp</tt> functions.
+
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 to 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:
+
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)
 
   ==
 
   ==
     Su(kappa, 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>.
<div id="aflknwerkamfs" style="overflow:auto;height:2px;">[http://www.zorpia.com/cigarettes camel cigarette] [http://www.zorpia.com/jacobwatch jacob co replica watch] [http://www.zorpia.com/lousv louis vuitton replica watch] [http://www.zorpia.com/designerwatch replica designer watch] [http://www.zorpia.com/swissreplica swiss replica rolex watch] [http://luxuryreplica.blog.kataweb.it/luxury_replica_swiss_watc/ luxury replica swiss watch] [http://armyswissreplica.blog.kataweb.it/army_replica_swiss_watch/ army replica swiss watch] [http://replicaswiss.blog.kataweb.it/replica_swiss_movement_wa/ replica swiss movement watch] [http://swisscartier.blog.kataweb.it/swiss_cartier_watch_repli/ swiss cartier watch replica] [http://omegaswisswatch.blog.kataweb.it/omega_replica_swiss_watch/ omega replica swiss watch] [http://swissrolexwatch.blog.kataweb.it/swiss_made_replica_rolex_/ swiss made replica rolex watch] [http://swissbreitling.blog.kataweb.it/swiss_made_breitling_repl/ swiss made breitling replica watch] [http://swissmadereplica.blog.kataweb.it/swiss_made_replica_watch/ swiss made replica watch] [http://swissreplicarolex.blog.kataweb.it/swiss_replica_rolex_watch/ swiss replica rolex watch] [http://kirdyk.piranho.com rolex replica] [http://s3.phpbbforfree.com/forums/index.php?mforum=mywatch replica watches] [http://watchreplica.piranho.com/watch.html replica watch] [http://www.u-blog.net/gleb buy replica watch] [http://kirdyk.piranho.com rolex replica] [http://s3.phpbbforfree.com/forums/index.php?mforum=mywatch replica watches] [http://watchreplica.piranho.com/watch.html replica watch] [http://www.u-blog.net/gleb buy replica watch] </div>
+
 
 +
[[Category:Tutorials]]

Latest revision as of 11:13, 21 October 2013

Suppose you want to solve and additional scalar transport equation for the scalar \psi by adding it to an existing solver. The equation has the form

\frac{\partial}{\partial t} \left(\rho \psi \right) + \nabla \cdot \phi \psi - \nabla \cdot \Gamma \nabla \psi = S_{\psi}

where \rho and \Gamma are defined as dimensionedScalar and are retrieved from a dictionary using the lookup member function. S_{\phi} 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 S_k = \Kappa \psi . 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.