CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Add source term to KEpsilon model in given location (https://www.cfd-online.com/Forums/openfoam-solving/234140-add-source-term-kepsilon-model-given-location.html)

Kbshariff February 24, 2021 10:37

Add source term to KEpsilon model in given location
 
Hello foamers,

I am simulating tidal turbine using actuator disc concept in OpenFOAM v2006.
I want to add a source term of turbulence production term around the disc region only.

How can I specify the location where the source term is added???

Thanks

mAlletto February 24, 2021 14:15

You can use a codedfvOption an include the source term in the k equation. Take a look at the actuator disk model how to specify the locations https://develop.openfoam.com/Develop...tionDiskSource

Best

Michael

Kbshariff March 8, 2021 03:27

1 Attachment(s)
Quote:

Originally Posted by mAlletto (Post 797167)
You can use a codedfvOption an include the source term in the k equation. Take a look at the actuator disk model how to specify the locations https://develop.openfoam.com/Develop...tionDiskSource

Best

Michael


Hello Michael,

I use the coded fvoptions as suggested and I got this error. First of all, I had to compile the coded fv options ( I am using a cluster server v2006)

below is my fv options file. I am interested in adding the following term (see attachment please)
Code:

codedSource
{
    type            scalarCodedSource;
    selectionMode  cellSet;
    cellSet        sourceDisk1;

    fields          (epsilon);
    name            codedSource;

    codeAddSup
    #{
        const Time& time = mesh().time();
        const scalarField& V = mesh_.V();
        const scalarField& rh        = 1000;
        const scalarField& eps = 0.06287;
        const scalarField& kk        = 1.215;
        const scalarField& Cm2        = 0.09;
        const scalarField & epsilonSource = eqn.source();

        forAll(C,i)
        {
                epsilonSource[i] += rh*Cm2*pow(eps,2)/kk*V[i];
        }
            Pout << "***codeAddSup***" << endl;
    #};


    codeCorrect
    #{
    #};

    codeConstrain
    #{
    #};
    sourceTimeCoeffs
    {
        // Dummy entry
    }
}

and here is the log file for the error message
Code:

smoothSolver:  Solving for Ux, Initial residual = 1, Final residual = 0.0496559290788, No Iterations 4
smoothSolver:  Solving for Uy, Initial residual = 0.999999999508, Final residual = 0.0927538575586, No Iterations 3
smoothSolver:  Solving for Uz, Initial residual = 0.999999999943, Final residual = 0.0388575837312, No Iterations 3
[125] swak4Foam: Allocating new repository for sampledGlobalVariables
GAMG:  Solving for p, Initial residual = 1, Final residual = 0.000945134305598, No Iterations 28
time step continuity errors : sum local = 4.29755393053e-06, global = -5.81621224202e-09, cumulative = -5.81621224202e-09
Using dynamicCode for fvOption::codedSource at line 52 in "/dlocal/run/8137670/constant/fvOptions.codedSource"
Could not load "/dlocal/run/8137670/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodedSource_80756ad56d8baed425ef1007b62ccf592e79c6c3.so"
/dlocal/run/8137670/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodedSource_80756ad56d8baed425ef1007b62ccf592e79c6c3.so: cannot open shared object file: No such file or directory
.....
.....
Invoking wmake libso /dlocal/run/8137670/dynamicCode/codedSource
wmake libso /dlocal/run/8137670/dynamicCode/codedSource
    ln: ./lnInclude
    dep: codedFvOptionTemplate.C
    Ctoo: codedFvOptionTemplate.C
/dlocal/run/8137670/constant/fvOptions.codedSource: In member function ‘virtual void Foam::fv::codedSourceFvOptionscalarSource::addSup(Foam::fvMatrix<double>&, Foam::label)’:
/dlocal/run/8137670/constant/fvOptions.codedSource:102:17: error: aggregate ‘std::ofstream file’ has incomplete type and cannot be defined
/dlocal/run/8137670/constant/fvOptions.codedSource:103:33: error: incomplete type ‘std::ofstream {aka std::basic_ofstream<char>}’ used in nested name specifier
/dlocal/run/8137670/constant/fvOptions.codedSource:103:54: error: incomplete type ‘std::ofstream {aka std::basic_ofstream<char>}’ used in nested name specifier
/dlocal/run/8137670/constant/fvOptions.codedSource: In member function ‘virtual void Foam::fv::codedSourceFvOptionscalarSource::addSup(const volScalarField&, Foam::fvMatrix<double>&, Foam::label)’:
/dlocal/run/8137670/constant/fvOptions.codedSource:102:17: error: aggregate ‘std::ofstream file’ has incomplete type and cannot be defined
/dlocal/run/8137670/constant/fvOptions.codedSource:103:33: error: incomplete type ‘std::ofstream {aka std::basic_ofstream<char>}’ used in nested name specifier
/dlocal/run/8137670/constant/fvOptions.codedSource:103:54: error: incomplete type ‘std::ofstream {aka std::basic_ofstream<char>}’ used in nested name specifier
make: *** [Make/linux64GccDPInt32Opt/codedFvOptionTemplate.o] Error 1
[0]
[0]
[0] --> FOAM FATAL IO ERROR:
[0] Failed wmake "dynamicCode/codedSource/platforms/linux64GccDPInt32Opt/lib/libcodedSource_80756ad56d8baed425ef1007b62ccf592e79c6c3.so"
[0]
[0]
[0] file: /dlocal/run/8137670/constant/fvOptions.codedSource at line 52.
[0]
[0]    From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
[0]    in file db/dynamicLibrary/codedBase/codedBase.C at line 237.
[0]
FOAM parallel run exiting
[0]
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0
In: PMI_Abort(1, application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0)
srun: Job step aborted: Waiting up to 32 seconds for job step to finish.
slurmstepd: error: *** STEP 8137670.2 ON my253 CANCELLED AT 2021-03-08T09:09:52 ***
srun: error: my261: tasks 112-139: Killed
srun: Terminating job step 8137670.2
srun: error: my253: tasks 0-27: Killed
srun: error: my254: tasks 28-55: Killed
srun: error: my260: tasks 84-111: Killed
srun: error: my259: tasks 56-83: Killed


Thank you

mAlletto March 8, 2021 03:58

Seems a problem with the output. Can you comment the Pout line.



In the error the appear some line numbers. Which line number are this?

Kbshariff March 8, 2021 04:14

Quote:

Originally Posted by mAlletto (Post 798177)
Seems a problem with the output. Can you comment the Pout line.



In the error the appear some line numbers. Which line number are this?


1./ I have commented the Pout line, but I still have the same problem


2/ The line numbers are for the parallel processors, I am running the simulation on cluster network.

mAlletto March 8, 2021 04:20

Code:



scalar rh        = 1000; scalar eps = 0.06287; scalar kk        = 1.215; scalar Cm2        = 0.09;




you're assign scalarField to scalars ... but you treat it as scalar inside the for loop

Kbshariff March 8, 2021 05:42

Quote:

Originally Posted by mAlletto (Post 798181)
Code:



scalar rh        = 1000; scalar eps = 0.06287; scalar kk        = 1.215; scalar Cm2        = 0.09;




you're assign scalarField to scalars ... but you treat it as scalar inside the for loop



I want to apply the source term to only cells defined in the cellset, not the entire domain

I have specified the cellset using topoSet

mAlletto March 8, 2021 06:39

Code:

forAll(C,i)    {        epsilonSource[i] += rh*Cm2*pow(eps,2)/kk*V[i];    }
in your code rh, Cmu, eps and kk are scalarFileds ...


you do not define the size either ...


this may be your mistake

Kbshariff March 8, 2021 08:58

Quote:

Originally Posted by mAlletto (Post 798202)
Code:

forAll(C,i)    {        epsilonSource[i] += rh*Cm2*pow(eps,2)/kk*V[i];    }
in your code rh, Cmu, eps and kk are scalarFileds ...


you do not define the size either ...


this may be your mistake

thank you for the observation

I found another method to apply scalar fields using the semi-implicit fvOptions below
Code:

scalarSource
{
    type            scalarSemiImplicitSource;
    selectionMode  cellSet;
    cellSet              sourceDisk1;

    volumeMode      absolute;

    injectionRateSuSp
    {
        k          (30.7 0);
        epsilon    (1.5  0);
    }
}

Is it correct to calculate the value as given in the formula and add it as explicit term in the relation?

Code:

generalSource
{
    type            <type>SemiImplicitSource;

    ...

    volumeMode      absolute; // absolute | specific

    injectionRateSuSp
    {
        <field>          (<explicit value> <implicit coefficient>);
        ...
    }
}

thanks

mAlletto March 8, 2021 09:30

No experience about your function objects. Is there no documentation


All times are GMT -4. The time now is 13:01.