Muscat.Containers.AnisotropicMetricComputation module¶
- ComputeGradient(mesh: Mesh, psi: ndarray[Any, dtype[_ScalarType_co]], tags: List[str] | None = None) ndarray[Any, dtype[_ScalarType_co]] [source]¶
Compute the gradient at each node from a scalar nodefield using a variational formulation: Find Grad such that int Grad . GradT dx = int grad(Psi) . GradT dx for all GradT
- Parameters:
mesh (Mesh) – the input mesh
psi (NDArray) – a scalar nodefield
tags (List[str]) – tags of the computational domain
- Returns:
grad – the gradient of psi at each node
- Return type:
NDarray
- ComputeGradient_L2projection(mesh: Mesh, psi: ndarray[Any, dtype[_ScalarType_co]], tags: List[str] | None = None) ndarray[Any, dtype[_ScalarType_co]] [source]¶
Compute the gradient at each node from a scalar nodefield psi using formula: grad_i(psi) = sum_{K in S_i} |K| grad_K(psi) / sum_{K in S_i} |K|
Warning : works only with simplex meshes
- Parameters:
mesh (Mesh) – the input mesh
psi (NDArray) – a scalar nodefield
tags (List[str]) – tags of the computational domain
- Returns:
grad – the gradient of psi at each node
- Return type:
NDarray
- ComputeHessian(mesh: Mesh, psi: ndarray[Any, dtype[_ScalarType_co]], gradL2: bool = False, tags: List[str] | None = None) ndarray[Any, dtype[_ScalarType_co]] [source]¶
Compute the hessian at each node from a scalar nodefield phi using twice the ComputeGradient function
- Parameters:
mesh (Mesh) – the input mesh
psi (NDArray) – a scalar nodefield
tags (List[str]) – tags of the computational domain
- Returns:
hess – the symmetric matrix hessian of psi at each node
- Return type:
NDarray
- ComputeMetric(mesh: Mesh, psi: ndarray[Any, dtype[_ScalarType_co]], p: int64 | None = None, err: float64 = 0.01, N: int64 | None = None, hmin: float64 = 0.001, hmax: float64 = 1000, gradL2: bool = False, zones: List[List[str]] | None = None) ndarray[Any, dtype[_ScalarType_co]] [source]¶
Construct a metric field for mesh adaptation from a given scalar nodefield phi in Lp norm
Warning : currently works only with simplex meshes
- Parameters:
mesh (Mesh) – the input mesh
psi (NDArray) – a scalar nodefield
p (MuscatIndex) – order of the Lp-norm (infinite by default)
err (MuscatFloat) – desired level for the interpolation error
N (MuscatIndex) – desired number of nodes in the adapted mesh
hmin (MuscatFloat) – bounds for the size of the mesh
hmax (MuscatFloat) – bounds for the size of the mesh
zones (List[List[str]]) – list of the various computational domains (to allow a remeshing by part in the presence of interfaces)
- Returns:
metric – the metric at each node a metric is a vector containing the (dim+1)*dim/2 coefficients of the associated symmetric definite positive matrix
- Return type:
NDarray
- ComputeSizeOfCell(mesh: Mesh, psi: ndarray[Any, dtype[_ScalarType_co]], err: float64 = 0.01, hmin: float64 = 0.001, hmax: float64 = 100, zones: List[List[str]] | None = None) ndarray[Any, dtype[_ScalarType_co]] [source]¶
Construct a map of size of mesh cells from a given scalar nodefield phi in L^inf norm
- Parameters:
mesh (Mesh) – the input mesh
psi (NDArray) – a scalar nodefield
err (MuscatFloat) – desired level for the interpolation error
hmin (MuscatFloat) – bounds for the size of the mesh
hmax (MuscatFloat) – bounds for the size of the mesh
zones (List[List[str]]) – list of the various computational domains (to allow a remeshing by part in the presence of interfaces)
- Returns:
sizeOfCell – the resulting size map at each node
- Return type:
NDarray
- IntersectionOfMetrics(metrics: List, active_scaling=True) ndarray[Any, dtype[_ScalarType_co]] [source]¶
Construct the Löwner-John metric from a set of metrics From article LMI approximations for the radius of the intersection of ellipsoids: a survey, D. Henrion, S. Tarbouriech, D. Arzelier, 1998
- Parameters:
metrics (List of NDarrays) – a list of metric nodefields of the same shape a metric is a vector containing the dimF = dim*(dim+1)/2 coefficients of the symmetric definite positive matrix
active_scaling (bool) – Activate or not the scaling of node metrics to improve clarabel convergence
- Returns:
metric – at each node, the Löwner-John metric corresponding to the largest ellipsoid included in the intersection of the input metrics
- Return type:
NDarray
- ObviousSolutionOrScale(node_metrics: ndarray[Any, dtype[_ScalarType_co]], active_scaling=True) Tuple[bool, int64, float64] [source]¶
Look if one of the metric to intersect at node is obviously solution, otherwise compute scaling to apply to help solver CLARABEL to compute intersection problem
Parameter¶
- node_metricsList of NDarrays
a list of metric at same node of the same shape a metric is a vector containing the dimF = dim*(dim+1)/2 coefficients of the symmetric definite positive matrix
- active_scalingbool
Activate or not the scaling of node metrics to improve clarabel convergence
- returns:
obvious (bool) – Is there a metric obviously solution
index (int) – Index of the metric solution
scale (float) – Scaling factor to apply to the metrics to help solver CLARABEL converge
- plotMetric(list_met: List)[source]¶
Function to generate a matplolib figure of ellipses/ellipsoids representing metrics
- Parameters:
list_met (List) – List of metrics to plot as ellipses,
format (metrics written under flat mmg) –
- Returns:
figure that can be plot or saved
- Return type:
fig (Matplotlib figure)