CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Error arising from Energy Equation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 15, 2017, 12:15
Default Error arising from Energy Equation
  #1
Member
 
fouad abi
Join Date: Nov 2015
Location: Geneva, Switzerland
Posts: 42
Rep Power: 10
faab is on a distinguished road
Send a message via Skype™ to faab
Dear FOAMers,

I have posted this in the section dedicated to Running, Solving and CFD, however as I am not getting any answer I imagine maybe this was the wrong forum to address.

I am actually working on a compressible solver (density based) that I created using the pre-existing chtMultiRegionFoam solver. As stated in the title, I get (see hereunder) an error when solving for the following energy equation:
fvScalarMatrix EEqn
(
fvm::ddt(rho, he) + fvm::div(phi, he)
+ fvc::ddt(rho, K) + fvc::div(phi, K)
==
fvm::laplacian(kEff, T)
+ HS
);
HS is just a volumetric source term, and kEff is the effective conductivity.
he is the internal energy (I compute it using an external Fortran code)
while K is set as being: const volScalarField& K = 0.5 * (U & U);

#0 Foam::error: rintStack(Foam::Ostream&) at ??:?
#1 Foam::sigSegv::sigHandler(int) at ??:?
#2
at sigaction.c:?
#3 memcpy at interp.c:?
#4 std::string::append(std::string const&) in "/home/faabid/OpenFOAM/ThirdParty-2.3.0/platforms/linux64/gcc-4.8.1/lib64/libstdc++.so.6"
#5 std::basic_string<char, std::char_traits<char>, std::allocator<char> > std: perator+<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at ~/OpenFOAM/ThirdParty-2.3.0/platforms/linux64/gcc-4.8.1/include/c++/4.8.1/bits/basic_string.h:2370
#6
at ~/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/lnInclude/fvcDiv.C:240 (discriminator 2)
#7
at ~/OpenFOAM/OpenFOAM-2.3.0/applications/solvers/heatTransfer/CompressibleHeSolver/./fluid/EEqn.H:24 (discriminator 1)
#8 __libc_start_main at ??:?
#9
at ??:?
Segmentation fault (core dumped)

Where fluid/EEqn.H:24 corresponds to:
+ fvc::ddt(rho, K) + fvc::div(phi, K)
I also remind that K is set to: const volScalarField& K = 0.5*magSqr(U);

Could anyone please help me ??

Thank you !!
faab is offline   Reply With Quote

Old   February 15, 2017, 15:46
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Why K is const reference (why not create just a copy of 0.5*(U & U) using constructor from tmp as volScalarField K(0.5*(U & U))? Are you sure, object it is referencing is not destroyed before construction of energy equation?
alexeym is offline   Reply With Quote

Old   February 16, 2017, 08:23
Default
  #3
Member
 
fouad abi
Join Date: Nov 2015
Location: Geneva, Switzerland
Posts: 42
Rep Power: 10
faab is on a distinguished road
Send a message via Skype™ to faab
Hi Alexey,

First of all, thank you very much for your attention and help!
I did modified the way I construct and call K and you were right to point this out because the error seems now corrected. However, I am getting an error from the energy term "he" and it is the following:

Code:
FOAM FATAL ERROR: 

    valueInternalCoeffs cannot be called for a calculatedFvPatchField
    on patch outsidewalls of field he in file "/home/faabid/OpenFOAM/faabid_cases/testCase/mine/CompressibleSolver/0/hell_channel/he"
    You are probably trying to solve for a field with a default boundary condition.

    From function calculatedFvPatchField<Type>::valueInternalCoeffs(const tmp<scalarField>&) const
    in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 154.

FOAM exiting
The "he" term is defined in my code as:

Code:
volScalarField& he = heFluids[i];
heFluids.set
        (
            i,
            new volScalarField
            (
                IOobject
                (
                    "he",
                    runTime.timeName(),
                    fluidRegions[i],
                    IOobject::MUST_READ,
                    IOobject::AUTO_WRITE
                ),
                fluidRegions[i],
                dimensionedScalar
                (
                    "he",
                    dimensionSet(1,2,-2,0,0,0,0),
                    scalar(1990.4)
                )
            )
        );
And computed using an external Fortran code, from the thermodynamic properties rho, T and P at every time step. Also in the fvSchemes dictionnary I defined:

Code:
divSchemes
{
    default         none;

    div(phi,U)      Gauss upwind;
    div(rho,he)      Gauss upwind;
    div(phi,he)      Gauss upwind;
    //div((p*U))        Gauss linear;
    div(phi,(0.5*magSqr(U)))      Gauss linear;
    grad(T)            Gauss linear;
}
And he is itself defined in the initial folder 0/ as:
Code:
dimensions      [1 2 -2 0 0 0 0];

internalField   uniform 1990.4;

boundaryField
{
    FrontAndBack
    {
        type            empty;
    }
    outsidewalls
    {
        type            gradientEnergy;
        gradient        uniform 0;
    }
    hell_channel_to_solid2
    {
        type            mixedEnergy;
        refValue        uniform 0;
        refGradient     uniform 0;
        valueFraction   uniform 0;
        value           $internalField;
    }
    hell_channel_to_solid1
    {
        type            mixedEnergy;
        refValue        uniform 0;
        refGradient     uniform 0;
        valueFraction   uniform 0;
        value           $internalField;
    }
}
Would you or anyone have a suggestion to get past this error ?
Once again thank you for your time and support, it's much appreciated!
faab is offline   Reply With Quote

Old   February 16, 2017, 08:35
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Default constructor of volScalarField (which is just typedef over GeometricField, http://cpp.openfoam.org/v4/a00931.ht...0d8f8a5fec0dc8) sets calculated type for all boundary conditions, hence the error. The easies ways if to add to your constructor "zeroGradient", so he field has zero gradient BCs everywhere.

Code:
heFluids.set(
  i,
  new volScalarField(
    IOobject("he", runTime.timeName(), fluidRegions[i], IOobject::MUST_READ,
             IOobject::AUTO_WRITE),
    fluidRegions[i],
    dimensionedScalar("he", dimEnergy, 1990.4),
    "zeroGradient"));
Strictly speaking, you need to set real BCs for he, which correspond to your problem.
alexeym is offline   Reply With Quote

Old   February 16, 2017, 09:36
Default
  #5
Member
 
fouad abi
Join Date: Nov 2015
Location: Geneva, Switzerland
Posts: 42
Rep Power: 10
faab is on a distinguished road
Send a message via Skype™ to faab
Hi Alexey,

I understand, I did not know about that, thanks a lot for the tip. I will try that as soon as I get my hands back on the code and will keep you posted. Thanks again for your valuable help !
faab is offline   Reply With Quote

Old   February 17, 2017, 05:27
Default
  #6
Member
 
fouad abi
Join Date: Nov 2015
Location: Geneva, Switzerland
Posts: 42
Rep Power: 10
faab is on a distinguished road
Send a message via Skype™ to faab
Hi again,

The solution you provided did the job, now I've got to figure out why the solution for "he" diverges and makes the solver crash after a few time steps. But you were of great help, thanks a lot for everything Alexey !

Faab
faab is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the height of the stream in the free channel kevinmccartin CFX 12 October 13, 2022 21:43
Error in computing Energy equation faab OpenFOAM Running, Solving & CFD 0 February 3, 2017 13:04
error message cuteapathy CFX 14 March 20, 2012 06:45
energy equation in rhoCentralFoam nakul OpenFOAM 0 October 10, 2010 15:07
SIMPLE and energy equation convergence Fabio Main CFD Forum 0 June 1, 2007 06:06


All times are GMT -4. The time now is 00:16.