|
TrioCFD 1.9.8
TrioCFD documentation
|
Manages the local polynomial basis functions for Discontinuous Galerkin elements. More...
#include <BasisFunction.h>
Public Member Functions | |
| BasisFunction ()=default | |
| virtual | ~BasisFunction () |
| void | initialize (const Domaine_DG &dom, const int &order, const bool &gram_schmidt) |
| Initializes the basis function object for a given DG domain and polynomial order. | |
| const int & | get_order () const |
| const int & | get_default_quadrature_order () const |
| const IntTab & | indices_glob_elem (const int dim=1) const |
| const int & | nb_bfunc () const |
| void | eval_bfunc (const Quadrature_base &quad, const int &nelem, DoubleTab &fbasis) const |
| Evaluates all basis functions at the element quadrature points. | |
| void | eval_bfunc_on_facets (const Quadrature_base &quad, const int &nelem, const int &num_face, DoubleTab &grad_fbasis) const |
| Evaluates all basis functions of element nelem at the quadrature points of face num_face. | |
| void | eval_bfunc (const DoubleTab &coord, const int &nelem, DoubleTab &fbasis) const |
| Evaluates all basis functions at a set of arbitrary coordinates. | |
| void | eval_grad_bfunc (const Quadrature_base &quad, const int &nelem, DoubleTab &fbasis) const |
| Evaluates the gradients of all basis functions at the element quadrature points. | |
| void | eval_grad_bfunc_on_facets (const Quadrature_base &quad, const int &nelem, const int &num_face, DoubleTab &grad_fbasis) const |
| Evaluates the gradients of all basis functions of element nelem at the quadrature points of face num_face. | |
| void | eval_div_bfunc_on_facets (const Quadrature_base &quad, const int &nelem, const int &num_face, DoubleTab &div_fbasis) const |
| Evaluates the divergence of the basis functions at the quadrature points of face num_face. | |
| void | eval_div_bfunc (const Quadrature_base &quad, const int &nelem, DoubleTab &div_fbasis) const |
| const Matrice_Dense | eval_invMassMatrix (const Quadrature_base &quad, const int &nelem) const |
| Computes the inverse of the local L2 mass matrix for element nelem. | |
| const DoubleTab & | get_eta_elem () const |
| const DoubleTab & | get_eta_facet () const |
Protected Member Functions | |
| void | allocate_transition_matrix () |
| Allocates the sparsity pattern of the block-diagonal transition matrix. | |
| void | compute_stab_param () |
| Computes the SIP penalty stabilization parameters eta_elem and eta_facet. | |
| const Matrice_Dense | build_local_mass_matrix (const Quadrature_base &quad, const int nelem) const |
| Computes the local L2 mass matrix M_ij = integral of phi_i * phi_j on element nelem. | |
| void | build_mass_matrix () |
| void | build_transition_matrix () |
| Computes and stores the Gram-Schmidt orthonormalization coefficients. | |
| void | orthonormalize (const int &nelem, const int &nb_pts_integ, DoubleTab &fbasis) const |
| Applies the pre-computed Gram-Schmidt transition matrix to a raw basis evaluation. | |
| void | gramSchmidt (DoubleTab &fbase, const Quadrature_base &quad, const int &num_elem, const int ¤t_indice, const int &nb_pts_integ, const double &volume, int index) |
| Recursively orthonormalizes the local basis using the modified Gram-Schmidt process. | |
| OBS_PTR (Domaine_DG) dom_ | |
Protected Attributes | |
| int | order_ = 1 |
| bool | is_orthonormalized_ = true |
| bool | is_diagonal_ = true |
| int | nb_bfunc_ = -1 |
| int | default_quad_order_ = -1 |
| IntTab | indices_glob_elem_ |
| IntTab | indices_glob_elem_2D_ |
| IntTab | indices_glob_elem_3D_ |
| Matrice_Morse | transition_matrix_ |
| DoubleTab | eta_elem |
| DoubleTab | eta_facet |
Manages the local polynomial basis functions for Discontinuous Galerkin elements.
This class builds, stores, and evaluates the local polynomial basis {phi_i} used in the DG discretization on each element. It supports orders 0, 1, and 2 in 2D (3D is not yet implemented and throws at runtime).
Basis definition The raw (non-orthonormalized) basis is defined on each element T as scaled monomials centered at the element barycenter xp and normalized by the characteristic length h_T:
Gram-Schmidt orthonormalization If orthonormalization is requested (gram_schmidt flag in initialize()), the raw basis is transformed into an L2-orthonormal basis on each element via the modified Gram-Schmidt process (gramSchmidt()). The change-of-basis coefficients are stored in a sparse transition_matrix_ (block-diagonal, one nb_bfunc x nb_bfunc block per element), which is then applied on-the-fly by orthonormalize() whenever a basis or gradient is evaluated.
Global DOF indexing indices_glob_elem_(e) gives the first global DOF index for element e. For scalar fields (dim=1) this maps directly; for vector fields (dim=2 or 3) the index is scaled accordingly via the indices_glob_elem(dim) accessor.
Stabilization parameters compute_stab_param() fills two arrays used by the SIP penalty term:
Evaluation methods All eval_* methods fill a pre-allocated output DoubleTab with values at the quadrature points provided by a Quadrature_base object. If the basis is orthonormalized, the transition matrix is applied automatically after the raw evaluation.
Definition at line 67 of file BasisFunction.h.
|
default |
|
inlinevirtual |
Definition at line 71 of file BasisFunction.h.
|
protected |
Allocates the sparsity pattern of the block-diagonal transition matrix.
Builds a stencil with a full nb_bfunc x nb_bfunc dense block for each element, then calls Matrix_tools::allocate_morse_matrix() to size transition_matrix_. The transition matrix is later filled by build_transition_matrix() with the Gram-Schmidt change-of-basis coefficients.
Definition at line 69 of file BasisFunction.cpp.
|
protected |
Computes the local L2 mass matrix M_ij = integral of phi_i * phi_j on element nelem.
| quad | Quadrature rule used for integration. |
| nelem | Index of the element. |
Definition at line 189 of file BasisFunction.cpp.
|
protected |
|
protected |
Computes and stores the Gram-Schmidt orthonormalization coefficients.
Iterates over all elements, evaluates the raw monomial basis at the element quadrature points, then calls gramSchmidt() to orthonormalize the basis in-place and record the change-of-basis coefficients in transition_matrix_. Sets is_orthonormalized_ to true upon completion.
Definition at line 97 of file BasisFunction.cpp.
|
protected |
Computes the SIP penalty stabilization parameters eta_elem and eta_facet.
Element parameters eta_elem(e) depend on the polynomial order and the element geometry:
Face parameters eta_facet(f) are derived from the adjacent element values:
Definition at line 671 of file BasisFunction.cpp.
| void BasisFunction::eval_bfunc | ( | const DoubleTab & | coords, |
| const int & | nelem, | ||
| DoubleTab & | fbasis ) const |
Evaluates all basis functions at a set of arbitrary coordinates.
Same polynomial evaluation as the quadrature-based overload but uses a caller-provided coordinate array instead of the quadrature point table. Useful for post-processing or point-wise evaluations.
| coords | Input coordinates array of shape (nb_points, dimension). |
| nelem | Element index (used for barycenter and mesh size). |
| fbasis | Output array of shape (nb_bfunc, nb_points), filled in-place. |
Definition at line 321 of file BasisFunction.cpp.
| void BasisFunction::eval_bfunc | ( | const Quadrature_base & | quad, |
| const int & | nelem, | ||
| DoubleTab & | fbasis ) const |
Evaluates all basis functions at the element quadrature points.
Fills fbasis(i, k) with the value of the i-th basis function at the k-th quadrature point of element nelem, using the scaled monomial basis centered at the element barycenter. If the basis is orthonormalized, the transition matrix is applied via orthonormalize().
| quad | Quadrature rule providing integration point coordinates. |
| nelem | Element index. |
| fbasis | Output array of shape (nb_bfunc, nb_pts_integ_max), filled in-place. |
Definition at line 226 of file BasisFunction.cpp.
| void BasisFunction::eval_bfunc_on_facets | ( | const Quadrature_base & | quad, |
| const int & | nelem, | ||
| const int & | num_face, | ||
| DoubleTab & | fbasis ) const |
Evaluates all basis functions of element nelem at the quadrature points of face num_face.
Same polynomial as eval_bfunc() but uses the face quadrature point coordinates instead of the element interior points. The basis is still centered at the element barycenter, so the evaluation is consistent with the interior values across the face. If the basis is orthonormalized, the transition matrix is applied via orthonormalize().
| quad | Quadrature rule providing face integration point coordinates. |
| nelem | Element index (provides barycenter and mesh size). |
| num_face | Face index (selects the row in the face quadrature point table). |
| fbasis | Output array of shape (nb_bfunc, nb_pts_integ_facets), filled in-place. |
Definition at line 456 of file BasisFunction.cpp.
| void BasisFunction::eval_div_bfunc | ( | const Quadrature_base & | quad, |
| const int & | nelem, | ||
| DoubleTab & | div_fbasis ) const |
Definition at line 370 of file BasisFunction.cpp.
| void BasisFunction::eval_div_bfunc_on_facets | ( | const Quadrature_base & | quad, |
| const int & | nelem, | ||
| const int & | num_face, | ||
| DoubleTab & | div_fbasis ) const |
Evaluates the divergence of the basis functions at the quadrature points of face num_face.
Computes the gradient via eval_grad_bfunc_on_facets() and then rearranges the result so that div_fbasis(d, i, k) = d(phi_i)/dx_d at the k-th face quadrature point. This permuted layout is used when assembling divergence-based operators.
| quad | Quadrature rule providing face integration point coordinates. |
| nelem | Element index. |
| num_face | Face index. |
| div_fbasis | Output array of shape (nb_bfunc, nb_pts_integ_facets), filled in-place. |
Definition at line 566 of file BasisFunction.cpp.
| void BasisFunction::eval_grad_bfunc | ( | const Quadrature_base & | quad, |
| const int & | nelem, | ||
| DoubleTab & | grad_fbasis ) const |
Evaluates the gradients of all basis functions at the element quadrature points.
Fills grad_fbasis(i, k, d) with the d-th component of grad(phi_i) at the k-th quadrature point of element nelem. The constant basis function (index 0) has a zero gradient (left implicitly as zero by the caller's initialization). If the basis is orthonormalized, the transition matrix is applied via orthonormalize().
| quad | Quadrature rule providing integration point coordinates. |
| nelem | Element index. |
| grad_fbasis | Output array of shape (nb_bfunc, nb_pts_integ_max, dimension), filled in-place. |
Definition at line 396 of file BasisFunction.cpp.
| void BasisFunction::eval_grad_bfunc_on_facets | ( | const Quadrature_base & | quad, |
| const int & | nelem, | ||
| const int & | num_face, | ||
| DoubleTab & | grad_fbasis ) const |
Evaluates the gradients of all basis functions of element nelem at the quadrature points of face num_face.
Same gradient formulas as eval_grad_bfunc() but evaluated at face quadrature points. Used in the SIP consistency and symmetry terms where the normal flux { nu * grad(phi_i) } . n must be integrated over a face. If the basis is orthonormalized, the transition matrix is applied via orthonormalize().
| quad | Quadrature rule providing face integration point coordinates. |
| nelem | Element index (provides barycenter and mesh size). |
| num_face | Face index (selects the row in the face quadrature point table). |
| grad_fbasis | Output array of shape (nb_bfunc, nb_pts_integ_facets, dimension), filled in-place. |
Definition at line 510 of file BasisFunction.cpp.
| const Matrice_Dense BasisFunction::eval_invMassMatrix | ( | const Quadrature_base & | quad, |
| const int & | nelem ) const |
Computes the inverse of the local L2 mass matrix for element nelem.
Two strategies are used depending on the polynomial order:
| quad | Quadrature rule used to compute the mass matrix entries. |
| nelem | Element index. |
Definition at line 594 of file BasisFunction.cpp.
|
inline |
Definition at line 76 of file BasisFunction.h.
|
inline |
Definition at line 119 of file BasisFunction.h.
|
inline |
Definition at line 120 of file BasisFunction.h.
|
inline |
Definition at line 75 of file BasisFunction.h.
|
protected |
Recursively orthonormalizes the local basis using the modified Gram-Schmidt process.
At step index, the function:
| fbase | Raw basis values at quadrature points (nb_bfunc x nb_pts_integ), modified in-place to become orthonormal. |
| quad | Quadrature rule used to compute inner products. |
| num_elem | Global element index (used to query the quadrature). |
| current_indice | First global DOF index of this element in transition_matrix_. |
| nb_pts_integ | Number of active quadrature points for this element. |
| volume | Volume of the element, used for normalization. |
| index | Current basis function index being orthonormalized (0-based). |
Definition at line 142 of file BasisFunction.cpp.
|
inline |
Definition at line 77 of file BasisFunction.h.
| void BasisFunction::initialize | ( | const Domaine_DG & | dom, |
| const int & | order, | ||
| const bool & | gram_schmidt ) |
Initializes the basis function object for a given DG domain and polynomial order.
Sets up the global DOF index table indices_glob_elem_, selects the default quadrature order (3 for order 1, 5 for order 2), and, if orthonormalization is requested, allocates and builds the block-diagonal transition matrix via allocate_transition_matrix() and build_transition_matrix(). Finally computes the element and face stabilization parameters via compute_stab_param().
| dom | The DG domain providing mesh geometry and connectivity. |
| order | Polynomial order of the basis (0, 1, or 2). |
| gram_schmidt | If true, the basis is L2-orthonormalized via Gram-Schmidt. |
Definition at line 34 of file BasisFunction.cpp.
|
inline |
Definition at line 102 of file BasisFunction.h.
|
protected |
|
protected |
Applies the pre-computed Gram-Schmidt transition matrix to a raw basis evaluation.
Iterates over basis functions in reverse order (exploiting the upper-triangular structure of the transition matrix) and replaces each raw value with the linear combination given by the corresponding row of transition_matrix_. Handles both 2D arrays (scalar basis: fbasis(i, k)) and 3D arrays (gradient basis: fbasis(i, k, d)).
| nelem | Element index, used to locate the block in transition_matrix_. |
| nb_pts_integ | Number of quadrature points to transform. |
| fbasis | Basis (or gradient) array to transform in-place. |
Definition at line 277 of file BasisFunction.cpp.
|
protected |
Definition at line 139 of file BasisFunction.h.
|
protected |
Definition at line 148 of file BasisFunction.h.
|
protected |
Definition at line 149 of file BasisFunction.h.
|
protected |
Definition at line 141 of file BasisFunction.h.
|
mutableprotected |
Definition at line 142 of file BasisFunction.h.
|
mutableprotected |
Definition at line 143 of file BasisFunction.h.
|
protected |
Definition at line 137 of file BasisFunction.h.
|
protected |
Definition at line 136 of file BasisFunction.h.
|
protected |
Definition at line 138 of file BasisFunction.h.
|
protected |
Definition at line 135 of file BasisFunction.h.
|
protected |
Definition at line 146 of file BasisFunction.h.