CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   initialization of scalar source using volume integral of source cells (http://www.cfd-online.com/Forums/openfoam-solving/115041-initialization-scalar-source-using-volume-integral-source-cells.html)

letzel March 22, 2013 08:21

initialization of scalar source using volume integral of source cells
 
Dear All,

my modified pisoFoam solver includes a passive scalar transport equation for LES:
Code:

...
        turbulence->correct();

        solve
        (
            fvm::ddt(s1)
          + fvm::div(phi, s1)
          - fvm::laplacian(turbulence->nut(), s1)
          ==
          s1Source
        );

        runTime.write();
...

In createFields.H, both s1 and s1Source are defined per Volume (m^-3):
Code:

    volScalarField s1
    (
        IOobject
        (
            "s1",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("s1", dimensionSet(1,-3,0,0,0,0,0), scalar(0))
    );

    Info<< "Reading field s1Source\n" << endl;
    volScalarField s1Source
    (
        IOobject
        (
            "s1Source",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("s1Source", dimensionSet(1,-3,-1,0,0,0,0), scalar(0))
    );

My practical scenario is an air pollution simulation where I know the source volume and its (total) emission rate in kg/s.

So far, I initialize s1Source using a region in setFieldsDict:
Code:

    boxToCell
    {
        box (35.75 0.0 27.5) (36.25 0.5 28.5);

        fieldValues
        (
            volScalarFieldValue s1Source 0.001
        );
    };

In my current mesh, setFields finds and sets two cells, and the total emission rate depends on the size of these cells. This is not what I want.

Instead, I need an algorithm that sets s1Source in these cells to values so that the volume integral of s1Source over these cells matches a prescribed total emission rate.

Can this be achieved using setFields, or perhaps funkySetFields? If not, how and in which file could it be coded?

Best regards,
Marcus

gschaider March 24, 2013 11:33

Quote:

Originally Posted by letzel (Post 415683)
Dear All,

my modified pisoFoam solver includes a passive scalar transport equation for LES:

My practical scenario is an air pollution simulation where I know the source volume and its (total) emission rate in kg/s.

So far, I initialize s1Source using a region in setFieldsDict:

In my current mesh, setFields finds and sets two cells, and the total emission rate depends on the size of these cells. This is not what I want.

Instead, I need an algorithm that sets s1Source in these cells to values so that the volume integral of s1Source over these cells matches a prescribed total emission rate.

Can this be achieved using setFields, or perhaps funkySetFields? If not, how and in which file could it be coded?

Somewhere between funkySetFields, coded and your solution: swak4Foam has something called expressionSource (search for that on the forum and you'll find an explanation how to integrate that) that you insert into your solver (at the place where you insert the field). That evaluates a funkySetFields-like expression and adds it as a source term. Built on that swak offers you child classes to basicSource (in OF up to 2.1) and fvOption (since 2.1) which you could add to your solver similarly. With that your solver doesn't need swak, but it can choose to use it via runtime selection.

If you don't want to change the solver anymore there is always the possibility to modify the s1-field with the modifyField-functionObject

wayne14 May 13, 2015 03:58

Quote:

Originally Posted by letzel (Post 415683)
Dear All,

my modified pisoFoam solver includes a passive scalar transport equation for LES:
Code:

...
        turbulence->correct();

        solve
        (
            fvm::ddt(s1)
          + fvm::div(phi, s1)
          - fvm::laplacian(turbulence->nut(), s1)
          ==
          s1Source
        );

        runTime.write();
...

In createFields.H, both s1 and s1Source are defined per Volume (m^-3):
Code:

    volScalarField s1
    (
        IOobject
        (
            "s1",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("s1", dimensionSet(1,-3,0,0,0,0,0), scalar(0))
    );

    Info<< "Reading field s1Source\n" << endl;
    volScalarField s1Source
    (
        IOobject
        (
            "s1Source",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("s1Source", dimensionSet(1,-3,-1,0,0,0,0), scalar(0))
    );

My practical scenario is an air pollution simulation where I know the source volume and its (total) emission rate in kg/s.

So far, I initialize s1Source using a region in setFieldsDict:
Code:

    boxToCell
    {
        box (35.75 0.0 27.5) (36.25 0.5 28.5);

        fieldValues
        (
            volScalarFieldValue s1Source 0.001
        );
    };

In my current mesh, setFields finds and sets two cells, and the total emission rate depends on the size of these cells. This is not what I want.

Instead, I need an algorithm that sets s1Source in these cells to values so that the volume integral of s1Source over these cells matches a prescribed total emission rate.

Can this be achieved using setFields, or perhaps funkySetFields? If not, how and in which file could it be coded?

Best regards,
Marcus

Hi Marcus,

I met the same problem. Did you find any solution?

Thank you!


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