elmer module

This module is the heart of pyelmer. It implements the objects used to construct the sif-file.

Wrapper for Elmer simulation input file (sif-file).

The sif file is represented by a Simulation object, which contains dictionaries of objects for each section (i.e. Solvers, Bodies, Materials, etc.). Each of these objects contains the data required in the sif in form of a dictionary called data.

class pyelmer.elmer.Body(simulation, name, body_ids=None, data=None)

Bases: object

Wrapper for bodies in sif-file.

__init__(simulation, name, body_ids=None, data=None)

Create body object.

Parameters:
  • simulation (Simulation Object) – The body is added to this simulation object.

  • name (str) – Name of the body

  • body_ids (list of int) – Ids of bodies in mesh.

  • data (dict, optional) – Body data as in sif-file.

get_data()

Generate dictionary with data for sif-file.

class pyelmer.elmer.BodyForce(simulation, name, data=None)

Bases: object

Wrapper for body forces in sif-file.

__init__(simulation, name, data=None)

Create body force object.

Parameters:
  • simulation (Simulation Object) – The body force is added to this simulation object.

  • name (str) – Name of the body force

  • data (dict, optional) – Body force data as in sif-file.

get_data()

Generate dictionary with data for sif-file.

class pyelmer.elmer.Boundary(simulation, name, geo_ids=None, data=None)

Bases: object

Wrapper for boundaries in sif-file.

__init__(simulation, name, geo_ids=None, data=None)

Create boundary object.

Parameters:
  • simulation (Simulation Object) – The boundary is added to this simulation object.

  • name (str) – Name of the body

  • surf_ids (list of int, optional) – Ids of boundaries in mesh.

  • data (dict, optional) – Boundary data as in sif-file.

get_data()

Generate dictionary with data for sif-file.

class pyelmer.elmer.Component(simulation, name, master_bodies=None, master_boundaries=None, data=None)

Bases: object

Wrapper for components in sif-file.

__init__(simulation, name, master_bodies=None, master_boundaries=None, data=None)

Create component object.

Parameters:
  • simulation (Simulation Object) – The component is added to this simulation object.

  • name (str) – Name of the component

  • master_bodies (list of Boundary, optional) – Master Body objects.

  • master_bodies – Master Boundary objects.

  • data (dict, optional) – Component data as in sif-file.

get_data()

Generate dictionary with data for sif-file.

class pyelmer.elmer.Equation(simulation, name, solvers, data=None)

Bases: object

Wrapper for equations in sif-file.

__init__(simulation, name, solvers, data=None)

Create equation object

Parameters:
  • simulation (Simulation Object) – The equation is added to this simulation object.

  • name (str) – Name of the equation

  • solvers ([list]) – Solvers in this equation

  • data (dict, optional) – Equation data as in sif-file.

get_data()

Generate dictionary with data for sif-file.

class pyelmer.elmer.InitialCondition(simulation, name, data=None)

Bases: object

Wrapper for initial condition in sif-file.

__init__(simulation, name, data=None)

Create initial condition object.

Parameters:
  • simulation (Simulation Object) – The initial condition is added to this simulation object.

  • name (str) – Name of the initial condition

  • data (dict, optional) – Initial condition data as in sif-file.

get_data()

Generate dictionary with data for sif-file.

class pyelmer.elmer.Material(simulation, name, data=None)

Bases: object

Wrapper for materials in sif-file.

__init__(simulation, name, data=None)

Create material object

Parameters:
  • simulation (Simulation Object) – The material is added to this simulation object.

  • name (str) – Name of the material

  • data (dict, optional) – Material data as in sif-file.

get_data()

Generate dictionary with data for sif-file.

class pyelmer.elmer.Simulation

Bases: object

Main wrapper for the sif file. The simulation class is used to collect all information. In the end, it writes the sif-file.

write_boundary_ids(simulation_dir)

Write yaml-file containing the boundary names and the assigned elmer body-ids.

Parameters:

simulation_dir (str) – Path of simulation directory

write_sif(simulation_dir)

Write sif file.

Parameters:

simulation_dir (str) – Path of simulation directory

write_startinfo(simulation_dir)

Write ELMERSOLVER_STARTINFO file in simulation directory.

Parameters:

simulation_dir (str) – simulation directory

class pyelmer.elmer.Solver(simulation, name, data=None)

Bases: object

Wrapper for solver in sif-file.

__init__(simulation, name, data=None)

Create solver object

Parameters:
  • simulation (Simulation Object) – The solver is added to this simulation object.

  • name (str) – Name of the solver

  • data (dict, optional) – Solver data as in sif-file.

get_data()

Generate dictionary with data for sif-file.

class pyelmer.elmer.StringFromList(content: list)

Bases: object

String including references to other Bodies, Boundaries, …

__init__(content: list)

Create StringWithReference object.

Parameters:
  • content (list) – The content of the string, separated into

  • text

  • boundaries (bodies /) –

  • ....

  • ["integer" (e.g.) –

  • type (boundary1];) –

pyelmer.elmer.load_body_force(name, simulation, setup_file='')

Load body force from data base and add it to simulation.

Parameters:
  • name (str) – body force name

  • simulation (Simulation object) –

  • setup_file (str, optional) – Path to yaml file cotaining setup.

Returns:

BodyForce object.

pyelmer.elmer.load_boundary(name, simulation, setup_file='')

Load boundary from data base and add it to simulation.

Parameters:
  • name (str) – boundary name

  • simulation (Simulation object) –

  • setup_file (str, optional) – Path to yaml file cotaining setup.

Returns:

Boundary object.

pyelmer.elmer.load_initial_condition(name, simulation, setup_file='')

Load initial condition from data base and add it to simulation.

Parameters:
  • name (str) – initial condition name

  • simulation (Simulation object) –

  • setup_file (str, optional) – Path to yaml file cotaining setup.

Returns:

InitialCondition object.

pyelmer.elmer.load_material(name, simulation, setup_file='')

Load material from data base and add it to simulation.

Parameters:
  • name (str) – material name

  • simulation (Simulation object) –

  • setup_file (str, optional) – Path to yaml file cotaining setup.

Returns:

Material object.

pyelmer.elmer.load_simulation(name, setup_file='')

Load simulation settings from database.

Parameters:
  • name (str) – Name of the simulation in database.

  • setup_file (str, optional) – Path to yaml file cotaining setup.

Returns:

Simulation object.

pyelmer.elmer.load_solver(name, simulation, setup_file='')

Load solver from data base and add it to simulation.

Parameters:
  • name (str) – solver name

  • simulation (Simulation object) –

  • setup_file (str, optional) – Path to yaml file cotaining setup.

Returns:

Solver object.