CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Darcy solver with boussinesq assumption. Solver crashes for zero gradient BC for Temp (https://www.cfd-online.com/Forums/openfoam-solving/218765-darcy-solver-boussinesq-assumption-solver-crashes-zero-gradient-bc-temp.html)

manuc July 3, 2019 07:47

Darcy solver with boussinesq assumption. Solver crashes for zero gradient BC for Temp
 
Hello All

I am trying to solver Darcy flow equation with boussinesq assumption. I simulate bottom heated top cooled 2D cavit with adiabatic sidewalls. The solver gives unphysical unbounded Temperature, when I give zeroGradient BC for T (adiabatic). However it doesnt crash when instead of adiabatic I give a fixed temperature value for the side walls as well(fixedValue BC).



Solver details below:
Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | foam-extend: Open Source CFD
  \\    /  O peration    | Version:    4.0
    \\  /    A nd          | Web:        http://www.foam-extend.org
    \\/    M anipulation  | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
    This file is part of foam-extend.

    foam-extend is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    foam-extend is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.

Application
    laplacianFoam

Description
    Solves a simple Laplace equation, e.g. for thermal diffusion in a solid.

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "simpleControl.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{

#  include "setRootCase.H"

#  include "createTime.H"
#  include "createMesh.H"

    simpleControl simple(mesh);
   
#  include "readGravitationalAcceleration.H"
#  include "createFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nCalculating flow and temperature distribution\n" << endl;

    while (simple.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;
       
        #include "pEqn.H"
        #include "TEqn.H"
           
     
       
       
       
       
       
    #      include "write.H"

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}


// ************************************************************************* //

pEqn.H
Code:

{
  //phi = fvc::interpolate(U) & mesh.Sf();
 
  surfaceScalarField phiG(Mf*fvc::interpolate(rhok)*(g & mesh.Sf()));

//Test
 // surfaceScalarField phiG(Mf*ghf*fvc::snGrad(rhok)*mesh.magSf());
       
  //    phi += phiG;
       



 //  while (simple.correctNonOrthogonal())
//      {
       
       
     
      fvScalarMatrix pEqn
        (
            //fvm::laplacian(-Mf,p) + fvc::div((fvc::interpolate(rhok) * Mf)* (g & mesh.Sf()))
            fvm::laplacian(-Mf,p)+ fvc::div(phiG)
        );
      //  pEqn.relax();
        pEqn.setReference(pRefCell, pRefValue);
        pEqn.solve();
      // phi= (phiG + fvc::snGrad(p)*Mf*mesh.magSf());
       
       
      //  if (simple.finalNonOrthogonalIter())
    //    {
      //   
          phi= (phiG+pEqn.flux());
          // p.relax();

       
       
 
    //Reconstruct the velocity field.
    //Velocity isnt involved in any calculation
    //multiplied by fluid density to convert to velocity
    //If needed the BC can be set using DarcyPressure BC , where velcoity is converted to pressure
          U=fvc::reconstruct
            (  phi      );
       
             
    //  U = fvc::reconstruct(phi);
      U.correctBoundaryConditions();
 //      }

   
 }

TEqn.H
Code:


{
//Solve 1 temperature equation for combined solid and fluid phase
        fvScalarMatrix TEqn
        (
            fvm::laplacian(DT, T)==
                  (eps*rhoCpf+(1.-eps)*rhoCps)*fvm::ddt(T)
                              + rhoCpf*fvm::div(phi,T)
                             
                             
        );
    //  TEqn.relax();

      TEqn.solve();
       
       
        //Density updation based on temperature p/rho is used in implementation
        //rhok thus doesnt have unit of density but dimensionless
        rhok=rhof*(1.0 - (beta*(T - TRef)));
       
      //solve pressure Eqn. Mf account for K/mu.
      //PhiG in createfields takes care of density induced flux
     
  }


Could someone help me to find why zeroGradient BC fails and not fixedValue

Regards
manu


All times are GMT -4. The time now is 12:26.