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

write value evaluated in boundary condition

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 15, 2011, 12:09
Default write value evaluated in boundary condition
  #1
Senior Member
 
Aram Amouzandeh
Join Date: Mar 2009
Location: Vienna, Vienna, Austria
Posts: 186
Rep Power: 8
mabinty is on a distinguished road
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
mabinty is offline   Reply With Quote

Old   September 15, 2011, 13:20
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
marupio is on a distinguished road
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.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   September 15, 2011, 13:29
Default
  #3
Senior Member
 
Aram Amouzandeh
Join Date: Mar 2009
Location: Vienna, Vienna, Austria
Posts: 186
Rep Power: 8
mabinty is on a distinguished road
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
mabinty is offline   Reply With Quote

Old   September 15, 2011, 13:41
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
marupio is on a distinguished road
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...
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   September 16, 2011, 08:34
Default
  #5
Senior Member
 
Aram Amouzandeh
Join Date: Mar 2009
Location: Vienna, Vienna, Austria
Posts: 186
Rep Power: 8
mabinty is on a distinguished road
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
mabinty is offline   Reply With Quote

Old   September 16, 2011, 11:06
Default
  #6
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
marupio is on a distinguished road
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.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   September 21, 2011, 03:49
Default
  #7
Senior Member
 
Aram Amouzandeh
Join Date: Mar 2009
Location: Vienna, Vienna, Austria
Posts: 186
Rep Power: 8
mabinty is on a distinguished road
hi!

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

regards,
aram
mabinty is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind turbine simulation Saturn CFX 34 October 16, 2014 05:27
problem with boundary condition??? smn CFX 5 November 24, 2009 07:37
how to set up a wall boundary condition according to calculated wall shear stress? gameoverli OpenFOAM Pre-Processing 1 May 21, 2009 08:28
Airfoil boundary condition Frank Main CFD Forum 1 April 21, 2008 18:36
How to write the boundary condition for round free jet Jason Main CFD Forum 8 July 26, 1999 16:15


All times are GMT -4. The time now is 22:24.