scrimp.utils
This folder contains useful functions that are beyond the port-Hamiltonian framework used in SCRIMP.
Config
file: utils/config.py
authors: Ghislain Haine
date: 23 jun. 2023
brief: functions to configure SCRIMP
- scrimp.utils.config.set_paths(path=None)
Set the default path of scrimp
- Args:
path (str): the path
- scrimp.utils.config.set_verbose(verbose=1)
Set the verbosity level of scrimp (0: quiet, 1: info, 2: debug)
In quiet mode, debug are saved in a log file.
- Args:
verbose (int): the level of verbosity, defaults to 1
- scrimp.utils.config.set_verbose_gf(verbose)
Set the verbosity level of getfem
- Args:
verbose (int): the level of verbosity
Linear algebra
file: utils/linalg.py
authors: Ghislain Haine, Florian Monteghetti
date: 29 nov. 2022
brief: linear algebra functions
- scrimp.utils.linalg.convert_PETSc_to_scipy(A)
Convert from PETSc.Mat to scipy sparse (csr).
- Args:
A (PETSc Mat): The matrix to convert
- Returns:
scipy.sparse.csr.csr_matrix: the matrix A in scipy.sparse.csr.csr_matrix format
- scrimp.utils.linalg.convert_gmm_to_petsc(M, B, comm=petsc4py.PETSc.COMM_WORLD)
Convert a GetFEM matrix M to a PETSc one B
- Args:
M (SPMat GetFEM): matrix to transfer B (PETSc.Mat): matrix to fill M with comm (MPI_Comm): MPI communicator
- Returns:
None
- scrimp.utils.linalg.extract_gmm_to_scipy(I, J, M)
Extract a sub-matrix A from M, on interval I, J
- Args:
I (Numpy array): line interval [begin, lenght] J (Numpy array): column interval [begin, lenght] M (SPMat GetFEM): matrix from which to extract the submatrix
- Returns:
PETSc.Mat: matrix with value M(I,J) in CSR format
- Returns:
scipy.sparse.csr.csr_matrix: the matrix A in scipy.sparse.csr.csr_matrix format
Mesh
file: utils/mesh.py
authors: Ghislain Haine
date: 22 nov. 2022
brief: built-in geometries for direct use in SCRIMP
- scrimp.utils.mesh.Ball(parameters={'R': 1.0, 'h': 0.1}, refine=0, terminal=1)
The geometry of a Ball of radius R centered in (0,0,0) with mesh size h
Domain Omega: 1,
Boundary Gamma: 10
- Args:
parameters (dict): The dictionary of parameters for the geometry
refine (int): Ask for iterative refinements by splitting elements
terminal (int): An option to print meshing infos in the prompt, value 0 (quiet) or 1 (verbose, default)
- Returns:
list[gf.Mesh, int, dict, dict]: The mesh to use with getfem, the dimension, a dict of regions with getfem indices for dim n and a dict of regions with getfem indices for dim n-1
- scrimp.utils.mesh.Concentric(parameters={'R': 1.0, 'h': 0.1, 'r': 0.6}, refine=0, terminal=1)
The geometry of a Disk of radius r surrounded by an annulus of radii r and R with mesh size h
Domain Omega_Disk: 1,
Domain Omega_Annulus: 2,
Interface Interface: 10,
Boundary Gamma: 20
- Args:
parameters (dict): The dictionary of parameters for the geometry
refine (int): Ask for iterative refinements by splitting elements
terminal (int): An option to print meshing infos in the prompt, value 0 (quiet) or 1 (verbose, default)
- Returns:
list[gf.Mesh, int, dict, dict]: The mesh to use with getfem, the dimension, a dict of regions with getfem indices for dim n and a dict of regions with getfem indices for dim n-1
- scrimp.utils.mesh.Disk(parameters={'R': 1.0, 'h': 0.1}, refine=0, terminal=1)
The geometry of a Disk center in (0,0) with radius R and mesh size h
Domain Omega: 1,
Boundary Gamma: 10
- Args:
parameters (dict): The dictionary of parameters for the geometry
refine (int): Ask for iterative refinements by splitting elements
terminal (int): An option to print meshing infos in the prompt, value 0 (quiet) or 1 (verbose, default)
- Returns:
list[gf.Mesh, int, dict, dict]: The mesh to use with getfem, the dimension, a dict of regions with getfem indices for dim n and a dict of regions with getfem indices for dim n-1
- scrimp.utils.mesh.Interval(parameters={'L': 1.0, 'h': 0.05}, refine=0, terminal=1)
The geometry of a segment (0,L) with mesh size h
Domain Omega: 1,
Left boundary Gamma_Left: 10,
Right boundary Gamma_Right: 11
- Args:
parameters (dict): The dictionary of parameters for the geometry
refine (int): Ask for iterative refinements by splitting elements
terminal (int): An option to print meshing infos in the prompt, value 0 (quiet) or 1 (verbose, default)
- Returns:
list[gf.Mesh, int, dict, dict]: The mesh to use with getfem, the dimension, a dict of regions with getfem indices for dim n and a dict of regions with getfem indices for dim n-1
- scrimp.utils.mesh.Rectangle(parameters={'L': 2.0, 'h': 0.1, 'l': 1}, refine=0, terminal=1)
The geometry of a Rectangle (0,L)x(0,l) with mesh size h
Domain Omega: 1,
Bottom boundary Gamma_Bottom: 10,
Right boundary Gamma_Right: 11,
Top boundary Gamma_Top: 12,
Left boundary Gamma_Left: 13
- Args:
parameters (dict): The dictionary of parameters for the geometry
refine (int): Ask for iterative refinements by splitting elements
terminal (int): An option to print meshing infos in the prompt, value 0 (quiet) or 1 (verbose, default)
- Returns:
list[gf.Mesh, int, dict, dict]: The mesh to use with getfem, the dimension, a dict of regions with getfem indices for dim n and a dict of regions with getfem indices for dim n-1
- scrimp.utils.mesh.built_in_geometries()
A function to get all the infos about available built_in geometries