CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   volScalarField question (http://www.cfd-online.com/Forums/openfoam/87569-volscalarfield-question.html)

adhiraj April 23, 2011 11:23

volScalarField question
 
Hi all,
I am trying to define a new volScalarField mu. I want to use it as a diffusivity in the transport equation. Now since this field is to be calculated, and not solved for, I cannot specify boundary conditions for it. But how do I make sure that the boundary fields also get updated? This would be important in my mind, as the value might need to be interpolated to call faces during use.
It would be very helpful if some one could come up with an answer.
Thanks.

benk April 26, 2011 09:16

You can specify boundary conditions for any field. Normally a diffusivity would have zeroGradient boundary conditions but you could also just make them fixedValue and then update the fixedValue boundaries appropriately.

After updating the field, do a:
Code:

mu.correctBoundaryConditions();
I think this is only required if you have a zeroGradient boundary condition and you update the internal fields, but I run this command each time I update the field (even if I don't have zeroGradient BCs) just to be safe.

adhiraj April 26, 2011 10:02

Quote:

Originally Posted by benk (Post 305117)
You can specify boundary conditions for any field. Normally a diffusivity would have zeroGradient boundary conditions but you could also just make them fixedValue and then update the fixedValue boundaries appropriately.

After updating the field, do a:
Code:

mu.correctBoundaryConditions();
I think this is only required if you have a zeroGradient boundary condition and you update the internal fields, but I run this command each time I update the field (even if I don't have zeroGradient BCs) just to be safe.

Thanks for replying. Can you give me a heads up as to what this function does? Like say for example, it takes the vales from the first row of cells at the boundary and puts them at the boundary faces.
Thanks.

benk April 26, 2011 10:28

Quote:

Originally Posted by adhiraj (Post 305125)
Thanks for replying. Can you give me a heads up as to what this function does? Like say for example, it takes the vales from the first row of cells at the boundary and puts them at the boundary faces.
Thanks.

I'm pretty sure that's how it works (ie. takes the neighboring cells and copies them to the boundary to ensure the zeroGradient BC). You can check to see if it works by doing something like this:


Code:

label wall = mesh.boundaryMesh().findPatchID("INSERT_PATCH_NAME_HERE");

Info << mu.boundaryField()[wall][0] << endl;
mu.correctBoundaryFields();
Info << mu.boundaryField()[wall][0] << endl;

This will print out the value of your mu field at the boundary for cell index 0 (or any other boundary index you want) before and after updating the boundaries.

I did find this post though: http://www.cfd-online.com/Forums/ope...perations.html which implies it may not work in parallel...but I haven't verified this and it's quite an old post.

atoof January 22, 2013 08:41

correcting internalfield of a not-solving volscalarfield in each time step
 
Quote:

Originally Posted by benk (Post 305117)
You can specify boundary conditions for any field. Normally a diffusivity would have zeroGradient boundary conditions but you could also just make them fixedValue and then update the fixedValue boundaries appropriately.

After updating the field, do a:
Code:

mu.correctBoundaryConditions();
I think this is only required if you have a zeroGradient boundary condition and you update the internal fields, but I run this command each time I update the field (even if I don't have zeroGradient BCs) just to be safe.

Dear benk,

I have a the following variable:
Code:

volScalarField diffus
(
        IOobject
        (
            "diffus",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
            ),
        lambda/cp
        );

where lambda and cp are volScalarField variables and varies in the fields in each time step.
How can I correct "diffus" before using it?

Thanks,

Mohammad


All times are GMT -4. The time now is 05:32.