CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Accessing phi field for sampling plane

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

Like Tree1Likes
  • 1 Post By CedricVH

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 17, 2011, 14:01
Default Accessing phi field for sampling plane
  #1
New Member
 
Francesco Balduzzi
Join Date: Feb 2010
Posts: 4
Rep Power: 16
francesco85 is on a distinguished road
Hi all,

I'm trying to modify the "sampledPlane" function. I need to calculate the mean value of the sampled field by both an area-weighted average and a massflow-weighted average. In the first case everything works fine, while for calculating the mass flow I need to access to the "phi" field.

I've tried something like this:

const surfaceScalarField& phi=db().lookupObject<surfaceScalarField>("phi");

but I got the error:

sampledSurface/sampledPlane/sampledPlaneTemplates.C:52: error: there are no arguments to ‘db’ that depend on a template parameter, so a declaration of ‘db’ must be available


Then I tried to modify it as follows:

const surfaceScalarField& phi=vField().db().lookupObject<surfaceScalarField> ("phi");


and I got a different error:

sampledSurface/sampledPlane/sampledPlaneTemplates.C:52: error: expected primary-expression before ‘>’ token
sampledSurface/sampledPlane/sampledPlaneTemplates.C: In member function ‘Foam::tmp<Foam::Field<Type> > Foam::sampledPlane::sampleField(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) const [with Type = double]’:


Which is the primary-expression needed for? Is it correct to call the db() function?
Any help would be appreciated!

Francesco
francesco85 is offline   Reply With Quote

Old   August 5, 2011, 06:49
Default
  #2
Member
 
Cedric Van Holsbeke
Join Date: Dec 2009
Location: Belgium
Posts: 81
Rep Power: 16
CedricVH is on a distinguished road
The database is not needed when working on top level code (like a utility or a solver). However, in lower level code, one should access the database and fetch the phi object with:

Code:
const objectRegistry& db = mesh.db();
const surfaceScalarField& phi=db.lookupObject<surfaceScalarField>("phi");
Normally, it should also work without a database:

Code:
const surfaceScalarField& phi=mesh.lookupObject<surfaceScalarField>("phi");
Luttappy likes this.
CedricVH is offline   Reply With Quote

Reply

Tags
sampling lookupobject phi

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
read scalar field phi, get flux through faces peterwy OpenFOAM Programming & Development 5 April 28, 2017 20:40
[Gmsh] Problem with Gmsh nishant_hull OpenFOAM Meshing & Mesh Conversion 23 August 5, 2015 03:09
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
Calculation of phi if velocity field is known ankgupta8um OpenFOAM Running, Solving & CFD 5 October 15, 2006 04:46


All times are GMT -4. The time now is 23:29.