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/)
-   -   Implementation a new solver in foam-extend (https://www.cfd-online.com/Forums/openfoam-programming-development/227009-implementation-new-solver-foam-extend.html)

Yujuan May 14, 2020 10:38

Implementation a new solver in foam-extend
 
Hi all,


Now I want to implement a new solver in foam-extend-4.1. In the solver, two equations for θ1 and θ2 have to be solved. The transient term, convection term and source term are similar to expressions in other solvers, but the diffusion terms look little bit different:
In the equation for θ1, the diffusion term is a*div(D1gradθ1+D2gradθ2).

In the equation for θ2, the diffusion term is b*div(D1gradθ1+D2gradθ2).


Now I implement these terms like follows:
(1) Define a fvBlockMatrix thetaEqn.

(2) Define fvScalarMatrix theta1Eqn and theta2Eqn for θ1 and θ2. For θ1, a*div(D1gradθ1) is expressed like: a*fvm::laplacian(D1,θ1), where a is a volScalarField. For θ2, it is similar.
(3) thetaEqn.insertEquation(0, theta1Eqn); thetaEqn.insertEquation(1, theta2Eqn).

(4) thetaEqn.insertEquationCoupling(0,1,a*fvm::laplaci an(D2,θ2)); thetaEqn.insertEquationCoupling(1,0,b*fvm::laplaci an(D1,θ1)).
(5) thetaEqn.solve();




However, the simulation just crashed after some time. Do you have any suggestions on how to implementing this diffusion term? Thanks a lot!


Best regards,
Yujuan

raumpolizei May 18, 2020 12:04

Hey Yujuan,
Depending on how your solver is structured (iterative solver), you can also directly embed the diffusion term linked to the "other scalar" explicitely. A combination of fvc::div and fvc::grad as you suggested should work while using fvm::laplancian for the scalar for which you are currently solving the equation. You should be able to iterate over both equations until convergence is reached for both scalars. However, I do not know how this will affect the overall stability of the solver. If you still havn't found a solution, it could be worth trying.
Good luck!
RP

Yujuan May 19, 2020 09:24

Quote:

Originally Posted by raumpolizei (Post 770987)
Hey Yujuan,
Depending on how your solver is structured (iterative solver), you can also directly embed the diffusion term linked to the "other scalar" explicitely. A combination of fvc::div and fvc::grad as you suggested should work while using fvm::laplancian for the scalar for which you are currently solving the equation. You should be able to iterate over both equations until convergence is reached for both scalars. However, I do not know how this will affect the overall stability of the solver. If you still havn't found a solution, it could be worth trying.
Good luck!
RP

Hi, raumpolizei


Thanks a lot for your suggestions. I'll have a try to use fvc::div(fvc::grad).


All times are GMT -4. The time now is 18:03.