|
[Sponsors] |
May 28, 2013, 04:04 |
null volScalarField
|
#1 |
Member
Fabian E.
Join Date: Nov 2009
Posts: 38
Rep Power: 16 |
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 |
|
May 28, 2013, 05:55 |
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
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>"); Code:
return <some object>; Niels |
|
May 30, 2013, 18:15 |
|
#3 |
Member
Thomas Boucheres
Join Date: May 2013
Posts: 41
Rep Power: 12 |
Hi,
return volScalarField::null(); works fine (as well for volScalarField than for tmp<volScalarField>) |
|
January 29, 2014, 04:19 |
|
#4 |
Member
Fabian E.
Join Date: Nov 2009
Posts: 38
Rep Power: 16 |
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()) { .... } |
|
January 29, 2014, 04:44 |
|
#5 |
Member
Fabian E.
Join Date: Nov 2009
Posts: 38
Rep Power: 16 |
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);
|
|
|
|
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 |