CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

null volScalarField

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

LinkBack Thread Tools Display Modes
Old   May 28, 2013, 04:04
Default null volScalarField
Fabian E.
Join Date: Nov 2009
Posts: 36
Rep Power: 8
galap is on a distinguished road
Since OF2.2 there are a lot of changes to the thermophysicalModels. We are running libs here derived from basicThermo which requires now the specification of several virtual functions. I want to solve this by returning NULL pointer fields. Unfortunately I am not able to clearify how a NULL volScalarField can be returned. Does anyone know this?

Thanks in advance
galap is offline   Reply With Quote

Old   May 28, 2013, 05:55
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,641
Rep Power: 25
ngj will become famous soon enoughngj will become famous soon enough
Hi Fabian,

In such cases, where certain functions need implementation, but I know that they will never be used/does not make sense, I use the following in the source code:

notImplemented("<some string describing the issue>");
This will terminate the simulation with a FatalError, so cleaner than making the program work on NULL-pointers. With respect to the return type, then I simply ignore the warnings in the compilation, since the program will never reach

return <some object>;
Kind regards

ngj is offline   Reply With Quote

Old   May 30, 2013, 18:15
New Member
Thomas Boucheres
Join Date: May 2013
Posts: 12
Rep Power: 4
thomasArk47 is on a distinguished road

return volScalarField::null();

works fine (as well for volScalarField than for tmp<volScalarField>)
thomasArk47 is offline   Reply With Quote

Old   January 29, 2014, 05:19
Fabian E.
Join Date: Nov 2009
Posts: 36
Rep Power: 8
galap is on a distinguished road
I met again this issue. The ::null() actually works, but I have problems to check, whether it is set or not.

What I am using now is: (schematic)

void request_data(autoPtr<volScalarField> data)
    if (..) { data.set(&<object-you-want-to-return>); }
    else { data.clear() }

    return data;

in main script:

autoPtr<volScalarField> data;

if (data.valid()) { .... }
Maybe this helps someone
galap is offline   Reply With Quote

Old   January 29, 2014, 05:44
Fabian E.
Join Date: Nov 2009
Posts: 36
Rep Power: 8
galap is on a distinguished road
Be aware that autoPtr takes over control of the prior associated pointer. Instead of autoPtr its better to use tmp. You can use the same syntax, just replace autoPtr with tmp. Instead the set function you have to use data = tmp<volScalarField>(&<object-you-want-to-return);
galap is offline   Reply With Quote


Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
libOpenSMOKE Tobi OpenFOAM Programming & Development 506 September 28, 2015 06:07
Metis for OpenFOAM 2.1.0 Kaskade OpenFOAM Installation 8 May 31, 2014 01:20
dimensionedScalar + volScalarField is evaluated elementwisely ? tianyikillua OpenFOAM Programming & Development 1 March 30, 2012 03:12
if-loop, volScalarField comparison volker OpenFOAM 5 April 23, 2010 14:18
momentum source in half-cylindrical null objects Noel Phoenics 1 December 16, 2008 06:51

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