CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Adding source term to u eq (http://www.cfd-online.com/Forums/openfoam-solving/58956-adding-source-term-u-eq.html)

roberthino March 14, 2008 04:24

hi everybody, me again with a
 
hi everybody, me again with a problem :-)
i now try to run my rans channel flow with cyclic boundary conditions, therefor i have to ad an extra term to the u eq in simpleFoam.C to keep a constant pressure gradient along the channel.
i really dont have a clue how to modify the u eq. i tried to do it like this:
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
+ 0.018
);

where 0.018 is the constant. this isnt working and it isnt compiling. maybe someone can help and tell me how to exactly implement the term.
thx
greetings robert

stephan March 14, 2008 06:50

hi, 0.018 is a scalar not a
 
hi,

0.018 is a scalar not an vector while U is a vector.
try to put the 0.018 as a component of a vector - this should work.
stephan

marhamat March 14, 2008 09:56

You must add volVectorField wi
 
You must add volVectorField with correct dimension

roberthino March 14, 2008 15:22

is there an example where i ca
 
is there an example where i can have a look in the code where a constant term is added? do i only have to add the term + volVectorField(0.018, 0, 0)?

alberto March 14, 2008 18:17

Hello Robert, you can add i
 
Hello Robert,

you can add it exactly as g (gravity) is added.

For sake of simplicity of use, just add the vector you want to add to the momentum equation to your transportProperties dictionary (check dimensions):

myVector myVector [0 1 -1 0 0 0 0] (0.018 0 0);

then read it in createFields.H after the dictionary declaration:

dimensionedVector myVector
(
transportProperties.lookup("myVector")
);

and then add it to the equation ( ... + myVector).

Regards,
Alberto

marhamat March 14, 2008 18:18

I mean you must define new va
 
I mean you must define new variable as a volVectorField with correct dimension.
>such as:
volVectorField NSconstant=fvm::ddt(U);
forAll(mesh.C(),i)
{
NSconstant[i]=(0.018,0,0);
}
>then

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
+ NSconstant
)

alberto March 14, 2008 23:46

You're right. Just shorter:
 
You're right. Just shorter:

volScalarField myVectorField("myVectorField", myVector & mesh.C());

Regards,
Alberto

marhamat March 15, 2008 01:36

Thank's Alberto I prefere you
 
Thank's Alberto
I prefere your method too.

roberthino March 15, 2008 09:02

well since my knowledge in c++
 
well since my knowledge in c++ is very very small i try to do it the first way described by alberto. as i understodd there has to be a file (transportproperties) where i first have to define this 0.018. then i have to ad it in the createfields so that the incompressible solver can read it. then i can finally ad the term in the momentum equation. well i managed to change the createfields the proper way and also put in the term in the momentum eq. but i cant find the transportProperties file where i have to ad
myVector myVector [0 1 -1 0 0 0 0] (0.018 0 0);
maybe you can help me out?

stephan March 15, 2008 10:11

hi, go to the tutorials-dir
 
hi,

go to the tutorials-dir in one of the cases from settlingFoam - there is a file called actually "environmentalProperties". just give the file a new name.
regards
stephan

mike_jaworski March 15, 2008 10:35

Robert, I wrote a tutorial
 
Robert,
I wrote a tutorial on adding a scalar transport equation and modifying the transportProperties dictionary (and how to read these things in openFOAM). It's on the wiki and maybe you can use it to help write your solver:

http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam

Good luck,
Mike J.

roberthino March 16, 2008 09:34

hi all, i posted this message
 
hi all, i posted this message under the installation topics and now also here so that maybe you have an idea.
i did everything the way how michael described it in the tutorial he wrote. the problem is that when i try to compile everything i got the following error message:

robert@robert-laptop:~/OpenFOAM/OpenFOAM-1.4.1/applications/solvers/incompressible/simpleFoam$ wmake
g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/robert/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude -I/home/robert/OpenFOAM/OpenFOAM-1.4.1/src/turbulenceModels -I/home/robert/OpenFOAM/OpenFOAM-1.4.1/src/transportModels -IlnInclude -I. -I/home/robert/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -pthread Make/linuxGccDPOpt/simpleFoam.o -L/home/robert/OpenFOAM/OpenFOAM-1.4.1/lib/linuxGccDPOpt \
-lincompressibleTurbulenceModels -lincompressibleTransportModels -lfiniteVolume -lmeshTools -lOpenFOAM -ldl penFOAM/linux/gcc-4.2.1/lib/libiberty.a -o /home/robert/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linuxGccDPOpt/simpleFoam
g++: penFOAM/linux/gcc-4.2.1/lib/libiberty.a: No such file or directory
make: *** [/home/robert/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linuxGccDPOpt/simpleFoam] Error 1
robert@robert-laptop:~/OpenFOAM/OpenFOAM-1.4.1/applications/solvers/incompressible/simpleFoam$

do i have to install any extra package to get rid of the problem? i already installed the binutils-dev package some time ago. i hope someone canhelp me

stephan March 16, 2008 11:32

hi, there should be a page
 
hi,

there should be a page called "how to compile openfoam". on this page you will find answers about the missing libiberty - i guess a partial reinstall of the binutils is what you need.
regards
stephan

dpalko March 16, 2008 16:56

Robert, Try to go to /home/ro
 
Robert,
Try to go to /home/robert/OpenFOAM/linux/gcc-4.2.1/lib and check if you have the file libiberty.a there. If not, try to download gcc-4.2.1 from OpenFoam webpage once more and unpack it. Maybe it helps.

David

roberthino March 17, 2008 04:06

jep, i already have the file.
 
jep, i already have the file. well i installed on another machine now suse and there after downloading the packages compiling works.
with adding a source term which has the exact value of my pressure gradient and setting pressure and everything as cyclic i dont get the suspected results. i took 700 cells in channel height direction and 2 to 4 in channel lenght direction. the solution always gives cyclic positive velocities at channel inlet and outlet and in the channel half negative velocities. should i change the number of cells in channel length direction to 1?

roberthino March 17, 2008 07:32

just to give an update. i thin
 
just to give an update. i think adding only a source term to the equation and choosing cyclic boundary conditions is not possible. i think the mass conservation is not necessarily fulfilled. i am trying to do my channel flow simulation now with boundaryFoam since i heard it works already with correctors for the mass conservation. the problem is that i dont see the boundaryFoam application in my FoamX-GUI. anyone knows what to do?

suredross April 14, 2008 04:35

hi, i am trying to add a conc
 
hi,
i am trying to add a concentration equation to the icofoam solver to cater for different liquids of different concentrations.how do i go about it?should i follow the same procedure as how to add temperature?

thanks
davey

suredross April 14, 2008 09:25

hi Mike J, i was trying to fo
 
hi Mike J,
i was trying to follow your tutorial to add an equation(for concentration) to the icofoam solver but it seems not to be working for me.could you explain,please,how you got this eqn:

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

TEqn.solve?

i am new to Openfoam and cfd and cant seem to get around this obstacle.

thanks
davey

sambatra March 19, 2009 03:47

inquiry
 
Hi there,
I'm kinda new to openfoam, and now I'm trying to learn more about it, it's very interesting but little hard. I got a question.
Can anybody comment a bit on this piece of code (it is in turbfoam code):

volScalarField rUA = 1.0/UEqn.A();
U = rUA*UEqn.H();
.......
U-=rUA*fvc::grad(p);
what I dont get is the 'UEqn.A()' (access function?) and the "U-=rUA*fvc::grad(p)"
last one, what does "fvc::interpolate(U) & mesh.Sf()"
I know the syntax interpolate but my trouble is the meaning of "& mesh.Sf()"

sambatra March 19, 2009 03:54

inquiry
 
Hi there,
I'm kinda new to openfoam, and now I'm trying to learn more about it, it's very interesting but little hard. I got a question.
Can anybody comment a bit on this piece of code (it is in turbfoam code):

volScalarField rUA = 1.0/UEqn.A();
U = rUA*UEqn.H();
.......
U-=rUA*fvc::grad(p);
what I dont get is the 'UEqn.A()' (access function?) and the "U-=rUA*fvc::grad(p)"
last one, what does "fvc::interpolate(U) & mesh.Sf()"
I know the syntax interpolate but my trouble is the meaning of "& mesh.Sf()"


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