fluidsimfoam.foam_input_files#

OpenFOAM input files

AST and parser

ast

Abstract Syntax Trees for OpenFOAM input files

generators

Internal machinery to generate the OpenFOAM input files

parser

Parser for OpenFOAM input files

format

Format OpenFOAM input files

Helper to create input files

blockmesh

Helper to create blockMeshDict files

control_dict

Helper to create controlDict files

fields

Helper to create field files

fv_schemes

Helper to create fvSchemes files

constant_files

Helper to create constant files

fv_options

Helper to create fvOptions files

decompose_par

Helper to create decomposeParDict files

util

Utilities

Functions

parse_header(code)

Parse the header ("FoamFile" entry) of an OpenFOAM file

read_header(path)

Read the header ("FoamFile" entry) of an OpenFOAM file

Classes

FileHelper()

Abstract class for "Helper" objects

fluidsimfoam.foam_input_files.parse(text, grammar=None)[source]#
fluidsimfoam.foam_input_files.dump(tree)[source]#
fluidsimfoam.foam_input_files.create_field_from_code(code)[source]#
class fluidsimfoam.foam_input_files.FoamInputFile(info, children=None, header=None, comments=None)[source]#
dump()[source]#
overwrite()[source]#
class fluidsimfoam.foam_input_files.ControlDictHelper(default=None)[source]#
complete_params(params)[source]#

Complete the params object

make_tree(params)[source]#

Make the AST corresponding to a file

new(default=None)[source]#
add_function(key, type, libs, entries=None)[source]#
include_function(name, kind=None)[source]#
include_functions(names, kind=None)[source]#
class fluidsimfoam.foam_input_files.Dict(data, name=None, directive=None, comments=None)[source]#
get_name()[source]#
dump(indent=0)[source]#
class fluidsimfoam.foam_input_files.List(iterable=None, name=None, dtype=None)[source]#

Represents an OpenFoam list

get_name()[source]#
dump(indent=0)[source]#
class fluidsimfoam.foam_input_files.Value(value, name=None, dimension=None)[source]#
dump_without_assignment(indent=0)[source]#
class fluidsimfoam.foam_input_files.BlockMeshDict[source]#
set_metric(metric)[source]#

set self.comvert_to_meters by word

set_scale(scale)[source]#
add_vertex(x, y=None, z=None, name=None)[source]#

add vertex by coordinate and uniq name x y z is coordinates of vertex name is uniq name to refer the vertex returns Vertex object whici is added.

del_vertex(name)[source]#

del name key from self.vertices

reduce_vertex(name1, *names)[source]#

treat name1, name2, … as same point.

name2.alias, name3.alias, … are merged with name1.alias the key name2, name3, … in self.vertices are kept and mapped to same Vertex instance as name1

merge_vertices()[source]#

call reduce_vertex on all vertices with identical values.

replicate_vertices_further_z(z, suffix='_dz', vnames=None)[source]#

Helper for 2d meshes

add_hexblock(vnames, nx_ny_nz, name=None, grading=<fluidsimfoam.foam_input_files.blockmesh.grading.SimpleGrading object>)[source]#
add_hexblock_from_2d(vnames, nx_ny_nz, name=None, grading=<fluidsimfoam.foam_input_files.blockmesh.grading.SimpleGrading object>, suffix_zm='', suffix_zp='_dz')[source]#
add_arcedge(vnames, name, inter_vertex)[source]#
add_splineedge(vnames, name, points)[source]#
add_boundary(type_, name, faces=None, neighbour=None)[source]#
add_merge_patch_pairs(boundary_name1: str, boundary_name2: str)[source]#

Add 2 boundaries to merge

add_cyclic_boundaries(name0, name1, faces0, faces1)[source]#

Add 2 cyclic boundaries

Example

2 cyclic boundaries can be created as follow:

add_cyclic_boundaries("outlet", "inlet", b0.face("e"), b0.face("w"))
assign_vertexid(sort=True)[source]#
  1. create list of Vertex which are referred by blocks only.

  2. sort vertex according to (x, y, z)

  3. assign sequence number for each Vertex

  4. sorted list is saved as self._vertices_in_blockmesh

format_vertices_section()[source]#

format vertices section. assign_vertexid() should be called before this method, because self._vertices_in_blockmesh should be available and members of self._vertices_in_blockmesh should have valid index.

format_blocks_section()[source]#

format blocks section. assign_vertexid() should be called before this method, because vertices refered by blocks should have valid index.

format_edges_section()[source]#

format edges section. assign_vertexid() should be called before this method, because vertices refered by blocks should have valid index.

format_boundary_section()[source]#

format boundary section. assign_vertexid() should be called before this method, because vertices refered by faces should have valid index.

format_mergepatchpairs_section()[source]#
format(header='/*--------------------------------*- C++ -*----------------------------------*\\\n| =========                 |                                                 |\n| \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |\n|  \\\\    /   O peration     | Version:  v2206                                 |\n|   \\\\  /    A nd           | Website:  www.openfoam.com                      |\n|    \\\\/     M anipulation  |                                                 |\n\\*---------------------------------------------------------------------------*/', sort_vortices=True)[source]#
class fluidsimfoam.foam_input_files.VolScalarField(name, dimension, tree=None, values=None)[source]#
cls_name: str = 'volScalarField'#
set_values(values)[source]#

Set internalField with value(s)

class fluidsimfoam.foam_input_files.VolVectorField(name, dimension, tree=None, values=None)[source]#
cls_name: str = 'volVectorField'#
set_values(values, vy=None, vz=None)[source]#

Set internalField with value(s)

get_components()[source]#
class fluidsimfoam.foam_input_files.FvSchemesHelper(ddt=None, grad=None, div=None, laplacian=None, interpolation=None, sn_grad=None)[source]#
keys = ['ddt', 'grad', 'div', 'laplacian', 'interpolation', 'snGrad']#
complete_params(params)[source]#

Complete the params object

make_tree(params)[source]#

Make the AST corresponding to a file

add_dict(name, data)[source]#
class fluidsimfoam.foam_input_files.Vertex(x, y, z, name, index=None)[source]#
format()[source]#
copy()[source]#
fluidsimfoam.foam_input_files.read_field_file(path, skip_boundary_field=True)[source]#
class fluidsimfoam.foam_input_files.FileHelper[source]#

Abstract class for “Helper” objects

abstract complete_params(params)[source]#

Complete the params object

abstract make_tree(params)[source]#

Make the AST corresponding to a file

class fluidsimfoam.foam_input_files.ConstantFileHelper(file_name: str, default: dict, default_dimension: str = False, dimensions: Optional[dict] = None, comments: Optional[dict] = None, doc: Optional[str] = None, cls: str = 'dictionary', dimension=None)[source]#
complete_params(params)[source]#

Complete the params object

make_tree(params)[source]#

Make the AST corresponding to a file

class fluidsimfoam.foam_input_files.BlockMeshDictRectilinear(lx, ly, lz, nx, ny, nz, scale)[source]#
class fluidsimfoam.foam_input_files.FvOptionsHelper[source]#
add_option(type, name=None, active=True, cell_zone=None, cell_set=None, points=None, default=None, coeffs=None, parameters=None, only_if_active=False)[source]#
remove_option(name)[source]#
complete_params(params)[source]#

Complete the params object

make_tree(params)[source]#

Make the AST corresponding to a file

class fluidsimfoam.foam_input_files.DimensionSet(foam_units)[source]#
dump_without_assignment(indent=0)[source]#
class fluidsimfoam.foam_input_files.DecomposeParDictHelper(nsubdoms=1, method='scotch', key_in_params='parallel')[source]#
add_region(name, data)[source]#
complete_params(params)[source]#

Complete the params object

make_tree(params)[source]#

Make the AST corresponding to a file

new(nsubdoms=None, method=None, key_in_params=None)[source]#
fluidsimfoam.foam_input_files.format_code(code, as_field=False, check=True)[source]#
exception fluidsimfoam.foam_input_files.FoamFormatError[source]#
fluidsimfoam.foam_input_files.read_header(path)[source]#

Read the header (“FoamFile” entry) of an OpenFOAM file

fluidsimfoam.foam_input_files.parse_header(code: str)[source]#

Parse the header (“FoamFile” entry) of an OpenFOAM file