Mesh

Mesh processing tools.

Mesh class

class argiope.mesh.Mesh(**kwargs)[source]

A single class to handle meshes and associated data. The class constructor only a redirection to the following methods:

A simple example is given below.

import numpy as np
import argiope as ag

# NODE COORDINATES
coords =  np.array([[0., 0., 0.], #1
                    [1., 0., 0.], #2 
                    [2., 0., 0.], #3
                    [1., 1., 0.], #4
                    [0., 1., 0.], #5
                    [0., 0., 1.], #6
                    [1., 0., 1.], #7 
                    [2., 0., 1.], #8
                    [1., 1., 1.], #9
                    [0., 1., 1.], #10
                    [0., 0., 2.], #11
                    [1., 0., 2.], #12
                    [2., 0., 2.], #13
                    [1., 1., 2.], #14
                    [0., 1., 2.], #15
                    [1., 0., 3.], #16
                    ])

# NODE LABELS
nlabels = np.arange(len(coords)) +1                    

# NODE SETS
nsets = {"nset1": nlabels > 2}              

# CONNECTIVITY : 
# Warning = nothing, only used to ensure renctangularity of the table.
conn =  [[ 1,  2,  4,  5,  0,  0,  0,  0], #1 = QUAD4
         [ 2,  3,  4,  0,  0,  0,  0,  0], #2 = TRI3
         [ 6,  7,  9, 10, 11, 12, 14, 15], # 3 = HEXA8
         [ 7,  8,  9, 12, 13, 14,  0,  0], # 4 = PRISM6
         [12, 13, 14, 16,  0,  0,  0,  0], # 5 = TETRA4
        ]

elabels = np.arange(1, len(conn) + 1)

types =  np.array(["quad4", "tri3", "hexa8", "prism6", "tetra4"])         

stypes = np.array(["CPS4", "CAX3", "C3D8", 
                   "C3D6", "C3D4"]) # Abaqus element naming convention.

esets = {"eset1": elabels < 2}       

materials = np.array(["mat1", "mat2", "mat2", "mat2", "mat2"])

mesh = ag.mesh.Mesh(nlabels = nlabels,
                    coords  = coords,
                    nsets   = nsets,
                    conn    = conn,
                    elabels = elabels,
                    esets   = esets,
                    types   = types,
                    stypes  = stypes,
                    )

For more complex examples, follow the notebook tutorials.

Set

Mesh.set_nodes(nlabels=[], coords=[], nsets={}, **kwargs)[source]

Sets the node data.

Parameters:
  • nlabels (1D uint typed array-like) – node labels. Items be strictly positive and int typed in 1D array-like with shape \((N_n)\).
  • coords (2D float typed array-like) – node coordinates. Must be float typed 2D array-like of shape \((N_n \times 3)\).
  • nsets (dict) – node sets. Contains boolean array-like of shape \((N_n)\).
Mesh.set_elements(elabels=None, types=None, stypes='', conn=None, esets={}, surfaces={}, materials='', **kwargs)[source]

Sets the element data.

Parameters:
  • elabels (1D uint typed array-like) – element labels. Items be strictly positive and int typed in 1D array-like with shape \((N_e)\).
  • types (str typed array-like) – element types chosen among argiope specific element types.
  • stypes (str typed array-like) – element types chosen in solver (depends on the chosen solver) specific element types.
  • conn (uint typed array-like) – connectivity table. In order to deal with non rectangular tables, \(0\) can be used to fill missing data.
  • esets (dict) – element sets. Contains boolean array-like of shape \((N_e)\).
  • surfaces (dict) – surfaces. Contains boolean array-like of shape \((N_e, N_s )\) with \(N_s\) being the maximum number of faces on a single element.
  • materials (str typed array-like) – material keys. Any number a of materials can be used.
Mesh.set_fields(fields=None, **kwargs)[source]

Sets the fields.

Verify

Mesh.check_elements()[source]

Checks element definitions.

Mesh.nvert()[source]

Returns the number of vertices of eache element according to its type/

Mesh.centroids_and_volumes(sort_index=True)[source]

Returns a dataframe containing volume and centroids of all the elements.

Mesh.angles(zfill=3)[source]

Returns the internal angles of all elements and the associated statistics

Mesh.edges(zfill=3)[source]

Returns the aspect ratio of all elements.

Mesh.stats()[source]

Returns mesh quality and geometric stats.

Mesh.fields_metadata()[source]

Returns fields metadata as a dataframe.

Modify

Mesh.element_set_to_node_set(tag)[source]

Makes a node set from an element set.

Mesh.node_set_to_surface(tag)[source]

Converts a node set to surface.

Mesh.surface_to_element_sets(tag)[source]

Creates elements sets corresponding to a surface.

Plot with Matplotlib

Mesh.to_polycollection(*args, **kwargs)[source]

Returns the mesh as matplotlib polygon collection. (tested only for 2D meshes)

Mesh.to_triangulation()[source]

Returns the mesh as a matplotlib.tri.Triangulation instance. (2D only)

Export

Mesh.write_inp(*args, **kwargs)[source]

Exports the mesh to the Abaqus INP format.

Fields

Meta classes

class argiope.mesh.MetaField(label=None, position='node', step_num=None, step_label=None, part=None, frame=None, frame_value=None, data=None, **kwargs)[source]

A field mother class.

Parameters:
  • label (str) – field label
  • position (in ["node", "element"]) – physical position
copy()

Returns a copy of self.

metadata()[source]

Returns metadata as a dataframe.

save(path)

Saves the instance into a compressed serialized file.

class argiope.mesh.Field(label=None, position='node', step_num=None, step_label=None, part=None, frame=None, frame_value=None, data=None, **kwargs)[source]
copy()

Returns a copy of self.

metadata()

Returns metadata as a dataframe.

save(path)

Saves the instance into a compressed serialized file.

Field classes

class argiope.mesh.ScalarField(label=None, position='node', step_num=None, step_label=None, part=None, frame=None, frame_value=None, data=None, **kwargs)[source]
copy()

Returns a copy of self.

metadata()

Returns metadata as a dataframe.

save(path)

Saves the instance into a compressed serialized file.

class argiope.mesh.Vector2Field(label=None, position='node', step_num=None, step_label=None, part=None, frame=None, frame_value=None, data=None, **kwargs)[source]

2D vector field.

copy()

Returns a copy of self.

metadata()

Returns metadata as a dataframe.

save(path)

Saves the instance into a compressed serialized file.

class argiope.mesh.Vector3Field(label=None, position='node', step_num=None, step_label=None, part=None, frame=None, frame_value=None, data=None, **kwargs)[source]

3D vector field.

copy()

Returns a copy of self.

metadata()

Returns metadata as a dataframe.

save(path)

Saves the instance into a compressed serialized file.

class argiope.mesh.Tensor4Field(label=None, position='node', step_num=None, step_label=None, part=None, frame=None, frame_value=None, data=None, **kwargs)[source]

Second order symmetric 2D tensor field.

copy()

Returns a copy of self.

metadata()

Returns metadata as a dataframe.

save(path)

Saves the instance into a compressed serialized file.

class argiope.mesh.Tensor6Field(label=None, position='node', step_num=None, step_label=None, part=None, frame=None, frame_value=None, data=None, **kwargs)[source]

Second order symmetric tensor field.

copy()

Returns a copy of self.

metadata()

Returns metadata as a dataframe.

save(path)

Saves the instance into a compressed serialized file.

Parsers

argiope.mesh.read_msh(path)[source]

Reads a GMSH msh file using MESHIO.

Mesh generation

argiope.mesh.structured_mesh(shape=(2, 2, 2), dim=(1.0, 1.0, 1.0))[source]

Returns a structured mesh.

Parameters:
  • shape (tuple) – 2 or 3 integers (eg: shape = (10, 10, 10)).
  • dim (tuple) – 2 or 3 floats (eg: dim = (4., 2., 1.))

Note

This function does not use GMSH for mesh generation.

>>> import argiope as ag
>>> mesh = ag.mesh.structured_mesh(shape =(10,10,10), dim=(1.,1.,1.)))