TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Terme_Source_Qdm_Elem_DG.cpp
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#include <Terme_Source_Qdm_Elem_DG.h>
17#include <Neumann_sortie_libre.h>
18#include <Domaine_Cl_DG.h>
19#include <Neumann_homogene.h>
20#include <Domaine_DG.h>
21#include <Champ_Uniforme.h>
22#include <BasisFunction.h>
23#include <Equation_base.h>
24#include <Milieu_base.h>
25#include <Neumann.h>
26#include <Field_base.h>
27
28Implemente_instanciable(Terme_Source_Qdm_Elem_DG, "Source_Qdm_Elem_DG", Source_base);
29
31
32/**
33 * @brief Reads the momentum source term from the input stream.
34 * @details Reads the source field la_source (a Champ_Don_base), then discretizes it
35 * onto the DG quadrature representation la_source_DG (Champ_Fonc_Quad_DG) using the
36 * problem's discretization. la_source_DG is initialized to zero and then filled by
37 * affectation from la_source, pre-sampling the field at all quadrature points.
38 * @param s The input stream.
39 * @return The input stream.
40 */
42{
43 s >> la_source;
44 const int nb_comp = la_source->nb_comp();
45
46 Noms noms;
47 Noms unites;
48 noms.add("Terme_Source_DG");
49 unites.add("kg.m.s^-1");
50
51 equation().probleme().discretisation().discretiser_champ("champ_fonc_quad_dg", equation().domaine_dis(), Nature_du_champ::vectoriel, noms, unites,nb_comp,0., la_source_DG);
52 la_source_DG->valeurs() = 0.;
53 la_source_DG->affecter(la_source);
54
55 return s ;
56}
57
59{
60 le_dom_DG = ref_cast(Domaine_DG, domaine_dis);
61 le_dom_Cl_DG = ref_cast(Domaine_Cl_DG, domaine_Cl_dis);
62}
63
64/**
65 * @brief Assembles the momentum source contribution into the right-hand side.
66 *
67 * @details For each element and each velocity DOF (fb, d), computes:
68 * secmem(elem, fb + d*nb_bfunc) += integral of f_d(x) * phi_fb(x) dV
69 * using a fixed order-5 quadrature. The integrand at quadrature point k is:
70 * product(k) = la_source_DG(elem, k + d*nb_pts_integ_max) * fbase(fb, k)
71 * For Champ_Uniforme sources, element index 0 is used for all elements.
72 * No matrix contribution is made (source terms are purely explicit here).
73 *
74 * @param matrices Unused (no matrix contribution).
75 * @param secmem The momentum right-hand side to accumulate into.
76 * @param semi_impl Unused.
77 */
78void Terme_Source_Qdm_Elem_DG::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
79{
80 const Domaine_DG& dom = ref_cast(Domaine_DG, le_dom_DG.valeur());
81
82 int order = Option_DG::Get_order_for("vitesse");
83
84 const BasisFunction& bfunc = dom.get_basisFunction(order);
85 const int nb_bfunc = bfunc.nb_bfunc();
86
87 const Quadrature_base& quad = dom.get_quadrature(5);
88 int nb_pts_integ_max = quad.nb_pts_integ_max();
89
90 DoubleTab product(nb_pts_integ_max);
91
92 DoubleTab fbase(nb_bfunc, nb_pts_integ_max);
93
94 const int dim = Objet_U::dimension;
95
96 for (int elem = 0; elem < dom.nb_elem(); elem++)
97 {
98 bfunc.eval_bfunc(quad, elem, fbase);
99 for (int d = 0; d < dim; d++)
100 for (int fb = 0; fb < nb_bfunc; fb++)
101 {
102 for (int k = 0; k < quad.nb_pts_integ(elem) ; k++)
103 product(k) = la_source_DG->valeurs()(sub_type(Champ_Uniforme,la_source.valeur()) ? 0 : elem, k + d*nb_pts_integ_max) * fbase(fb, k);
104
105 secmem(elem, fb + d*nb_bfunc) += quad.compute_integral_on_elem(elem, product);
106 }
107 }
108}
109
111{
112 la_source->mettre_a_jour(temps);
113}
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
Champ_Uniforme Represents a field that is constant in space and time.
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Quadrature_base & get_quadrature(int order) const
Definition Domaine_DG.h:100
const BasisFunction & get_basisFunction(int order) const
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Probleme_base & probleme()
Returns the problem associated with the equation.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
Definition MorEqn.h:62
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static int Get_order_for(const Nom &n)
Definition Option_DG.cpp:70
const Discretisation_base & discretisation() const
Returns the discretization associated with the problem.
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
Compute the integral of a function on one triangle.
Base class for output streams.
Definition Sortie.h:52
Source_base A Source_base object is a term appearing on the right-hand side of an.
Definition Source_base.h:42
DG momentum source term for element-based velocity unknowns.
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
Assembles the momentum source contribution into the right-hand side.