TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Op_Diff_DG_base.h
1/****************************************************************************
2* Copyright (c) 2025, 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 Op_Diff_DG_base_included
17#define Op_Diff_DG_base_included
18
19#include <Op_Diff_Turbulent_base.h>
20#include <Operateur_Diff_base.h>
21#include <Domaine_DG.h>
22#include <TRUST_Ref.h>
23#include <SFichier.h>
24#include <Champ_Uniforme.h>
25
26class Domaine_Cl_DG;
27/**
28 * @brief This class provides the common infrastructure shared by all DG diffusion operators in TRUST.
29 * It handles the association with the DG domain and its boundary conditions, the management of
30 * an effective diffusivity field (nu_), and the computation of a stable explicit time step.
31 *
32 * The stable time step calculation (calculer_dt_stab) follows a diffusive CFL criterion:
33 * dt ~ h^2 / (2 * dim * alpha_max)
34 * with special handling for:
35 * - Variable-density flows: rho * h^2 / (2 * dim * nu), with VDF-like and general mesh branches.
36 * - Robin / external-heat-exchange boundary conditions (Echange_externe_impose): the effective
37 * diffusivity is scaled by the Biot number when Bi > 1, making the criterion more conservative.
38 *
39 * Derived classes are responsible for implementing the actual flux assembly (ajouter()) according
40 * to their specific DG formulation.
41 */
43{
44 Declare_base(Op_Diff_DG_base);
45public:
46 void associer(const Domaine_dis_base&, const Domaine_Cl_dis_base&, const Champ_Inc_base&) override;
47
48 double calculer_dt_stab() const override;
49
50 void associer_diffusivite(const Champ_base& diffu) override
51 {
52 diffusivite_ = diffu;
53 is_var_ = sub_type(Champ_Uniforme, diffu) ? 0 : 1;
54 is_aniso_ = (diffu.nb_comp() > 1);
55 }
56
57 void completer() override;
58 const Champ_base& diffusivite() const override { return diffusivite_.valeur(); }
59 void mettre_a_jour(double t) override
60 {
62 nu_a_jour_ = 0;
63 }
64
65 void update_nu() const; //updates nu
66 inline double nu(int i, int compo) const { return nu_(is_var_ * i, compo); }
67
68 DoubleTab& calculer(const DoubleTab&, DoubleTab&) const override;
69 int impr(Sortie& os) const override;
70
71protected:
72 OBS_PTR(Domaine_DG) le_dom_dg_;
74 mutable SFichier Flux, Flux_moment, Flux_sum; // Output files .out
75
76 OBS_PTR(Champ_base) diffusivite_;
77 mutable int nu_a_jour_ = 0; //whether nu needs to be updated
78 mutable DoubleTab nu_;
79
80 bool is_var_; //if the diffusivity is Uniforme or heterogeneous
81 bool is_aniso_; //if the diffusivity is anisotropic
82
83};
84
85
86#endif /* Op_Diff_DG_base_included */
Class Champ_Inc_base.
Champ_Uniforme Represents a field that is constant in space and time.
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
virtual int nb_comp() const
Definition Field_base.h:56
This class provides the common infrastructure shared by all DG diffusion operators in TRUST....
OBS_PTR(Domaine_DG) le_dom_dg_
DoubleTab & calculer(const DoubleTab &, DoubleTab &) const override
Computes the diffusion operator applied to inco and stores the result in resu.
void associer_diffusivite(const Champ_base &diffu) override
double calculer_dt_stab() const override
Computes the maximum stable explicit time step for the diffusion operator.
int impr(Sortie &os) const override
DOES NOTHING - to override in derived classes.
void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &) override
Associates the operator with a DG domain and its boundary conditions.
void mettre_a_jour(double t) override
DOES NOTHING - to override in derived classes.
OBS_PTR(Domaine_Cl_DG) la_zcl_dg_
double nu(int i, int compo) const
void completer() override
Finalizes the operator setup after all associations have been made.
const Champ_base & diffusivite() const override
void update_nu() const
Updates the cached effective diffusivity field nu_ by combining molecular and turbulent contributions...
OBS_PTR(Champ_base) diffusivite_
Base class for diffusion operators in a turbulent flow.
Operateur_Diff_base This class is the base of the hierarchy of operators representing.
virtual void mettre_a_jour(double temps)
DOES NOTHING - to override in derived classes.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
Base class for output streams.
Definition Sortie.h:52