bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils package

Submodules

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.evaluateCheckMesh module

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.evaluateCheckMesh.parse_checkMesh_log(file_path)
bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.evaluateCheckMesh.parse_snappyHexMeshLog(file_path)
bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.evaluateCheckMesh.process_key_value(line)

Splits a line into key and value.

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.evaluateCheckMesh.set_in_nested_dict(nested, keys, value)

Sets a value in a nested OrderedDict based on a list of keys.

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.openfoam_utils module

class bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.openfoam_utils.OpenFOAMUtils

Bases: object

detriangulize(obj)

2-step algorithm for removing triangularizaton from an obj as TopoDS_Compound. 1. remove inner edges. 2. remove collinear and coincident points.

static dict_to_string(d)
static duplicate_table_for_restart(dict_with_string_tables: dict, add_number_to_keys: int) dict
static get_edge_lengths(edges)

Calculate the lengths of edges in 3D space.

Parameters:

edges (list of tuples): A list where each element is a tuple containing two 3D coordinates (e.g., [((x1, y1, z1), (x2, y2, z2)), …]).

Returns:

list: A list of lengths corresponding to the edges.

static get_min_internal_dist(points: list[OCC.Core.gp.gp_Pnt]) float

Computes the minimal internal distance of a TopoDS Shape.

static get_min_refdist_between_shapes(shape1: TopoDS_Shape, shape2: TopoDS_Shape, dist_bound=0.05) float

Computes the minimal distance between two TopoDS Shapes and returns the distance divided by 3 such that in the refinement zone, there will be 3 cells in between two objects. Optional argument dist_bound can specify a maximal minimal distance (default: 1cm).

static get_refinement_level(dist: float, bM_size: float, mean_dist: float = None) list

Computes the refinement level based on the desired refined cell size and the blockMesh cell size. bM_size/2^X = min_dist

static get_vol_from_cells(case) float

Compute the volume of the simulated room based on the FVM cells.

case must be the path to the corresponding OpenFOAM case directory.

static get_vol_from_geometry(base_dir: str, inlet_type: str, outlet_type: str) float

Compute the volume of the simulated room based on the STL files.

base_dir must be the path to the triSurface directory of the corresponding OpenFOAM case. inlet_type and outlet_type must be equal to the corresponding sim_setting options.

static prime_factors(n)
static remove_coincident_vertices(vert_list: list) list

Slightly modified version of the method in PyOCCTools. Remove coincident vertices from list of gp_Pnt. Vertices are coincident if closer than tolerance. Does not assume vertices to be sorted.

static split_into_three_factors(n)
static split_openfoam_elements(openfoam_elements: dict) tuple[list, list, list, list, list]
static string_to_dict(s)
validate_volumes_cells(case: str, inlet_type: str, outlet_type: str) bool

Compute the absolute difference in the volumes of the geometry of the room and the volume of the discretized domain. If the V directory was not created in the controlDict, it can be created after meshing using (Linux):

postProcess -func writeCellVolumes -time 0 gzip -d V.gz

The total discretized volume can also be obtained from the checkMesh functionality.

case must be the path to the corresponding OpenFOAM case directory. inlet_type and outlet_type must be equal to the corresponding sim_setting options.

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.paraViewScripts module

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.postProcessingPlots module

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.postProcessingPlots.MinMaxPlot(of_directory: str, min_max_dir='MinMax', vol_field_dir='volFieldValue', max_dir='', min_dir='', name='')

Creates a plot of minimal and maximal values of the velocity’s magnitude (U) and temperature (T) over the simulated iteration steps.

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.postProcessingPlots.add_simulation_times(fig, of_directory, name='', number=0)
bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.postProcessingPlots.analyze_execution_times(of_directory, target_iterations=[1000, 'final'])

Extracts execution times from an OpenFOAM log file, prints times for specific iterations, and plots all execution times over the course of the iterations with target times annotated.

Parameters: - of_directory (str or Path): Directory containing the OpenFOAM log file. - target_iterations (list): List of iteration numbers to print and annotate (e.g., [1000, ‘final’]).

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.postProcessingPlots.convergencePlot(of_directory: str)

Creates a plot of velocity (U) and temperature (T, directly proportional to h) residuals over the simulated iteration steps.

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.postProcessingPlots.convergencePlot2(of_directory: str)

Creates a plot of velocity (U) and temperature (T, directly proportional to h) residuals over the simulated iteration steps and detects the stabilization point where residuals converge with minimal variations.

bim2sim.plugins.PluginOpenFOAM.bim2sim_openfoam.utils.postProcessingPlots.get_next_unused_color(ax)