16#include <Adhoc_JFNK.h>
17#include <Schema_Euler_Semi_Implicite.h>
18#include <Schema_Cahn_Hilliard.h>
19#include <Fermeture_Thermo_base.h>
20#include <Potentiel_Chimique_base.h>
28 os <<
"--------------------------------------------------" << finl;
30 os <<
" -- residual threshold = " <<
tol_ << finl ;
31 os <<
" -- residue min = " <<
tol_min_ << finl;
32 os <<
" -- residue max = " <<
tol_max_ << finl;
33 os <<
" -- number of iterations = " <<
maxit_ << finl;
34 os <<
" -- Krylov space dimension = " <<
nkr_ << finl;
35 os <<
"--------------------------------------------------" << finl;
41 Cerr <<
"Reading parameters of " <<
que_suis_je() <<
" solver ..." << finl;
56 param.lire_avec_accolades_depuis(is);
68 const double delta = 1.e-5;
70 DoubleTrav c_autre_direction(c_theta);
72 c_autre_direction = v0;
73 c_autre_direction *= delta;
74 c_autre_direction += c_theta;
100 Cout <<
" -------- [Adhoc_JFNK] Solving..." << finl;
104 Cerr <<
"[Adhoc_JFNK] Cannot solve any other equation than Cahn_Hilliard yet. Needs to be generalized." << finl;
109 DoubleTrav c_n(inconnue);
110 DoubleTrav c_theta(inconnue);
119 DoubleTrav r(
nkr_ + 1);
120 DoubleTrav v0(c_theta);
121 DoubleTrav v1(c_theta);
131 res = mp_norme_vect(v0);
133 Cout <<
" - At it = " << 0 <<
", residu scalar = " << res << finl;
137 SFichier fichier_residu(
"residu.out", ios::app);
138 fichier_residu << statistics().get_time_since_last_open(STD_COUNTERS::total_execution_time)
149 Cout <<
"Stopping rule scalar : " <<
tol_min_ << finl;
152 for (
int it = 1; it <
maxit_+1; it++)
163 for (
int j = 0; j <
nkr_; j++)
174 for (
int i = 0; i <= j; i++)
177 DoubleTab& vvi = v[i];
178 h(i,j) += mp_prodscal(v0,vvi);
181 for (
int ii = 0; ii < v0.
dimension(0); ii++)
182 for (
int k = 0; k < nb_param; k++)
183 v0(ii, k) -= h(i,j) * vvi(ii, k);
188 double tem = mp_norme_vect(v0);
208 for (
int i = 0; i < nk; i++)
211 double tem = 1. / sqrt(h(i, i) * h(i, i) + h(iplus1, i) * h(iplus1, i));
212 double ccos = h(i, i) * tem;
213 double ssin = -h(iplus1, i) * tem;
214 for (
int j = i; j < nk; j++)
217 h(i, j) = ccos * tem - ssin * h(iplus1,j);
218 h(iplus1, j) = ssin * tem + ccos * h(iplus1,j);
220 r[iplus1] = ssin * r[i];
225 for (
int i = nk - 1; i >= 0; i--)
228 for (
int i0 = i - 1; i0 >= 0; i0--)
229 r[i0] -= h(i0, i) * r[i];
233 for(
int i=0; i<nk; i++)
235 DoubleTrav vvi = v[i];
237 for (
int ii = 0; ii < c_theta.
dimension(0); ii++)
238 for (
int k = 0; k < nb_param; k++)
239 c_theta(ii, k) += r[i] * vvi(ii, k);
248 res=mp_norme_vect(v0);
250 Cout <<
" - At it = " << it <<
", residu scalar = " << res << finl;
252 double temps_exec = statistics().get_time_since_last_open(STD_COUNTERS::total_execution_time);
255 SFichier fichier_residu(
"residu.out", ios::app);
269 Cerr <<
"Stopped before convergence" << finl;
bool iterer_eqn(Equation_base &equation, const DoubleTab &inconnue, DoubleTab &result, double dt, int numero_iteration, int &ok) override
Permet de résoudre l'équation non linéaire H(c) = c_theta - c_n - theta * dt * M^-1 * D * mu_theta = ...
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
DoubleTab jacobian_vect(const DoubleTab &, DoubleTab &, Cahn_Hilliard &)
Construire le jacobien.
void nommer(const Nom &name) override
Assigns a name to the Objet_U. Virtual method to override.
virtual DoubleTab fonction_residu(const DoubleTab &)
Construit la fonction résidu pour un algorithme de Newton :
Class defining operators and methods for all reading operation in an input flow (file,...
class Equation_base The role of an equation is the calculation of one or more fields....
Schema_Temps_base & schema_temps()
Returns the time scheme associated with the equation.
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
double temps_courant() const
Returns the current time.
class Solveur_non_lineaire
Base class for output streams.
_SIZE_ dimension(int d) const
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")