Muscat.MeshTools.AnisotropicMetricComputation module¶
- BuildMet(eigenValue: ndarray[tuple[Any, ...], dtype[_ScalarT]], eigenVector: ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]¶
Build metric from eigenValue and eigenVector
- Parameters:
eigenValue – NDArray computed eigenValues for metric on nodes
eigenVector – NDArray eigenVectors for metric on nodes
- Returns:
- NDArray
a vector containing the (dim+1)*dim/2 coefficients of the associated symmetric definite positive matrix
- Return type:
metric
- ComputeDensity(mesh: Mesh, eigenValue: ndarray[tuple[Any, ...], dtype[_ScalarT]], ratio: ndarray[tuple[Any, ...], dtype[_ScalarT]], err: float64 = None, N: int64 = 1, p: int64 = None, renormalization: bool = True) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]¶
Construct at each node of the mesh the density d = 1 /(h_1 h_2 h_3) where h_i is the length of the optimal metric
It is given by d = N VO det / integralOfdet where det = (sum_i ratio_i^(2/dim) * gamma_i )^(dim*p/(2*p+dim)))
- Parameters:
mesh (Mesh) – the input mesh
eigenValue (NDArray) – the absolute values of the eigenValues of the hessian
err (MuscatFloat) – desired level for the absolute interpolation error
N (MuscatIndex) – desired number of elements in the adapted mesh
p (MuscatIndex) – order of the Lp-norm (infinite by default)
- Returns:
density
- Return type:
MuscatFloat
- ComputeGradient(mesh: Mesh, psi: ndarray[tuple[Any, ...], dtype[_ScalarT]], tags: List[str] = None) ndarray[tuple[Any, ...], dtype[_ScalarT]][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]) – eTags of the computational domain, if None the domain is the entire mesh
- Returns:
grad – the gradient of psi at each node
- Return type:
NDarray
- ComputeGradient_L2projection(mesh: Mesh, psi: ndarray[tuple[Any, ...], dtype[_ScalarT]], tags: List[str] = None) ndarray[tuple[Any, ...], dtype[_ScalarT]][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 linear meshes
- Parameters:
mesh (Mesh) – the input mesh
psi (NDArray) – a scalar nodefield
tags (List[str]) – eTags of the computational domain, if None the domain is the entire mesh
- Returns:
grad – the gradient of psi at each node
- Return type:
NDarray
- ComputeHessian(mesh: Mesh, psi: ndarray[tuple[Any, ...], dtype[_ScalarT]], gradL2: bool = False, tags: List[str] = None) ndarray[tuple[Any, ...], dtype[_ScalarT]][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]) – eTags of the computational domain, if None the domain is the entire mesh
gradL2 (bool) – if True, use a L2 projection to compute the gradients
- Returns:
hess – the symmetric matrix hessian of psi at each node
- Return type:
NDarray
- ComputeMetric(mesh: Mesh, psi: ndarray[tuple[Any, ...], dtype[_ScalarT]], err: float64 = None, N: int64 = 1, p: int64 = None, gradL2: bool = False, zones: List[List[str]] = None, isotropic: bool = False) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]¶
Construct a metric field for mesh adaptation from a given scalar nodefield phi in Lp norm From article Continuous mesh framework part II: validations and applications by Adrien Loseille and Frédéric Alauzet, SIAM Journal of Numerical Analysis, 2011.
- 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 relative interpolation error (with respect to normLp(psi))
N (MuscatIndex) – desired number of elements in the adapted mesh
zones (List[List[str]]) – list of the eTags of the computational subdomains, if None, the entire domain is considered
isotropic (bool, default False) – if True, an isotropic scalar metric is returned
- Returns:
metric – the metric at each node a metric is either a vector of the sizes of the cells (if option isotropic = True) or a vector containing the (dim+1)*dim/2 coefficients of the associated symmetric definite positive matrix warning : order of metric component imposed by mmg3d, different from order read by paraview
- Return type:
NDarray
- ComputeMetricOnSubdomain(mesh: Mesh, psi: ndarray[tuple[Any, ...], dtype[_ScalarT]], err: float64 = None, N: int64 = 1, p: int64 = None, gradL2: bool = False, tags: List[str] = None, isotropic: bool = False, renormalization: bool = True) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]¶
Construct a metric field for mesh adaptation from a given scalar nodefield phi in Lp norm From article Continuous mesh framework part II: validations and applications by Adrien Loseille and Frédéric Alauzet, SIAM Journal of Numerical Analysis, 2011.
- 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 absolute interpolation error
N (MuscatIndex) – desired number of elements in the adapted mesh
tags (List[str]) – eTags of the computational subdomain, if None, the entire domain is considered
isotropic (bool, default False) – if True, an isotropic scalar metric is returned
flag (bool, default True) – if False, the global density is set to 1
- Returns:
metric – the metric at each node a metric is either a vector of the sizes of the cells (if option isotropic = True) or a vector containing the (dim+1)*dim/2 coefficients of the associated symmetric definite positive matrix warning : order of metric component imposed by mmg3d and Inria Tools, different from order read by paraview
- Return type:
NDarray
- ComputeRatio(eigenValue: ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]¶
Construct at each node of the mesh the ratios r_i = h_i^3 /(h_1 h_2 h_3) where h_i is the length of the optimal metric It is given by r_1 = gamma_1^-1 * gamma_2^1/2 * gamma_3^1/2
- Parameters:
eigenValue (NDArray) – the absolute values of the eigenValues of the hessian
- Returns:
ratio
- Return type:
NDarray
- GeometricMeanOfMatrices(matrices: List, weights: List = None) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]¶
Construct the log-euclidian weighted mean of a set of symmetric definite positive matrices From article A SURVEY AND COMPARISON OF CONTEMPORARY ALGORITHMS FOR COMPUTING THE MATRIX GEOMETRIC MEAN, BEN JEURIS, RAF VANDEBRIL AND BART VANDEREYCKEN, 2012.
- Parameters:
matrices (List of NDarrays) – a list of symmetric definite positive matrices of the same dimension
weights (List of floats) – the corresponding weights for the mean
- Returns:
matrix – the weighted log-euclidian mean
- Return type:
NDarray
- IntersectionOfMetrics(metrics: List, active_scaling: bool = True, preprocessing: bool = True) ndarray[tuple[Any, ...], dtype[_ScalarT]][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_preprocessing (bool) –
Activate or not the pre processing of the metrics to improve clarabel convergence active_scaling : bool
Activate or not the scaling of the metrics
- 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[tuple[Any, ...], dtype[_ScalarT]], active_scaling: bool = 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_metricsNDarrays
an array of metrics of the same shape at a given node 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 the 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)