CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   A NEW solver for steady Poissonbs equation (

Ali (Ali) February 4, 2005 14:13

I need to solve a 1d axisymmet
I need to solve a 1d axisymmetric problem in a channel (1d steady state solution of pipe flow under constant pressure gradient). So, I would use an axisymmetric geometry and set number of cells in "x" direction equal to one and left and right boundaries as 'empty' and say number of grids in "r" direction 100 grids (lower boundary is axis, upper one is wall, and front and back boundaries as wedge). Now about solver, this is the equation:


where Px is pressure gradient in "x" direction, I start with laplacianFOAM, rename it to channel1dFoam. Then, in the main 'channel1dFoam', I need to define a vector in "Px".

I define it like below:

Info<< "\nCalculating velocity distribution\n" << endl;

dimensionedVector Px
dimensionSet(1, -2, -2, 0, 0, 0, 0),

for (runTime++; !runTime.end(); runTime++)
Info<< "\n Time = " << runTime.timeName() << nl << endl;

# include "readSIMPLEControls.H"

for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
Px + fvm::laplacian(1, U)

When I compile it, I get this error. Any clue what to do:

ali@ns microFluid1dFoam]$ wmake

SOURCE=channel1dFoam.C ; g++ -m32 -Dlinux -DlinuxOpt -DscalarMachine -DoptSolvers -Wall -W -Wno-unused-parameter -O3 -ffast-math -DNoRepository -ftemplate-depth-30 -I/home/ali/foam/foam2.3.2/src/foam/lnInclude -IlnInclude -I. -DWM_PROJECT_VERSION='"'2.3.2'"' -I/home/ali/foam/foam2.3.2/src/cfdTools/incompressible -I/home/ali/foam/foam2.3.2/src/cfdTools/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxOpt/channel1dFoam.o
channel1dFoam.C: In function `int main(int, char**)':
channel1dFoam.C:54: error: expected primary-expression before ')' token
make: *** [Make/linuxOpt/channel1dFoam.o] Error 1

Sorry if this seems stupid question.

Henry Weller (Henry) February 4, 2005 14:28

boundaryFoam does what you ne
boundaryFoam does what you need

Ali (Ali) February 6, 2005 18:57

If I have this equation: 1/
If I have this equation:

1/r*d/dr(r*dU/dr) = k*tanh(U)

where 'k' is a constant.

volScalarField tanhU = tanh(U);

tmp UrEqn
fvm::laplacian(mm, U)
fvm::Sp(k, tanhU)


where mm=1 is just a constant.

when I compile it, it gives no error, but when I want to run it, it gives this error:

Time = 1

--> FOAM FATAL ERROR : incompatible fields for operation
[tanhU] == [tanh(U)]

Function: checkMethod(const fvMatrix&, const fvMatrix&)
in file: /home/ali/foam/foam2.3.2/src/foam/lnInclude/fvMatrix.C at line: 936.

FOAM aborting

I don't know what's wrong, as if I change tanh(U) to U itself, there is no problem and it works. What I'm missing here?

Another thing is that if I have the main variable (here 'U') in the RHS of equation, I should use 'Sp()' function for source term (as I've used in the above equation), otherwise, if the RHS doesn't contain main variable U and would be something like


where Px is just an independent scalar that's given, we do not necessary need to use can use 'Sp()' and the following also works:

fvm::laplacian(mu, UExact) + gradP


where 'mu' is kinematic viscosity.

Is my perception right or I can implement every equation without using 'Sp()' or it's better I always use 'Sp()'? Please guide me. Thanks.

Ali (Ali) February 7, 2005 05:01

Also, how to use spatial i

how to use spatial integration in openFOAM's FVM formulation. i.e. if I find a scalar say 'T' from solving one of the above equations and want to calculate this integral:

from 0 to R (bounds):

or another intergral:

from 0 to R (bounds):

How can I do this? Thanks.

Niklas Nordin (Niklas) February 7, 2005 05:38

You cannot solve the equation
You cannot solve the equation treating tan(U) implicitly.

fvm::laplacian(mm, U)

is what you want

fvm::Sp(k, tanhU)
constructs a matrix treating the variable tanhU implicit, not U (which is what I think you want)

Ali (Ali) February 7, 2005 13:26

Now, it's becoming interestin
Now, it's becoming interesting:

If the RHS is tanh(T) it works, but if it's sinh(T), it diverges quickly and gives very high numbers that are unaccetbale. It's odd because in MATLAB it's solvable, but here it can't be solved. Even if I start from a good intial condition for T, again it doesn't work.

fvm::laplacian(mm, T)

where mm=1. The linearized version (if we assume sinh(T)=T for small enough T) is easily solvable if I replace sinh(T) by T itself.

Any clue where the problem would be?

PS: I even changed the nNonOrthogonaslCorrectors and used a couple of different laplacian schemes, but no success.

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