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

lookup 'rho' in scalarcoded source

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 14, 2021, 08:33
Default lookup 'rho' in scalarcoded source
  #1
Member
 
Kabir Shariff
Join Date: Oct 2016
Location: France
Posts: 53
Rep Power: 10
Kbshariff is on a distinguished road
Hello foamers,
I want to add a source term to k-epsilon model. I I want to extract the value of 'rho' define by openfoam. My source term for k is of the form

Code:
Ksource = rho*eps;

I defined my source term as:


Code:
kSource
{
    type            scalarCodedSource;
    selectionMode   all;
    fields          (k);
    name            kSource;

        codeCorrect
        #{
        #};

    codeConstrain
    #{
    #};

    codeAddSup
    #{
	scalarField& kSource = eqn.source();

	Info<< "Reading density rho\n" << endl;
	dimensionedScalar rho	(transportProperties.lookup("rho"));
	const scalar Io_ = 0.08;
	const scalar Kin_ = pow((Io_*2.7),2);
	const scalar epsin_ = pow(0.09,0.75)*pow(Kin_,1.5)/3.5;

	const labelList& cellIDs = cells();
		
		forAll(cellIDs,i)
		{
			label cellI = cellIDs[i];
			kSource[cellI] -=rho*epsin_;
		}
	#};
}

I have this error message

Code:
    ln: ./lnInclude
    dep: codedFvOptionTemplate.C
    Ctoo: codedFvOptionTemplate.C
/dlocal/run/8991139/constant/fvOptions.kSource: In member function ‘virtual void Foam::fv::kSourceFvOptionscalarSource::addSup(Foam::fvMatrix<double>&, Foam::label)’:
/dlocal/run/8991139/constant/fvOptions.kSource:61:25: error: ‘transportProperties’ was not declared in this scope
/dlocal/run/8991139/constant/fvOptions.kSource:71:19: error: no match for ‘operator-=’ (operand types are ‘double’ and ‘Foam::dimensionedScalar {aka Foam::dimensioned<double>}’)
/dlocal/run/8991139/constant/fvOptions.kSource: In member function ‘virtual void Foam::fv::kSourceFvOptionscalarSource::addSup(const volScalarField&, Foam::fvMatrix<double>&, Foam::label)’:
/dlocal/run/8991139/constant/fvOptions.kSource:61:25: error: declaration of ‘Foam::dimensionedScalar rho’ shadows a parameter
/dlocal/run/8991139/constant/fvOptions.kSource:61:25: error: ‘transportProperties’ was not declared in this scope
/dlocal/run/8991139/constant/fvOptions.kSource:71:19: error: no match for ‘operator-=’ (operand types are ‘double’ and ‘Foam::dimensionedScalar {aka Foam::dimensioned<double>}’)
make: *** [Make/linux64GccDPInt32Opt/codedFvOptionTemplate.o] Error 1
Attached Images
File Type: jpg kkasmi.JPG (9.7 KB, 0 views)
Kbshariff is offline   Reply With Quote

Old   December 14, 2021, 10:05
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
You will likely need codeInclude and codeLibs etc to do what are want. You will need to read some docs.
olesen is offline   Reply With Quote

Reply

Tags
dimensioned scalars, fvoptions, kepsilon, scalarcodedsource


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 17:05
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 tlcoons OpenFOAM Installation 13 April 20, 2016 18:34
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 18:18
[swak4Foam] swak4Foam-groovyBC build problem zxj160 OpenFOAM Community Contributions 18 July 30, 2013 14:14
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 06:18


All times are GMT -4. The time now is 03:54.