CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   surface and volume fields multiplication (https://www.cfd-online.com/Forums/openfoam-programming-development/85629-surface-volume-fields-multiplication.html)

 Zato_Ichi March 2, 2011 20:10

surface and volume fields multiplication

Greetings !

I have two fields: volVectorField X and surfaceScalarField M. Is there any method to multiply them to get volume field on new time step like that :
X(n+1,i) = X(n,i-1)*M(n,1-1/2)-X(n,i+1)*M(n,i+1/2)
there n timestep index and i index of a cell. i+1/2 - right face of a cell i-1/2 - left face.

I assumed that this will look like interpolate(interpolate(X)*M) with upwind interpolation schemes, but as i know there is no method for interpolating face field onto cell volumes.
Is there any way to make such construction in solver ?

Best regards !

 cliffoi March 7, 2011 13:10

Something along these lines should do the trick. You're going to have to sort out the the discretization and mathematical correctness of it all. Since the mesh is unstructured you'll probably need to use the face normal vector or something to get the direction. Also take a look at finiteVolume/finiteVolume/fvc/fvcReconstruct.C, which does something similar.
Code:

```    vectorField& Xi = X.internalField();     const vectorField& X0i = X.oldTime().internalField();     const scalarField& M0i = M.oldTime().internalField();     const unallocLabelList& owner = mesh.owner();     const unallocLabelList& neighbour = mesh.neighbour();     Xi = vector::zero;         forAll(owner, faceI)     {         label P = owner[faceI];         label N = neighbour[faceI];         // You're gonna have to sort out the sign issue here         // This will probably need the face normal         Xi[P] += X0i[N]*M0i[faceI];         Xi[N] -= X0i[P]*M0i[faceI];     }     forAll(mesh.boundaryMesh(), patchI)     {         fvPatchVectorField& pf = X.boundaryField()[patchI];         const fvPatchVectorField& pf0 = X.oldTime().boundaryField()[patchI];         const fvsPatchScalarField& psf = M.oldTime().boundaryField()[patchI];         const unallocLabelList& faceCells = mesh.boundaryMesh()[patchI].faceCells();         if (pf.coupled())         {             // I'm going to leave this one up to you         }         else         {             forAll(pf, faceI)             {                 Xi[faceCells[faceI]] += pf0[faceI]*psf[faceI];             }         }            }     X.correctBoundaryConditions();```

 cliffoi March 7, 2011 13:25

This might be a much simpler alternative. Again, you need to sort out the discretization and mathematical correctness.
X = fvc::surfaceSum(fvc::interpolate(X.oldTime())*M.ol dTime())

 Zato_Ichi March 7, 2011 18:44