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

Read fields from viscosity model

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 20, 2013, 07:45
Question Read fields from viscosity model
  #1
New Member
 
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 13
Gaetano is on a distinguished road
Hi all.

I'm having a I/O related problem. To put it simple: I need to read some scalar fields defined in the main solver (based on interFoam, OpenFOAM 2.1.1).
Here's what I've done (myModel.C):

Code:
// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //

Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::myModel::calcNu() const
{

    const volScalarField& myField = U_.db().lookupObject<volScalarField>("myField");
//    THE SAME WITH:
//    const volScalarField& myField = U_.mesh().lookupObject<volScalarField>("myField");

    return
    (
        min
        (
            nu0_,
            //MY FUNCTION GOES HERE
       )
    );
}
Both the viscosityModel (wmake libso) and the solver compiles without errors/warnings.
Here's the output of the simulation:

Code:
Reading transportProperties

./mySolver: symbol lookup error: ./mySolver: undefined symbol: _ZN4Foam15twoPhaseMixtureC1ERKNS_14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEERKNS1_IdNS_13fvsPatchFieldENS_11surfaceMeshEEERKNS_4wordE
The field is defined (in createFields.H, before defining "twoPhaseProperties") as:
Code:
    volScalarField myField
    (
        IOobject
        (
            "myField",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
What am I doing wrong? What does that error mean? Are those weird sequence of character interpretable or not (I found here that 1ERKNS is the representation base 33 of the number 56731153!!!)?

Another question: how can I access the overall rho field from within my viscosity model?

Thanks in advance
Gaetano
Gaetano is offline   Reply With Quote

Old   November 20, 2013, 09:51
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
I think what you need, is probably to look up the fields from the object registry database, which you can access via the mesh.

There are multiple topics that should help you find how to do it, using these keywords
http://www.cfd-online.com/Forums/ope...-registry.html contains a lot of info.
Bernhard is offline   Reply With Quote

Old   November 21, 2013, 06:29
Default
  #3
Senior Member
 
Aurelien Thinat
Join Date: Jul 2010
Posts: 165
Rep Power: 15
Aurelien Thinat is on a distinguished road
Hi Gaetano and Bernhard,

I'm dealing with the same problem.

- In incompressible models, the viscosity object constructor contains the reference of the volScalarField U. So we can define an object "mesh" :
Code:
mesh& myMesh = U.mesh();
And then with look up object, we can get everything (not tested, but I guess it may be right) :
Code:
volScalarField& T = myMesh().lookupObject<volScalarField>("T");
- Now for compressible models. The constructor doesn't contain any volVectorField or volScalarField. And the function "mu()" takes only two scalars p and T in arguments.
How can I get an access to the mesh without modifying the transport object's constructor ?
I also saw this :
Code:
const volVectorField& U = obr_.lookupObject<volvectorField>("U");
But I need to find out how to declare the object "obr_".
Aurelien Thinat is offline   Reply With Quote

Old   November 26, 2013, 13:37
Default
  #4
New Member
 
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 13
Gaetano is on a distinguished road
As said by Bernhard and Aurelien it is possible to access fields in this way:

Code:
const volScalarField& myField = U_.mesh().lookupObject<volScalarField>("myField");
For future reference, a useful step-by-step tutorial is this implementation of a temperature dependent viscosity model.

Thanks for your help!
Gaetano is offline   Reply With Quote

Reply

Tags
interfoam, ioobject, read fields, viscosity models

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
Use of k-epsilon and k-omega Models Jade M Main CFD Forum 40 January 27, 2023 08:18
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
Phase change PYJG CFX 10 November 19, 2013 08:59
Piecewise viscosity model awacs OpenFOAM Running, Solving & CFD 3 June 22, 2010 00:10
Questions about Cross-Arrhenius and Cross-WLF viscosity model awacs OpenFOAM Running, Solving & CFD 4 August 13, 2009 07:56


All times are GMT -4. The time now is 04:17.