Pipes

Create pipes and pipe networks using the Network class.

See the Readme for more details and examples.

Author: Duncan Hunter

class pipemesh.pipes.Network(length, radius, direction, lcar=0.1)

Represents a pipe or network of pipes.

Pipes are built from an inlet in a sequential, modular fashion. When a junction is added, a new “out surface” is added, which can be added to. In this way, a network of pipes can be built.

physical_in_out_surfaces

Dictionary of Physical surface tags to GMSH surface tags for inlets/outlets.

phyiscal_no_slip

Dictionary of Physical surface tags for walls/outside of cylinder.

physical_volume

Physical tag of the volume. Only available after generate.

add_cylinder()

Add a cylinder to the Network.

add_curve()

Add a curve to the Network.

add_mitered()

Add a mitered bend to the Network.

add_change_radius()

Add a cylinder with change in radius to the Network.

add_t_junction()

Add a T junction the the network.

generate()

Fuse the network and generates the msh file.

get_inlet_outlet_phys_ids()

Returns a list of physical ids of inlets.

get_cyl_phys_ids()

Returns a list of physical ids of cylinder surfaces.

get_velocities_reynolds()

Returns velocity vectors for inlets using Reynolds number.

get_velocities_vel_mag()

Returns velocity vectors for inlets using velocity magnitude.

add_change_radius(length, new_radius, change_length, lcar=0.1, out_number=0)

Adds a piece that changes the radius of the outlet.

The piece is length long, and changes the Network radius to new_radius, over change_length, which controls how gentle the change is.

Parameters:
  • length – (float) Length of the piece.
  • new_radius – (float) radius to change to.
  • change_length – (float) Length that the change takes place over. Must be less than length and > 0.
  • lcar – (float) mesh size for this piece.
  • out_number – Out surface to add to. If <= 1, will add to the first out surface.
Raises:

ValueErrors – change_length is not between length and 0. If radius does not change.

add_curve(new_direction, bend_radius, lcar=0.1, out_number=0)

Adds a curve to the Network at the outlet.

Parameters:
  • new_direction – (list) Direction pipe will be facing in x, y, z vector format. e.g. [0, 1, 0] faces positive y.
  • bend_radius – (float) Radius of the bend.
  • lcar – (float) Size of mesh in this piece.
  • out_number – Out surface to add to. If <= 1, will add to the first out surface.
Raises:

ValueError – new_direction vector isn’t right size. Bend radius isn’t big enough (<1.1 inlet radius).

add_cylinder(length, lcar=0.1, out_number=0)

Adds a pipe to the Network at the outlet.

Parameters:
  • length – (float) length of pipe.
  • lcar – (float) mesh size of piece.
  • out_number – Out surface to add to. If <= 1, will add to the first out surface.
add_mitered(new_direction, lcar=0.1, out_number=0)

Adds a mitered bend to the Network at the outlet.

A mitered bend is a sharp change in direction. Hard to simulate.

Parameters:
  • new_direction – (list, length 3) xyz vector representing the new direction of the pipe.
  • lcar – (float) size of mesh of this piece.
  • out_number – Out surface to add to. If <= 1, will add to the first out surface.
add_t_junction(t_direction, lcar=0.1, t_radius=-1, out_number=0)

Adds a T junction to the Network at the outlet.

This represents a pipe joining this pipe, creating a place to add a Network to this Network.

Parameters:
  • t_direction – (list, length 3) representing the direction that the joining pipe’s inlet is facing.
  • lcar – (float) mesh size for this piece.
  • t_radius – radius of the piece joining the pipe. If <= 0, will default to radius of the pipe.
  • out_number – Out surface to add to. If <= 1, will add to the first out surface.
generate(filename=None, binary=False, mesh_format='msh2', write_info=False, write_xml=False, run_gui=False)

Generates mesh and saves if filename.

Parameters:
  • filename – (string) filename (without extension) to save as.
  • binary – (Bool) Save mesh as binary or not. Default (False).
  • mesh_format – (string) mesh format to save as. Default is msh2. To save as msh4, use ‘msh4’.
  • write_info – (Bool) write filename.txt with mesh mesh information (physical surfaces, locations and directions).
  • write_xml – (Bool) write information in an xml file. Still under development.
  • run_gui – (Bool) run the gmsh gui to view the mesh. May stop saving of information/meshes.
get_cyl_phys_ids()

Returns a list of physical ids of cylinder surfaces.

get_inlet_outlet_phys_ids()

Returns a list of physical ids of inlets.

By default, the inlet phys_id is 1, then the default outlet is 2, followed by any added outlets in the order they were added.

get_velocities_reynolds(physical_ids, reynolds_no, density, viscosity)

Creates velocity vectors for inlets using reynolds number.

Must be run after generate(). Physical ids are turned into indices, which are used to select surfaces from self.physical_in_out_surfaces. By default, the inlet phys_id is 1, then the default outlet is 2, followed by any added outlets in the order they were added. Reynolds is turned into velocity mag using Reynolds*visc/(2*radius*density).

Parameters:
  • physical_ids – (list of ints) physical ids of inlets/outlet surfaces to get velocity vectors for.
  • reynolds_no – (float) reynolds number resulting from velocity vectors created.
  • density – (float) density of the fluid simulated. Should match density used in simulation for accurate results.
  • viscosity – (float) viscosity of the fluid simulated. Should match viscosity used in simulation for accurate results.
get_velocities_vel_mag(physical_ids, velocity_magnitude)

Returns velocity vectors for inlets using velocity magnitude.

Must be run after generate(). Physical ids are turned into indices, which are used to select surfaces from self.physical_in_out_surfaces. By default, the inlet phys_id is 1, then the default outlet is 2, followed by any added outlets in the order they were added.

rotate_network(axis, angle)

Rotates the network from old_direction to new_direction.

Parameters:
  • axis – (array-like, shape (3,)) xyz vector representing the axis of rotation.
  • angle – angle to rotate network about axis.
translate_network(vector)

Translates a network by vector.

Parameters:vector – (list length 3) representing xyz vector to translate network by.