OpenFoam Core

This stores the basic classes and functions needed to interact with OpenFoam
files.
Written By: Matthew Stadelman
Date Written: 2016/03/22
Last Modifed: 2016/08/08
class apmapflow.openfoam.openfoam.OpenFoamDict(name, values=None)[source]

Class used to build the dictionary style OpenFoam input blocks

__init__(name, values=None)[source]
Creates an OpenFoamDict:

name - string printed at top of dictionary in files values - any valid iterable that can be used to initialize

a dictionary
__str__(indent=0)[source]

Prints a formatted output readable by OpenFoam

class apmapflow.openfoam.openfoam.OpenFoamFile(*args, **kwargs)[source]

Class used to build OpenFoam input files

__init__(*args, **kwargs)[source]

Creates and instance of the class passing the first three arguments to the FileFile header dict and the final argument can be used to initialize the OpenFoamFile object with entries.

location : string, sets the subdirectory location of the file
during output.
object_name : string, sets initial value of self.name attribute used
to name the output file and the ‘object’ key in the FoamFile dict
class_name : string, optional, sets the ‘class’ key in the FoamFile
dict, it defaults to ‘dictionary’
values : iterable, optional, any valid iterable that can be used to
initialize a regular Python dictionary
__str__()[source]

Prints a formatted OpenFoam input file

static _init_from_file(filename)[source]

Reads an existing OpenFoam input file and returns an OpenFoamFile instance. Comment lines are not retained.

write_foam_file(path='.', create_dirs=True, overwrite=False)[source]

Writes out the foam file, adding proper location directory if create_dirs is True

class apmapflow.openfoam.openfoam.OpenFoamList(name, values=None)[source]

Class used to build the output lists used in blockMeshDict.

__init__(name, values=None)[source]
Creates an OpenFoamList:

name - string printed at top of dictionary in files values - any valid iterable that can be used to initialize

a list
__str__(indent=0)[source]

Prints a formatted output readable by OpenFoam

__weakref__

list of weak references to the object (if defined)

class apmapflow.openfoam.openfoam.OpenFoamObject[source]

General class used to recognize other OpenFoam objects

__weakref__

list of weak references to the object (if defined)