mupif Package

mupif Package

This is a MuPIF module (Multi-Physics Integration Framework)

agent Module

class mupif.agent.Agent(pyroDaemon, pyroNs, name, rank=None)[source]

Bases: mupif.api.api.API

giveBBoxFieldView(bbox, fieldID, tStep, unlinkMaster=True)[source]
giveField(fieldID, tStep)[source]
giveFieldUri(fieldID, tStep)[source]
giveMesh(fieldID, tstep)[source]
registerField(field, fieldID, tStep)[source]
class mupif.agent.AgentFieldRec(field, uri=None)[source]

bbox Module

class mupif.bbox.BBox(coords_ll, coords_ur)[source]

Represents an axis aligned bounding box - a rectange in 2d and prism in 3d. Its geometry is described using two points - lover left and upper right. The bounding box class provides fast and efficient methods for testing whether point is inside and whether intersection with other bbox exist.

containsPoint(point)[source]

Returns true if point inside receiver.

intersects(bbox)[source]

Returns true if receiver intersects given bounding box.

merge(entity)[source]

merges receiver with given entity (position or bbox)

cell Module

class mupif.cell.Brick_3d_lin(mesh, number, label, vertices)[source]

Bases: mupif.cell.Cell

Unstructured 3d tetrahedral element with linear interpolation

containsPoint(point)[source]
copy()[source]

This will copy the receiver, making deep copy of all atributes EXCEPT mesh attribute

giveGeometryType()[source]

Returns geometry type of receiver

glob2loc(coords)[source]

Converts global coordinates to local (area) coordinates

interpolate(point, vertexValues)[source]
class mupif.cell.Cell(mesh, number, label, vertices)[source]

Representation of computational cell. It is an attribute of a domain.

It is asumed, that cell can return its vertices, they can be either attributes of a cell (unstructured grids) or verices can be generated based on cell number and domain (structured grids). In the latter case, the derived class is to be created to handle this correctly.

containsPoint(point)[source]

Returns true if cell contains given point

copy()[source]

This will copy the receiver, making deep copy of all atributes EXCEPT mesh attribute

giveBBox()[source]

Returns bounding box of the receiver

giveGeometryType()[source]

Returns geometry type of receiver

giveVertices()[source]

Returns the list of cell vertices

interpolate(point, vertexValues)[source]

Interpolates given vertex values to given point)

class mupif.cell.Quad_2d_lin(mesh, number, label, vertices)[source]

Bases: mupif.cell.Cell

Unstructured 2d quad element with linear interpolation

containsPoint(point)[source]
copy()[source]

This will copy the receiver, making deep copy of all atributes EXCEPT mesh attribute

giveGeometryType()[source]

Returns geometry type of receiver

glob2loc(coords)[source]

Converts global coordinates to local (area) coordinates

interpolate(point, vertexValues)[source]
class mupif.cell.Tetrahedron_3d_lin(mesh, number, label, vertices)[source]

Bases: mupif.cell.Cell

Unstructured 3d tetrahedral element with linear interpolation

containsPoint(point)[source]
copy()[source]

This will copy the receiver, making deep copy of all atributes EXCEPT mesh attribute

giveGeometryType()[source]

Returns geometry type of receiver

glob2loc(coords)[source]

Converts global coordinates to local (area) coordinates

interpolate(point, vertexValues)[source]
class mupif.cell.Triangle_2d_lin(mesh, number, label, vertices)[source]

Bases: mupif.cell.Cell

Unstructured 2d triangular element with linear interpolation

containsPoint(point)[source]
copy()[source]

This will copy the receiver, making deep copy of all atributes EXCEPT mesh attribute

giveGeometryType()[source]

Returns geometry type of receiver

glob2loc(coords)[source]

Converts global coordinates to local (area) coordinates

interpolate(point, vertexValues)[source]

field Module

class mupif.field.Field(mesh, field_id, field_type, value_type, values=None)[source]

Representation of field. Field is generraly a mapping, that assigns a value to points in space. The field values stored in self.__values numpy array. The index is either vertex or cell id. In case of cell-based fields, the value may be list (or tuple) containing values of individual IPs. Then a dictionary with mapping from cell, IP to array index needs to be established.

asArray()[source]
commit()[source]

Commits the recorded changes (via setValue method) to primary field.

evaluate(position, eps=0.001)[source]
evaluateAtVertex(vertexID)[source]
giveFieldID()[source]
giveFieldType()[source]
giveMesh()[source]
giveValue(componentID)[source]

Returns the value associated to given component (vertex or cell IP). The component is a tuple: (vertexID,) or (CellID, IPID)

giveValueType()[source]
merge(field)[source]

Merges the receiver with given field together. The both fields should be on different parts of the domain (can also overlap), but should refer to same underlying discretization, otherwise unpredictable results can occur.

setValue(componentID, value)[source]

Sets the value associated to given component (vertex or cell IP). The componentID is a tuple: (vertexID,) or (CellID, IPID)

ToDo: If mesh has mapping attached (it is a mesh view) then we have to remember value locally and record change. The source field values are updated after commit() method is invoked.

class mupif.field.FieldID[source]

Datermines the physical meaning of field values

FID_Displacement = 1
FID_Humidity = 5
FID_StrainTensor = 2
FID_StressTensor = 3
FID_Temperature = 4
class mupif.field.FieldType[source]

Represent the supported values of FieldType.

cell_based = 2
vertex_based = 1
class mupif.field.FieldValueType[source]

Represent the supported values of Field value types.

scalar = 1
tensor = 3
vector = 2
class mupif.field.FieldView(meshView, masterField, mirror=False)[source]

Bases: mupif.field.Field

Field view represents a subset of master feild, defined by mesh view and its mapping context.

commit()[source]
evaluate(position)[source]
evaluateAtVertex(vertexID)[source]
giveValue(componentID)[source]
localComponentID2MasterID(componentID)[source]
setValue(componentID, value)[source]
update()[source]

Updates receiver values (if mirroring)

localizer Module

class mupif.localizer.Localizer[source]

A Localizer is an abstract class representing an algorithm used to partition space and quicly localize the contained objects.

delete(item)[source]

Deletes the given object from Localizer data structure.

evaluate(functor)[source]

Returns the list of all objects for which the functor is satisfied. The functor is a class with two methods: giveBBox() which returns an initial functor bbox evaluate(obj) which should return true if functor is satisfied for given object.

giveItemsInBBox(bbox)[source]

Returns the list of all objects which bbox intersects with given bbox

insert(item)[source]

Inserts given object to Localizer. Object is assume to provide giveBBox() method returning bounding volume if itself.

mesh Module

class mupif.mesh.Mesh[source]

Bases: object

Abstract representation of a computaional domain. Described using computational cells and vertices, determining the cell geometry. Derived classes represent structured, unstructred FE grids, FV grids, etc.

Mesh is assumed to provide a suitable instance of cell and vertex localizers.

cellLabel2Number(label)[source]

Returns local cell number corresponding to given label. If no label corresponds, thows an exception

cells()[source]
copy()[source]

This will return a copy of the receiver. DeepCopy will not work, as individual cells contain mesh link attributes, leading to underliing mesh duplication in every cell!

giveCell(i)[source]

Returns i-th cell.

giveCellLocalizer()[source]

Returns the cell localizer.

giveMapping()[source]

Returns the mapping associated to mesh.

giveNumberOfCells()[source]

Returns the number of Cells.

giveNumberOfVertices()[source]

Returns the number of Vertices.

giveVertex(i)[source]

Returns i-th vertex.

giveVertexLocalizer()[source]

Returns the vertex localizer.

vertexLabel2Number(label)[source]

Returns local vertex number corresponding to given label. If no label corresponds, thows an exception

vertices()[source]
class mupif.mesh.MeshIterator(mesh, type)[source]

Class representing iterator on Mesh components (vertices, cells).

next()[source]
class mupif.mesh.UnstructuredMesh[source]

Bases: mupif.mesh.Mesh

Represents unstructured mesh. Maintains the list of vertices and cells.

cellLabel2Number(label)[source]

Returns local cell number corresponding to given label. If no label corresponds, thows an exception

copy()[source]

This will return a copy of the receiver. DeepCopy will not work, as individual cells contain mesh link attributes, leading to underliing mesh duplication in every cell!

giveCell(i)[source]
giveCellLocalizer()[source]

Returns the cell localizer.

giveNumberOfCells()[source]

Returns the number of Cells.

giveNumberOfVertices()[source]

Returns the number of Vertices.

giveVertex(i)[source]
giveVertexLocalizer()[source]

Returns the vertex localizer.

merge(mesh)[source]

Merges receiver with given mesh. This is based on merging mesh entities (vertices, cells) based on their labels, as they refer to global ids of each entity, that should be unique

setup(vertexList, cellList)[source]
vertexLabel2Number(label)[source]

Returns local vertex number corresponding to given label. If no label corresponds, thows an exception

meshview Module

class mupif.meshview.MeshView(mappingContext, masterMesh)[source]

Bases: mupif.mesh.Mesh

Mesh view represents a subset of master mesh, defined by mapping context.

giveCell(i)[source]

Returns i-th cell.

giveVertex(i)[source]

Returns i-th vertex.

locateCell(position)[source]

Locates cell containing given point

merge(mview)[source]

Merges receiver with another mesh view instance, same underliying master mesh is required

octree Module

class mupif.octree.Octant(octree, parent, origin, size)[source]

Defines Octree Octant: a cell containing either terminal data or its child octants.

containsBBox(_bbox)[source]

Returns true if bbox intersects with receiver.

delete(item, itemBBox=None)[source]

Deletes given object from receiver data

divide()[source]

Divides receiver locally.

evaluate(functor)[source]

Adds those managed objects into itemList for which functor.evaluate returned Trues. The functor should also provide its BBox to exclude remote octants from the search.

giveDepth()[source]
giveItemsInBBox(itemList, bbox)[source]

Adds those managed object into itemList which bbox intersects with given bbox. Note: an object can be included several times, as can be assigned to several octants.

giveMyBBox()[source]

Returns receiver BBox.

insert(item, itemBBox=None)[source]

Inserts given object into receiver’s list if object bbox intersects receiver.

isTerminal()[source]
class mupif.octree.Octree(origin, size, mask)[source]

Bases: mupif.localizer.Localizer

An octree is used to partition space by recursively subdividing the root cell (square or cube) into octants. Each terminal octant contains the objects within the octant. Each object that can be inserted is assumed to provide following methods: - giveBBox - returning its bounding box

Octree mask is a tuple containing 0 or 1 values. If corresponding mask value is nonzero, receiver is subdivided in corresponding direction. The mask allows to create ocrtrees for various 2d and 1d settings

delete(item)[source]
evaluate(functor)[source]
giveDepth()[source]
giveItemsInBBox(bbox)[source]
insert(item)[source]

timestep Module

class mupif.timestep.TimeStep(_t, _dt, _istep=1)[source]

Class representing time step. Attributes:

time - time at the end of time step. delta_t - time step length

transferoperator Module

class mupif.transferoperator.CellInterpolationTO[source]

Bases: mupif.transferoperator.TransferOperator

Uses source cell interpolation to determine target data at vertices

map(source, target, **options)[source]
class mupif.transferoperator.TransferOperator[source]

Abstract class representing transfer operator to map source field to target field. Source and target fields can have different meshed associated. Parameter options contains a dictionary of optional named parameters.

map(source, target, **options)[source]

Maps source field to target one

util Module

mupif.util.attachPrimaryField(ug, _field)[source]
mupif.util.create_tvtk_ug(mesh)[source]

generate tvtk.UnstructuredGrid grid with different cell types. Returns a created unstructured grid

mupif.util.field2VTKDataSource(field)[source]
mupif.util.mesh2VTKDataSource(mesh)[source]
mupif.util.mesh2VTKDatasetManager(mesh)[source]
mupif.util.quadratic_real(a, b, c)[source]
mupif.util.readOfemMesh(oofemInputFileName)[source]

vertex Module

class mupif.vertex.Vertex(number, label, coords)[source]

Represent vertex.

viewcontext Module

class mupif.viewcontext.BBoxViewContext(box, masterMesh, mirrorMesh=None)[source]

Bases: mupif.viewcontext.ExplicitViewContext

This view context is defined by given BBox. It will contain all elements hit by given BBox and corresponding nodes.

class mupif.viewcontext.ExplicitViewContext[source]

Bases: mupif.viewcontext.ViewContext

This view context is defined by (explicitly given) dictionary.

giveMasterCellNumberData(localCellID)[source]

Returns the master cell number corresponding to given local number (id)

giveMasterVertexNumber(localVertexID)[source]

Returns the master vertex number corresponding to given local number (id)

giveNumberOfCells()[source]

Returns the number of local (mapped) cells

giveNumberOfVertices()[source]

Returns the number of local (mapped) vertices

merge(vc)[source]

Merges the receiver and given context into the receiver

class mupif.viewcontext.ViewContext[source]

Determines the mapping between master domain and associated view. Defines the local numbering of mapped vertices and cells, provides mapping method between local component number (vertex or cell number) and corresponding global number. This class is supposed to be an abstract class, derived classes are assumed to define mapping.

To be more general, the mapping should be also capable to map also element edges and surfaces, as well to adress components on remote/distrubuted nodes. This info can be returned as a tuple, containing all information. At present DataRecord is assumed to have following format: (number,)

giveMasterCellData(localCellID)[source]

Returns the master cell info (number, etc.) corresponding to given local number (id)

giveMasterCellNumber(localCellID)[source]

Returns the master cell number corresponding to given local number (id)

giveMasterVertexData(localVertexID)[source]

Returns the master vertex info (including number, etc) corresponding to given local number (id)

giveMasterVertexNumber(localVertexID)[source]

Returns the master vertex number corresponding to given local number (id)

giveNumberOfCells()[source]

Returns the number of local (mapped) cells

giveNumberOfVertices()[source]

Returns the number of local (mapped) vertices

merge(vc)[source]

Merges the receiver and given context into the receiver