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

Adding new lookup parameter to OF21

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 22, 2022, 01:42
Default Adding new lookup parameter to OF21
  #1
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
Hello all
I want to add a new dimensionless parameter to pimpleFoam in OF21. I know that if I add these lines to OF6 or OF7, it will work, but it does not work in OF21;

Code:
 dimensionedScalar FFarzad
(
     "FFarzad",
     dimless, 
     transportProperties.lookup("FFarzad")
    
);
Why these lines does not work in OF21? and what should I do?

Error;
Code:
pimpleFoamEpsilonGeneral.C: In function ‘int main(int, char**)’:
pimpleFoamEpsilonGeneral.C:205:6: error: ‘transportProperties’ was not declared in this scope
      transportProperties.lookup("FFarzad")
      ^~~~~~~~~~~~~~~~~~~
pimpleFoamEpsilonGeneral.C:205:6: note: suggested alternative: ‘transportModel_H’
      transportProperties.lookup("FFarzad")
      ^~~~~~~~~~~~~~~~~~~
      transportModel_H
In file included from pimpleFoamEpsilonGeneral.C:353:0:
Thanks,
Farzas
Attached Images
File Type: jpg photo_2022-07-21_23-40-24.jpg (80.6 KB, 8 views)
farzadmech is offline   Reply With Quote

Old   July 22, 2022, 02:52
Default
  #2
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
The reason for that is, that the transport properties dictionary gets defined within the createFields.H file in OF6. I assume that it gets initialized somewhere else


Most probably this dictionary is defined elsewhere (after the createFields.H) file or within an object.


Since I'm not familiar with the ESI version, but maybe this will work out for you:


Make a reference to the dictionary

Code:
const dictionary& transportProperties = db().lookupObject<IOdictionary>("transportProperties");
and then your code snippet should work.

Code:
dimensionedScalar FFarzad
  (
      "FFarzad",
      dimless,  
      transportProperties.lookup("FFarzad")
  );

It should also be possible to gain acces by following code, but I dont know exactly.

Code:
dimensionedScalar FFarzad
 (
      "FFarzad",
      dimless,  
      db().lookupObject<IOdictionary>
      (
          "transportProperties"
      ).lookup("FFarzad")
      );

Last edited by überschwupper; July 22, 2022 at 03:00. Reason: i dont get the formatting...
überschwupper is offline   Reply With Quote

Old   July 22, 2022, 23:00
Default
  #3
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
Thanks überschwupper. It worked, but what about scalar lookup?
I used below code and it gives me error;

Code:
   scalar prescribedTKE;     
   prescribedTKE(transportProperties.lookup("prescribedTKE"));
Error;
Code:
pimpGeneral.C:217:61: error: ‘prescribedTKE’ cannot be used as a function
    prescribedTKE(transportProperties.lookup("prescribedTKE"));
Thanks,
Farzad
farzadmech is offline   Reply With Quote

Old   July 23, 2022, 04:25
Default
  #4
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
This solves the problem for scalars;

Code:
	IOdictionary transportProperties
(
    IOobject
    (
        "transportProperties",
        runTime.constant(),
        mesh,
        IOobject::MUST_READ_IF_MODIFIED,
        IOobject::NO_WRITE
    )
);
 

 
   scalar prescribedTKE;    	
   transportProperties.lookup("prescribedTKE") >> prescribedTKE ;
Farzad


Quote:
Originally Posted by farzadmech View Post
Thanks überschwupper. It worked, but what about scalar lookup?
I used below code and it gives me error;

Code:
   scalar prescribedTKE;     
   prescribedTKE(transportProperties.lookup("prescribedTKE"));
Error;
Code:
pimpGeneral.C:217:61: error: ‘prescribedTKE’ cannot be used as a function
    prescribedTKE(transportProperties.lookup("prescribedTKE"));
Thanks,
Farzad
farzadmech is offline   Reply With Quote

Old   July 25, 2022, 05:21
Default
  #5
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
Quote:
Originally Posted by farzadmech View Post
Thanks überschwupper. It worked, but what about scalar lookup?
I used below code and it gives me error;

Code:
   scalar prescribedTKE;     
   prescribedTKE(transportProperties.lookup("prescribedTKE"));
Error;
Code:
pimpGeneral.C:217:61: error: ‘prescribedTKE’ cannot be used as a function
    prescribedTKE(transportProperties.lookup("prescribedTKE"));
Thanks,
Farzad

When you want to initialize your variable, then you need a declarator to use the direct initialization. If you want to seperate the declaration and the definition you have to use the assignment operator, otherwise it will be regocnized as a function.


Code:
scalar prescribedTKE(transportProperties.lookup<scalar>("prescribedTKE"));

should work fine.
überschwupper is offline   Reply With Quote

Reply

Tags
lookup, new parameter, of21, openfoam2106


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
multiRegionHeater error ordinary OpenFOAM Running, Solving & CFD 2 June 9, 2020 18:43
Long output in terminal. ssa_cfd OpenFOAM Running, Solving & CFD 1 March 18, 2019 06:25
DPMFoam - Serious Error --particle-laden flow in simple geometric config benz25 OpenFOAM Running, Solving & CFD 27 December 19, 2017 21:47
conjugateHeatFoam + interFoam farhagim OpenFOAM Programming & Development 15 July 19, 2016 08:55
Convergence on anisotropic tetahedral meshes pbo OpenFOAM Running, Solving & CFD 12 December 14, 2010 12:59


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