CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Building a solver with fixedTemperatureConstraint using fvOptions (http://www.cfd-online.com/Forums/openfoam-programming-development/121464-building-solver-fixedtemperatureconstraint-using-fvoptions.html)

Fluido July 29, 2013 11:41

Building a solver with fixedTemperatureConstraint using fvOptions
 
Dear Foamers,

I have been using OpenFOAM for several months for a student project. Everything has been working quite well. But at the moment I am a bit stuck at a problem. Maybe someone can help…:)

For version 2.2.0 OpenFOAM seems to have introduced a very nice new feature of fvOptions called ‘fixedTemperatureConstraint’, to ‘to fix the temperature to a given value’ (see http://www.openfoam.org/version2.2.0/fvOptions.php). I would like to use this feature to set the temperature of air flowing through a heater to a fixed temperature instead of having to model the heater as a heat source.

My input for the fvOptions file would look like this

Code:

fixedTemperaure1
  {
      type                      fixedTemperatureConstraint;
      active                    true;
      selectionMode        cellZone;
      cellZone                heater;
 
      fixedTemperatureConstraintCoeffs
      {
          mode              uniform;
          temperature    350;
      }
  }

I would like to include the fixedTemperatureConstraint to a self-built solver for a decoupled, steady state, incompressible temperature equation. The solver is working already. It is just missing the handling of sources. So, here is what I did:

  • add fvOptions(T) to the temperature equation
  • add fvOptions.constrain(TEqn) to TEqn.H
  • #include "fvIOoptionList.H" to solver .C file
  • #include "createFvOptions.H" to solver .C file
The code of the TEqn file looks like this now (not showing the definition of the coefficient alphaEff):

Code:

      fvScalarMatrix TEqn
      (
          fvm::div(phi, T)
        - fvm::laplacian(alphaEff, T)
        ==
        fvOptions(T)
      );
 
      TEqn.relax();
 
      fvOptions.constrain(TEqn);
 
      TEqn.solve();



Compiling of the solver works fine. But when trying to run a case, I get the following error massage.


Code:

  --> FOAM FATAL ERROR:
 
      request for basicThermo thermophysicalProperties from objectRegistry region0 failed
      available objects of type basicThermo are
 
  0
  (
  )

From my understanding of this error message, OpenFOAM is missing a thermophysical model. So I am wondering:


Is there a thermophysical model necessary for the implementation of the fixedTemperatureConstraint?

If not, do you have any hints where the error messages might come from?

Thank you very much for your help!
- Fluido -

olivierG July 30, 2013 08:08

Hello,

My guess is you forget the "-I$(LIB_SRC)/fvOptions/lnInclude" in your Make/options file.

regards,
olivier

andre.weiner July 30, 2013 21:36

Hey!

You have a simple transport equation for a scalar T, so you have to use the explicitSetValue fvOption. The fixedTemperatureConstraint is for energy equations.
Check also the post of olivier about the wmake options.

regards,
Andre

Fluido August 1, 2013 04:20

Quote:

Originally Posted by olivierG (Post 442806)
Hello,

My guess is you forget the "-I$(LIB_SRC)/fvOptions/lnInclude" in your Make/options file.

regards,
olivier

Hello Olivier,

thank you for your idea!
I checked the options file once again. The fvOptions entry is there. So, that's not the problem...

Regards
- Fluido -

Fluido August 1, 2013 04:36

Quote:

Originally Posted by andre.weiner (Post 442927)
Hey!

You have a simple transport equation for a scalar T, so you have to use the explicitSetValue fvOption. The fixedTemperatureConstraint is for energy equations.
Check also the post of olivier about the wmake options.

regards,
Andre

Hello Andre,

thank you for the info!

If the fixedTemperatureConstraint is made for energy equations, the call for a thermophysical model makes sense somehow. Can I find this information somewhere inside OpenFOAM (without having to dig deep into the code) or somewhere else?

I will try the explicitSetValue option now...

Regards
- Fluido -

Fluido August 1, 2013 04:41

There was a little error in my original post. The error message does not appear when compiling, but when running a case with the compiled solver. So, compiling of the solver works, without any errors.

andre.weiner August 1, 2013 05:21

Quote:

Originally Posted by Fluido (Post 443220)
Hello Andre,

thank you for the info!

If the fixedTemperatureConstraint is made for energy equations, the call for a thermophysical model makes sense somehow. Can I find this information somewhere inside OpenFOAM (without having to dig deep into the code) or somewhere else?

I will try the explicitSetValue option now...

Regards
- Fluido -

You don't have to dig that deep :-)

Code:

void Foam::fv::fixedTemperatureConstraint::setValue
(
    fvMatrix<scalar>& eqn,
    const label
)
{
    const basicThermo& thermo =
        mesh_.lookupObject<basicThermo>("thermophysicalProperties");

    if (eqn.psi().name() == thermo.he().name())
    {...

This is a part of the member function that sets the value. As you see it looks for some thermophysicalProperties and then it checks your equation for a part called psi and so on. So this fixedTemperatureConstraint is a little more complicated than what you need.

Regards, Andre

Fluido August 1, 2013 10:23

Quote:

Originally Posted by andre.weiner (Post 443236)
You don't have to dig that deep :-)

Code:

void Foam::fv::fixedTemperatureConstraint::setValue
(
    fvMatrix<scalar>& eqn,
    const label
)
{
    const basicThermo& thermo =
        mesh_.lookupObject<basicThermo>("thermophysicalProperties");

    if (eqn.psi().name() == thermo.he().name())
    {...

This is a part of the member function that sets the value. As you see it looks for some thermophysicalProperties and then it checks your equation for a part called psi and so on. So this fixedTemperatureConstraint is a little more complicated than what you need.

Regards, Andre

Ok. I had not looked at the .C file yet (or not close enough). But it is quite obvious from code you posted that OpenFOAM would look for a thermophysical model. Thanks!

Meanwhile I tried the explicitSetValue option. I just changed the input in the fvOptions file to:
Code:

source1
{
    type            scalarExplicitSetValue;
    active          true;
    selectionMode  cellZone;
    cellZone        fluid-porous;

    scalarExplicitSetValueCoeffs
    {
        volumeMode      absolute;
        injectionRate
        {
            T              323;
        }
    }
}

And...it works perfectly! :-)

So, thank you again!

- Fluido -

samiam1000 February 14, 2014 07:25

Dear All,

I am trying to do something like what you did, but instead of temperatures, I wanna add in a certain cellSet a constant bodyForce.

Do you have an idea about I can do this?

Thanks a lot,
Samuele


All times are GMT -4. The time now is 13:25.