CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Adding a cross product source term (http://www.cfd-online.com/Forums/openfoam-solving/88979-adding-cross-product-source-term.html)

lazersos May 31, 2011 15:18

Adding a cross product source term
 
I want to solve for 2-Fluid (ion-electron) steady state flow. Now it seems that between mhdFoam and simpleFoam this should be possible. In essence I need to add a v x B term to the simpleFoam velocity solver. My guess is this should look something like:

Code:

{
  fvVectorMatrix UEqn
  (
          fvm::div(phi,U)
  );
  eqnResidual = solve(UEqn == -fvc::grad(p)+  fvm::Sp(qi,crossProduct(Ui,B))).initialResidual();
}

In essence I'll want to solve this once for the ion fluid then once for the electron fluid. Then I'll calculate the current from the velocities and the modification of the field by the current. I'm also going to assume a fixed pressure profile. Any thoughts on adding a source term or experience with the forms of Sp?

lazersos June 6, 2011 12:14

Followup
 
Well I got a version to compile anyway, now I just have to figure out how to set my initial condition for my solver (gradient fields, etc). Here's the code:

Code:

      volVectorField UxF;
      {
            UxF = U ^ F;  // U x F Term
            // --- Solve for Ion Velocity
            fvVectorMatrix UiEqn
            (
                  fvm::div(phii, U)
                + fvm::Sp(q, UxF)
             
            );
            eqnResidual = solve(UiEqn == -fvc::grad(p)).initialResidual();
            maxResidual = max(eqnResidual, maxResidual);

        }


fisch June 9, 2011 10:44

Hello lazersos,

as far as i get it you add a source term called UxF and then you have to integrate it over the control volume.

For that you call "+fvm::Sp(q,UxF)" to integrate UxF over each cell volume, right? But what is q here?

thanks for a reply,
rupert

lazersos June 9, 2011 11:24

This is what I got to compile:

Code:

            UxF = U ^ F;
            // --- Solve for Ion Velocity
            fvVectorMatrix UEqn
            (
                  fvm::div(phi, U)
                + fvm::Sp(q, UxF)
             
            );
            eqnResidual = solve(UEqn == -fvc::grad(p)).initialResidual();
            maxResidual = max(eqnResidual, maxResidual);

I believe this is the correct way to proceed as U is the quantity being varied so the implicit source term should reside in the fvVectorMatrix. The q term is just some scalar multiple in front of the source term as far as I can tell.


All times are GMT -4. The time now is 16:09.