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

Error adding the temperature icoFoam

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 14, 2014, 22:11
Default Error adding the temperature icoFoam
  #1
Member
 
JuNNioR
Join Date: Feb 2014
Location: Brazil
Posts: 44
Rep Power: 12
jrsilvio_ver is on a distinguished road
Dear, good night.
I used the openfoamwiki's tutorial to edit the solve icoFoam and add the energy equation, however when trying to visualize the temperature field, it simply disappears.
Below is example solver and edited example cavity.
I appreciate everyone's attention.

createFields.H

Code:
Info<< "Reading transportProperties\n" << endl;

    IOdictionary transportProperties
    (
        IOobject
        (
        "transportProperties",
        runTime.constant(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
        )
    );

    dimensionedScalar nu
    (
        transportProperties.lookup("nu")
    );


dimensionedScalar DT
(
     transportProperties.lookup("DT")
);

    Info<< "Reading field p\n" << endl;
    volScalarField p
    (
        IOobject
        (
            "p",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );


    Info<< "Reading field U\n" << endl;
    volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

Info<< "Reading field T\n" <<endl;
volScalarField T
(
    IOobject
    (
         "T",
         runTime.timeName(),
         mesh,
         IOobject::MUST_READ,
         IOobject::AUTO_WRITE
     ),
     mesh
);


#   include "createPhi.H"


    label pRefCell = 0;
    scalar pRefValue = 0.0;
    setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);
icoFoamTemp.C

Code:
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM 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.

    OpenFOAM 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 OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Application
    icoFoamTemp

Description
    Transient solver for incompressible, laminar flow of Newtonian fluids.

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

#include "fvCFD.H"

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

int main(int argc, char *argv[])
{
    #include "setRootCase.H"

    #include "createTime.H"
    #include "createMesh.H"
    #include "createFields.H"
    #include "initContinuityErrs.H"

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

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        #include "readPISOControls.H"
        #include "CourantNo.H"

        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        );

        solve(UEqn == -fvc::grad(p));

        // --- PISO loop

        for (int corr=0; corr<nCorr; corr++)
        {
            volScalarField rAU(1.0/UEqn.A());

            volVectorField HbyA("HbyA", U);
            HbyA = rAU*UEqn.H();
            surfaceScalarField phiHbyA
            (
                "phiHbyA",
                (fvc::interpolate(HbyA) & mesh.Sf())
              + fvc::ddtPhiCorr(rAU, U, phi)
            );

            adjustPhi(phiHbyA, U, p);

            for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
            {
                fvScalarMatrix pEqn
                (
                    fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
                );

                pEqn.setReference(pRefCell, pRefValue);
                pEqn.solve();

                if (nonOrth == nNonOrthCorr)
                {
                    phi = phiHbyA - pEqn.flux();
                }
            }

            #include "continuityErrs.H"

             U -= rUA*fvc::grad(p);
             U.correctBoundaryConditions();
        }

        fvScalarMatrix TEqn
        (
            fvm::ddt(T)
            + fvm::div(phi, T)
            - fvm::laplacian(DT, T)
        );

        TEqn.solve();
 
        runTime.write();

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

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

    return 0;
}
By using the command wmake, has:

Code:
Making dependency list for source file icoFoamTemp.C
SOURCE=icoFoamTemp.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam222/src/finiteVolume/lnInclude -I/opt/openfoam222/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/icoFoamTemp.o
icoFoamTemp.C: Na função ‘int main(int, char**)’:
icoFoamTemp.C:100:19: erro: ‘rUA’ was not declared in this scope
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:3:15: aviso: unused variable ‘nOuterCorr’ [-Wunused-variable]
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:12:16: aviso: unused variable ‘momentumPredictor’ [-Wunused-variable]
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:15:16: aviso: unused variable ‘transonic’ [-Wunused-variable]
make: ** [Make/linux64GccDPOpt/icoFoamTemp.o] Erro 1

Last edited by wyldckat; February 16, 2014 at 09:49. Reason: Added [CODE][/CODE]
jrsilvio_ver is offline   Reply With Quote

Old   February 14, 2014, 22:18
Default
  #2
Member
 
JuNNioR
Join Date: Feb 2014
Location: Brazil
Posts: 44
Rep Power: 12
jrsilvio_ver is on a distinguished road
fvSchemes

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
    default         Euler;
}

gradSchemes
{
    default         Gauss linear;
    grad(p)         Gauss linear;
}

divSchemes
{
    default         none;
    div(phi,U)      Gauss linear; //NOTICE: there is no space between the comma and the variables
    div(phi,T)      Gauss upwind;
}

laplacianSchemes
{
    default         none;
    laplacian(nu,U) Gauss linear corrected;
    laplacian((1|A(U)),p) Gauss linear corrected;
    laplacian(DT,T) Gauss linear corrected;
}

interpolationSchemes
{
    default         linear;
    interpolate(HbyA) linear;
}

snGradSchemes
{
    default         orthogonal;
}

fluxRequired
{
    default         no;
    p               ;
}
fvSolution

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    p
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance       1e-06;
        relTol          0;
    }

    // GW Add a solver for T
    T
    {
        solver          BICCG;
        preconditioner  DILU; //GW or: none, GAMG, diagonal
        tolerance       1e-7;
        relTol          0;
    }

    U
    {
        solver          PBiCG;
        preconditioner  DILU;
        tolerance       1e-06;
        relTol          0;
    }
}

PISO
{
    nCorrectors     2;
    nNonOrthogonalCorrectors 0;
    pRefCell        0;
    pRefValue       0;
}
T

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      T;
}
//**********************************//

dimensions       [0 0 0 1 0 0 0];

internalField    uniform 300;

boundaryField
{
    movingWall
    {
        type        fixedValue;
        value       uniform 350;
    }

    fixedWalls
    {
        type        fixedValue;
        value       uniform 300;
    }

    frontAndBack
    {
        type        empty;
    }
}

Last edited by wyldckat; February 16, 2014 at 09:50. Reason: Added [CODE][/CODE]
jrsilvio_ver is offline   Reply With Quote

Old   February 15, 2014, 11:45
Default
  #3
Member
 
JuNNioR
Join Date: Feb 2014
Location: Brazil
Posts: 44
Rep Power: 12
jrsilvio_ver is on a distinguished road
Can anyone help me identify the problem?
jrsilvio_ver is offline   Reply With Quote

Old   February 16, 2014, 02:58
Default
  #4
Senior Member
 
shinji nakagawa
Join Date: Mar 2009
Location: Japan
Posts: 113
Blog Entries: 1
Rep Power: 18
snak is on a distinguished road
Hi,

You got an error in compilation. How did you execute new solver?

Error message says unknown word ‘rUA’ exists in line 100 of icoFoamTemp.C.
Yes, its true. What is rUA? It will be rAU, isn't it?


Quote:
Originally Posted by jrsilvio_ver View Post
By using the command wmake, has:

Making dependency list for source file icoFoamTemp.C
SOURCE=icoFoamTemp.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam222/src/finiteVolume/lnInclude -I/opt/openfoam222/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/icoFoamTemp.o
icoFoamTemp.C: Na função ‘int main(int, char**)’:
icoFoamTemp.C:100:19: erro: ‘rUA’ was not declared in this scope
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:3:15: aviso: unused variable ‘nOuterCorr’ [-Wunused-variable]
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:12:16: aviso: unused variable ‘momentumPredictor’ [-Wunused-variable]
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:15:16: aviso: unused variable ‘transonic’ [-Wunused-variable]
make: ** [Make/linux64GccDPOpt/icoFoamTemp.o] Erro 1
snak is offline   Reply With Quote

Old   February 16, 2014, 16:47
Default
  #5
Member
 
JuNNioR
Join Date: Feb 2014
Location: Brazil
Posts: 44
Rep Power: 12
jrsilvio_ver is on a distinguished road
Mr. Nakagawa,
Firstly thank you very much for your help.
I modified the solver icoFOAM as the tutorial link: http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam
Really, it was the correct rAU.
But when running the modified ICOFOAM, the temperature field is still not appearing in the solution presented by PARAFOAM. Temperatures simply disappear.
Wmake command again, we have:



silvio@ubuntu:~/OpenFOAM/silvio-2.2.2/applications/solvers/icoFoamTemp$ wmake
Making dependency list for source file icoFoamTemp.C
SOURCE=icoFoamTemp.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam222/src/finiteVolume/lnInclude -I/opt/openfoam222/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/icoFoamTemp.o
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H: Na função ‘int main(int, char**)’:
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:3:15: aviso: unused variable ‘nOuterCorr’ [-Wunused-variable]
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:12:16: aviso: unused variable ‘momentumPredictor’ [-Wunused-variable]
/opt/openfoam222/src/finiteVolume/lnInclude/readPISOControls.H:15:16: aviso: unused variable ‘transonic’ [-Wunused-variable]
g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam222/src/finiteVolume/lnInclude -I/opt/openfoam222/src/sampling/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPOpt/icoFoamTemp.o -L/opt/openfoam222/platforms/linux64GccDPOpt/lib \
-lfiniteVolume -lsampling -lOpenFOAM -ldl -lm -o /home/silvio/OpenFOAM/silvio-2.2.2/platforms/linux64GccDPOpt/bin/my_icoFoamTemp



What can be the problem?
I appreciate everyone's attention
jrsilvio_ver is offline   Reply With Quote

Old   February 16, 2014, 20:48
Default
  #6
Member
 
JuNNioR
Join Date: Feb 2014
Location: Brazil
Posts: 44
Rep Power: 12
jrsilvio_ver is on a distinguished road
No suggestion?
jrsilvio_ver is offline   Reply With Quote

Old   February 16, 2014, 22:08
Default
  #7
Senior Member
 
shinji nakagawa
Join Date: Mar 2009
Location: Japan
Posts: 113
Blog Entries: 1
Rep Power: 18
snak is on a distinguished road
Hi,

Questions:

(1) Did you do "icoFoamTemp" instead of "icoFoam"?

(2) what exactly happens? "Temperatures simply disappear. "
Do you have a T file in time directories?


Please provide clear, concise and complete information about what you did and what you got.
snak is offline   Reply With Quote

Old   February 17, 2014, 16:34
Default
  #8
Member
 
JuNNioR
Join Date: Feb 2014
Location: Brazil
Posts: 44
Rep Power: 12
jrsilvio_ver is on a distinguished road
(1) I used the command icoFoamTemp. I did not use command icoFoam .

(2) When displaying the simulated results by command paraFoam, check that the temperature disappears over time. That is, at time t = 0, s is the temperature field and as time goes by following the temperature disappears.

What can be happening?
Below, we have the result of ControlDict and icoFoamTemp command.
I appreciate everyone's attention.

-----------------------------------------------------------------------------------------------------------------------------------
Time = 0.495

Courant Number mean: 0.222159 max: 0.852134
DILUPBiCG: Solving for Ux, Initial residual = 3.77171e-08, Final residual = 3.77171e-08, No Iterations 0
DILUPBiCG: Solving for Uy, Initial residual = 8.93865e-08, Final residual = 8.93865e-08, No Iterations 0
DICPCG: Solving for p, Initial residual = 7.67456e-07, Final residual = 7.67456e-07, No Iterations 0
time step continuity errors : sum local = 7.3935e-09, global = -1.93974e-19, cumulative = -1.32121e-17
DICPCG: Solving for p, Initial residual = 9.33333e-07, Final residual = 9.33333e-07, No Iterations 0
time step continuity errors : sum local = 8.75324e-09, global = 8.34212e-19, cumulative = -1.23778e-17
ExecutionTime = 0.23 s ClockTime = 0 s

Time = 0.5

Courant Number mean: 0.222159 max: 0.852134
DILUPBiCG: Solving for Ux, Initial residual = 3.10465e-08, Final residual = 3.10465e-08, No Iterations 0
DILUPBiCG: Solving for Uy, Initial residual = 7.20119e-08, Final residual = 7.20119e-08, No Iterations 0
DICPCG: Solving for p, Initial residual = 1.08094e-06, Final residual = 1.61882e-07, No Iterations 1
time step continuity errors : sum local = 2.42633e-09, global = 1.12397e-18, cumulative = -1.12539e-17
DICPCG: Solving for p, Initial residual = 4.79724e-07, Final residual = 4.79724e-07, No Iterations 0
time step continuity errors : sum local = 5.02954e-09, global = -1.26633e-18, cumulative = -1.25202e-17
ExecutionTime = 0.23 s ClockTime = 0 s
-----------------------------------------------------------------------------------------------------------------------------------

FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ControlDict

application icoFoamTemp;

startFrom startTime;

startTime 0;

stopAt endTime;

endTime 0.5;

deltaT 0.005;

writeControl timeStep;

writeInterval 20;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

timePrecision 6;

runTimeModifiable true;
jrsilvio_ver is offline   Reply With Quote

Old   February 17, 2014, 19:57
Default
  #9
Senior Member
 
shinji nakagawa
Join Date: Mar 2009
Location: Japan
Posts: 113
Blog Entries: 1
Rep Power: 18
snak is on a distinguished road
hi,

I read your #5 post again and found the cause of the problem.
http://www.cfd-online.com/Forums/ope...tml#post475242

Your new solver will be "my_icoFoamTemp" which is shown in the last line of wmake output.
It is written in "files" file in Make subdirectory.
Running my_icoFoamTemp will do what you want to do with your posted source code.

I don't know what is icoFoamTemp in your system. Have you make a solver in that name before? It should be...

This is the reason why you have been able to execute icoFoamTemp before you successfully compile the code, I think.
snak is offline   Reply With Quote

Old   February 17, 2014, 23:10
Default
  #10
Member
 
JuNNioR
Join Date: Feb 2014
Location: Brazil
Posts: 44
Rep Power: 12
jrsilvio_ver is on a distinguished road
Problem solved.
The error was in charge.
Thank you for your attention.
jrsilvio_ver is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 07:15
Problems adding temperature to icoFoam sur4j OpenFOAM Programming & Development 8 January 11, 2015 01:14
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 06:27
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 01:27
adding temperature field to icofoam houkensjtu OpenFOAM 5 September 26, 2012 22:20


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