CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Trouble adding a directional derivative source term (http://www.cfd-online.com/Forums/openfoam-programming-development/114789-trouble-adding-directional-derivative-source-term.html)

cpro March 17, 2013 21:19

Trouble adding a directional derivative source term
 
Hi everyone. Thanks for checking this.

I am a new OpenFOAM user, and I have been trying to create my own solver to model ferrofluid motion. In the model that I am using, there is a directional derivative source term (i.e. M \cdot \nabla B which I plan to approximate as \nabla\left( M \cdot B \right) where M and B are vectors).

I have M and B set up as volVectorFields, and I want multiply the entire thing by a the volume of each cell over the (constant) density. It looks like the fvc::div function needs one surface scalar field, so I created a phiB in a similar way to the phi for velocity using
Code:

(fvc::interpolate(B) & mesh.Sf())
Next, I try to modify phiB by the constant. Here is some relevant code:

Code:

            phiB=phiB*mesh.V()/rho;

            fvVectorMatrix UEqn
            (
                fvm::ddt(U)
              + fvm::div(phi, U)
              - fvm::laplacian(nu, U)
            );

            solve(UEqn == -fvc::grad(p) + fvc::div(phiB, M));

When I try to compile it, it lists a large number of errors that were not there before attempting to multiply by volume. So, I think the problem occurs when I multiply by the volume of each cell (using mesh.V), but I'm lost as to how to fix it. Any tips or suggestions? Is there a better way to do this?

I really appreciate your help.

alundilong March 19, 2013 17:51

Quote:

Originally Posted by cpro (Post 414577)
Hi everyone. Thanks for checking this.

I am a new OpenFOAM user, and I have been trying to create my own solver to model ferrofluid motion. In the model that I am using, there is a directional derivative source term (i.e. M \cdot \nabla B which I plan to approximate as \nabla\left( M \cdot B \right) where M and B are vectors).

I have M and B set up as volVectorFields, and I want multiply the entire thing by a the volume of each cell over the (constant) density. It looks like the fvc::div function needs one surface scalar field, so I created a phiB in a similar way to the phi for velocity using
Code:

(fvc::interpolate(B) & mesh.Sf())
Next, I try to modify phiB by the constant. Here is some relevant code:

Code:

            phiB=phiB*mesh.V()/rho;

            fvVectorMatrix UEqn
            (
                fvm::ddt(U)
              + fvm::div(phi, U)
              - fvm::laplacian(nu, U)
            );

            solve(UEqn == -fvc::grad(p) + fvc::div(phiB, M));

When I try to compile it, it lists a large number of errors that were not there before attempting to multiply by volume. So, I think the problem occurs when I multiply by the volume of each cell (using mesh.V), but I'm lost as to how to fix it. Any tips or suggestions? Is there a better way to do this?

I really appreciate your help.

phiB ---> surfaceScalarField
mesh.V() ---> volScalarField
rho ---> volScalarField

I think you have to do linear interpolation for volScalarField before math operations.:)


All times are GMT -4. The time now is 17:47.