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

[ERROR] IF logic

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 20, 2025, 18:23
Default [ERROR] IF logic
  #1
gu1
Senior Member
 
Guilherme
Join Date: Apr 2017
Posts: 246
Rep Power: 10
gu1 is on a distinguished road
Hi,


I'm having trouble implementing if logic in my code (OpenFOAM 9). I need help.


Code:

const volScalarField Lt(this->Lt());


const volScalarField delta(this->delta());
    
const scalar tmp = 0; 
    
if (Lt == delta)
{
      tmp = Ck_*sqrt(k_)*Lt;    
}

this->nut_ = tmp


this->nut_.correctBoundaryConditions();
fvConstraints::New(this->mesh_).constrain(this->nut_);

ERROR:


Code:

error: no match for ‘operator==’ (operand types are ‘const volScalarField’ {aka ‘const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’} and ‘const volScalarField’ {aka ‘const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’})
  229 |     if (Lt == delta)
      |         ~~ ^~ ~~~~~
      |         |     |
      |         |     GeometricField<[...],[...],[...]>
      |         GeometricField<[...],[...],[...]>





error: assignment of read-only variable ‘tmp’
  231 |         tmp = Ck_*sqrt(k_)*Lt;

Thanks
gu1 is offline   Reply With Quote

Old   January 25, 2025, 17:35
Default internal field referencing?
  #2
New Member
 
Jim Park
Join Date: Nov 2020
Posts: 5
Rep Power: 6
bmb333 is on a distinguished road
Have you tried .internalField()?

For example,

if (Lt.internalField() == delta.internalField()) ...
bmb333 is offline   Reply With Quote

Reply

Tags
openfoam9

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
[mesh manipulation] [Error] Wedge patch 'frontAndBackPlanes' is not planar Danny_cfd OpenFOAM Meshing & Mesh Conversion 0 June 4, 2021 10:32
[Error] SIGSERV when continuing simulation Luiz FLUENT 0 March 28, 2019 18:52
[Error] Fluent Not Responding on Workbench Environment Luiz FLUENT 8 September 5, 2018 22:55
can anyone explian the logic behind defining the vertices gandesk OpenFOAM 3 November 11, 2010 01:18
Streamline plotting logic soggy316 Main CFD Forum 8 July 10, 2009 09:14


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