CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Set cell volume integrated field values to preserve integral (https://www.cfd-online.com/Forums/openfoam-pre-processing/201368-set-cell-volume-integrated-field-values-preserve-integral.html)

Diro7 April 30, 2018 10:01

Set cell volume integrated field values to preserve integral
 
Hello to everyone!

What I'm doing is basically scalar transport with a custom solver which I wrote by adding a scalar transport equation to simpleFoam.

Since for the moment I'm simulating point sources, I created a source volScalarField Qc which is set to zero everywhere except for a single cell, using setFields:

Code:

defaultFieldValues
(
    volScalarFieldValue Qc 0
);

regions
(
    nearestToCell
    {
        points ((0.02 0.015 0));

        fieldValues
        (
            volScalarFieldValue Qc 1
        );
    }
);

The cell is selected with nearestToCell, which looks for the nearest cell to a specified cartesian point.

I would like to impose the total scalar source rate (e.g. in kg/s) located at the specific point, but setFields obviously sets the volume field, meaning that the value I set in setFieldsDict (1 in the above example) would be the "volume averaged" one, so that the volume integral of the source field would depend on the volume of the specific cell.

At the beginning I was using a simple geometry and a structured mesh, so that I could knew the cell volume in advance. Now I need to use an unstructured mesh and to move the position of the source from one simulation to another.

Is there any simple way to set the volume-integral value instead of the volume-average one to the cell (or, equivalently, to know the specific cell volume)?

Thanks in advance,
Andrea

EDIT: another way of putting it would be to get the volume of the cellSet in which the source is defined. I'm no expert with OpenFOAM, but maybe it would be easier to manipulate a "cellSet entity" rather than a "cell" itself. The cellSet can be easily created with topoSet, and being able to calculate its volume would be a more general procedure (like in the case of non-point source). Unfortunately I've been reasoning about this possibility, but I couldn't find anything on this forum

fumiya June 3, 2018 00:47

You can use the SemiImplicitSource fvOption to specify your mass source.
There is the volumeMode entry and you can choose absolute option.

https://github.com/OpenFOAM/OpenFOAM...plicitSource.H

Diro7 June 3, 2018 10:44

Quote:

Originally Posted by fumiya (Post 694407)
You can use the SemiImplicitSource fvOption to specify your mass source.
There is the volumeMode entry and you can choose absolute option.

https://github.com/OpenFOAM/OpenFOAM...plicitSource.H


Hi fumiya,

thank you very much for your reply. I'm not expert with using fvOptions, but it seems very useful so I'll definitely go and see what I can do with it.

Regarding my initial problem, I solved it by writing a slightly modified version of setFields which computes the total volume of the cell set and divides the source intensity by it before setting the field.


Thank you again!


Andrea


All times are GMT -4. The time now is 06:20.