TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Pb_Cahn_Hilliard_Navier_Stokes.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
17#include <Pb_Cahn_Hilliard_Navier_Stokes.h>
18#include <Schema_Cahn_Hilliard_Navier_Stokes.h>
19
20// XD pb_cahn_hilliard_navier_stokes pb_base pb_cahn_hilliard_navier_stokes INHERITS_BRACE Problem coupling the
21// XD_CONT Cahn-Hilliard phase-field equation with a variable-density Navier-Stokes flow.
22// XD attr Milieu_Incompressible_Phase_Field bloc_lecture Milieu_Incompressible_Phase_Field REQ Phase-field
23// XD_CONT incompressible medium (rho, mu, beta_co, fermeture, …).
24// XD attr Navier_Stokes_Variable_Density bloc_lecture Navier_Stokes_Variable_Density OPT Variable-density Navier-Stokes
25// XD_CONT equation block (pressure solver, convection, diffusion, boundary conditions, …). Use this variant or
26// XD_CONT Navier_Stokes_standard.
27// XD attr Navier_Stokes_standard bloc_lecture Navier_Stokes_standard OPT Constant-density (standard) Navier-Stokes
28// XD_CONT equation block. Use this variant or Navier_Stokes_Variable_Density.
29// XD attr Cahn_Hilliard_Convection bloc_lecture Cahn_Hilliard_Convection REQ Cahn-Hilliard transport equation with
30// XD_CONT convection (convection, boundary conditions on c and on the chemical potential, …).
31Implemente_instanciable( Pb_Cahn_Hilliard_Navier_Stokes, "Pb_Cahn_Hilliard_Navier_Stokes", Pb_Fluide_base ) ;
32
34{
36 return os;
37}
38
40{
42 return is;
43}
44
46{
47 assert((i == 0) || (i == 1));
48 if (nb_equations == 2 && i == 0)
49 return eq_navier_stokes;
50 else
51 return eq_cahn_hilliard;
52}
53
55{
56 assert((i == 0) || (i == 1));
57 if (nb_equations == 2 && i == 0)
58 return eq_navier_stokes;
59 else
60 return eq_cahn_hilliard;
61}
62
64{
65// Pb_Fluide_base::lire_equations(is, mot);
66 nb_equations = 2; // we can set the number of equations because, now, the Navier-Stokes equation will be typed
67 const int nb_eq = nombre_d_equations();
68 is >> mot;
69 if (nb_eq == 0)
70 return is;
71 Cerr << "Reading of the equations" << finl;
72 bool already_read = true;
73 if (mot == "correlations")
74 {
76 already_read = false;
77 }
78 for (int i = 0; i < nb_eq; i++)
79 {
80 if (!already_read)
81 is >> mot;
82 if (mot.debute_par("Navier_Stokes"))
83 {
84 Cout << "[Pb_Cahn_Hilliard_Navier_Stokes]: the selected Navier-Stokes equations is " << mot << finl;
85 // here, we have to do the for the selected Navier-Stokes equation in the same ways as for an optional equation (see Probleme_base::read_optional_equations)
86 eq_navier_stokes.typer(mot);
87 eq_navier_stokes->associer_pb_base(*this);
88 eq_navier_stokes->associer_milieu_base(le_milieu_[0]);
89 const Schema_Temps_base& schema_convection = ref_cast(Schema_Cahn_Hilliard_Navier_Stokes, le_schema_en_temps_.valeur()).get_schema_convection();
90 eq_navier_stokes->associer_sch_tps_base(schema_convection);
91 eq_navier_stokes->associer_domaine_dis(domaine_dis());
92 eq_navier_stokes->discretiser();
93 is >> eq_navier_stokes.valeur();
94 eq_navier_stokes->associer_milieu_equation();
95 }
96 else
97 {
98 is >> getset_equation_by_name(mot);
99 }
100 already_read = false;
101 }
103 //
104 // the two source terms that are associated with the coupling with Cahn-Hilliard equation are added in the Navier-Stokes equation source term list
105 Cout << "[Pb_Cahn_Hilliard_Navier_Stokes]: adding capillary force in Navier-Stokes equation"<< finl;
106 Source force_capillaire;
107 Source& ref_force_capillaire = eq_navier_stokes->sources().add(force_capillaire);
108 ref_force_capillaire.typer("Source_Force_Capillaire", eq_navier_stokes);
109 ref_force_capillaire->associer_eqn(eq_navier_stokes);
110 if (milieu().a_gravite())
111 {
112 Cout << "[Pb_Cahn_Hilliard_Navier_Stokes]: adding gravity force in Navier-Stokes equation"<< finl;
113 Source force_gravite;
114 Source& ref_force_gravite = eq_navier_stokes->sources().add(force_gravite);
115 if (sub_type(Navier_Stokes_Variable_Density, eq_navier_stokes.valeur()))
116 {
117 ref_force_gravite.typer("Gravite", eq_navier_stokes);
118 }
119 else
120 {
121 ref_force_gravite.typer("Source_Force_Boussinesq", eq_navier_stokes);
122 }
123 ref_force_gravite->associer_eqn(eq_navier_stokes);
124 }
125 return is;
126}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Equation_base Le role d'une equation est le calcul d'un ou plusieurs champs....
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
: class Navier_Stokes_Variable_Density
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
: class Pb_Cahn_Hilliard_Navier_Stokes
const Equation_base & equation(int) const override
Entree & lire_equations(Entree &is, Motcle &mot) override
Lecture des equations du probleme.
classe Pb_Fluide_base Cette classe a pour but de disposer d une classe amont pour
virtual Entree & lire_correlations(Entree &is)
Entree & read_optional_equations(Entree &is, Motcle &mot)
std::vector< OWN_PTR(Milieu_base)> le_milieu_
virtual const Milieu_base & milieu() const
Renvoie le milieu physique associe au probleme.
const Domaine_dis_base & domaine_dis() const
Renvoie le domaine discretise associe au probleme.
virtual Equation_base & getset_equation_by_name(const Nom &)
(B. Math): Methode virtuelle ajoutee pour les problemes ayant plusieurs equations de meme type (Probl...
class Schema_Temps_base
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Source Classe generique de la hierarchie des sources, un objet Source peut
Definition Source.h:33
void typer(const Nom &, const Equation_base &)
Type la source en calculant le nom du type necessaire grace aux parametres fournis.
Definition Source.cpp:52