CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Scalartransportfoam (

sunnysun April 29, 2008 05:46

sorry for my stupid question..
sorry for my stupid I am new to CFD and openfoam...
I would like to simulate the spreading of contrast agent in a tube. My idea is to use icofoam to obtain the velocity and then pass the velocity to scalartransportfoam, may i know how to get the concentration of contrast agent in each cell?

jaswi April 29, 2008 05:51

Hi Vivien As far as I under
Hi Vivien

As far as I understand the concentration of contrast agent is a some kind of field, perhaps a volume scalar field which means you have that scalar stored at each cell centre.

If that guess is correct then you can easily create the field as an IOobject and use it for your purpose.

Hope that helps,


sunnysun April 29, 2008 06:09

Hi, Jaswinder, Thanks for you
Hi, Jaswinder,
Thanks for your idea.the contrast agent concentration is volume scalar field. But can you let me know more about how to creat the IOobject...this is the second day i use this software...

jaswi April 29, 2008 06:18

I can post it for you but i su
I can post it for you but i suggest you
Look into the createFields.H of icoFoam solver.

All the fields you are using are created as an IOobject and if you will try on your own a little bit, you will be able to help other newcomers :-)

Warm Regards

sunnysun April 29, 2008 07:43

Hi, Jaswi, I will follow yo
Hi, Jaswi,

I will follow your advice~~~

BTW, if I understand correctly, I can import the velocity field at the endtime of icofoam to scalartransportfoam in the case when flow is steady. but what if the velocity is periodically changing?

Many thanks!!


jaswi April 29, 2008 07:54

Hi Viven If you need to do
Hi Viven

If you need to do a scalartransport for a periodically changing velocity field then may be you want to couple the two solvers or better say combine them.

Its should not be very difficult. Solve the scalar transport equation after you have solved for the velocity using icoFoam. just include that equation into your main solver and solve it with the updated phi.

Take a look at the turbFoam solver. It solves the turbulence equation by making a call turbulence->correct();. In the same way you can solve your scalartransport equation at this point .

Give it a try and let the error messages flow to forum :-)

Hope that helps

sunnysun April 29, 2008 09:03

Hi,Jaswi, I know it is a sill
I know it is a silly question...but may i know where can i find this createFields.H ??I can not find it in icofoam tutorial...


ngj April 29, 2008 09:42

Hi Vivien It can be found t
Hi Vivien

It can be found together with the source code in:


Best regards,


jaswi April 29, 2008 09:45

Hi Vivien No question is si
Hi Vivien

No question is silly as all of them lead to a purposeful answer :-).

Find it here:


Basically all the solvers live here categorized in their individual directory. under this directory you will find


and there lives this file. This is what it contains. I have put the horizontal lines so you can see it consists of several blocks of code:

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

IOdictionary transportProperties

dimensionedScalar nu
Info << "Reading field p\n" << endl;
volScalarField p
Info << "Reading field U\n" << endl;
volVectorField U
# include "createPhi.H"
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);

Take a look at for instant:

volVectorField U

Here a volumetric vector field is being created as an IOobject. If you take a closer look at the definition then you will see

volVectorField U ( IOobject(), mesh )

implies that a volVectorField named U being created from an IOobject and mesh. Now IOobject takes following aruguments:

"U", // name
runTime.timeName(), // instance
mesh, // not clear to me but its always mesh
IOobject::MUST_READ, // read option
IOobject::AUTO_WRITE // write option

Let me know if you have further ?s. i will try to answer as far as I know :-)


sunnysun April 29, 2008 09:57

If there is only a 'bin' file
If there is only a 'bin' file in this directory /home/openfoam/OpenFOAM/OpenFOAM-1.4.1/applications/
, which means, no 'solvers', is it mean there is something wrong with my installation?

jaswi April 29, 2008 10:10

Well I am afraid to say that y
Well I am afraid to say that yes, something is wrong . Please issue the command

foamInstallationTest and see if it goes thru well.


sunnysun April 30, 2008 06:09

Hi, Jaswi, i found the source
Hi, Jaswi, i found the source code...
then i combined the Scalartransportfoam with icofoam ~
the geometry is a cylinder...seems everything ok..
but when i run the simulation, after a while it returns 'floating point exception' ...

any idea what is the reason for that?


jaswi April 30, 2008 06:16

Hi Vivien its very difficul
Hi Vivien

its very difficult to say for me what went wrong. i can only find it out if i have the test case and the solver. send it to me and i can take a look. i have some time free tomorrow.


sunnysun April 30, 2008 10:55

Hi, Jaswi,I already sent the f
Hi, Jaswi,I already sent the files to your email, pleae have a look!

Many many thanks!

Best wishes,


jmmeena May 13, 2009 11:44

I used Uequ.h from BuoyantSimpleFoam in scalarTransportFoam....... Now it will read value of phi or I have to give some other command ??



jmmeena May 15, 2009 05:59

New solver compiled like this:
/bin/sh: /usr/lib/OpenFOAM-1.5/wmake/rules/linux64Gcc/wmkdep: not found
SOURCE=buoyantTransportSimpleFoamNew.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -I/usr/lib/OpenFOAM-1.5/src/finiteVolume/cfdTools -I/usr/lib/OpenFOAM-1.5/src/finiteVolume/lnInclude -I/usr/lib/OpenFOAM-1.5/src/thermophysicalModels/basic/lnInclude -I/usr/lib/OpenFOAM-1.5/src/turbulenceModels/RAS -IlnInclude -I. -I/usr/lib/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/usr/lib/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc/buoyantTransportSimpleFoamNew.o
g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -I/usr/lib/OpenFOAM-1.5/src/finiteVolume/cfdTools -I/usr/lib/OpenFOAM-1.5/src/finiteVolume/lnInclude -I/usr/lib/OpenFOAM-1.5/src/thermophysicalModels/basic/lnInclude -I/usr/lib/OpenFOAM-1.5/src/turbulenceModels/RAS -IlnInclude -I. -I/usr/lib/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/usr/lib/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC Make/linux64Gcc/buoyantTransportSimpleFoamNew.o -L/usr/lib/OpenFOAM-1.5/lib \
-lfiniteVolume -lmeshTools -lbasicThermophysicalModels -lspecie -lcompressibleRASModels -lOpenFOAM -liberty -ldl -lm -o/home/users/jagmohan//OpenFOAM/jagmohan-1.5/applications/bin/buoyantTransportSimpleFoamNew

Please see the 1st line !! Is there any problem in compilation ??
After this I found solver in bin directory and thought it should be okay !!

So I tried to use it for one of the cases. Then what it reported is this:
jagmohan@biquad:/home/users/jagmohan/OpenFOAM/jagmohan-1.5/run/coude_diffusion_thermal$ buoyantTransportSimpleFoamNew
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: |
| \\/ M anipulation | |
Exec : buoyantTransportSimpleFoamNew
Date : May 15 2009
Time : 11:44:17
Host : biquad
PID : 19369
Case : /home/users/jagmohan/OpenFOAM/jagmohan-1.5/run/coude_diffusion_thermal
nProcs : 1

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading environmentalProperties
Reading thermophysical properties

Selecting thermodynamics package hThermo<pureMixture<constTransport<specieThermo<hC onstThermo<perfectGas>>>>>
Reading field T

Reading field W

Reading field U

Reading transportProperties

Reading diffusivity DT

Reading diffusivity DW

Reading/calculating face flux field phi

Creating turbulence model

Selecting RAS turbulence model kEpsilon
Cmu 0.09;
C1 1.44;
C2 1.92;
C3 0.85;
alphah 1;
alphak 1;
alphaEps 0.76923;

Calculating field g.h

Creating field pd

Starting time loop

Time = 0.01

DILUPBiCG: Solving for Ux, Initial residual = 1, Final residual = 8.03917e-06, No Iterations 4
DILUPBiCG: Solving for Uy, Initial residual = 1, Final residual = 8.25025e-06, No Iterations 4
DILUPBiCG: Solving for Uz, Initial residual = 1, Final residual = 6.78799e-07, No Iterations 5
DILUPBiCG: Solving for h, Initial residual = 1, Final residual = 8.7112e-06, No Iterations 5
DICPCG: Solving for pd, Initial residual = 1, Final residual = 6.39622e-09, No Iterations 404
time step continuity errors : sum local = 2.35897e-11, global = 7.22445e-14, cumulative = 7.22445e-14
rho max/min : 5.28627 0.726473

incompatible dimensions for operation
[T[0 0 -1 1 0 0 0] ] + [T[1 -3 -1 1 0 0 0] ]#0 Foam::error::printStack(Foam::Ostream&) in "/usr/lib/OpenFOAM-1.5/lib/"
#1 Foam::error::abort() in "/usr/lib/OpenFOAM-1.5/lib/"
#2 void Foam::checkMethod<double>(Foam::fvMatrix<double> const&, Foam::fvMatrix<double> const&, char const*) in "/home/users/jagmohan//OpenFOAM/jagmohan-1.5/applications/bin/buoyantTransportSimpleFoamNew"
#3 Foam::tmp<Foam::fvMatrix<double> > Foam::operator+<double>(Foam::tmp<Foam::fvMatrix<d ouble> > const&, Foam::tmp<Foam::fvMatrix<double> > const&) in "/home/users/jagmohan//OpenFOAM/jagmohan-1.5/applications/bin/buoyantTransportSimpleFoamNew"
#4 main in "/home/users/jagmohan//OpenFOAM/jagmohan-1.5/applications/bin/buoyantTransportSimpleFoamNew"
#5 __libc_start_main in "/lib/"
#6 _start in "/home/users/jagmohan//OpenFOAM/jagmohan-1.5/applications/bin/buoyantTransportSimpleFoamNew"

From function checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)
in file /usr/lib/OpenFOAM-1.5/src/finiteVolume/lnInclude/fvMatrix.C at line 1184.

FOAM aborting


It started solving for U. But I think at scalar transport equation there is some error of dimensions. I have checked it and equation is correct. What I think that dimensions of phi made a problem. But I have no clue how to deal with this. Please help regarding this. I would really be thankful to you.


su_junwei May 15, 2009 07:16


there should be some problem in your equation definition of T. Compile the code in debug mode, and it will tell you the exact place of the error.


jmmeena May 16, 2009 06:16

Hi Junwei,
thank you very much for your reply...but compilation was successful...this dimension error came during running the case. Can you tell me wat are the dimensions of phi ??

I think this error is occurred during solving the transport equation for T !


jmmeena May 16, 2009 06:18

I combined icoFoam and scalarTransportFoam.. combination worked perfectly !! but m still not able to find what is the problem in combination of buoyantSimpleFoam and ScalarTransportFoam !!

plzz tell me how to run a case in debug mode so that I will get exact location of error....or I can post my code if you want.


su_junwei May 16, 2009 15:02

add the following line to EXE_INC
and recompile your solver, and run your application.
Note the "\" for the connection of different line of code


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