Source code for Muscat.Experimental.Containers.PartitionedMesh
# -*- coding: utf-8 -*-## This file is subject to the terms and conditions defined in# file 'LICENSE.txt', which is part of this source code package.#fromtypingimportOptional,ListimportnumpyasnpfromMuscat.Containers.MeshimportMeshGlobalIdsFieldName="GlobalIDs"
[docs]classPartitionedMesh():""" Class PartitionedMesh, Class to store a partitioned mesh we use two field to store the global numbering of the elements and the nodes. theses field are stored in the every mesh .nodesFields["GlobalIDs"] .elemFields["GlobalIDs"]. np.union(GlobalIds)[0] = 0 , np.union(GlobalIds)[-1] = len(np.union(GlobalIds))-1 """def__init__(self)->None:super().__init__()self.storage:List[Mesh]=[]
[docs]defAddMesh(self,mesh:Mesh,nodesGlobalIDs:Optional[np.ndarray]=None,elementsGlobalIDs:Optional[np.ndarray]=None)->None:"""Add mesh to the PartitionedMesh extra data is needed. "GlobalIDs" on the nodes and "GlobalIDs" on the elements. Theses int fields can be provided inside the mesh (nodeFields, elemFields) or as extra arguments. the extra fields will be pushed to the mesh Parameters ---------- mesh : Mesh the mesh nodesGlobalIDs : Optional[np.ndarray], optional an numpy array of ints over the nodes, by default None elementsGlobalIDs : Optional[np.ndarray], optional an numpy array of ints over the elements, by default None Raises ------ RuntimeError if no nodes GlobalIDs are provided RuntimeError if no elements GlobalIDs are provided """ifnodesGlobalIDsisNone:ifGlobalIdsFieldNamenotinmesh.nodeFields:# pragma: no coverraiseRuntimeError("globalNodesIds not provided and absent of nodeFields")else:mesh.nodeFields[GlobalIdsFieldName]=nodesGlobalIDsifelementsGlobalIDsisNone:ifGlobalIdsFieldNamenotinmesh.elemFields:# pragma: no coverraiseRuntimeError("globalElementIds not provided and absent of elemFields")else:mesh.elemFields[GlobalIdsFieldName]=elementsGlobalIDsself.storage.append(mesh)