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

Doubts about refCast

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 1, 2011, 05:24
Default Doubts about refCast
  #1
New Member
 
Diego Sene Alves
Join Date: Aug 2011
Posts: 7
Rep Power: 15
diegosene is on a distinguished road
Hi guys, Iam new in Open Foam and I have a doubt about refCast.
The problem is.
I created a boundary condition (called eulerRho) that calculates the amplitude variation (L1) in the density file of the 0 folder for an outlet.
In the pressure file of the 0 folder for an outlet, I need to take the value of L1 calculated in the eulerRho using another Boundary (called eulerPressure).
I was told that I must use the refcast to take the valuer from eulerRho and to pass to eulerPressure.

But how I do this?
I really dont know how to use the refCast, and already looked in the c++ source guide but i didnt understand.
Can someone help me? =)

Thanks
diegosene is offline   Reply With Quote

Old   December 1, 2011, 14:50
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
I can only guess they wanted you to implement a custom access function in your eulerRho boundary condition, and gain access to it by refCasting the generic const fvPatchField reference you'd be able to acquire through the objectRegistry. That's a little ugly.

The code for this function is in src/OpenFOAM/db/typeInfo/typeInfo.H, by the way.

Do you only need const access to L1 in eulerPressure? If so, there are easier ways. For starters, you could use the IOReferencer that I released a while back, available here: http://openfoamwiki.net/index.php/Contrib_IOReferencer

Or, you could have eulerRho create an IOdictionary (NO_READ, NEVER_WRITE), and put L1 into it. Then use the object registry to lookup that IOdictionary and read the value from it.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   December 5, 2011, 05:43
Default
  #3
New Member
 
Diego Sene Alves
Join Date: Aug 2011
Posts: 7
Rep Power: 15
diegosene is on a distinguished road
Thanks David for the tips.
I was looking through the Doxygen and found this in the
fieldAverageTemplates.C

Quote:
// Store on registry
obr_.store
(
new fieldType
(
IOobject
(
meanFieldName,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
1*baseField
)
);
That way can I store the field I want and then gain access in another boundary condition(in my case eulerPressure) looking up in the registry?
diegosene is offline   Reply With Quote

Old   December 5, 2011, 08:15
Default
  #4
New Member
 
Diego Sene Alves
Join Date: Aug 2011
Posts: 7
Rep Power: 15
diegosene is on a distinguished road
I was able to store my scalarField variable as an IOField.
Thanks David, i think now i can access the variable from the other boundary condition(eulerpressure).
diegosene is offline   Reply With Quote

Old   July 21, 2017, 14:39
Default
  #5
Senior Member
 
Alejandro
Join Date: Jan 2014
Location: Argentina
Posts: 128
Rep Power: 12
ancolli is on a distinguished road
Quote:
Originally Posted by diegosene View Post
I was able to store my scalarField variable as an IOField.
Thanks David, i think now i can access the variable from the other boundary condition(eulerpressure).
Can u explain, step by step, how to do that.
Thanks in advance
ancolli is offline   Reply With Quote

Old   July 23, 2017, 18:38
Default
  #6
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16
babakflame is on a distinguished road
Hey man,

Take a look at this thread. Here, I have explained it step by step:

Snippet for redefining fixedGradient boundary condition for a patch inside solver
babakflame is offline   Reply With Quote

Reply


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
Some basic doubts on solvers pkr OpenFOAM Programming & Development 1 February 28, 2011 08:46
Doubts about DES simulation L3munoz FLUENT 1 April 1, 2010 11:50
Doubts in HVAC vivekkumarmishra2003 Main CFD Forum 0 January 25, 2010 08:11
Mesh inflation / Wall condition doubts Kushagra Mittal CFX 2 September 21, 2007 16:34
some trivial doubts Arnab Siemens 2 March 25, 2004 06:57


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