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/)
-   -   write value evaluated in boundary condition (https://www.cfd-online.com/Forums/openfoam-programming-development/92487-write-value-evaluated-boundary-condition.html)

mabinty September 15, 2011 12:09

write value evaluated in boundary condition
 
dear all,

i m working on a coupled temperature BC (based on solidWallMixedTemperatureCoupled) where beside the evaluation of the boundaryPatch-value another "different" radiation temperature "TRad" is calculated. Now, how can I write this value in an own file <timeDirectory>/TRad in order to allow another BC (e.g. for the radiation variable) to use it.

in ceratFields i created a

Code:

            volScalarField
            (
                IOobject
                (
                    "TRad",
                    runTime.timeName(),
                    fluidRegions[i],
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
                ),
            thermo.T()
            )

to place it in the objectRegistry. But how can i update TRad now with the value calculated in the mentioned BC at the respective patch?

i greatly appreciate your comments!!

cheers,
aram

marupio September 15, 2011 13:20

You should be able to gain access to Trad with db.lookupObject<volScalarField>("TRad");

or something like that. Not sure about the db. part. May need to be db.time(), db(), db().time()... don't have FOAM with me today.

mabinty September 15, 2011 13:29

david, thanks for your quick reply!!

the problem is that the lookupObject function of objectRegistry returns a constant object and does not allow changes, as far as i can understand the code (src/OpenFOAM/db/objectRegistry/objectRegistry.H line 152):

Code:

//- Lookup and return the object of the given Type
template<class Type>
const Type& lookupObject(const word& name) const;

anyway, i ll give it a try and report.

thanks again!!
aram

marupio September 15, 2011 13:41

No no, you are right.

So this boundary condition is "special", and only works with your solver? I steer away from code that does this... but sometimes there's little choice. If that's the case, you can use the solver to search for boundary patches of the specified type, and treat them differently.

Here's one option off the top of my head:
The solver normally interfaces with boundary field patches through fvPatchField, but since you are being specific, you could try dynamic casting to myTRadAwareFvPatchField (look in src/OpenFOAM/db/typeInfo... one of the files there has the right function). Then you can use functions you create in that boundary condition alone. Simplest would be to give the boundary condition a pointer to TRad, and have the solver execute assignPointer(volScalarField& TRad);

I don't like dynamic casting because it can make mistakes...

mabinty September 16, 2011 08:34

hi david!

Quote:

So this boundary condition is "special", and only works with your solver? I steer away from code that does this... but sometimes there's little choice.
yes that s a bit special and i m not sure yet if it makes sens. actually i want BCs of two different variables to communicate. normally the BC for the radiation variable (I or G) needs a wall temperature which is specified in the BC, e.g:

Code:

wall
{
    type            greyDiffusiveRadiation;
    T                T;
    emissivity    1.0;
    value          uniform 1e-25;
}

the BC looks up "T" in the objectRegistry. now i want the radiation BC not to take the temperature T prescribed by the temperature BC (for the enthalpy equation) but TRad which is calculated there (in the temperature BC). so use TRad instead of T in the radiation BC.

Quote:

If that's the case, you can use the solver to search for boundary patches of the specified type, and treat them differently.

Here's one option off the top of my head:
The solver normally interfaces with boundary field patches through fvPatchField, but since you are being specific, you could try dynamic casting to myTRadAwareFvPatchField (look in src/OpenFOAM/db/typeInfo... one of the files there has the right function). Then you can use functions you create in that boundary condition alone. Simplest would be to give the boundary condition a pointer to TRad, and have the solver execute assignPointer(volScalarField& TRad);
the reason why i want to calculate Trad in the temperature BC is because all needed parameters are already available there. but yes, maybe its easier to calculate Trad at the solver level: identify the coupled patch, look up the needed parameters, and calculate and update TRad. or, as you suggested implement a function in the temperature BC which gives access to TRad from the solver.

i will think about it, try and report.

thanks a lot for your input!!
aram

marupio September 16, 2011 11:06

If you can calculate TRad in the solver, then all you have to do is store the result and use lookup<objectType> in you BC.

mabinty September 21, 2011 03:49

hi!

finally I calculated TRad in the solver and updated it from there, and it works. thanks for your input!!

regards,
aram


All times are GMT -4. The time now is 11:07.