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/)
-   -   [OpenFOAM 11] Adding new equations in modular solvers (https://www.cfd-online.com/Forums/openfoam-programming-development/255382-openfoam-11-adding-new-equations-modular-solvers.html)

blackk100 April 4, 2024 19:09

[OpenFOAM 11] Adding new equations in modular solvers
 
I'm setting up a custom modular solver to simulate electrochemical cells in OpenFOAM 11. I've created a derived class from multicomponentFluid that compiles and runs.

I'm currently attempting to add in another scalar field variable for the electric potential, but I cannot figure out how to do that exactly (OF10 & OF2312 are straightforward with this).

This is what I attempted (does not compile):
customFluid.C:
Code:

Foam::solvers::customFluid::customFluid(fvMesh& mesh)
:
multicomponentFluid(mesh),
E_(
    IOobject("E", runTime.name(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE),
    mesh
),
E(E_)
{}

customFluid.H:
Code:

...
class customFluid: public multicomponentFluid
{
protected:
    volScalarField &E_;
private:
public:
    const volScalarField &E;

  TypeName("customFluid");
...
}

I did notice the scalarTransport function, but it does not cover all of my needs (I need to add terms dependent on E to the U and Y equations).

Would appreciate any help on this!


All times are GMT -4. The time now is 19:33.