preprocessing.py

Define the preprocessing dictionary and its functions. preprocessing dictionary contain the main parameters for PETGEM preprocessing tasks: mesh file, conductivity model and receivers file.

petgem.preprocessing.preprocessing.buildPreprocessing(rank, NEDELEC_ORDER, MESH_FILE, MATERIAL_CONDUCTIVITIES, RECEIVERS_FILE, OUT_DIR)[source]

Build a dictionary with main parameters for PETGEM preprocessing.

Parameters:
  • rank (int) – MPI rank.
  • NEDELEC_ORDER (in) – nedelec element order.
  • MESH_FILE (str) – file name of mesh.
  • MATERIAL_CONDUCTIVITIES (ndarray) – conductivity values of materials in the mesh.
  • RECEIVERS_FILE (str) – file name of receivers position.
  • OUT_DIR (str) – path for output.
Returns:

preprocessing dictionary

Return type:

python dictionary

petgem.preprocessing.preprocessing.checkNumberParamsPreprocessing(init_params)[source]

Check number of initial preprocessing parameters.

Parameters:init_params (list) – list of initial preprocessing parameters.
Returns:a parameters file name.
Return type:str.

Note

if the number of init_params is different to 2, PETGEM preprocessing will stop.

petgem.preprocessing.preprocessing.checkPreprocessingConsistency(rank, in_dict, file_name)[source]

Check if preprocessing dictionary consistency match with PETGEM requirements.

Params int rank:
 MPI rank.
Params dict in_dict:
 input preprocessing dictionary to be tested.
Params str file_name:
 preprocessing parameters file name.
Returns:preprocessing dictionary after test.
Return type:preprocessing dictionary.
petgem.preprocessing.preprocessing.preprocessNodes(mesh_file, out_dir, rank)[source]

Preprocess nodal coordinates of a given mesh in Gmsh format.

Parameters:
  • mesh_file (str) – mesh file name to be preprocess.
  • out_dir (str) – path for output.
  • rank (int) – MPI rank.
Returns:

number of nodes

Return type:

int

petgem.preprocessing.preprocessing.preprocessingConductivityModel(mesh_file, material_conductivities, out_dir, rank)[source]

Preprocess conductivity model associated to a given mesh in Gmsh format.

Parameters:
  • mesh_file (str) – mesh file name to be preprocess.
  • material_conductivities (ndarray) – conductivity values for each material in the mesh.
  • out_dir (str) – path for output.
  • rank (int) – MPI rank.
Returns:

None

petgem.preprocessing.preprocessing.preprocessingDataReceivers(nedelec_order, mesh_file, receivers_file, out_dir, rank)[source]

Preprocess receivers and its data for a given 3D CSEM model.

Parameters:
  • nedelec_order (int) – nedelec element order.
  • mesh_file (str) – mesh file name to be preprocess.
  • receivers_file (str) – receiver positions file name to be preprocess.
  • out_dir (str) – path for output.
  • rank (int) – MPI rank.
Returns:

None

petgem.preprocessing.preprocessing.preprocessingEdges(nedelec_order, mesh_file, out_dir, rank)[source]

Preprocess edges, edge boundaries and its associated data structures of a given mesh in Gmsh format. For edge finite element of linear order the edges are the dofs. For edge finite element of second order the dofs are computed in runtime based on edges and faces on each tetrahedral element.

Parameters:
  • nedelec_order (int) – nedelec element order.
  • mesh_file (str) – mesh file name to be preprocess.
  • out_dir (str) – path for output.
  • rank (int) – MPI rank.
Returns:

number of edges.

Return type:

int

petgem.preprocessing.preprocessing.preprocessingFaces(nedelec_order, mesh_file, out_dir, rank)[source]

Preprocess faces, face boundaries and its associated data structures of a given mesh in Gmsh format.

Parameters:
  • nedelec_order (int) – nedelec element order.
  • mesh_file (str) – mesh file name to be preprocess.
  • out_dir (str) – path for output.
  • rank (int) – MPI rank.
Returns:

number of edges.

Return type:

int

petgem.preprocessing.preprocessing.preprocessingNNZ(nedelec_order, mesh_file, out_dir, rank)[source]

Preprocess sparsity pattern (NNZ) for parallel matrix allocation of a given mesh in Gmsh format.

Since PETGEM parallelism is based on PETSc, computation of the matrix sparsity pattern is critical in sake of performance. Furthermore, PETGEM is based on tetrahedral edge finite elements of first, second and third order which produces:

  • 6 DOFs per element in first order discretizations
  • 20 DOFs per element in second order discretizations
  • 45 DOFs per element in third order discretizations

Hence, the tetrahedral valence is equal to:

  • 34 in first order discretizations
  • 134 in second order discretizations
  • 363 in third order discretizations
Parameters:
  • nedelec_order (int) – nedelec element order.
  • mesh_file (str) – mesh file name to be preprocess.
  • rank (int) – MPI rank.
Returns:

None

petgem.preprocessing.preprocessing.preprocessingNodalConnectivity(mesh_file, out_dir, rank)[source]

Preprocess nodal connectivity of a given mesh in Gmsh format.

Parameters:
  • mesh_file (str) – mesh file name to be preprocess.
  • out_dir (str) – path for output.
  • rank (int) – MPI rank.
Returns:

number of tetrahedral elements

Return type:

int

petgem.preprocessing.preprocessing.printPreprocessingData(input_preprocessing, file_name)[source]

Print the content of a preprocessing dictionary.

Parameters:
  • dictionary – input_preprocessing.
  • file_name (str) – preprocessing file name
Returns:

None.

petgem.preprocessing.preprocessing.printPreprocessingSummary(nElems, nNodes, nFaces, nDofs, nReceivers, rank)[source]

Print a summary of data preprocessed.

Parameters:
  • nElems (int) – number of tetrahedral elements in the mesh.
  • nNodes (int) – number of nodes in the mesh.
  • nFaces (int) – number of faces in the mesh.
  • nDofs (int) – number of DOFS in the mesh.
  • nReceivers (int) – number of receivers.
  • rank (int) – MPI rank.
Returns:

None.

petgem.preprocessing.preprocessing.readPreprocessingParams(input_params, rank)[source]

Read a preprocessing input, namely a preprocessing parameters file name.

Params list input_params:
 user input parameters.
Parameters:rank (int) – MPI rank.
Returns:a modelling dictionary.
Return type:dict of type modelling.