Loading geodynamic model data
- class geoteqpy.ModelData(vts: str | None = None)
Class to read and manipulate data from a pTatin3d simulation. It also provides methods to interpolate data from the pTatin3d mesh to a uniform mesh.
- Parameters:
vts (str) – Name of the vts file to read. Default:
None.- Attributes:
- ptatin_mesh: pvt.cfemesh.CFEMeshQ1
pTatin3d mesh object. Default:
None.
- uniform_mesh: pvt.cfemesh.CFEMeshQ1
Uniform mesh object. Default:
None.
- O: np.ndarray
Minimum coordinates of the domain in each direction. Default:
None.
- L: np.ndarray
Maximum coordinates of the domain in each direction. Default:
None.
- Methods:
- check_ptatin_mesh() None
Verify that a mesh object has been created for the pTatin3d simulation results.
- Raises:
ValueError – If the mesh object does not exist.
- get_deviatoric_stress(**keys)
Get deviatoric stress from its key in the cell data of the pTatin3d mesh or compute it from the viscosity and strain rate fields such that:
\[\tau_{ij} = 2 \eta \dot{\varepsilon}_{ij}\]where \(\tau_{ij}\) is the deviatoric stress tensor, \(\eta\) is the viscosity and \(\dot{\varepsilon}_{ij}\) is the strain rate tensor.
- Parameters:
keys (dict) –
Dictionary of keys:
deviatoric_stress_key(str): Key to identify the deviatoric stress field in the cell data.viscosity_key(str): Key to identify the viscosity field in the cell data.strainrate_key(str): Key to identify the strain rate field in the cell data.velocity_key(str): Key to identify the velocity field in the point data.
If
deviatoric_stress_keyis provided and found in data, the deviatoric stress field is returned and no other field key is required. If not found, the deviatoric stress field is computed from the viscosity and strain rate fields. If the strain rate field is not found, it will be computed from the velocity field using the methodget_strainrate. Therefore, the only two mandatory fields are the viscosity and the velocity fields.- Returns:
Deviatoric stress field. Shape
(n_cells,9).- Return type:
np.ndarray
- get_strainrate(**keys) ndarray
Get strain rate from its key in the cell data of the pTatin3d mesh or compute it from the velocity field such that:
\[\dot{\varepsilon}_{ij} = \frac{1}{2} \left( \frac{\partial u_i}{\partial x_j} + \frac{\partial u_j}{\partial x_i} \right)\]where \(\dot{\varepsilon}_{ij}\) is the strain rate tensor and \(u_i\) is the velocity vector.
- Parameters:
keys (dict) –
Dictionary of keys to identify the strain rate field and the velocity field.
strainrate_key(str): Key to identify the strain rate field in the cell data.velocity_key(str): Key to identify the velocity field in the point data.
The velocity field is mandatory only if the strain rate field is not found in the cell data. If the strain rate key is not provided or not found in the data it will be computed from the velocity field.
- Raises:
ValueError – If both the strain rate and the velocity field are not found or provided.
- Returns:
Strain rate field. Shape
(n_cells,9).- Return type:
np.ndarray
- get_total_stress(**keys)
Get the total stress field from its key or compute it from the deviatoric stress and the pressure fields such that:
\[\sigma_{ij} = \tau_{ij} - p \delta_{ij}\]where \(\tau_{ij}\) is the deviatoric stress tensor, \(p\) is the pressure and \(\delta_{ij}\) is the Kronecker delta.
- Parameters:
keys (dict) –
Dictionary of keys:
total_stress_key(str): Key to identify the total stress field in the cell data.deviatoric_stress_key(str): Key to identify the deviatoric stress field in the cell data.viscosity_key(str): Key to identify the viscosity field in the cell data.strainrate_key(str): Key to identify the strain rate field in the cell data.velocity_key(str): Key to identify the velocity field in the point data.pressure_key(str): Key to identify the pressure field in the cell data.
If the total stress field is not found in the cell data, it will be computed from the deviatoric stress using the method
get_deviatoric_stressand the pressure fields. Seeget_deviatoric_stressfor more details.- Returns:
Total stress field. Shape
(n_cells,9).- Return type:
np.ndarray
- interpolate_to_uniform_mesh(fields: list | None = None) None
Interpolate fields from the pTatin3d mesh created with
mesh_create_from_vtsto a uniform mesh created withmesh_create_from_options.Warning
During the interpolation, all cell fields are projected to point fields.
Note
Interpolation is linear and uses \(Q_1\) isoparametric element shape functions.
- Parameters:
fields (list) – List of keys corresponding to fields to interpolate. Default:
None. If no fields are provided, all cell and point fields present on the ptatin mesh object are considered.- Raises:
ValueError – If the uniform mesh has not been created yet.
- mesh_create_from_options(O: ndarray, L: ndarray, m: ndarray) CFEMeshQ1
Create a
pyviztools.CFEMeshQ1object from a bounding box and mesh size.- Parameters:
O (np.ndarray) – Minimum coordinates of the domain in each direction.
L (np.ndarray) – Maximum coordinates of the domain in each direction.
m (np.ndarray) – Number of elements in each direction.
- Returns:
Mesh object.
- Return type:
pyviztools.CFEMeshQ1- Example:
import numpy as np O = np.array([0,0,0], dtype=np.float32) L = np.array([1,1,1], dtype=np.float32) m = np.array([8,8,8], dtype=np.int32) M = ModelData() mesh = M.mesh_create_from_options(O,L,m)
- mesh_create_from_vts(fname: str) CFEMeshQ1
Create a
pyviztools.CFEMeshQ1object from a vts file.- Parameters:
fname (str) – Name of the vts file to read.
- Returns:
Mesh object.
- Return type:
pyviztools.CFEMeshQ1
- set_default_fields() list[str]
Set default fields to interpolate from the pTatin3d mesh to the uniform mesh. By default, all cell and point fields are considered.
- Returns:
List of keys corresponding to fields to interpolate.
- Return type:
list[str]