CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   ODE solver extension to RKtime integration for CFD (https://www.cfd-online.com/Forums/openfoam-solving/59418-ode-solver-extension-rktime-integration-cfd.html)

 luca_g September 26, 2007 05:18

I'm working on RK time integra

I'm working on RK time integration for a compressible flow solver.
I now would like to implement the RK-solver as an extension of the ODE/ODEsolver class.
I understand that current ODE class only solves a system of scalar equations, while I obviously need to solve a mix of scalar/vector equations.
I was thinking of doing something like:
- specify n_scalars and n_vectors
- specify y_scalars and y_vectors as well as dydx_scalars and dydx_vectors

Could anybody suggest a better way ?

Regards,

Luca G.

 hjasak September 26, 2007 05:28

Yes: the ODE solver works with

Yes: the ODE solver works with the coeffs array and does not care much what's in it. Therefore, make an array of the size of number of scalars + 3*number of vectors, load up all the scalars and individual components into the coeffs and after the solution fill them back into your vectors. That way no intervention is required in the ODE base class or the solver and you will have a natural interface for scalars and vectors in your ODE.

Enjoy,

Hrv

 luca_g September 26, 2007 05:50

Thanks Hrvoje, I was also t

Thanks Hrvoje,

I was also thinking of copying the components of the vector field into scalar fields and then back to the vector field, but wouldn't this cost the extra time to copy the fields back and forth ?
Is there any way to avoid the copy ?

Regards,

Luca

 hjasak September 26, 2007 06:11

There are ways, but it hurts.

There are ways, but it hurts. In any case, the cost of copy is probably negligible. All field etc copies in OpenFOAM will cost you around 4% CPU time in total and there are some massive things being copied like for example matrices.

Unless you are solving hundreds of thousands of ODEs per time-step, I wouldn't sweat it.

Hrv

 luca_g September 26, 2007 06:44

Well, actually I will be solvi

Well, actually I will be solving for each cell in the grid which means millions of ODEs per time-step, plus there will be the extra memory usage of a copy of the fields.
It doesn't look optimal, although I agree it will probably increase only a few percent CPU time.

Luca

 All times are GMT -4. The time now is 14:32.