CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   semiImplicitSource, Source defined for field but never used (https://www.cfd-online.com/Forums/main/226360-semiimplicitsource-source-defined-field-but-never-used.html)

Tom Lauriks April 24, 2020 12:22

semiImplicitSource, Source defined for field but never used
 
Hi Foamers,


I’m performing an atmospheric boundary layer simulation with OpenFOAM v6. The domain is a cuboid. In the middle, there are 2 buildings. In between the buildings at the ground level, a passive scalar should be released from 4 volumes, collectively known as source1, this at a fixed mass flow rate. These volumes are created via topoSet as a cellSet and are indeed present (verified in paraFoam).



I used the simpleFoam solver and added the scalar transport as a function object of type scalarTransport. The field has the name sf6. When I specify a concentration at the inlet, sf6 is calculated. When I specify concentration 0 at the inlet and a scalarSemiImplicitSource in fvOptions, in the log file I get the line “Source scalarSource defined for field sf6 but never used”. I checked the scalarTransport.C file and the source term is present in the equation: fvScalarMatrix sEqn ( fvm::ddt(rho, s_) + fvm::div(phi, s_, divScheme) - fvm::laplacian(D, s_, laplacianScheme) == fvOptions_(rho, s_) );



What I found so far on the forum isn’t helping. Does anyone have an idea how to solve this issue?



The semiImplicitSource is defined in fvOptions as follows:


Code:

scalarSource//name
 {
 
 
    type            scalarSemiImplicitSource;
    active          true;//Usable with any type
 
 
 
 
    scalarSemiImplicitSourceCoeffs
    {
 
 
 //        timeStart      0;//Usable with any type
 //        duration        1e6;//Usable with any type
        selectionMode  cellSet;// all, cellSet, points, cellZone 
        cellSet      source1;//Name of cell set or cell zone
 
 
 
 
        volumeMode    absolute; //absolute <quantity>; specific <quantity>/m^3
        injectionRateSuSp 
        {
            sf6      (10.0 0.0); //keyword is field name. 1st value is explicit value, 2nd implicit coefficient. 
                              //Units: [M T-1], where these units should probably be consistent with time and mass used in other the simulation settings
                              //CODASC case: source strength is 10 g s-1
        }
 
 
 
 
    }
 }

p { margin-bottom: 0.1in; line-height: 115%; orphans: 2; widows: 2 } a.western:visited { so-language: en-GB } a.cjk:visited { so-language: en-US } a.ctl:visited { so-language: ar-SA } a:link { color: #0563c1 }
p { margin-bottom: 0.1in; line-height: 115%; orphans: 2; widows: 2 } a.western:visited { so-language: en-GB } a.cjk:visited { so-language: en-US } a.ctl:visited { so-language: ar-SA } a:link { color: #0563c1 }
p { margin-bottom: 0.1in; line-height: 115%; orphans: 2; widows: 2 } a.western:visited { so-language: en-GB } a.cjk:visited { so-language: en-US } a.ctl:visited { so-language: ar-SA } a:link { color: #0563c1 }p { margin-bottom: 0.1in; line-height: 115%; orphans: 2; widows: 2 } a.western:visited { so-language: en-GB } a.cjk:visited { so-language: en-US } a.ctl:visited { so-language: ar-SA } a:link { color: #0563c1 }

LuckyTran April 24, 2020 12:52

Is there any chance that your transported scalar is NOT named sf6? What do you have in your 0 dir?

Tom Lauriks April 24, 2020 13:10

In the 0 dir, I have the file sf6, with the following header:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 6 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object sf6;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

LuckyTran April 24, 2020 13:17

So in your definition of the scalar you correctly named the field not vapour but sf6? E.g.:
Code:

scalar1 {
    type            scalarTransport;
    libs            ("libsolverFunctionObjects.so");
      // Optional entries      // Name of scalar field to transport, default = 's'
    field          vapour;


Tom Lauriks April 24, 2020 13:44

Already thanks for helping out!

Do you mean in the functionObject definition? If yes, I indeed named the field sf6. This is how wrote the functionObject:

sf6 //Object name
{
type scalarTransport;
functionObjectLibs ("libsolverFunctionObjects.so");

enabled true;

writeControl outputTime;
//writeControl timeStep;
//writeInterval 1;

log yes;

nCorr 1;//Number of corrector iterations. At least 1 is recommended.

//Diffusion coefficient
// D 9.30E-6;//[m2 s-1] Molecular difussion coefficient
//If turbulent modeling in use, can define alphaD and alphaDt. OF source code manual D = alphaD*nu + alphaDt*nut. OF source code, scalarTransport.C:
//fvScalarMatrix sEqn ( fvm::ddt(rho, s_) + fvm::div(phi, s_, divScheme) - fvm::laplacian(D, s_, laplacianScheme) == fvOptions_(rho, s_) );
//Hence D is sum of molecular and turbulent diffusion. In COMSOL manual, diffusive flux is made up by: (D+nu_t/Sc_t). The sum of everything between the brackets should be the
//equivalent of D from the OF source code manual. Hence, in D=alphaD*nu + alphaDt*nut, alphaD*nu is the molecular diffusion coefficient and alphaDt*nut the turbulent diffusion coefficient.
//Hence, alphaD=D_molecular/nu. From the COMSOL manual and the info in en.wikipedia.org/wiki/Schmidt_number, it is clear that alphaDt=1/Sc_t, since Sc_t=nu_t/D_t
alphaD 0.62;
alphaDt 1.4286;

field sf6;//name of field. Need to select discretization schemes and linear solvers for this field. Also need to define boundary conditions and initial conditions for this field.

//Optional. Use the schemes of field, in this case, U
//schemesField U;
}

LuckyTran April 24, 2020 14:35

The message Source scalarSource defined for field sf6 but never used comes from fvOption. Seeing this msg means fvOption is supported and that it was read but it doesn't know what to do with it. If there was missing definitions, you would get the corresponding error.

Usually what happens is, you define a source for a field (in this case sf6) and that field doesn't exist (or it exists but it's not registered) for the particular solver because you misnamed one or the other.

So my next question is... where are these dicts? I'm guessing the scalarTransport is defined as a function object in your control dict. Where did you put the fvOptions stuff? In its own dict in the system or constants? It needs to be declared as a sub-dict inside the same function object. E.g.


Code:

    s
    {
        type            scalarTransport;
        libs            ("libsolverFunctionObjects.so");
        field          s;

        fvOptions
        {
            s
            {
                type            scalarSemiImplicitSource;
                volumeMode      absolute;
                injectionRateSuSp
                {
                    s    (1000 0);
                }
            }
        }


Tom Lauriks April 24, 2020 15:43

(I've defined my function objects external to controlDict and I load them as follows:
functions
{
#include "externalFunctionObjects"
})

I was indeed placing fvOptions in either system or constant. I tried what you specified and it works! I would've never found that on my own. Thanks a lot, you've really, really, really made my day!

LuckyTran April 24, 2020 20:25

Great!


In general you can and should put the fvOptions stuff in its own dict in the constant or system dirs. If you had done this for any normal field (like p, T, U) chances are, it would have worked.



Your case was a bit special because your sf6 field is defined by a coded function object (it not a pre-registered fieldname).

SHANRU July 18, 2022 17:44

In my case, the fvOption was missed in thee equation.

Quote:

Originally Posted by Tom Lauriks (Post 767242)
Hi Foamers,


I’m performing an atmospheric boundary layer simulation with OpenFOAM v6. The domain is a cuboid. In the middle, there are 2 buildings. In between the buildings at the ground level, a passive scalar should be released from 4 volumes, collectively known as source1, this at a fixed mass flow rate. These volumes are created via topoSet as a cellSet and are indeed present (verified in paraFoam).



I used the simpleFoam solver and added the scalar transport as a function object of type scalarTransport. The field has the name sf6. When I specify a concentration at the inlet, sf6 is calculated. When I specify concentration 0 at the inlet and a scalarSemiImplicitSource in fvOptions, in the log file I get the line “Source scalarSource defined for field sf6 but never used”. I checked the scalarTransport.C file and the source term is present in the equation: fvScalarMatrix sEqn ( fvm::ddt(rho, s_) + fvm::div(phi, s_, divScheme) - fvm::laplacian(D, s_, laplacianScheme) == fvOptions_(rho, s_) );



What I found so far on the forum isn’t helping. Does anyone have an idea how to solve this issue?



The semiImplicitSource is defined in fvOptions as follows:


Code:

scalarSource//name
 {
 
 
    type            scalarSemiImplicitSource;
    active          true;//Usable with any type
 
 
 
 
    scalarSemiImplicitSourceCoeffs
    {
 
 
 //        timeStart      0;//Usable with any type
 //        duration        1e6;//Usable with any type
        selectionMode  cellSet;// all, cellSet, points, cellZone 
        cellSet      source1;//Name of cell set or cell zone
 
 
 
 
        volumeMode    absolute; //absolute <quantity>; specific <quantity>/m^3
        injectionRateSuSp 
        {
            sf6      (10.0 0.0); //keyword is field name. 1st value is explicit value, 2nd implicit coefficient. 
                              //Units: [M T-1], where these units should probably be consistent with time and mass used in other the simulation settings
                              //CODASC case: source strength is 10 g s-1
        }
 
 
 
 
    }
 }

p { margin-bottom: 0.1in; line-height: 115%; orphans: 2; widows: 2 } a.western:visited { so-language: en-GB } a.cjk:visited { so-language: en-US } a.ctl:visited { so-language: ar-SA } a:link { color: #0563c1 }
p { margin-bottom: 0.1in; line-height: 115%; orphans: 2; widows: 2 } a.western:visited { so-language: en-GB } a.cjk:visited { so-language: en-US } a.ctl:visited { so-language: ar-SA } a:link { color: #0563c1 }
p { margin-bottom: 0.1in; line-height: 115%; orphans: 2; widows: 2 } a.western:visited { so-language: en-GB } a.cjk:visited { so-language: en-US } a.ctl:visited { so-language: ar-SA } a:link { color: #0563c1 }p { margin-bottom: 0.1in; line-height: 115%; orphans: 2; widows: 2 } a.western:visited { so-language: en-GB } a.cjk:visited { so-language: en-US } a.ctl:visited { so-language: ar-SA } a:link { color: #0563c1 }



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