TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Multigrille_Adrien.cpp
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#include <Param.h>
17#include <Parser.h>
18#include <TRUSTArray.h>
19#include <Multigrille_Adrien.h>
20#include <communications.h>
21#include <Domaine.h>
22#include <Schema_Comm.h>
23#include <IJK_VDF_converter.h>
24#include <Interprete_bloc.h>
25#include <Perf_counters.h>
26#include <SSE_kernels.h>
27using namespace SSE_Kernels;
28
29Implemente_instanciable_sans_constructeur(Multigrille_Adrien, "Solv_Multigrille_Adrien", Multigrille_base);
30
32{
33 return os;
34}
35
37{
38 ghost_size_ = 1;
39}
40
42{
43 param.ajouter("ghost_size", &ghost_size_);
44 param.ajouter("coarsen_operators", &coarsen_operators_);
45
47}
48
50{
51 Nom ijkdis_name;
52 Param param(que_suis_je());
53 ajouter_param(param);
54 param.ajouter("ijkdis_name", &ijkdis_name);
55 param.lire_avec_accolades(is);
56
57 if (ijkdis_name != Nom())
58 {
59 const IJK_VDF_converter& ijkdis = ref_cast(IJK_VDF_converter, Interprete_bloc::objet_global(ijkdis_name));
60 const Domaine_IJK& split = ijkdis.get_domaine();
61
62 initialize(split);
63 }
64 return is;
65}
66
68{
69 // fait dans readOn si on a lu ijkdis_name
70 // fetch the vdf_to_ijk translator (assume there is one unique object, with conventional name)
71 const Nom& ijkdis_name = IJK_VDF_converter::get_conventional_name();
72 const IJK_VDF_converter& ijkdis = ref_cast(IJK_VDF_converter, Interprete_bloc::objet_global(ijkdis_name));
73 const Domaine_IJK& split = ijkdis.get_domaine();
74
75 initialize(split);
76
77 return 1;
78}
79
105
106// Says that the Poisson equation has variable coefficient rho, given at elements
107// Must be called in parallel.
108// (the function converts the given field to ijk ordering, computes the coarsened
109// rho fields, the matrix coefficients with boundary conditions for all levels
110// and the coarse matrix for the coarse grid solver).
111void Multigrille_Adrien::set_rho(const DoubleVect& rho)
112{
113 statistics().create_custom_counter("Multigrid_Adrien::set_rho",2,"IJK");
114 statistics().begin_count("Multigrid_Adrien::set_rho",statistics().get_last_opened_counter_level()+1);
116 {
117 IJK_Field_double ijk_rho(grids_data_double_[0].get_update_rho());
118 convert_to_ijk(rho, ijk_rho);
119 set_rho(ijk_rho);
120 }
121 else
122 {
123 IJK_Field_float ijk_rho(grids_data_float_[0].get_update_rho());
124 convert_to_ijk(rho, ijk_rho);
125 set_rho(ijk_rho);
126 }
127 statistics().end_count("Multigrid_Adrien::set_rho");
128}
129
130
132{
133 return nsweeps_jacobi_residu(level);
134}
135
137{
138 Cerr << "Multigrille_Adrien::completer_double_for_residue" << finl;
139 grids_data_double_.dimensionner(1);
140 grids_data_double_[0].initialize(splitting, ghost_size_, nsweeps_jacobi_residu(0));
141}
142
144{
145 IJK_Field_double& b = get_storage_double(STORAGE_RHS, 0);
146 IJK_Field_double& x = get_storage_double(STORAGE_X, 0);
147 IJK_Field_double& residu = get_storage_double(STORAGE_RESIDUE, 0);
148
149 set_coarse_matrix().build_matrix(set_grid_data<double>(0).get_faces_coefficients());
150 coarse_solver(x, b);
151 jacobi_residu(x, &b, 0, 0 /* not jacobi */, &residu);
152 return norme_ijk(residu);
153}
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
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....
void allocate(const Domaine_IJK &d, Domaine_IJK::Localisation l, int ghost_size, int additional_k_layers=0, int nb_compo=1, const Nom &name=Nom(), bool external_storage=false, int monofluide=0, double rov=0., double rol=0., int use_inv_rho_in_pressure_solver=0)
static const char * get_conventional_name()
const Domaine_IJK & get_domaine() const
static Objet_U & objet_global(const Nom &nom)
cherche l'objet demande dans l'Interprete_bloc courant (Interprete_bloc::interprete_courant()) et dan...
void build_matrix(const IJK_Field_template< _TYPE_, _TYPE_ARRAY_ > &coeffs_face)
int completer(const Equation_base &eq)
void ajouter_param(Param &param) override
void set_rho(const DoubleVect &rho)
void completer_double_for_residue(const Domaine_IJK &splitting)
IJK_Field_double & get_storage_double(StorageId si, int level) override
int needed_kshift_for_jacobi(int level) const override
void jacobi_residu(IJK_Field_float &x, const IJK_Field_float *secmem, const int grid_level, const int n_jacobi, IJK_Field_float *residu) const override
double multigrille_failure() override
void initialize(const Domaine_IJK &)
void completer_template(const Domaine_IJK &)
virtual void ajouter_param(Param &)
void convert_to_ijk(const DoubleVect &x, IJK_Field_template< _TYPE_, _TYPE_ARRAY_ > &ijk_x)
const int precision_double_
Matrice_Grossiere & set_coarse_matrix()
int nsweeps_jacobi_residu(int level) const
void coarse_solver(IJK_Field_template< _TYPE_, _TYPE_ARRAY_ > &x, const IJK_Field_template< _TYPE_, _TYPE_ARRAY_ > &b)
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
Classe de base des flux de sortie.
Definition Sortie.h:52