CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Add source term to KEpsilon model in given location

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 24, 2021, 10:37
Default Add source term to KEpsilon model in given location
  #1
Member
 
Kabir Shariff
Join Date: Oct 2016
Location: France
Posts: 53
Rep Power: 9
Kbshariff is on a distinguished road
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
Kbshariff is offline   Reply With Quote

Old   February 24, 2021, 14:15
Default
  #2
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
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
mAlletto is offline   Reply With Quote

Old   March 8, 2021, 03:27
Default
  #3
Member
 
Kabir Shariff
Join Date: Oct 2016
Location: France
Posts: 53
Rep Power: 9
Kbshariff is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
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
Attached Images
File Type: png ep.PNG (5.2 KB, 10 views)
Kbshariff is offline   Reply With Quote

Old   March 8, 2021, 03:58
Default
  #4
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
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?
mAlletto is offline   Reply With Quote

Old   March 8, 2021, 04:14
Default
  #5
Member
 
Kabir Shariff
Join Date: Oct 2016
Location: France
Posts: 53
Rep Power: 9
Kbshariff is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
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.
Kbshariff is offline   Reply With Quote

Old   March 8, 2021, 04:20
Default
  #6
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
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
mAlletto is offline   Reply With Quote

Old   March 8, 2021, 05:42
Default
  #7
Member
 
Kabir Shariff
Join Date: Oct 2016
Location: France
Posts: 53
Rep Power: 9
Kbshariff is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
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
Kbshariff is offline   Reply With Quote

Old   March 8, 2021, 06:39
Default
  #8
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
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
mAlletto is offline   Reply With Quote

Old   March 8, 2021, 08:58
Default
  #9
Member
 
Kabir Shariff
Join Date: Oct 2016
Location: France
Posts: 53
Rep Power: 9
Kbshariff is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
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
Kbshariff is offline   Reply With Quote

Old   March 8, 2021, 09:30
Default
  #10
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
No experience about your function objects. Is there no documentation
mAlletto is offline   Reply With Quote

Reply

Tags
actuationdisksource, kepsilonmodel

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM.com] swak4foam compiling issues on a cluster saj216 OpenFOAM Installation 5 January 17, 2023 16:05
How to add Source term (2) for PYROLYSIS - reactingOneDim Kummi OpenFOAM 10 April 12, 2021 21:11
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 10:59
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 10:57
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24


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