CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Adding new lookup parameter to OF21 (https://www.cfd-online.com/Forums/openfoam-solving/244109-adding-new-lookup-parameter-of21.html)

farzadmech July 22, 2022 00:42

Adding new lookup parameter to OF21
 
1 Attachment(s)
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

überschwupper July 22, 2022 01:52

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")
      );


farzadmech July 22, 2022 22:00

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 July 23, 2022 03:25

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 (Post 832278)
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


überschwupper July 25, 2022 04:21

Quote:

Originally Posted by farzadmech (Post 832278)
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.


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