TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Convection_Diffusion_Phase_field.cpp
1/****************************************************************************
2* Copyright (c) 2021, 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 <Convection_Diffusion_Phase_field.h>
17#include <Navier_Stokes_phase_field.h>
18#include <Frontiere_dis_base.h>
19#include <Milieu_Phase_field.h>
20#include <Matrice_Morse_Sym.h>
21#include <Probleme_base.h>
22#include <Fluide_base.h>
23#include <Discret_Thyd.h>
24#include <TRUSTTrav.h>
25#include <Param.h>
26
27//#include <Mass_Redistribution_Phase_Field.h>
28
29Implemente_instanciable(Convection_Diffusion_Phase_field,"Convection_Diffusion_Phase_field",Convection_Diffusion_Concentration);
30// XD convection_diffusion_phase_field convection_diffusion_concentration convection_diffusion_phase_field INHERITS_BRACE Cahn-Hilliard equation of the Phase Field problem. The unknown of this equation is the concentration C.
31// XD attr mu_1 floattant mu_1 OPT Dynamic viscosity of the first phase.
32// XD attr mu_2 floattant mu_2 OPT Dynamic viscosity of the second phase.
33// XD attr rho_1 floattant rho_1 OPT Density of the first phase.
34// XD attr rho_2 floattant rho_2 OPT Density of the second phase.
35// XD attr potentiel_chimique_generalise chaine(into=["avec_energie_cinetique","sans_energie_cinetique"]) potentiel_chimique_generalise REQ To define (chaine set to avec_energie_cinetique) or not (chaine set to sans_energie_cinetique) if the Cahn-Hilliard equation contains the cinetic energy term.
36
38{
40}
41
43{
45}
46
48{
50 param.ajouter_non_std("potentiel_chimique_generalise", (this), Param::REQUIRED);
51}
52
54{
55 if (mot == "potentiel_chimique_generalise")
56 {
57 Motcle temp_mutype_;
58 is >> temp_mutype_;
59 if (temp_mutype_ == "avec_energie_cinetique")
60 mutype_ = 1;
61 else if (temp_mutype_ == "sans_energie_cinetique")
62 mutype_ = 0;
63 else
64 Process::exit("Allowed keywords for potentiel_chimique_generalise are : avec_energie_cinetique or sans_energie_cinetique");
65 return 1;
66 }
67 else if (mot=="diffusion")
68 {
69 /*
70 * XXX : Elie Saikali : on pirate l'att terme_diffusif pour forcer a negligeable ... eviter des soucis.
71 * et ce qu'on trouve dans le jdd on passe a terme_diffusif_bidon_
72 */
73 Cerr << "Reading and typing of the diffusion operator of Convection_Diffusion_Phase_field : " << finl;
74 EChaine ngl(" { negligeable }");
75 terme_diffusif.associer_diffusivite(diffusivite_pour_transport());
76 ngl >> terme_diffusif;
77 terme_diffusif.associer_diffusivite_pour_pas_de_temps(diffusivite_pour_pas_de_temps());
78
79 Cerr << "Reading and typing a useless diffusion operator from data file : " << finl;
80 Operateur_Diff terme_diffusif_bidon_;
81 terme_diffusif_bidon_.associer_eqn(*this);
82 terme_diffusif_bidon_.associer_diffusivite(diffusivite_pour_transport());
83 is >> terme_diffusif_bidon_;
85 return 1;
86 }
87 else
89}
90
91/*! @brief Discretise l'equation.
92 *
93 */
95{
96 const Discret_Thyd& dis = ref_cast(Discret_Thyd, discretisation());
97 const Milieu_Phase_field& mil = ref_cast(Milieu_Phase_field, le_fluide_.valeur());
99
100 Cerr << "Discretisation de mutilde " << finl;
101 dis.discretiser_champ("temperature", domaine_dis(), "potentiel_chimique_generalise", ".", nb_constituants_, schema_temps().temps_courant(), ch_mutilde_);
102 champs_compris_.ajoute_champ(ch_mutilde_);
103
104 const Navier_Stokes_std& eq_ns = ref_cast(Navier_Stokes_std, probleme().equation(0));
105 gradient_.associer_eqn(eq_ns);
106 gradient_.typer();
107 gradient_.l_op_base().associer_eqn(*this);
108
109 /*
110 * XXX Elie Saikali : on saute la classe mere ...
111 */
112 Cerr << "Transport concentration(s) equation discretization " << finl;
113 dis.concentration(schema_temps(), domaine_dis(), la_concentration, nb_constituants_);
114 champs_compris_.ajoute_champ(la_concentration);
116
117 Cerr << "Convection_Diffusion_Phase_field::discretiser() ok" << finl;
118}
119
125
134
136{
137 /*
138 * XXX Elie Saikali : on saute la classe mere ...
139 */
141
142 Cerr << "Convection_Diffusion_Phase_field::preparer_calcul" << finl;
143
144 // ATTENTION : avec le nouveau modele, on n'utilise plus div_alpha_rho_gradC mais
145 // div_alpha_gradC. Si on veut reutiliser l'ancienne forme, il faut remodifier le code.
146
147 // mutilde, div_alpha_gradC, alpha_gradC_carre et pression_thermo
148 // ont la meme structure que la concentration
149
151 mutilde_ = 0.;
152
153 //Mass_Redistribution_Phase_Field::c_ini = inconnue().valeurs();//Mass_redistribution
154
155 // si on traite une variable avec "dis." (voir discretiser()), l'operation "resize" est inutile car "dis." s'en charge.
156 // En sequentiel : resize() autorise
157 // En parallele : resize() interdit, car alors on ne prend pas en compte les joints
158
161
163 div_alpha_gradC_ = 0.;
164
166
167 sources().mettre_a_jour(schema_temps().temps_courant());
168 return 1;
169}
170
172{
173 le_fluide_ = ref_cast(Fluide_base, mil);
174}
175
177{
178 return le_fluide_->viscosite_cinematique(); /* inutile */
179}
180
182{
183 return le_fluide_.valeur();
184}
185
187{
188 return le_fluide_.valeur();
189}
190
class Champ_Don_base base class of Given Fields (not calculated)
DoubleTab & valeurs() override
Returns the array of field values at the current time.
Convection_Diffusion_Concentration Special case of Convection_Diffusion_std.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
const Champ_Inc_base & inconnue() const override
Returns the unknown field of the equation: the concentration.
classe Convection_Diffusion_Phase_field Cas particulier de Convection_Diffusion_Concentration
void discretiser() override
Discretise l'equation.
int preparer_calcul() override
Everything that does not depend on other possible problems.
void completer() override
Completes the construction (initialization) of objects associated with the equation.
void mettre_a_jour(double) override
The value of the unknown at the time step has been calculated.
void associer_milieu_base(const Milieu_base &) override
Associates a physical medium to the equation; the medium is cast to Constituant and associated with t...
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
const Champ_Don_base & diffusivite_pour_transport() const override
const Milieu_base & milieu() const override
Returns the physical medium of the equation.
virtual const Champ_base & diffusivite_pour_pas_de_temps() const
class Discret_Thyd This class is the base class representing a discretization
void concentration(const Schema_Temps_base &, Domaine_dis_base &, OWN_PTR(Champ_Inc_base)&, int=1, const Nom nom_champ="concentration") const
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
An input stream whose source is a character string.
Definition EChaine.h:31
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Sources & sources()
Returns the source terms associated with the equation.
const Discretisation_base & discretisation() const
Returns the discretization associated with the equation.
virtual void mettre_a_jour(double temps)
The value of the unknown at the time step has been calculated.
virtual void completer()
Completes the construction (initialization) of objects associated with the equation.
virtual int preparer_calcul()
Everything that does not depend on other possible problems.
Probleme_base & probleme()
Returns the problem associated with the equation.
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
virtual void discretiser()
Discretizes the equation.
Champs_compris champs_compris_
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
const Fermeture_Phase_field_base & get_fermeture() const
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
void associer_eqn(const Equation_base &)
Associates an equation with the object.
Definition MorEqn.cpp:28
A character string (Nom) in uppercase.
Definition Motcle.h:26
Navier_Stokes_std This class carries the terms of the momentum equation.
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
Operateur_Diff Generic class of the hierarchy of operators representing a diffusion.
void associer_diffusivite_pour_pas_de_temps(const Champ_base &)
void associer_diffusivite(const Champ_base &)
Associates the diffusivity to the operator.
Classe Operateur_Grad Generic class of the hierarchy of operators computing the gradient.
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
@ REQUIRED
Definition Param.h:115
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
void mettre_a_jour(double temps)
Time update of all sources in the list.
Definition Sources.cpp:109