CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Specifying nonuniform initial condition (https://www.cfd-online.com/Forums/openfoam-solving/58077-specifying-nonuniform-initial-condition.html)

gschaider March 28, 2006 06:19

C() is described in Table 2.1
 
C() is described in Table 2.1 of the Programmer's guide. component() accesses components of a tensor/vector.

anja March 28, 2006 06:56

so then why is it component(0
 
so then why is it component(0 ?! )

gschaider March 28, 2006 07:15

Because C++ (==Foam) starts to
 
Because C++ (==Foam) starts to count with 0 (as opposed to Fortran which starts with 1). Therefor the first component (== x-coordinate) is accessed with the index 0.

hjasak March 28, 2006 07:37

OK, let's do chapter and verse
 
OK, let's do chapter and verse on this:

1) OpenFOAM field class is called GeometricField and it can contain scalars, vectors, tensors etc. These things are defined as surfaceScalarField, volVectorField, pointScalarField, volTensorField etc.

2) For some of those fiels it makes sense to ask for a component. So, if I've got a volVectorField, I could ask for the x() component (this is a sensible and meaningful operation), whereas for the volTensorField I may asn for the xy() component. How do I do that?

Well, since volVectorField is a GeometricField<vector,>, I cannot add the x() member function to it - it would not make sense for scalar or tensor fields, right? Thus, I need a general way to as for a component of a field.

3) The first step is in the definition of scalars, vectors and tensors. Here, I define two things:
- an enumeration for the component. For a vector, this will say X, Y, Z and for a tensor XX, XY, XZ, YX, YY, YZ, etc. Note that enumeration is basically an int wrapped up for use and that the count starts from zero. Thus, in a vector X is 0, Y is 1 etc. and the tensor you can work it out yourself.
- a member function returning a component. Thus, you know what the following bit of the code does:


vector a(1, 2, 3);
a.component(vector::Y);


Now, we can pull through the component function through the fields and GeometricFields. Examples:


vectorField a(10);
// fill it up
scalarField ax = a.component(vector::X);


or


tensorField t(33);
scalarField tyz = t.component(tensor::YZ);


Alll clear, I hope.

Thus:

- mesh.C() returns a volVectorField of cell centres.
- mesh.C()[cellI] gets the cellI element from the internal field (you have jumped into the internal field directly because the GeometricField is derived from the internal field.
- mesh.C()[cellI].component(0) is equivalent to mesh.C()[cellI].component(vector::X), which should be clear.

Note that you can also do:

volScalarField cx = mesh.C().component(vector::X);

or

scalarField cxIn = mesh.C().internalField().component(vector::X);


Better?

Enjoy,

Hrv

anja March 28, 2006 07:50

Thanks a lot
 
Thanks a lot

anne May 22, 2006 12:24

Hello, I would like to read
 
Hello,

I would like to read the velocity
field U obtained as an output in time directory.

My mesh is made of several blocks.
when using one block I had no problem to read
the file through the loop:

do k=1,nz
do j=1,ny
do i=1,nx
...
where nx ,ny and nx were the total number of cell.

However, now using several blocks in the
0x, 0y and 0z directions I can not
read correctely the file.
(Looking at the file with ParaFoam all
is OK, so that the file is OK).

Could you let me know the writing format of the
output file when uing several blocks?
Is this a writing block by block?

Thanks,

Anne

msrinath80 May 27, 2007 04:08

Can someone verify if I'm doin
 
Can someone verify if I'm doing this right using funkySetFields. I wish to create a sphere of radius 0.5 in the center of the 3D geometry. The syntax I'm using is:

funkySetFields . cavity -field gamma -expression '(grad(dist())^vector(0,0,0))*mag(pos()-vector(0.5,0.5,0.5))/0.5' -time 0

If this is incorrect, I would appreciate if someone can help. Thanks!

gschaider May 29, 2007 07:15

Hi! I would suggest funk
 
Hi!

I would suggest

funkySetFields . cavity -field gamma -condition "mag(pos()-vector(0.5,0.5,0.5))<0.5" -expression "1." -time 0 -keepPatches

assuming that (0.5,0.5,0.5) is the center of your geometry and gamma originally was set to "uniform 0"
Whatever the other stuff in your example does it is going to become zero because of the product with vector(0,0,0).

Bernhard

hjasak May 29, 2007 07:51

Only one word for you Bernhard
 
Only one word for you Bernhard: BEAUTIFUL!

Hrv

msrinath80 May 29, 2007 13:53

Thanks Bernhard. That was very
 
Thanks Bernhard. That was very useful http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

msrinath80 June 15, 2007 13:20

Hi Bernhard, funkySetFields
 
Hi Bernhard,

funkySetFields[1] compiles and runs as intended on OF 1.3. However, OF 1.4 does not like it. Can you post the API modifications required for it to work on OF 1.4.

Thanks!

[1] http://openfoamwiki.net/images/7/79/...s.r7241.tar.gz

7islands June 17, 2007 04:00

Hi, One might be able to try
 
Hi,
One might be able to try this patch (with some modifications for my own purpose) until Bernhard makes a new release (I believe it won't be so long anyway) for OF 1.4. This contains
* harsh fix for building problem and SIGFPE crash by constant scalar division on OF 1.4
* deltaT(): returns the value of deltaT in controlDict
* rdist(x, y, z): equivalent of mag(pos() - vec(x,y,z)) where x, y, z are scalars

Takuya

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif funkySetFields.r7241-20070528.diff

msrinath80 June 17, 2007 05:14

Thanks Takuya. It compiled nic
 
Thanks Takuya. It compiled nicely!

Here are the quick instructions for those new to patching:

1. First patch the file using patch -p0 < funkySetFields.r7241-20070528.diff

2. Copy all files from the GeneratedFiles subdirectory to the current directory (i.e. directory which contains funkySetFields.C).

3. Execute wmake in the same directory.

gschaider June 20, 2007 09:23

Hi! Thanks to Takuya for hi
 
Hi!

Thanks to Takuya for his fixes. I've incorporated these into my sources (which are now updated to 1.4, plus they sould be less restrictive in their choice of a bison-version). I've also added a time()-function (don't need it, but the deltaT was there, so it seemed logical)


Description and download link:

http://openfoamwiki.net/index.php/Co...funkySetFields

http://openfoamwiki.net/images/7/79/...s.r7241.tar.gz

Bernhard

gschaider June 20, 2007 12:12

Ignor the link for the downloa
 
Ignor the link for the download in the last posting. It should have been
http://openfoamwiki.net/images/f/fe/...s.r7568.tar.gz

markdowlinguk July 27, 2007 12:31

Can somebody tell me how to ex
 
Can somebody tell me how to extract and compile the funkySetFields .gz file and which directory in which to place the files ?

Apologies for the stupid question - but I'm completely new to linux.

Thanks
Mark

qtian July 29, 2007 14:55

Hello, I am using funkySetFiel
 
Hello, I am using funkySetFields to set my non uniform inflow boundary

Here is the command I used for epsilon,

funkySetFields . nufbump -time 0 -field epsilon -keepPatches -valuePatches 'inlet' -expression '0.4983*pow(pos().y,-1.209)'

Here is the error message I got,

#0 Foam::error::printStack(Foam:http://www.cfd-online.com/OpenFOAM_D...part/proud.gifstream&)
#1 Foam::sigFpe::sigFpeHandler(int)
#2 Uninterpreted: [0xffffe420]
#3 pow
#4 Foam::pow(Foam::Field<double>&, Foam::UList<double> const&, double const&)
#5 Foam::tmp<foam::geometricfield<double,> > Foam::pow<foam::fvpatchfield,>(Foam::GeometricFiel d<double,> const&, Foam::dimensioned<double> const&)
#6 Foam::tmp<foam::geometricfield<double,> > Foam::pow<foam::fvpatchfield,>(Foam::GeometricFiel d<double,> const&, double const&)
#7 .L25229 at ValueExpressionParser.C:0
#8 ValueExpressionDriver::parse(std::string const&)
#9 doAnExpression(Foam::fvMesh const&, Foam::word const&, Foam::string const&, Foam::string const&, Foam::Time const&, bool, bool, Foam::dimensionSet const&, bool, Foam::List<foam::word> const&)
#10 main
#11 __libc_start_main
#12 Foam::regIOobject::readIfModified()
Floating point exception (core dumped)

I also found out if I change -1.209 to 1, error message disappear. I guess this might be the format problem for pow(,),but I really don't know how to make it work. Sorry about the silly question. Can anyone give me some help? Thanks for your help.

Best
QT

msrinath80 July 29, 2007 18:09

Apologies for the delay. Here
 
Apologies for the delay. Here you go Mark:

[madhavan@head01 ~]$ cd OpenFOAM/madhavan-1.4/

[madhavan@head01 madhavan-1.4]$ ls
applications custom_utils lib run

[madhavan@head01 madhavan-1.4]$ cd custom_utils/

[madhavan@head01 custom_utils]$ cd Bernhard_Gschaider/

[madhavan@head01 Bernhard_Gschaider]$ ls
parabolic_velocity_inlet

[madhavan@head01 Bernhard_Gschaider]$ mkdir funkySetFields

[madhavan@head01 Bernhard_Gschaider]$ cd funkySetFields/

[madhavan@head01 funkySetFields]$ wget http://openfoamwiki.net/images/f/fe/...s.r7568.tar.gz
--15:59:40-- http://openfoamwiki.net/images/f/fe/...s.r7568.tar.gz
=> `FunkySetFields.r7568.tar.gz'
Resolving openfoamwiki.net... 193.171.80.115
Connecting to openfoamwiki.net|193.171.80.115|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 48,785 (48K) [application/x-tar]

100%[================================================== ===>] 48,785 102.10K/s

15:59:41 (101.89 KB/s) - `FunkySetFields.r7568.tar.gz' saved [48785/48785]

[madhavan@head01 funkySetFields]$ ls
FunkySetFields.r7568.tar.gz

[madhavan@head01 funkySetFields]$ tar xzf FunkySetFields.r7568.tar.gz

[madhavan@head01 funkySetFields]$ cd funkySetFields.r7568/

[madhavan@head01 funkySetFields.r7568]$ ls
GeneratedFiles ValueExpressionDriverLogicalTemplates.H funkySetFieldsDict
Make ValueExpressionLexer.ll getGenerated.sh
ValueExpressionDriver.C ValueExpressionParser.yy insertGenerated.sh
ValueExpressionDriver.H funkySetFields.C

[madhavan@head01 funkySetFields.r7568]$ cp -r GeneratedFiles/* .

[madhavan@head01 funkySetFields.r7568]$ wmake
Making dependency list for source file ValueExpressionParser.C
Making dependency list for source file ValueExpressionLexer.C
Making dependency list for source file funkySetFields.C
SOURCE=ValueExpressionParser.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -IMake/linux64Gcc4DPOpt -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/finiteVolume/lnInclude -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/meshTools/lnInclude -IlnInclude -I. -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc4DPOpt/ValueExpressionParser.o
ValueExpressionParser.tab.cc: In member function 'unsigned char ve::ValueExpressionParser::yytranslate_(int)':
ValueExpressionParser.tab.cc:1814: warning: use of old-style cast
SOURCE=ValueExpressionLexer.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -IMake/linux64Gcc4DPOpt -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/finiteVolume/lnInclude -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/meshTools/lnInclude -IlnInclude -I. -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc4DPOpt/ValueExpressionLexer.o
ValueExpressionLexer.C:245: warning: use of old-style cast
ValueExpressionLexer.C:296: warning: use of old-style cast
ValueExpressionLexer.C:296: warning: use of old-style cast
lex.ve.c: In function 'int velex(ve::ValueExpressionParser::semantic_type*, ve::location*, ValueExpressionDriver&)':
lex.ve.c:3894: warning: use of old-style cast
lex.ve.c:3894: warning: use of old-style cast
lex.ve.c:3910: warning: use of old-style cast
lex.ve.c:4229: warning: use of old-style cast
lex.ve.c: In function 'int yy_get_next_buffer()':
lex.ve.c:4397: warning: use of old-style cast
lex.ve.c:4424: warning: use of old-style cast
lex.ve.c:4437: warning: use of old-style cast
lex.ve.c:4438: warning: use of old-style cast
lex.ve.c:4459: warning: use of old-style cast
lex.ve.c: In function 'yy_state_type yy_get_previous_state()':
lex.ve.c:4507: warning: use of old-style cast
lex.ve.c:4507: warning: use of old-style cast
lex.ve.c: In function 'int yyinput()':
lex.ve.c:4664: warning: use of old-style cast
lex.ve.c: In function 'yy_buffer_state* ve_create_buffer(FILE*, int)':
lex.ve.c:4741: warning: use of old-style cast
lex.ve.c:4750: warning: use of old-style cast
lex.ve.c: In function 'void ve_delete_buffer(yy_buffer_state*)':
lex.ve.c:4773: warning: use of old-style cast
lex.ve.c:4776: warning: use of old-style cast
lex.ve.c:4778: warning: use of old-style cast
lex.ve.c: In function 'yy_buffer_state* ve_scan_buffer(char*, yy_size_t)':
lex.ve.c:4857: warning: use of old-style cast
lex.ve.c: In function 'yy_buffer_state* ve_scan_bytes(const char*, int)':
lex.ve.c:4911: warning: use of old-style cast
lex.ve.c: In function 'void yy_push_state(int)':
lex.ve.c:4950: warning: use of old-style cast
lex.ve.c:4954: warning: use of old-style cast
lex.ve.c:4954: warning: use of old-style cast
lex.ve.c: In function 'void* yy_flex_alloc(yy_size_t)':
lex.ve.c:5061: warning: use of old-style cast
lex.ve.c: In function 'void* yy_flex_realloc(void*, yy_size_t)':
lex.ve.c:5079: warning: use of old-style cast
lex.ve.c:5079: warning: use of old-style cast
lex.ve.c: At global scope:
lex.ve.c:4936: warning: 'void yy_push_state(int)' defined but not used
lex.ve.c:4969: warning: 'void yy_pop_state()' defined but not used
lex.ve.c:4980: warning: 'int yy_top_state()' defined but not used
SOURCE=ValueExpressionDriver.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -IMake/linux64Gcc4DPOpt -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/finiteVolume/lnInclude -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/meshTools/lnInclude -IlnInclude -I. -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc4DPOpt/ValueExpressionDriver.o
SOURCE=funkySetFields.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -IMake/linux64Gcc4DPOpt -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/finiteVolume/lnInclude -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/meshTools/lnInclude -IlnInclude -I. -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc4DPOpt/funkySetFields.o
g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -IMake/linux64Gcc4DPOpt -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/finiteVolume/lnInclude -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/meshTools/lnInclude -IlnInclude -I. -I/homes/madhavan/OpenFOAM/OpenFOAM-1.4/src/OpenFOAM/lnInclude -fPIC Make/linux64Gcc4DPOpt/ValueExpressionParser.o Make/linux64Gcc4DPOpt/ValueExpressionLexer.o Make/linux64Gcc4DPOpt/ValueExpressionDriver.o Make/linux64Gcc4DPOpt/funkySetFields.o -L/homes/madhavan/OpenFOAM/OpenFOAM-1.4/lib/linux64Gcc4DPOpt \
-lfiniteVolume -lmeshTools -lOpenFOAM -liberty -ldl -lm -o /homes/madhavan/OpenFOAM/madhavan-1.4/applications/bin/linux64Gcc4DPOpt/funkySet Fields
[madhavan@head01 funkySetFields.r7568]$

PS: The first half of the instructions are not mandatory. I keep all custom utilities organized in folders. You can do the same or else put them somewhere you find convenient. On a side-note, you can survive longer in the OpenFOAM world without knowing C++, but you certainly will not if you are not familiar with the terminal/command line. My advice is to try and get familiar with it as soon as you can.

qtian July 29, 2007 20:23

Srinath or anyone, Is it po
 
Srinath or anyone,

Is it possible for you to answer my above question also? I am really stuck. Thanks.

Quinn

markdowlinguk July 31, 2007 10:25

Srinath, Huge thanks for th
 
Srinath,

Huge thanks for the very clear instructions...
It turns out I was doing something similar, but my lack of linux experience (which I'm having to rapidly overcome) made me wonder if I'd done something wrong...

Either way - when following your instructions about the program fails to compile with the following error (NB I used the insertGenerated.sh command because I have an earlier version of bison)

[PTS@tcad funkySetFields.r7568]$ . insertGenerated.sh
Preparing run to avoid usage of bison
[PTS@tcad funkySetFields.r7568]$ wmake
Making dependency list for source file ValueExpressionParser.C
Making dependency list for source file ValueExpressionLexer.C
Making dependency list for source file funkySetFields.C
Making dependency list for source file ValueExpressionDriver.C
SOURCE=ValueExpressionParser.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -IMake/linuxGcc4DPOpt -I/home/PTS/OpenFOAM/OpenFOAM-1.4/src/finiteVolume/lnInclude -I/home/PTS/OpenFOAM/OpenFOAM-1.4/src/meshTools/lnInclude -IlnInclude -I. -I/home/PTS/OpenFOAM/OpenFOAM-1.4/src/OpenFOAM/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGcc4DPOpt/ValueExpressionParser.o
ValueExpressionParser.tab.cc: In member function 'unsigned char ve::ValueExpressionParser::yytranslate_(int)':
ValueExpressionParser.tab.cc:1814: warning: use of old-style cast
/tmp/ccvmLazQ.s: Assembler messages:
/tmp/ccvmLazQ.s:13: Internal error, aborting at ../../gas/config/tc-i386.c line 3501 in output_imm
Please report this bug.
make: *** [Make/linuxGcc4DPOpt/ValueExpressionParser.o] Error 1


Any ideas??

Many thanks again - in the couple of times I have used it I am struck by how rapid and helpful the responses are from the OpenFoam forum - so huge thanks to everybody for that!

Mark


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