CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Getting old values of psi internal (

ffbof August 27, 2008 07:23

Hello i want to have the psi
i want to have the psi internal values of a previous time step to access them in the updateInterfaceMatrix function of my fvPatchField.

The updateInterfaceMatrix has a parameter lduMatrix& which is the base class for the fvMatrix which has a function psi() to access the psi value.

But i cannot cast the lduMatrix into the fvMatrix so my question is how to downcast from the const lduMatrix& to fvMatrix& is that possible in OpenFOAM framework ?.

hjasak August 27, 2008 07:36

You have to be a bit careful,
You have to be a bit careful, depending where the cast is, eg. you should probably be in templated code. Otherwise, it's easy:




ffbof August 27, 2008 09:25

Thank you very much for the fa
Thank you very much for the fast answer Mr Jasak,

in my case it is about the following method of a coupledFvPatchField derived class.

const scalarField& psiInternal,
const lduMatrix& matrix,
const scalarField&,
const direction,
const bool bufferdTransfer
) const
// here i want to cast the lduMatrix down to the // fvMatrix i tried the following

const fvMatrix<type>& test =
dynamic_cast<const> >(matrix);
// const fvMatrix<type> in dynamic_cast braces
// had problem to display in forum preview
The compiler complains that :
cannot dynamic_cast const lduMatrix& to const fvMatrix<type>&
so i also tried to const_cast the lduMatrix reference with no improvement

So right now i don't know how to access the old psi field within that method.

The thing why i need that is because i am trying to implement a phase lag or direct storage method mentioned by Erdos, J. I. & Alzner, E. Computation of Unsteady Transonic Flows Through Rotating and Stationary Cascades
I - Method of Analysis Nasa Contract Report 2900, 1977, 2900

So what i want to do is to store the psi field of one previous time step the geometric handling is all done only the storage is the remaining problem

If you know a workaround for the template casting problem i would welcome that very much :-)

hjasak August 27, 2008 13:34

Hi Franz, The problem is that
Hi Franz, The problem is that you are trying to get this done at the wrong place. Explaining it in detail would be a lot of effort; in short, you need to go back to the (templated, coupled) boundary condition and do the work there.


ffbof August 27, 2008 14:46

Sorry for that i think i hav
Sorry for that i think
i have typed it wrong it seems you are thinking that i am in the global function

thats the header of my test class which is my boundary condition
class test:
public testLduInterfaceField,
public coupledFvPatchField<type>

Sorry for that strange notation
But i thought i am in the ,as you called it,
(templated, coupled) boundary condition
The code at August 27, 2008 - 07:25 am is implemented in the class test which is a template and derived from coupledFvPatchField.
Maybe i just misunderstood your words

But again thank you for reply

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