Difference between revisions of "Contrib/simpleFunctionObjects"

From OpenFOAMWiki
m (Added to the Function Objects category)
m (Remov link to version that is no longer working)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{VersionInfo}}{{Version1.4.1}}{{Version1.5}}{{Version1.6}}
+
{{VersionInfo}}{{Version1.4.1}}{{Version1.5}}{{Version1.6}}{{Version1.7}}
  
 
== Description ==
 
== Description ==
  
 
Starting with Version 1.4 OpenFOAM has the facility of <tt>functionObject</tt>s. These are basically small pieces of code that are being executed at every time-step without explizitly being linked to the application. They are activated by the <tt>functions</tt>-list in the <tt>controlDict</tt> of the case.
 
Starting with Version 1.4 OpenFOAM has the facility of <tt>functionObject</tt>s. These are basically small pieces of code that are being executed at every time-step without explizitly being linked to the application. They are activated by the <tt>functions</tt>-list in the <tt>controlDict</tt> of the case.
 +
 +
'''Note:''' This library will be integrated into [[Contrib/swak4Foam|swak4Foam]] starting with OF 2.0. The library is still compilable independently of the other parts of swak
  
 
=== Invitation for contributions ===
 
=== Invitation for contributions ===
Line 56: Line 58:
 
;fields: The fields for which this calculation is done
 
;fields: The fields for which this calculation is done
 
;patches: The patches on which this calculation is done
 
;patches: The patches on which this calculation is done
 +
 +
You can also use this in post-processing with the <tt>[[ExecFlowFunctionObjects]]</tt> tool. Add this to <tt>controlDict</tt>:
 +
<cpp>
 +
functions
 +
(
 +
  massFlow
 +
  {
 +
      type patchMassFlow;
 +
      functionObjectLibs
 +
        (
 +
          "libsimpleFunctionObjects.so"
 +
        );
 +
      verbose true;
 +
      patches
 +
        (
 +
          inlet
 +
          outlet
 +
        );
 +
      factor 19.7363;
 +
      outputControl timeStep;
 +
      outputInterval 1;
 +
  }
 +
);
 +
</cpp>
 +
Then call <tt>execFlowFunctionObjects -noFlow</tt> {{VersionInfo}}{{Version2.2}}
  
 
=== Available types ===
 
=== Available types ===
Line 73: Line 100:
 
* misc
 
* misc
 
** panicDump: Dumps all available data if a field exceeds certain bounds ans finishes the simulation
 
** panicDump: Dumps all available data if a field exceeds certain bounds ans finishes the simulation
 +
** trackDictionary: Write the contents of selected dictionaries as they change. [http://openfoam-extend.svn.sourceforge.net/viewvc/openfoam-extend/trunk/Breeder_1.6/libraries/simpleFunctionObjects/trackDictionary/README.trackDictionary?revision=1891&view=markup Detailed documentation]
 
* sample
 
* sample
 
** sampleSurface (has been removed for the {{Version1.5}}-version because a similar facility is included with the release)
 
** sampleSurface (has been removed for the {{Version1.5}}-version because a similar facility is included with the release)
Line 83: Line 111:
 
=== OpenFOAM 1.4.1 ===
 
=== OpenFOAM 1.4.1 ===
 
The library is available by subversion
 
The library is available by subversion
  svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder/libraries/simpleFunctionObjects/
+
  svn checkout svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder/libraries/simpleFunctionObjects/
 
This is the latest (possibly unstable/broken) version. The initial (hopefully stable) version is available with
 
This is the latest (possibly unstable/broken) version. The initial (hopefully stable) version is available with
  svn checkout -r 595 https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder/libraries/simpleFunctionObjects/
+
  svn checkout -r 595 svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder/libraries/simpleFunctionObjects/
  
 
=== OpenFOAM 1.5 ===
 
=== OpenFOAM 1.5 ===
 
This version is available at  
 
This version is available at  
  svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/libraries/simpleFunctionObjects
+
  svn checkout svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.5/libraries/simpleFunctionObjects
  
 
=== OpenFOAM 1.6 ===
 
=== OpenFOAM 1.6 ===
 
This version is available at  
 
This version is available at  
  svn checkout https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.6/libraries/simpleFunctionObjects
+
  svn checkout svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.6/libraries/simpleFunctionObjects
 +
It also works with 1.7
 +
 
 +
=== OpenFOAM 2.0 ===
 +
Starting with this version of OF is a part of [[Contrib/swak4Foam|swak4Foam]].
  
 
--[[User:Bgschaid|Bgschaid]] 18:25, 21 April 2008 (CEST)
 
--[[User:Bgschaid|Bgschaid]] 18:25, 21 April 2008 (CEST)
  
 
[[Category:Function Objects]]
 
[[Category:Function Objects]]

Latest revision as of 21:00, 3 June 2014

Valid versions: OF version 141.png OF version 15.png OF version 16.png OF version 17.png

1 Description

Starting with Version 1.4 OpenFOAM has the facility of functionObjects. These are basically small pieces of code that are being executed at every time-step without explizitly being linked to the application. They are activated by the functions-list in the controlDict of the case.

Note: This library will be integrated into swak4Foam starting with OF 2.0. The library is still compilable independently of the other parts of swak

1.1 Invitation for contributions

The scope of this library are functionObjects that are

  • simple
  • general enough to be used with more than one solver

Anybody who thinks that a something is missing from the library (a patchLiftDrag-object comes to mind) and feels able to implement it is invited to do so (you just need write access to the OpenFOAM-extend subversion archive)

2 Usage

2.1 Compilation and installation

Just do

wmake libso

in the directory of the sources. The library will be compiled and installed in a place (%FOAM_USER_LIBBIN) where it is usable

2.2 Additions to controlDict

A function object is activated by adding an entry like this to the system/controlDict of a case:

functions 
(
   massFlow
   {
      type patchMassFlow;
     functionObjectLibs
       (
         "libsimpleFunctionObjects.so"
       );
     verbose true;
     patches
       (
         inlet
         outlet
       );
     factor 19.7363;
   }
);

(There can be more than one function objects; each entry just has to be one named dictionary).

The entries pre-defined by the OpenFOAM-functionObject mechanism are

functionObjectLibs
Libraries that have to be loaded in order for this functionObject to work
type
the type of the function object

Standard entries (not all have to be defined) for the functionObjects in this library are

region
The mesh region for multi-mesh simulations (like FSI etc). Usually not used
verbose
The results of the calculations should be printed to the terminal (as well as being written to disk)
after
The function object should only be called after a certain time (if undefined the start of the simulation is used)
factor
A factor with which the results should be multiplied before being written to disk/terminal. Used to account for symmetries etc (not used by all function objects)

Depending on the type of the functionObject in this library these entries are used:

phi
The variable that is to be used as phi for flow calculations (Default: phi)
fields
The fields for which this calculation is done
patches
The patches on which this calculation is done

You can also use this in post-processing with the ExecFlowFunctionObjects tool. Add this to controlDict:

 
functions 
(
   massFlow
   {
       type patchMassFlow;
       functionObjectLibs
         (
           "libsimpleFunctionObjects.so"
         );
       verbose true;
       patches
         (
           inlet
           outlet
         );
       factor 19.7363;
       outputControl timeStep;
       outputInterval 1;
   }
);

Then call execFlowFunctionObjects -noFlow Valid versions: OF Version 22.png

2.3 Available types

Currently the functionObjects in the library fall in two categories (the names should speak for themselves):

  • per-patch calculations:
    • patchAverage; does an area-weighted averaging of a field \overline{\Phi} = \frac{\sum_i \Phi_i A_i}{\sum_i A_i}
    • patchFieldFlow; does a mass-flux-weighted integration of a field \overline{\Phi} = \sum_i \Phi_i \varrho_i (\vec{n}_i \bullet \vec{U}_i) A_i
    • patchForce (has been removed for the OF version 15.png-version because a similar facility is included with the release)
    • patchIntegrate; does an area-weighted integration of a field \overline{\Phi} = \sum_i \Phi_i A_i
    • patchMassFlowAverage (has been included for the OF version 16.png); does a mass-flux-weighted averaging of a field \overline{\Phi} = \frac{\sum_i \Phi_i\varrho_i (\vec{n}_i \bullet \vec{U}_i) A_i}{\sum_i \varrho_i (\vec{n}_i \bullet \vec{U}_i) A_i}
    • patchMassFlow; computes the mass-flux through a patch \dot{m} = \sum_i \varrho_i (\vec{n}_i \bullet \vec{U}_i) A_i
  • total-volume calculations:
    • volumeAverage (has been removed for the OF version 15.png-version because a similar facility is included with the release - and is now being reintroduced because the average-functionObject in OpenFOAM does time-averaging)
    • volumeIntegrate
    • volumeMinMax
  • misc
    • panicDump: Dumps all available data if a field exceeds certain bounds ans finishes the simulation
    • trackDictionary: Write the contents of selected dictionaries as they change. Detailed documentation
  • sample
    • sampleSurface (has been removed for the OF version 15.png-version because a similar facility is included with the release)
  • extended fields writing
    • writeFieldsOften: lets the user specify an additional set of fields that is to be written more frequently than specified in the controlDict
    • writeAdditionalFields: lets the user specify an additional set of fields that is to be written with the other fields; they are written by AUTO_WRITE

3 Download

3.1 OpenFOAM 1.4.1

The library is available by subversion

svn checkout svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder/libraries/simpleFunctionObjects/

This is the latest (possibly unstable/broken) version. The initial (hopefully stable) version is available with

svn checkout -r 595 svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder/libraries/simpleFunctionObjects/

3.2 OpenFOAM 1.5

This version is available at

svn checkout svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.5/libraries/simpleFunctionObjects

3.3 OpenFOAM 1.6

This version is available at

svn checkout svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.6/libraries/simpleFunctionObjects

It also works with 1.7

3.4 OpenFOAM 2.0

Starting with this version of OF is a part of swak4Foam.

--Bgschaid 18:25, 21 April 2008 (CEST)