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

Specifying nonuniform initial condition

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 25, 2005, 12:05
Default Hi, I have a 2D domain consis
  #1
msyaml
Guest
 
Posts: n/a
Hi,
I have a 2D domain consisting of four blocks. I want to specify the initial condition for a field variable as T=1 in block 0 and as T=0 in the other three blocks. Is there a way to specify the initial condition block-by-block? i.e., in file T in folder 0 use the keyword non-uniform and specify a list of blocks and the corresponding T values. I am a novice user and was not able find an example for this in the user's or programmer's guide or in tutorial cases (e.g., damBreak example is similar but seems to use an initialization program). Thanks.
Syam
  Reply With Quote

Old   March 25, 2005, 12:34
Default The concept of blocks only exi
  #2
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
The concept of blocks only exists in blockMesh. (assuming that you are using blockMesh) After mesh generation (with whichever mesh generator you use) OpenFOAM has no concept of blocks. The whole mesh is one unstructured set of cells of arbitrary shape.

Since there is no information kept on what cells originate from what block you'll have to select them yourself. The damBreak application comes closest to your needs I think.

Mattijs
mattijs is offline   Reply With Quote

Old   March 25, 2005, 13:04
Default What if you build another case
  #3
Member
 
diablo80@web.de
Join Date: Mar 2009
Posts: 93
Rep Power: 17
sampaio is on a distinguished road
What if you build another case, with only one block, coinciding with the one you want T=1. Than, if you use mapFields from there to your actual case....
Would that work for you?
I know, it is a little dirty solution...
Luiz
sampaio is offline   Reply With Quote

Old   March 25, 2005, 16:16
Default Luiz, Thanks for that clever
  #4
msyaml
Guest
 
Posts: n/a
Luiz,
Thanks for that clever solution! Although an additional case was needed, your solution reduced the complexity of the original case (fewer blocks) and eliminated the need for an initialization program.
Syam
  Reply With Quote

Old   November 15, 2005, 15:06
Default I'm trying to set a turbulent
  #5
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
I'm trying to set a turbulent nonuniform initial condition for a channel flow case. The field is available in a file with the format (column-wise):

x y z u v w p

1) I found that SetField utility that is used in the dam break case (1.2) is designed to do similar job but it uses dictionary as its input. Can any body explain how to use or modify the utility to use a data file as input.

2) I also thought of using mapField utility after trying to make a new case and cast my data into the OpenFOAM format but I faced the following problem:

the file constant/polyMesh/"points" describes vertices while what is available at my case is the node values that correspond to the values of 0/U and 0/p. I would be grateful if some body can give some help about how to solve this problem.


3) one final question about constant/polyMesh/cells: does the file format of openFOAM enforces any rules regarding the order of cells in the file or it is fully unstructured and I can order the cells as I like as long as it is consistent with 0/U, and 0/p format.

Thanks.
best regards,
Maka
maka is offline   Reply With Quote

Old   November 15, 2005, 15:40
Default I noticed a talk about cellSet
  #6
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
I noticed a talk about cellSet in:
http://www.cfd-online.com/OpenFOAM_D...tml?1131637441
http://www.cfd-online.com/OpenFOAM_D...es/1/1240.html

Can any one explain or give example of how to use cellSet to solve this problem or even what is cellSet? sorry I'm a beginner. Thanks.

Regards,
Maka
maka is offline   Reply With Quote

Old   November 16, 2005, 05:28
Default Look at e.g. interFoam/system/
  #7
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Look at e.g. interFoam/system/setFieldsDict.

It uses the 'boxToCell' source. Instead you can use say the 'cellToCell' source which allows you to use a cellSet. (b.t.w. these sources are exactly the same one cellSet uses)

Mistype it and run setFields to see all the possible sources.
mattijs is offline   Reply With Quote

Old   November 16, 2005, 11:36
Default in boxToCell, we have ďťżdef
  #8
Member
 
VVqf
Join Date: Mar 2009
Location: Braunschweig
Posts: 66
Rep Power: 17
vvqf is on a distinguished road
in boxToCell, we have
ďťżdefaultFieldValues
(
volScalarFieldValue alpha 1
);

regions
(
boxToCell
{
box (0.4 0 0) (1 1 0.1);

fieldValues
(
volScalarFieldValue alpha 0.1
);
}

What about cellToCell, how to write this?
I looked into the source codes cellToCell.H/C, but didn't find answer.
vvqf is offline   Reply With Quote

Old   November 17, 2005, 06:05
Default to e.g. read cellSet c0 replac
  #9
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
to e.g. read cellSet c0 replace the

boxToCell
{
box (..)(..)

fieldValues ...
}

with:


cellToCell
{
set "c0";

fieldValues ...
}


(or maybe lose the quotes around c0)
Also look at the sample cellSetDict in the cellSet utility.
mattijs is offline   Reply With Quote

Old   January 4, 2006, 07:39
Default Hi Mattijis How to read in
  #10
Member
 
Nico Petry
Join Date: Mar 2009
Posts: 36
Rep Power: 17
nico is on a distinguished road
Hi Mattijis

How to read in a file containig a list of cells, for example /constant/polyMesh/sets/fluid.1 ?


The file looks like:

/*---------------------------------------------------------------------------*
FoamFile
{
version 2.0;
format ascii;

root "OpenFOAM/nico-1.2/run/tutorials/simpleFoam";
case "test01";
instance ""constant"";
local "polyMesh/sets";

class cellSet;
object fluid.4;
}

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


240
(
50
51
52
53
.
.
279
280
)

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

Thanks and a happy new year
nico is offline   Reply With Quote

Old   January 13, 2006, 05:04
Default As an example for reading a ce
  #11
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
As an example for reading a cellSet and manipulating data in these cells you can use this:

http://openfoamwiki.net/index.php/Contrib_setfiel dbycellset
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   March 20, 2006, 12:29
Default Hello, I would like to spec
  #12
Member
 
Mélanie Piellard
Join Date: Mar 2009
Posts: 86
Rep Power: 17
melanie is on a distinguished road
Hello,

I would like to specify non uniform initial conditions for my case, with respect to the coordinates of the nodes.
Exemple: the velocity field is defined such as
r = x^2 + y^2
U[x] = y * a/ r^2
U[y] = -x * b/ r^2

How would you write it ? Firstly, I don't know how to access to the nodes coordinates which is blocking me...

Thanks.
melanie is offline   Reply With Quote

Old   March 21, 2006, 05:09
Default Look at the setGammaDambreak a
  #13
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Look at the setGammaDambreak app from OpenFOAM1.1. Or look on this site for setGammaField. It should contain how to access coordinates.
mattijs is offline   Reply With Quote

Old   March 21, 2006, 05:54
Default Mattijs, I looked at the DamB
  #14
Member
 
Mélanie Piellard
Join Date: Mar 2009
Posts: 86
Rep Power: 17
melanie is on a distinguished road
Mattijs,
I looked at the DamBreak case, but the velocity field is set thanks to a bounding box, so this is a different case.
Here I report what I have already written, with the error message at compilation:

#include "fvCFD.H"
#include "physicalConstants.H"

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

int main(int argc, char *argv[])
{

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

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

scalar pi = physicalConstant::pi;
scalar r_0 = 0.0036;
scalar r_c = r_0*2.0/9.0;
scalar gamma = 4.0 * pi * r_c * 340.0 / 2.0;


forAll(mesh.C(), celli)
{
scalar x = mesh.C()[celli].x;
scalar y = mesh.C()[celli].y;

scalar r_1 = ::pow((x+r_0)*(x+r_0) + y*y ,0.5);
scalar r_2 = ::pow((x-r_0)*(x-r_0) + y*y ,0.5);

scalar V_theta1 = - gamma * r_1/(2.*pi*(r_c*r_c + r_1*r_1));
scalar V_theta2 = - gamma * r_2/(2.*pi*(r_c*r_c + r_2*r_2));

scalar Ux = -y * (V_theta1/r_1 + V_theta2/r_2);
scalar Uy = (x-r_0) * V_theta1/r_1 + (x+r_0) * V_theta2/r_2;
scalar Uz = 0.0;

U[celli] = (Ux Uy Uz);

}

U.write();

Info << "\n end\n";

return(0);
}

--------------------------------------------------
--------------------------------------------------

tzntgq@cfdlem04:~/OpenFOAM/OpenFOAM-1.2.1/applications/utilities/preProcessing/corotVortex> wmake
Making dependency list for source file corotVortex.C

SOURCE_DIR=.
SOURCE=corotVortex.C ; g++ -m64 -DlinuxAMD64 -Wall -W -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -ffast-math -DNoRepository -ftemplate-depth-30 -Wno-deprecated -I/home/tzntgq/OpenFOAM/OpenFOAM-1.2.1/src/cfdTools/compressible -I/home/tzntgq/OpenFOAM/OpenFOAM-1.2.1/src/cfdTools/general/lnInclude -I/home/tzntgq/OpenFOAM/OpenFOAM-1.2.1/src/OpenFOAM/lnInclude -IlnInclude -I. -fPIC -c $SOURCE -o Make/linuxAMD64Gcc4Opt/corotVortex.o
corotVortex.C: In function 'int main(int, char**)':
corotVortex.C:57: error: cannot resolve overloaded function 'x' based on conversion to type 'Foam::scalar'
corotVortex.C:58: error: cannot resolve overloaded function 'y' based on conversion to type 'Foam::scalar'
corotVortex.C:70: error: expected `)' before 'Uy'
corotVortex.C:70: error: no match for 'operator=' in 'U.Foam::GeometricField<foam::vector,>::<anonymous >.Foam::Field<foam::vector>::< anonymous>.Foam::List<foam::vector<foam::scalar> >::<anonymous>.Foam::UList<t>::operator[] [with T = Foam::vector](celli) = Ux'
/home/tzntgq/OpenFOAM/OpenFOAM-1.2.1/src/OpenFOAM/lnInclude/Vector.H:62: note: candidates are: Foam::Vector<foam::scalar>& Foam::Vector<foam::scalar>::operator=(const Foam::Vector<foam::scalar>&)
corotVortex.C:67: warning: unused variable 'Uy'
corotVortex.C:68: warning: unused variable 'Uz'
make: *** [Make/linuxAMD64Gcc4Opt/corotVortex.o] Error 1

At compilation, x and y are not recognized and the vector field U is not understood...
Could anyone give me a hint please ?
achinta likes this.
melanie is offline   Reply With Quote

Old   March 21, 2006, 08:35
Default maybe try forAll(mesh.cells(
  #15
Member
 
Pierre Le Fur
Join Date: Mar 2009
Location: UK
Posts: 60
Rep Power: 17
pierre is on a distinguished road
maybe try
forAll(mesh.cells(), cellsI)
scalar x = mesh.C()[cellI].component(0)
rather than forAll(mesh.C(), celli)...

Pierre
pierre is offline   Reply With Quote

Old   March 21, 2006, 09:26
Default Thank you Pierre, it worked fo
  #16
Member
 
Mélanie Piellard
Join Date: Mar 2009
Posts: 86
Rep Power: 17
melanie is on a distinguished road
Thank you Pierre, it worked for x and y with actually
forAll(mesh.cells(),cellI)
scalar x = mesh.C()[cellI].component(0).

Now I still have a problem with the velocity; I have defined Ux, Uy and Uz, and the line
U[cellI] = (Ux, Uy, Uz);
gives me the error message

corotVortex.C:71: warning: left-hand operand of comma has no effect
corotVortex.C:71: warning: right-hand operand of comma has no effect
corotVortex.C:71: error: no match for 'operator=' in 'U.Foam::GeometricField<foam::vector,>::<anonymous >.Foam::Field<foam::vector>::< anonymous>.Foam::List<foam::vector<foam::scalar> >::<anonymous>.Foam::UList<t>::operator[] [with T = Foam::vector](cellI) = (((void)Ux, (void)Uy), Uz)'
/home/tzntgq/OpenFOAM/OpenFOAM-1.2.1/src/OpenFOAM/lnInclude/Vector.H:62: note: candidates are: Foam::Vector<foam::scalar>& Foam::Vector<foam::scalar>::operator=(const Foam::Vector<foam::scalar>&)
melanie is offline   Reply With Quote

Old   March 21, 2006, 09:55
Default try U = vector(Ux, Uy, Uz);
  #17
Member
 
Pierre Le Fur
Join Date: Mar 2009
Location: UK
Posts: 60
Rep Power: 17
pierre is on a distinguished road
try
U[cellI] = vector(Ux, Uy, Uz);

Pierre
pierre is offline   Reply With Quote

Old   March 21, 2006, 10:54
Default thank you Pierre, now everythi
  #18
Member
 
Mélanie Piellard
Join Date: Mar 2009
Posts: 86
Rep Power: 17
melanie is on a distinguished road
thank you Pierre, now everything is working well !
mélanie
melanie is offline   Reply With Quote

Old   March 26, 2006, 18:21
Default Inspired by this thread (and b
  #19
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Inspired by this thread (and because I wanted such a thing for myself for some time) I decided to visit two friends of the time of my diploma thesis (the compiler generators bison and flex) and write a utility that can set fields using complex expressions (from the command line or with a dictionary). A first version is available at

http://openfoamwiki.net/index.php/Contrib_funkySe tFields

For instance the velocity field Melanie specified on the 20th:

r = x^2 + y^2
U[x] = y * a/ r^2
U[y] = -x * b/ r^2

could be set with the utility with the call (assuming a and b to be 1 and 2):

funkySetFields . theCase -field U -expression 'vector(pos().y*1/pow(mag(pos()),4),-pos().x*2/pow(mag(pos()),4),0)' -time 0

Another example would be setting the initial condition for the damBreak-tutorial:

funkySetFields . damBreak -time 0 -field gamma -expression " pos().x <= 0.1461 && pos().y <= 0.292 ? 1 : 0"

or (if you don't want to overwrite the whole gamma field):

funkySetFields . damBreak -time 0 -field gamma -expression 1 -condition "pos().x <= 0.1461 && pos().y <= 0.292"
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   March 28, 2006, 06:54
Default Hi, can someone please expl
  #20
Member
 
Anja Stretz
Join Date: Mar 2009
Posts: 92
Rep Power: 17
anja is on a distinguished road
Hi,

can someone please explain me, what the following line defines

forAll(mesh.cells(),cellI)
scalar x = mesh.C()[cellI].component(0)

Thanks
Anja
anja 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
Specifying nonuniform boundary condition maka OpenFOAM Running, Solving & CFD 59 October 22, 2014 15:52
Nonuniform initial condition using cellSetDict rinao OpenFOAM Running, Solving & CFD 6 January 9, 2013 01:42
Initial Condition Tang Kuei FLUENT 0 May 17, 2006 20:54
Nonuniform gradient boundary condition ankgupta8um OpenFOAM Running, Solving & CFD 1 March 14, 2006 02:34
Nonuniform initial conditions nico OpenFOAM Pre-Processing 2 January 4, 2006 07:37


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