CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Global parameters for customized boundary conditions (https://www.cfd-online.com/Forums/openfoam-programming-development/223835-global-parameters-customized-boundary-conditions.html)

JanBeh January 28, 2020 11:18

Global parameters for customized boundary conditions
 
Hello Foamers!
recently i've had to deal with - guess the well known and much discussed- compiling errors if one would like to upgrade to a newer version of openFoam.
actually i have to upgrade my solver and boundaryConditions (programmed in oF 2.3) due to the fact that of Version 2.3 won't be no longer supported.

i really benefited from the threads and discussions about the openFoam updates but i simply can't find a solution to my kind of problem.

long story short…
i'd like to add global parameters in a customized boundaryCondition. thoose parameters should be non-const (runtime dependent).
basically what i would like to have is a status parameter which is updated in the main (solver) code depending on the actual runtime.
back in version 2.3 it was pretty easy to deal with that kind of problem. One just had to work with the "external int.." definition/declaration but it seems that something -at least for me- essential had changed.

I will try to clarify the problem using a simple example (that's how it actually worked in version 2.3.x)


back in version 2.3.x it was possible to define a -let's name it- Status.H file like this
Status.H
#ifndef Status_H
#define Status_H

extern int status = 1;

#endif

Now lets make a my_zeroGradient boundaryCondition like this:
my_zeroGradient.H
#ifndef my_zeroGradient_h

#include Status.H

#endif

To keep that kind of problem simple i'll do a simple Info output in the my_zeroGradient.C

my_zeroGradient.C
#include "my_zeroGradient.H"

void Foam::my_zeroGradientFvPatchField<Type>::evaluate…
{
Info << "Hello World, your Status is " << status << endl;
….
}


To make the point clear ill now copy paste the compressilbeInterFoam solver and compile it to my_compressibleInterFoam solver. Before compiling just some changes:

my_compressibleInterFoam.C
#include....
#include "Status.H"
….
int main(…
….
if (this is true)
status = 2; (and not 1 any longer)


no compiling errors but if i run a simple case (f.e. the depthCharge2D tutorial) the Info Output from the my_zeroGradient bc still remains 1.
So the question is : how am i able to update or how to change this non-const parameter (i thought global parameter) in the my_zeroGradient bc?

to keep in mind: the way i tried to show or to explain here still workes for version 2.3.x.

Guess this kind of problem is not such a big deal but i really dont know how to handle it right now. maybe it's an easy, or even a silly, question but i didn't get that part. Hence, i need some help


Thanks in advance

btw: im using OF 18.12 rn


All times are GMT -4. The time now is 18:53.