CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Collection of simple functionObjects (https://www.cfd-online.com/Forums/openfoam/60812-collection-simple-functionobjects.html)

gschaider April 21, 2008 13:12

OpenFOAM has this cool feature
 
OpenFOAM has this cool feature named functionObjects of which the only incarnation I've seen so far is the probesFunctionObject. functionObject enables the user to "add" code to the solver at runtime (without recompiling it) that is executed at every time-step.

I have published a collection of such function objects on
http://openfoamwiki.net/index.php/Co...unctionObjects
that do simple evaluations that are sometimes useful like averages, integrals, forces, mass-flows on patches and/or volumes.

The actual library can be downloaded via subversion:
svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breede r/libraries/simpleFunctionObjects/

If anyone has
* ideas for extensions (a liftDrag-FunctionObject comes to mind)
* bugfixes/stylistic suggestions (and there are bound to be some)
she/he is welcome to contribute these via the technical wonder that is called subversion (you'll just need write access to the svn)

Bernhard

alberto April 21, 2008 23:50

This looks interesting. Tha
 
This looks interesting.

Thanks!

hannes April 22, 2008 04:57

Hello, Maybe this is also o
 
Hello,

Maybe this is also of interest for someone: I have wrapped the code of the sampleSurface tool into a function object.
Together with an additional writer for the PlotMTV-Format (PlotMTV is a very lightweight contour plot program), this makes it possible to get insight into the fields without always copying files and loading the whole case into Paraview. I find this especially useful for large, parallelized cases (no reconstruction is needed, this is done for the sample planes on the fly).

The code is in our SVN-repository: https://janus.fms.uni-rostock.de/svn/repository/OpenFOAM/trunk/LTTRostockExtensi ons

Username is "gast" with blank password.

Best regards, Hannes

olesen April 22, 2008 05:25

Hannes, Does plotmtv requir
 
Hannes,

Does plotmtv require regular distances between data points, or does it perform its own kriging?

/mark

hannes April 22, 2008 06:59

Hi Mark, PlotMTV can interp
 
Hi Mark,

PlotMTV can interpolate in unstructured triangulated surfaces. The data is written out that way. But it is limited to planar surfaces and the writer currently only supports "interpolatedPlane"s

Hannes

gschaider April 22, 2008 18:23

Hi Hannes! That is really a
 
Hi Hannes!

That is really a nice one. But is my impression correct that currently each time it writes out the sampled surfaces for one timestep all the previous outputs get erased? I had to comment out the lines in the sampleSurfaceProbesFunctionObject::execute()-method that erased sampleSurfaces-directory in order to get time-series

Bernhard

hannes April 23, 2008 06:43

Hi Bernhard, yes, you are r
 
Hi Bernhard,

yes, you are right. Initially, I also used it without deleting the directories. But since I usually write out samples pretty often and do not want to end up with lots of data garbage, I put it in again.

I have inserted a switch for that right now ("deleteOutputDirectory") , which defaults to "yes"

Hannes

gschaider April 23, 2008 07:29

Hi Hannes! Cool. I know thi
 
Hi Hannes!

Cool. I know this is becoming annoying BUT:

1. I think the setting outputInterval should be called outputInterleave because setting it to 1 outputs every second timeStep. Setting it to 0 switches the output of (this is obviously intended). So it is not possible to output every timestep. Initializing the timeSteps_ variable to 1 instead of 0 (I think in 3 places in the code) would give the behaviour I would expect
2. If deleteOutputDirectory==No removing the directory in the start-method would give a behaviour that is semantically similar to what the original probes does
3. I know this is asking much: would it be possible to factor this thing out into a separate library? Right now I've got to edit Make/options and Make/files to get it to compile (the chemistry-stuff). And while you're at it: would you consider putting it on openfoam-extend (just this sampleSurface-stuff)?

Bernhard

hannes April 24, 2008 03:08

Hi Bernhard, Please feel fr
 
Hi Bernhard,

Please feel free to improve the code as you want.
I would add that stuff e.g. to the "simpleFunctionObjects" library and remove it from our lib. But I guess I need write access to the sourceforge repository to do so (my sourceforge username is "hanneskroeger").

Hannes

gschaider April 24, 2008 04:36

Hi Hannes! Great. I added y
 
Hi Hannes!

Great. I added you to the users with svn write access and prepared a directory "sampling". Just put your stuff there (in such a way that if someone else feels like adding a sample-functionObject, it can live in parallel to your stuff) and add yourself as a contributor to the README-file.

Just one question? Did you have to do any changes to the original sampleSurface-stuff you're using? If not, it should be possible to modify the Make/files to

sampleSurface=$(FOAM_UTILITIES)/postProcessing/miscellaneous/sampleSurface
$(sampleSurface)/surfaces/surface/surface.C
.....

thus pulling in the original stuff (and not adding it to the repository) and only add the new stuff (the MTV-writer) from that hierarchy

Bernhard

hannes April 24, 2008 06:21

Hi Bernhard, I have done as
 
Hi Bernhard,

I have done as you suggested and added all the sampleSurface-stuff to Make/files at their original location.

Unfortunately, there might be problems due to the *.dep files in $(FOAM_UTILITIES)/postProcessing/miscellaneous/sampleSurface. After compilation of the sampleSurface utility, they contain relative paths.

So you might consider doing a "wclean" in $(FOAM_UTILITIES)/postProcessing/miscellaneous/sampleSurface
to delete all *.dep files first, before building the library. After building the library, the *.dep files contain absolute paths.

Hannes

gschaider April 25, 2008 10:01

Hi Hannes! I noticed so, to
 
Hi Hannes!

I noticed so, too. It's especially inconvenient for people who don't have write-rights on their OF-installation. I'll think of a fix

Bernhard

gschaider May 26, 2008 16:43

Hi Hannes! I "fixed" the pr
 
Hi Hannes!

I "fixed" the problem with the external dependencies some time ago (maybe you noticed in the SVN), but forgot to mention it here: the fix consists of a script that copies the external dependencies to the compilation directory (it is described in the README)

Bernhard

PS: the real reason why I'm writing here is that I added a new functionObject (panicDump) to the library and wanted to advertise it. It checks whether the values in a field are inside certain bounds and if they are outside writes all fields to disk and exits. The purpose of this FO is to gracefully stop simulations that are obviously going to explode while the fields still might be useful for post-mortem analysis (not full of NaNs or 1e43)

juho May 27, 2008 02:54

When I try to compile the simp
 
When I try to compile the simpleFunctionObjects at /utilities/simpleFunctionObjects with

wmake libso

I get the error message

make: *** No rule to make target `externalStuff/surfaces/surface/surface.dep', needed by `Make/linuxGccDPOpt/dependencies'. Stop.

I'm using 1.4.1, GCC 4.2.1 and Binutils 2.18

Could anyone give me guidance on how to get it to compile?

gschaider May 27, 2008 03:50

Hi Juho! Please do the foll
 
Hi Juho!

Please do the following (just to make sure we're starting off the same version). In the directory

- do a "svn update"
- remove externalStuff
- do "wclean" and "rmdepall"

Then set up the externalStuff as described in the README and retry

Bernhard

juho May 27, 2008 04:15

Oh, there's a README... Com
 
Oh, there's a README...

Compiled without complaints!

Thank you for the help and sorry for the stupid question!

juho May 29, 2008 02:22

Could you point me in a direct
 
Could you point me in a direction for modifying the output of patchFieldFlow in a way that it could be used as an input for timeVaryingUniformFixedValue boundary condition?

Only thing the output would need is brackets around the values. ie.

(
1 0
2 1
3 1
4 10
5 1
)

juho May 29, 2008 03:07

The first bracket was easy, ju
 
The first bracket was easy, just added it to timelineFunctionObject.C

prapanj April 2, 2009 02:00

compilation error
 
Hi Bernhard,

Thank you for this cool tool.

I have OF 1.5. When I tried to compile using wmake libso, I got a compilation error.

Let me paste the last few lines of the compilation output:

SOURCE=trackDictionary/trackDictionaryFunctionObject.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/meshTools/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/sampling/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/triSurface/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/lagrangian/basic/lnInclude -IlnInclude -I. -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/trackDictionaryFunctionObject.o
trackDictionary/trackDictionaryFunctionObject.C: In member function ‘void Foam::trackDictionaryFunctionObject::echoSwitchesV alues()’:
trackDictionary/trackDictionaryFunctionObject.C:201: error: ‘tolerances’ is not a member of ‘Foam::debug’
make: *** [Make/linuxGccDPOpt/trackDictionaryFunctionObject.o] Error 1



And then compilation exits. I am not able to use the functions after this. Is that a bug or am I doing something wrong here?

Thank you

Prapanj.

mbeaudoin April 2, 2009 08:29

My mistake,

I published a new functionObject this week on openfoam-extend, and this code was developed for 1.5-dev.

The "tolerances" switches are available only under the dev version of OpenFOAM.

I will fix this shortly.

Martin

Quote:

Originally Posted by prapanj (Post 211671)
Hi Bernhard,

Thank you for this cool tool.

I have OF 1.5. When I tried to compile using wmake libso, I got a compilation error.

Let me paste the last few lines of the compilation output:

SOURCE=trackDictionary/trackDictionaryFunctionObject.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/meshTools/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/sampling/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/triSurface/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/lagrangian/basic/lnInclude -IlnInclude -I. -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/rwdi-india/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/trackDictionaryFunctionObject.o
trackDictionary/trackDictionaryFunctionObject.C: In member function ‘void Foam::trackDictionaryFunctionObject::echoSwitchesV alues()’:
trackDictionary/trackDictionaryFunctionObject.C:201: error: ‘tolerances’ is not a member of ‘Foam::debug’
make: *** [Make/linuxGccDPOpt/trackDictionaryFunctionObject.o] Error 1



And then compilation exits. I am not able to use the functions after this. Is that a bug or am I doing something wrong here?

Thank you

Prapanj.



All times are GMT -4. The time now is 05:13.