foamgen.morphology

Morphology module

synopsis

Create foam morphology in CAD format.

Functions

add_walls(iname, cname, wname, wall_thickness)

Create walls by shrinking each cell.

clean_files()

Delete unnecessary files.

make_walls(fname, wall_thickness, clean)

Add walls to a tessellated foam.

to_box(iname, cname, wname, ncells[, method])

Move foam to periodic box.

foamgen.morphology.add_walls(iname, cname, wname, wall_thickness)[source]

Create walls by shrinking each cell.

Uses files in gmsh CAD format.

Parameters
  • iname (str) – input filename

  • cname (str) – output filename with cells

  • wname (str) – output filename with walls

  • wall_thickness (float) – wall thickness parameter

Returns

number of cells

Return type

int

foamgen.morphology.clean_files()[source]

Delete unnecessary files.

foamgen.morphology.create_compound(obj, compound, builder)[source]

Add objects to compound using builder.

Parameters
  • obj (list) – list of objects to be added to compound

  • compound (obj) – the compound

  • builder (obj) – BREP builder

foamgen.morphology.finalize_geo(iname, oname, verbose, method='pythonocc')[source]

Define periodic surfaces and physical volumes.

Also remove point duplicity and restore OpenCASCADE compatibility.

foamgen.morphology.make_walls(fname, wall_thickness, clean)[source]

Add walls to a tessellated foam.

Walls are created in gmsh CAD format. Geometry is then converted to BREP format, in which it is moved to periodic box using pythonOCC (separately for cells and walls). Final file merges generated file in gmsh-readable format.

FileTessellation.geo -> FileCells.geo + FileWalls.geo -> FileCellsBox.brep + FileWallsBox.brep -> FileMorphology.geo

Parameters
  • fname (str) – base filename

  • wall_thickness (float) – wall thickness parameter

  • clean (bool) – delete redundant files if True

foamgen.morphology.move_to_box(iname, cname, wname, visualize=False)[source]

Move foam to periodic box.

Works on BREP files. Information about physical volumes is lost.

Parameters
  • iname (str) – input filename

  • cname (str) – output filename with cells

  • wname (str) – output filename with walls

  • visualize (bool) – show picture of foam morphology in box if True

foamgen.morphology.slice_and_move(obj, box, vec)[source]

Cut, move, and join and object

One object is cut by another object. Sliced part is moved by a vector. Moved part is joined with non-moved part.

Parameters
  • obj (Solid) – object to be cut

  • box (Solid) – object used for cutting

  • vec (gp_Vec) – vector defining the offset

foamgen.morphology.to_box(iname, cname, wname, ncells, method='pythonocc')[source]

Move foam to periodic box.

Remove point duplicity, restore OpenCASCADE compatibility, define periodic and physical surfaces.

Only pythonocc method is currently functional.

Parameters
  • iname (str) – input filename

  • cname (str) – output filename with cells

  • wname (str) – output filename with walls

  • ncells (int) – number of cells

  • method (str) – gmsh or pythonocc (default)

foamgen.morphology.translate_topods_from_vector(brep, vec, copy=False)[source]

Translate a brep over a vector.

Parameters
  • brep (BRep) – the Topo_DS to translate

  • vec (gp_Vec) – the vector defining the translation

  • copy (bool) – copies to brep if True