proteus.mprans.SpatialTools module

This module adds functionality to proteus.SpatialTools module by enabling two-phase flow functionality such as converting shapes to moving rigid bodies, or adding wave absorption and generation zones.

Example

from proteus import Domain from proteus.mprans import SpatialTools as st import numpy as np

domain = Domain.PlanarStraightLineGraphDomain() tank = st.Tank2D(domain. dim=[4., 4.]) tank.setSponge(left=0.4) tank.setAbsorptionZones(left=true) shape = st.Rectangle(domain, dim=[0.5, 0.5], coords=[1., 1.]) shape.setRigidBody() shape2.rotate(np.pi/3.) shape2.BC.left.setNoSlip()

st.assembleDomain(domain)

class proteus.mprans.SpatialTools.ShapeRANS(domain, nd)[source]

Bases: proteus.SpatialTools.Shape

Base/super class of all shapes. Sets the boundary condition class to proteus.mprans.BoundaryConditions.BC_RANS.

Parameters
  • domain (proteus.Domain.D_base) – Domain class instance that hold all the geometrical informations and boundary conditions of the shape.

  • nd (Optional[int]) – Number of dimensions of the shape. If not set, will take the number of dimensions of the domain.

attachPointGauges(model_key, gauges, activeTime=None, sampleRate=0, fileName='point_gauges.csv')[source]

Attaches Point Gauges (in the Proteus/Gauges.py style) to the shape.

Parameters
  • model_key (string) – Label of the model to use as a key for selecting particular gauges.

  • parameters. (See proteus Gauges.py PointGauges class for the remaining) –

attachLineGauges(model_key, gauges, activeTime=None, sampleRate=0, fileName='line_gauges.csv')[source]

Attaches Line Gauges (in the Proteus/Gauges.py style) to the shape.

Parameters
  • model_key (string) – Label of the model to use as a key for selecting particular gauges.

  • parameters. (See proteus Gauges.py LineGauges class for the remaining) –

attachLineIntegralGauges(model_key, gauges, activeTime=None, sampleRate=0, fileName='line_integral_gauges.csv')[source]

Attaches Line Integral Gauges (in the Proteus/Gauges.py style).

Parameters
  • model_key (string) – Label of the model to use as a key for selecting particular gauges.

  • parameters. (See proteus Gauges.py LineIntegralGauges class for the remaining) –

setTank()[source]

Sets tank boundary conditions (for moving domain).

setTurbulentWall(wall)[source]

Sets a turbulent wall as an object to be attacched to auxiliaryVariable. The objects has to be defined with WallFunction class.

Parameters

wall (list of WallFunction class object) –

setTurbulentKWall(kWall)[source]

Sets a turbulent wall as an object to be attacched to auxiliaryVariable. The objects has to be defined with WallFunction class.

Parameters

kWall (list of WallFunction class object for kappa) –

setAbsorptionZones(flags, epsFact_porous, center, orientation, dragAlpha, vert_axis=None, dragBeta=0.0, porosity=1.0)[source]

Sets a region (given the local flag) to an absorption zone

Parameters
  • dragAlpha (Optional) – Relaxation zone coefficient.

  • flags (array_like, int) – Local flags of the region. Can be an integer or a list.

  • epsFact_porous (float) – Half of absorption zone (region) length (used for blending func).

  • center (array_like) – Coordinates of the center of the absorption zone.

  • orientation (array_like) – Orientation vector pointing TOWARDS incoming waves.

  • vert_axis (Optional[int]) – index of vertical position vector (x:0, y:1, z:2), must always be aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z).

  • dragBeta (Optional[float]) – Relaxation zone coefficient.

  • porosity (Optional[float]) – Relaxation zone coefficient.

setGenerationZones(flags, epsFact_porous, center, orientation, waves, dragAlpha, vert_axis=None, wind_speed=(0.0, 0.0, 0.0), dragBeta=0.0, porosity=1.0, smoothing=0.0)[source]

Sets a region (given the local flag) to a generation zone

Parameters
  • flags (array_like, int) – Local flags of the region. Can be an integer or a list.

  • epsFact_porous (float) – Half of absorption zone (region) length (used for blending func).

  • center (array_like) – Coordinates of the center of the absorption zone.

  • orientation (array_like) – Orientation vector pointing ACCORDING WITH the direction of generated waves.

  • waves (proteus.WaveTools) – Class instance of wave generated from proteus.WaveTools.

  • dragAlpha (Optional[float]) – Relaxation zone coefficient.

  • vert_axis (Optional[int]) – index of vertical position vector (x:0, y:1, z:2), must always be aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z).

  • wind_speed (Optional[array_like]) – Speed of wind in generation zone (default is (0., 0., 0.))

  • dragBeta (Optional[float]) – Relaxation zone coefficient.

  • porosity (Optional[float]) – Relaxation zone coefficient.

setPorousZones(flags, dragAlpha, dragBeta, porosity)[source]

Sets a region (given the local flag) to a porous zone

Parameters
  • flags (array_like, int) – Local flags of the region. Can be an integer or a list.

  • dragAlpha (float) – Darcy-type coefficient

  • dragBeta (float) – Forchheimer-type coefficient

  • porosity (float) – Porosity

class proteus.mprans.SpatialTools.Tank3D(domain, dim=(0.0, 0.0, 0.0), coords=None)[source]

Bases: proteus.mprans.SpatialTools.ShapeRANS

Class to create a 3D tank (cuboidal shape).

Parameters
  • domain (proteus.Domain.D_base) – Domain class instance that hold all the geometrical informations and boundary conditions of the shape.

  • dim (Optional[array_like]) – Dimensions of the cuboid.

  • coords (Optional[array_like]) – Coordinates of the centroid of the shape.

count = 0[source]
setSponge(x_p=None, x_n=None, y_p=None, y_n=None)[source]

Set length of sponge layers of the tank (used for wave absorption or generation zones). (!) Sponge layers expand outwards.

Parameters
  • x_p (Optional[float]) – length of sponge layer in +x direction.

  • x_n (Optional[float]) – length of sponge layer in -x direction.

  • y_p (Optional[float]) – length of sponge layer in +y direction.

  • y_n (Optional[float]) – length of sponge layer in -y direction.

setDimensions(dim)[source]

Set dimension of the tank :param dim: dimensions of the tank (excluding sponge layers), array of length 3. :type dim: array_like

setAbsorptionZones(dragAlpha, allSponge=False, y_n=False, y_p=False, x_n=False, x_p=False, dragBeta=0.0, porosity=1.0)[source]

Sets regions (x+, x-, y+, y-) to absorption zones

Parameters
  • dragAlpha (float) – Relaxation zone coefficient.

  • allSponge (bool) – If True, all sponge layers are converted to absorption zones.

  • x_p (bool) – If True, x+ region is converted to absorption zone.

  • x_n (bool) – If True, x- region is converted to absorption zone.

  • y_p (bool) – If True, y+ region is converted to absorption zone.

  • y_n (bool) – If True, y- region is converted to absorption zone.

  • dragBeta (Optional[float]) – Relaxation zone coefficient.

  • porosity (Optional[float]) – Relaxation zone coefficient.

setGenerationZones(dragAlpha, smoothing, waves=None, wind_speed=(0.0, 0.0, 0.0), allSponge=False, y_n=False, y_p=False, x_n=False, x_p=False, dragBeta=0.0, porosity=1.0)[source]

Sets regions (x+, x-, y+, y-) to generation zones

Parameters
  • dragAlpha (float) – Relaxation zone coefficient.

  • smoothing (float) – Smoothing distance (typically 3.*he)

  • waves (proteus.WaveTools) – Class instance of wave generated from proteus.WaveTools.

  • wind_speed (Optional[array_like]) – Speed of wind in generation zone (default is (0., 0., 0.))

  • allSponge (bool) – If True, all sponge layers are converted to generation zones.

  • x_p (bool) – If True, x+ region is converted to generation zone.

  • x_n (bool) – If True, x- region is converted to generation zone.

  • y_p (bool) – If True, y+ region is converted to generation zone.

  • y_n (bool) – If True, y- region is converted to generation zone.

  • dragBeta (Optional[float]) – Relaxation zone coefficient.

  • porosity (Optional[float]) – Relaxation zone coefficient.

class proteus.mprans.SpatialTools.Tank2D(domain, dim, coords=None)[source]

Bases: proteus.mprans.SpatialTools.ShapeRANS

Class to create a 2D tank (rectangular shape).

Parameters
  • domain (proteus.Domain.D_base) – Domain class instance that hold all the geometrical informations and boundary conditions of the shape.

  • dim (array_like) – Dimensions of the tank (excluding sponge layers).

  • coords (Optional[array_like]) – Coordinates of the centroid of the shape.

count = 0[source]
constructShape()[source]

Construct the geometry of the tank: segments, regions, etc.

Parameters
  • frame (array_like) – An array of (x,y) coordinates in counterclockwise order to define the boundaries of the main (that is, excluding extensions such as sponge zones) shape. This can be generated with tank2DFrame or subclass specific methods.

  • frame_flags (array_like) – A corresponding array of boundary tags associated with each point in the frame. This can be generated with tank2DFrame or subclass specific methods.

setSponge(x_n=None, x_p=None)[source]

Set length of sponge layers of the tank (used for wave absorption or generation zones). (!) Sponge layers expand outwards.

Parameters
  • x_p (Optional[float]) – length of sponge layer in +x direction.

  • x_n (Optional[float]) – length of sponge layer in -x direction.

setAbsorptionZones(dragAlpha, x_n=False, x_p=False, dragBeta=0.0, porosity=1.0)[source]

Sets regions (x+, x-) to absorption zones

Parameters
  • dragAlpha (float) – Relaxation zone coefficient.

  • allSponge (bool) – If True, all sponge layers are converted to absorption zones.

  • x_p (bool) – If True, x+ region is converted to absorption zone.

  • x_n (bool) – If True, x- region is converted to absorption zone.

  • dragBeta (Optional[float]) – Relaxation zone coefficient.

  • porosity (Optional[float]) – Relaxation zone coefficient.

setGenerationZones(dragAlpha, smoothing, waves=None, wind_speed=(0.0, 0.0, 0.0), x_n=False, x_p=False, dragBeta=0.0, porosity=1.0)[source]

Sets regions (x+, x-) to generation zones

Parameters
  • dragAlpha (float) – Relaxation zone coefficient

  • smoothing – Smoothing distance

  • waves (proteus.WaveTools) – Class instance of wave generated from proteus.WaveTools.

  • wind_speed (Optional[array_like]) – Speed of wind in generation zone (default is (0., 0., 0.))

  • allSponge (bool) – If True, all sponge layers are converted to generation zones.

  • x_p (bool) – If True, x+ region is converted to generation zone.

  • x_n (bool) – If True, x- region is converted to generation zone.

  • dragBeta (Optional[float]) – Relaxation zone coefficient.

  • porosity (Optional[float]) – Relaxation zone coefficient.

class proteus.mprans.SpatialTools.TankWithObstacles2D(domain, dim=(0.0, 0.0), obstacles=None, special_boundaries=None, full_circle=False, coords=None, hole=True, obstacle_regions=None)[source]

Bases: proteus.mprans.SpatialTools.Tank2D

Class to create a 2D rectangular tank with obstacles built out of any wall.

An obstacle is defined by a contiguous list of points which start and end on the walls or corners of the tank.

This also covers special boundary conditions. To tag a segment with a unique boundary tag, add the starting vertex (in the counterclockwise format the shape is generated in) of the segment as a value in a dictionary element keyed to the name of the boundary tag.

(!) Warning: If each of the four corners of the rectangular tank is inside an obstacle or a vertex for an obstacle, then the tank’s region is defined in a pseudorandom manner, which may make it unreliable when dealing with holes caused by other shapes. (!) Warning: Obstacle boundary tags are keyed to whichever edge they started from. If this is undesirable, it may be manually overriden by applying special boundary conditions to affected segments.

Parameters
  • domain (proteus.Domain.D_base) – Domain class instance that hold all the geometrical informations and boundary conditions of the shape.

  • dim (Optional[array_like]) – Dimensions of the cuboid.

  • obstacles (Optional[array_like]) – A list of lists of (x,y) coordinates. Each (x,y) coordinate is a length and height relative to the x-,y- corner of the tank. Each list of coordinates is an obstacle defined by points connected in the order of their index. The list of lists gives all such obstacles in a counterclockwise manner of which they should be appended, starting from the (x-,y-) corner.

  • special_boundaries (Optional[mapping]) – A dictionary of lists of vertices keyed to boundary names. The vertices listed will be given the boundary name they are keyed to, overriding any other designation they would be given. If this is a distinct boundary name, the segment starting from the vertex will be assigned the same boundary tag.

  • full_circle (Optional[bool]) – A boolean tag to check if the final obstacle ends on the same edge that the first obstacle starts on. Default is False.

  • coords (Optional[array_like]) – Coordinates of the centroid of the shape.

  • hole (Optional[bool]) – If True (default), the obstacle of the tank is just an open hole at the bottom of the tank. If False, a segment at the bottom of the obstacle is created to close the hole.

  • obstacle_regions (Optional[array_like]) – To use only if hole=False.(x,y) coordinates of a point inside the obstacle in order to fill the obstacle with what should be inside (for example a porous material).

setAbsorptionZones(dragAlpha, x_n=False, x_p=False, dragBeta=0.0, porosity=1.0)[source]

Sets regions (x+, x-) to absorption zones

Parameters
  • dragAlpha (float) – Relaxation zone coefficient

  • allSponge (bool) – If True, all sponge layers are converted to absorption zones.

  • x_p (bool) – If True, x+ region is converted to absorption zone.

  • x_n (bool) – If True, x- region is converted to absorption zone.

  • dragBeta (Optional[float]) – Relaxation zone coefficient.

  • porosity (Optional[float]) – Relaxation zone coefficient.

setGenerationZones(dragAlpha, smoothing, waves=None, wind_speed=(0.0, 0.0, 0.0), x_n=False, x_p=False, dragBeta=0.0, porosity=1.0)[source]

Sets regions (x+, x-) to generation zones

Parameters
  • dragAlpha (float) – Relaxation zone coefficient.

  • smoothing (float) – Smoothing distance (typically 3*he)

  • waves (proteus.WaveTools) – Class instance of wave generated from proteus.WaveTools.

  • wind_speed (Optional[array_like]) – Speed of wind in generation zone (default is (0., 0., 0.))

  • allSponge (bool) – If True, all sponge layers are converted to generation zones.

  • x_p (bool) – If True, x+ region is converted to generation zone.

  • x_n (bool) – If True, x- region is converted to generation zone.

  • dragBeta (Optional[float]) – Relaxation zone coefficient.

  • porosity (Optional[float]) – Relaxation zone coefficient.

proteus.mprans.SpatialTools.assembleDomain(domain)[source]

This function sets up everything needed for the domain, meshing, and AuxiliaryVariables calculations (if any). It should always be called after defining and manipulating all the shapes to be attached to the domain.

Parameters

domain (proteus.Domain.D_base) – Domain class instance that hold all the geometrical informations and boundary conditions of the shape.

proteus.mprans.SpatialTools.assembleAuxiliaryVariables(domain)[source]

Adds the auxiliary variables to the domain.

Parameters

domain (proteus.Domain.D_base) – Domain class instance that hold all the geometrical informations and boundary conditions of the shape.

Notes

Should be called after assembleGeometry

proteus.mprans.SpatialTools.get_unit_vector(vector)[source]