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/)
-   -   Doubts about refCast (https://www.cfd-online.com/Forums/openfoam-programming-development/94959-doubts-about-refcast.html)

diegosene December 1, 2011 04:24

Doubts about refCast
 
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

marupio December 1, 2011 13:50

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.

diegosene December 5, 2011 04:43

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 December 5, 2011 07:15

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).

ancolli July 21, 2017 13:39

Quote:

Originally Posted by diegosene (Post 334668)
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

babakflame July 23, 2017 17:38

Hey man,

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

https://www.cfd-online.com/Forums/op...de-solver.html


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