CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)

 lazersos May 31, 2011 14: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 11: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 09: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?

```            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);```