TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Eval_Puiss_Th_DG_Elem.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Eval_Puiss_Th_DG_Elem_included
17#define Eval_Puiss_Th_DG_Elem_included
18
19#include <Evaluateur_Source_Elem.h>
20#include <Champ_Uniforme.h>
21#include <Equation_base.h>
22#include <Champ_Don_base.h>
23#include <TRUST_Ref.h>
24#include <TRUSTTab.h>
25#include <Champ_Elem_DG.h>
26#include <Domaine_DG.h>
27#include <BasisFunction.h>
28
29/**
30 * @brief Evaluator computing the volumetric heat source contribution for DG element unknowns.
31 *
32 * For each element e, this evaluator computes the projection of the volumetric heat
33 * power density Q onto each basis function phi_i:
34 * S(i) = integral of Q(x) * phi_i(x) dV
35 * using a fixed order-5 quadrature rule. The power field Q is expected to be
36 * pre-evaluated at the quadrature points and stored in the puissance array
37 * (shape: nb_elem x nb_pts_integ_max), as set up by associer_champs().
38 *
39 * calculer_terme_source() is templated on Type_Double to allow both scalar and
40 * small-vector output types
41 *
42 * @sa Terme_Puissance_Thermique_DG_Elem, Evaluateur_Source_Elem
43 */
45{
46public:
47 void mettre_a_jour() override { }
49
50 template <typename Type_Double>
51 inline void calculer_terme_source(const int, Type_Double&) const;
52
53protected:
54 OBS_PTR(Champ_Don_base) la_puissance;
55 DoubleTab puissance;
56};
57
58/**
59 * @brief Computes the heat source projection onto the local DG basis for element e.
60 *
61 * @details Evaluates the integral S(fb) = integral of Q * phi_fb over element e
62 * using a fixed order-5 quadrature. The integrand at each quadrature point k is:
63 * product(k) = puissance(e, k) * fbase(fb, k)
64 * where puissance contains Q pre-sampled at quadrature points and fbase contains
65 * the basis function values from eval_bfunc().
66 *
67 * @tparam Type_Double Output type (typically a fixed-size array of nb_bfunc values).
68 * @param e Element index.
69 * @param S Output array of size nb_bfunc, filled with the projected source values.
70 */
71template <typename Type_Double>
72inline void Eval_Puiss_Th_DG_Elem::calculer_terme_source(const int e, Type_Double& S) const
73{
74 const Champ_Elem_DG& ch = ref_cast(Champ_Elem_DG, la_zcl->inconnue());
75 const Nom& nom_inc = ch.le_nom();
76
77 const Domaine_DG& dom = ref_cast(Domaine_DG, le_dom.valeur());
78
79 int order = Option_DG::Get_order_for(nom_inc);
80
81 const BasisFunction& bfunc = dom.get_basisFunction(order);
82 const int nb_bfunc = bfunc.nb_bfunc();
83
84 const Quadrature_base& quad = dom.get_quadrature(5);
85 int nb_pts_integ_max = quad.nb_pts_integ_max();
86
87 DoubleTab product(nb_pts_integ_max);
88
89 DoubleTab fbase(nb_bfunc, nb_pts_integ_max);
90 bfunc.eval_bfunc(quad, e, fbase);
91
92 for (int fb = 0; fb < nb_bfunc; fb++)
93 {
94 for (int k = 0; k < quad.nb_pts_integ(e) ; k++)
95 product(k) = puissance(e,k) * fbase(fb, k);
96
97 S(fb) = quad.compute_integral_on_elem(e, product);
98 }
99}
100
101#endif /* Eval_Puiss_Th_DG_Elem_included */
Manages the local polynomial basis functions for Discontinuous Galerkin elements.
void eval_bfunc(const Quadrature_base &quad, const int &nelem, DoubleTab &fbasis) const
Evaluates all basis functions at the element quadrature points.
const int & nb_bfunc() const
classe Champ_Don_base classe de base des Champs donnes (non calcules)
const Quadrature_base & get_quadrature(int order) const
Definition Domaine_DG.h:100
const BasisFunction & get_basisFunction(int order) const
Evaluator computing the volumetric heat source contribution for DG element unknowns.
OBS_PTR(Champ_Don_base) la_puissance
void associer_champs(const Champ_Don_base &)
void calculer_terme_source(const int, Type_Double &) const
Computes the heat source projection onto the local DG basis for element e.
const Nom & le_nom() const override
Renvoie le nom du champ.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int Get_order_for(const Nom &n)
Definition Option_DG.cpp:70
int nb_pts_integ(int e) const
int nb_pts_integ_max() const
double compute_integral_on_elem(int num_elem, Parser_U &parser) const