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

Check if volumetric scalar field exists or is declared

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 5 Post By mAlletto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 3, 2017, 05:50
Default Check if volumetric scalar field exists or is declared
  #1
RGS
Member
 
Rohit George Sebastian
Join Date: May 2017
Posts: 42
Rep Power: 9
RGS is on a distinguished road
Hello all!

Is there a way to check if a volumetric scalar field has already been declared?

I have the following code for a function:

Code:
Foam::tmp<Foam::volScalarField>
Foam::viscosityModels::tempPowerLaw::calcNu() const
{
    const volScalarField& T = U_.mesh().lookupObject<volScalarField>("T");
    return a_*exp(b_*T) + c_*exp(d_*T);
}
And I want to lookup the value of T only if T has already been defined.

Any suggestions?

Thanks in advance!!
RGS is offline   Reply With Quote

Old   November 12, 2020, 06:34
Default
  #2
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16
mAlletto will become famous soon enough
just in case someone looks at this thread:


Code:

U_.mesh().foundObject<volScalarField>("T")

returns true if T is found in the database and false if not
salehi144, Kojote, Pagoda and 2 others like this.
mAlletto 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
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 08:15
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
issue compiling new turbulence model perplexed user OpenFOAM Programming & Development 1 January 13, 2012 04:40
[Netgen] Installation of Netgen in SuSE Linux 92 edvardsenpriv OpenFOAM Meshing & Mesh Conversion 23 January 16, 2009 07:12
How to get the max value of the whole field waynezw0618 OpenFOAM Running, Solving & CFD 4 June 17, 2008 06:07


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