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/)
-   -   build my own multi-region solver : pb with flux continuity (https://www.cfd-online.com/Forums/openfoam-programming-development/112392-build-my-own-multi-region-solver-pb-flux-continuity.html)

Cyp January 28, 2013 03:52

build my own multi-region solver : pb with flux continuity
 
Hi !

I am currently trying to develop my own multi-region solver. For sake of simplicity, let's say I have two regions, a "solid" and a "fluid". I want to solve heat transfers in both regions, with continuity and flux continuity at the solid/fluid interface.

Code:

fvScalarMatrix TsEqn
(
    fvm::laplacian(DTs,Ts)
);
TsEqn.solve();

fvScalarMatrix TfEqn
(
    fvm::laplacian(DTf,Tf)
);
TfEqn.solve();

Basically, I defined a solid_to_fluid and a fluid_to_solid patch to patch interpolation

Code:


    patchToPatchInterpolation solid_to_fluid
    (
        solidMesh.boundaryMesh()[labelSolid],
        fluidMesh.boundaryMesh()[labelFluid]
    );


    patchToPatchInterpolation fluid_to_solid
    (
        fluidMesh.boundaryMesh()[labelFluid],
        solidMesh.boundaryMesh()[labelSolid]
   
    );

I apply successfully the value of Ts at the solid/fluid interface as a boundary condition for Tf :

Code:

    scalarField &TsP = Ts.boundaryField()[labelSolid];
    scalarField &TfP = Tf.boundaryField()[labelFluid];

    TfP = solid_to_fluid.faceInterpolate(TsP);

This part is ok.

My problem concern the flux continuity at the region interface. I want to apply the flux continuity imposing the solid temperature gradient at the interface with

Code:

    vectorField n = fluidMesh.boundary()[labelFluid].nf();

    volVectorField gradTf = DTf/DTs*fvc::grad(Tf);

    scalarField nGradTf = n & gradTf.boundaryField()[labelFluid] ;

    fixedGradientFvPatchScalarField& gradTsPatch=refCast<fixedGradientFvPatchScalarField>(Ts.boundaryField()[labelSolid]);
    scalarField& gradTsField =  gradTsPatch.gradient();

    gradTsField = p2_to_p1.faceInterpolate(nGradTf);

However it fails to have good result, and I can't have flux continuity. Is someone have an idea to solve my problem ?

best regards,
Cyp

styleworker November 27, 2013 08:38

There is a multiregion solver available:
http://www.cfd-online.com/Forums/ope...eheatfoam.html

Cyp November 27, 2013 12:19

Yes I worked on its basis.

Actually, to solve the "problem" I mentionede above, one need to under-relax the flux boundary condition, and iterate until convergence.


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