foampy package¶
Subpackages¶
Submodules¶
foampy.case module¶
Module to contain Case
object.
foampy.core module¶
Core functionality for foamPy.
-
foampy.core.
gen_dynmeshdict
(U, R, meantsr, cellzone=’AMIsurface’, rpm_fluc=3.7, npoints=400, axis=’(0 0 1)’, direction=1)[source]¶ Generates a dynamicMeshDict for a given U, R, meantsr, and an optional rpm fluctuation amplitude. Phase is fixed.
-
foampy.core.
get_n_processors
(casedir=’./’, dictpath=’system/decomposeParDict’)[source]¶ Read number of processors from decomposeParDict.
-
foampy.core.
get_ncells
(casedir=’./’, logname=’log.checkMesh’, keyword=’cells’, autogen=True)[source]¶
-
foampy.core.
get_solver_times
(casedir=’./’, solver=None, log_fpath=None, window=400)[source]¶ Read last N lines from file solver log and return t (current Time), deltaT, and clockTime.
-
foampy.core.
load_forces
(casedir=’./’, object_name=’forces’, start_time=0)[source]¶ Load forces and moments as a pandas DataFrame.
-
foampy.core.
load_probes_data
(casedir=’./’, object_name=’probes’, start_time=0, field_name=’U’)[source]¶ Load probes data as pandas
DataFrame
.
-
foampy.core.
load_sample_xy
(casedir=’./’, profile=’U’)[source]¶ Import text data created with the OpenFOAM sample utility.
-
foampy.core.
load_set
(casedir=’./’, name=’profile’, quantity=’U’, fmt=’xy’, axis=’xyz’)[source]¶ Import text data created with the OpenFOAM sample utility.
-
foampy.core.
load_theta_omega
(casedir=”, t_interp=[], theta_units=’degrees’)[source]¶ Import omega from
dynamicMeshDict
table. Returns t, theta, omega (rad/s) where theta is calculated using the trapezoidal rule.t_interp is a keyword argument for an array over which omega and theta will be interpolated.
-
foampy.core.
load_torque_drag
(casedir=”, folder=‘0’, filename=None, torque_axis=’z’, drag_axis=’x’)[source]¶ Loads time, z-axis torque, and streamwise force from specified forces folder. Case name can be left empty if running within a case folder.
-
foampy.core.
read_case
()[source]¶ Will eventually read all case dicts and put in a hierarchy of dicts.
-
foampy.core.
read_dict
(dictname=None, dictpath=None, casedir=’./’)[source]¶ Read an OpenFOAM dict into a Python dict. Right now this is quite crude, but gets the job done decently for 1 word parameters.
-
foampy.core.
read_log_end
(logname, nlines=20)[source]¶ Read last lines from log and return as a list.
foampy.dictionaries module¶
Functions for reading and writing dictionaries.
-
foampy.dictionaries.
build_header
(dictobject=”, version=‘2.3.x’, fileclass=’dictionary’, incl_foamfile=True)[source]¶ Creates the header for an OpenFOAM dictionary. Inputs are the object and version.
foampy.foil module¶
Module for working with foil data.
-
class
foampy.foil.
FoilData
[source]¶ Bases:
object
Object that represents a foil characteristic database.
foampy.gui module¶
foampy.templates module¶
Code related to templating.
-
foampy.templates.
fill_template
(src, dest=None, **params)[source]¶ Fill a template file based on given parameters using new style Python string formatting.
-
foampy.templates.
gen_from_template_dir
(fpath_out, template_dir=’templates’, fname_out=None, **params)[source]¶ Generate a file from a template with the same relative path inside
template_dir
.
-
foampy.templates.
make_template
(fpath, template_dir=’templates’, keywords=[], git=True, delete=True)[source]¶ Convert an OpenFOAM dictionary to a template for use with Python’s string formatting.
- fpath : str
- Path to file to be converted to a template.
- template_dir : str
- Path to directory in which to store templates.
- keywords : list
- List of strings to setup as formatted keywords in template.
- git : bool
- If
True
, attempt to remove file from Git repo and add to.gitignore
file.
foampy.types module¶
This module contains classes to work with custom OpenFOAM classes, e.g., lists and dictionaries.
-
class
foampy.types.
BlockMeshDict
(name=’blockMeshDict’, casedir=’./’, subdir=’system’)[source]¶ Bases:
foampy.types.FoamDict
Object to represent a blockMeshDict.
-
class
foampy.types.
FoamDict
(name=”, casedir=’./’, subdir=’system’, **kwargs)[source]¶ Bases:
collections.OrderedDict
Object that represents an OpenFOAM dictionary.