|
[Sponsors] |
November 20, 2013, 07:45 |
Read fields from viscosity model
|
#1 |
New Member
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 14 |
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 ) ); } 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 Code:
volScalarField myField ( IOobject ( "myField", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Another question: how can I access the overall rho field from within my viscosity model? Thanks in advance Gaetano |
|
November 20, 2013, 09:51 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
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. |
|
November 21, 2013, 06:29 |
|
#3 |
Senior Member
Aurelien Thinat
Join Date: Jul 2010
Posts: 165
Rep Power: 16 |
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(); Code:
volScalarField& T = myMesh().lookupObject<volScalarField>("T"); 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"); |
|
November 26, 2013, 13:37 |
|
#4 |
New Member
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 14 |
As said by Bernhard and Aurelien it is possible to access fields in this way:
Code:
const volScalarField& myField = U_.mesh().lookupObject<volScalarField>("myField"); Thanks for your help! |
|
Tags |
interfoam, ioobject, read fields, viscosity models |
|
|
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 |