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

null volScalarField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 28, 2013, 04:04
Default null volScalarField
  #1
Member
 
Fabian E.
Join Date: Nov 2009
Posts: 38
Rep Power: 16
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
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
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:

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

Code:
return <some object>;
Kind regards

Niels
ngj is offline   Reply With Quote

Old   May 30, 2013, 18:15
Default
  #3
Member
 
Thomas Boucheres
Join Date: May 2013
Posts: 41
Rep Power: 12
thomasArk47 is on a distinguished road
Hi,

return volScalarField::null();

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

Old   January 29, 2014, 04:19
Default
  #4
Member
 
Fabian E.
Join Date: Nov 2009
Posts: 38
Rep Power: 16
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)

Code:
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;
request_data(data);

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

Old   January 29, 2014, 04:44
Default
  #5
Member
 
Fabian E.
Join Date: Nov 2009
Posts: 38
Rep Power: 16
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

Reply


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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 09:21
if-loop, volScalarField comparison volker OpenFOAM 7 March 6, 2020 20:03
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
momentum source in half-cylindrical null objects Noel Phoenics 1 December 16, 2008 05:51


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