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

runTimeSelection of viscosityModels in pimpleFoam !

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 18, 2014, 00:12
Post runTimeSelection of viscosityModels in pimpleFoam !
  #1
Member
 
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 13
bieshuxuhe is on a distinguished road
hi !
In pimpleFoam/createFields.H , there is a line of code :

Code:
singlePhaseTransportModel laminarTransport(U, phi);
I think that code means reading transportProperties ! So I check it in the source guide , there is :
Code:
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 Foam::singlePhaseTransportModel::singlePhaseTransportModel
34 (
35  const volVectorField& U,
36  const surfaceScalarField& phi
37 )
38 :
39  transportModel(U, phi),
40  viscosityModelPtr_(viscosityModel::New("nu", *this, U, phi))  
41 {}
42 


31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 Foam::transportModel::transportModel
34 (
35  const volVectorField& U,
36  const surfaceScalarField& phi
37 )
38 :
39  IOdictionary
40  (
41  IOobject
42  (
43  "transportProperties",
44  U.time().constant(),
45  U.db(),
46  IOobject::MUST_READ_IF_MODIFIED,
47  IOobject::NO_WRITE
48  )
49  )
50 {}
please note the red "*this" , "this" pointer should point to the object of "singlePhaseTransportModel class" ! so the "*this" is the laminarTransport ,but the New() function need a dictionary not a singlePhaseTransportModel ! look down the code:
Code:
Foam::autoPtr<Foam::viscosityModel> Foam::viscosityModel::New
(
    const word& name,
    const dictionary& viscosityProperties,
    const volVectorField& U,
    const surfaceScalarField& phi
)
{
    const word modelType(viscosityProperties.lookup("transportModel"));

    Info<< "Selecting incompressible transport model " << modelType << endl;

    dictionaryConstructorTable::iterator cstrIter =
        dictionaryConstructorTablePtr_->find(modelType);

    if (cstrIter == dictionaryConstructorTablePtr_->end())
    {
        FatalErrorIn
        (
            "viscosityModel::New(const volVectorField&, "
            "const surfaceScalarField&)"
        )   << "Unknown viscosityModel type "
            << modelType << nl << nl
            << "Valid viscosityModels are : " << endl
            << dictionaryConstructorTablePtr_->sortedToc()
            << exit(FatalError);
    }

    return autoPtr<viscosityModel>
        (cstrIter()(name, viscosityProperties, U, phi));
}
I know that the singlePhaseTransportModel is a multiplely derived class from dictionary class ! is it why we can regard singlePhaseTransportModel as a dictionary when using New()?

thanks!
bieshuxuhe is offline   Reply With Quote

Old   April 18, 2014, 02:30
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Yes.

Code:
class transportModel
:
    public IOdictionary
{
...
}
Code:
Foam::transportModel::transportModel
(
    const volVectorField& U,
    const surfaceScalarField& phi
)
:
    IOdictionary
    (
        IOobject
        (
            "transportProperties",
            U.time().constant(),
            U.db(),
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    )
{}
alexeym is offline   Reply With Quote

Old   April 18, 2014, 03:08
Default
  #3
Member
 
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 13
bieshuxuhe is on a distinguished road
Thanks for your reply !
runTimeSelection mechanism is so beautiful !
so is the objectRegistry.
bieshuxuhe is offline   Reply With Quote

Old   August 4, 2015, 20:45
Default transportmodel
  #4
New Member
 
jafar
Join Date: Jul 2014
Posts: 16
Rep Power: 12
bagherij is on a distinguished road
Hi
I am working on creeping flow (non- Newtonian steady),i used simple foam with a viscosity model ,i need to use kinematic viscosity
(nu(), which returned from viscosity model) to calculate shear stress ,how can i use nu in a utility or a function?i modify the utility "stresscomponent.C" as follow but this message coming
"nu is not declared in this scope"
code:
#include "fvCFD.H"
#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
#include "zeroGradientFvPatchFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
timeSelector::addOptions();

# include "setRootCase.H"
# include "createTime.H"

instantList timeDirs = timeSelector::select0(runTime, args);

# include "createMesh.H"

forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);

Info<< "Time = " << runTime.timeName() << endl;

IOobject Uheader
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);

// Check U exists
if (Uheader.headerOk())
{
mesh.readUpdate();

Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);

# include "createPhi.H"

singlePhaseTransportModel laminarTransport(U, phi);

volScalarField strainRate
(
IOobject
(
"strainRate",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
nu()*sqrt(2.0f)*mag(symm(fvc::gra d(U))) //this command will calculate strainRate
);
strainRate.write();//this will write file "StrainRate" in each time dir!!

}
else
{
Info<< " No U" << endl;
}

Info<< endl;
}

Info<< "End" << endl;

return 0;
}

best regards
jafar

Last edited by bagherij; August 4, 2015 at 20:51. Reason: more explain
bagherij is offline   Reply With Quote

Reply

Tags
runtimeselection


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
Running stably with a large Courant number using pimpleFoam mlawson OpenFOAM 11 November 29, 2014 11:37
pimpleFoam initialization? TBERGE OpenFOAM Running, Solving & CFD 2 April 2, 2014 09:20
pimpleFoam: turbulence->correct(); is not executed when using residualControl hfs OpenFOAM Running, Solving & CFD 3 October 29, 2013 09:35
Understanding pimpleFoam convergence criterion Nucleophobe OpenFOAM Running, Solving & CFD 0 March 13, 2013 19:46
Differences simpleFoam vs. pimpleFoam / RASModel.H vs turbulenceModel.H uli OpenFOAM Programming & Development 7 January 26, 2013 16:01


All times are GMT -4. The time now is 14:25.