13#include "arcane/aleph/tests/AlephTest.h"
28: ArcaneAlephTestModuleObject(
mbi)
37, m_aleph_factory(
new AlephFactory(subDomain()->application(), traceMng()))
42, m_get_solution_idx(0)
43, m_fake_nb_iteration(0)
45 debug() <<
"\33[37m[AlephTestModule::AlephTestModule] Loading AlephTestModule\33[0m";
51 delete m_aleph_kernel;
52 delete m_aleph_params;
53 delete m_aleph_factory;
63 m_aleph_mat.resize(options()->alephNumberOfSolvers);
64 m_aleph_rhs.resize(options()->alephNumberOfSolvers);
65 m_aleph_sol.resize(options()->alephNumberOfSolvers);
68 m_local_nb_cell = MESH_OWN_ACTIVE_CELLS(mesh()).size();
69 m_total_nb_cell = subDomain()->parallelMng()->reduce(Parallel::ReduceSum, m_local_nb_cell);
70 debug() <<
"\33[37m[AlephTestModule::init] m_total_nb_cell=" << m_total_nb_cell
71 <<
", local=" << m_local_nb_cell <<
"\33[0m";
74 m_global_deltat = options()->deltaT;
78 m_cell_temperature[
icell] = options()->initTemperature();
80 m_face_temperature[
iFace] = options()->initTemperature();
84 m_sub_domain_id[
icell] = subDomain()->subDomainId();
86 m_unique_id[
icell] =
icell->uniqueId().asInteger();
89 options()->schema()->boundaries(options());
92 if ((options()->initAmr() < 0) || (options()->initAmr() > 1.0))
95 initAmrRefineMesh((Integer)(mesh()->cellFamily()->allItems().own().size() * options()->initAmr()));
96 mesh()->checkValidMeshFull();
105void AlephTestModule::
108 const Integer nb_row_size = m_total_nb_cell;
109 const Integer nb_row_rank = m_local_nb_cell;
114 info() <<
"[AlephTestModule::initAlgebra] ALEPH init, " << nb_row_size
115 <<
" lines in total, " << nb_row_rank <<
" for me";
116 info() <<
"[AlephTestModule::initAlgebra] alephUnderlyingSolver="
118 info() <<
"[AlephTestModule::initAlgebra] alephNumberOfCores="
119 << options()->alephNumberOfCores;
121 delete m_aleph_factory;
122 m_aleph_factory =
new AlephFactory(subDomain()->application(), traceMng());
126 delete m_aleph_kernel;
132 options()->alephNumberOfCores,
133 options()->alephCellOrdering);
137 const bool use_is_even = (subDomain()->parallelMng()->commSize() % 2) == 0;
145 m_aleph_kernel->solverInitializeArgs().setCommandLineArguments(args);
147 m_aleph_kernel->initialize(nb_row_size, nb_row_rank);
149 delete m_aleph_params;
153 TypesSolver::DIAGONAL,
165 "SolveErrorAlephMatrix.dbg",
174 TypesSolver::SymHybGSJ_smoother,
175 TypesSolver::ParallelRugeStuben,
176 TypesSolver::CG_coarse_solver,
183 m_cell_matrix_idx.fill(-1);
187 m_vector_indexs.resize(0);
188 m_vector_zeroes.resize(0);
189 m_vector_lhs.resize(0);
190 const AlephInt row_offset = m_aleph_kernel->topology()->part()[m_aleph_kernel->rank()];
194 m_vector_zeroes.add(0.0);
195 m_vector_lhs.add(0.0);
199 m_cell_matrix_idx.synchronize();
204 m_rows_nb_element.resize(nb_row_rank);
206 options()->schema()->preFetchNumElementsForEachRow(m_rows_nb_element,
207 m_aleph_kernel->topology()->part()[m_aleph_kernel->rank()]);
208 debug() <<
"\33[37m[AlephTestModule::initAlgebra] done\33[0m";
214void AlephTestModule::
220 debug() <<
"\33[37m[AlephTestModule::compute]\33[0m";
221 const Integer rank_offset = m_aleph_kernel->topology()->part()[m_aleph_kernel->rank()];
222 ItacFunction(AlephTestModule);
224 for (
int i = 0; i < options()->alephNumberOfSolvers; i += 1)
228 for (
int i = options()->alephNumberOfSolvers - 1; i >= 0; i -= 1) {
229 debug() <<
"\33[37m[AlephTestModule::compute] Getting solution #" << i <<
"\33[0m";
232 info() <<
"\33[37mSolved in \33[7m" <<
nb_iteration <<
"\33[m iterations,"
234 debug() <<
"\33[37m[AlephTestModule::compute] Applying solution #" << m_get_solution_idx <<
"\33[0m";
235 solution->getLocalComponents(m_vector_indexs.size(), m_vector_indexs.view(), m_vector_lhs.view());
236 m_get_solution_idx += 1;
238 m_get_solution_idx %= options()->alephNumberOfSolvers;
259 if (options()->alephDeleteKernel() ==
true) {
260 debug() <<
"\33[37m[AlephTestModule::compute] DELETE the KERNEL between each iteration"
266 debug() <<
"\33[37m[AlephTestModule::compute] Now get our results"
273 if (subDomain()->commonVariables().globalIteration() >= options()->iterations +
delta_amr)
274 subDomain()->timeLoopMng()->stopComputeLoop(
true);
276 debug() <<
"\33[37m[AlephTestModule::compute] done"
283void AlephTestModule::
284postSolver(
const Integer i)
286 ItacFunction(AlephTestModule);
287 debug() <<
"\33[37m[AlephTestModule::postSolver] #" << i <<
"\33[0m";
288 const Integer rank_offset = m_aleph_kernel->topology()->part()[m_aleph_kernel->rank()];
291 debug() <<
"\33[37m[AlephTestModule::postSolver] Remplissage du second membre"
293 m_vector_rhs.resize(0);
295 m_vector_rhs.add(m_cell_temperature[
iCell]);
298 debug() <<
"\33[37m[AlephTestModule::postSolver] ENUMERATE_FACE"
301 if (!
iFace->cell(0).isOwn())
304 options()->deltaT * (m_face_temperature[
iFace]) / geoFaceSurface(*
iFace, nodesCoordinates());
308 m_aleph_mat.setAt(i, m_aleph_kernel->createSolverMatrix());
309 m_aleph_rhs.setAt(i, m_aleph_kernel->createSolverVector());
310 m_aleph_sol.setAt(i, m_aleph_kernel->createSolverVector());
313 m_aleph_mat.at(i)->create();
314 m_aleph_rhs.at(i)->create();
315 m_aleph_sol.at(i)->create();
318 options()->schema()->setValues(options()->deltaT, m_aleph_mat.at(i));
319 m_aleph_mat.at(i)->assemble();
321 debug() <<
"\33[37m[AlephTestModule::postSolver] setLocalComponents"
323 m_aleph_rhs.at(i)->setLocalComponents(m_vector_indexs.size(), m_vector_indexs.view(), m_vector_rhs.view());
324 m_aleph_rhs.at(i)->assemble();
326 m_aleph_sol.at(i)->setLocalComponents(m_vector_indexs.size(), m_vector_indexs.view(), m_vector_zeroes.view());
327 m_aleph_sol.at(i)->assemble();
330 debug() <<
"\33[37m[AlephTestModule::postSolver] Now solve with Aleph"
332 m_aleph_mat.at(i)->solve(m_aleph_sol.at(i),
335 &m_fake_residual_norm[0],
343Real AlephTestModule::
355 return (
xyz0 -
xyz1).squareNormL2();
363void AlephTestModule::
366 ItacFunction(AlephTestModule);
375 if ((cell.
type() == IT_Hexaedron8) || (cell.
type() == IT_Quad4)) {
378 info(5) <<
"\t[amrRefineMesh] refine cell.uid=" << cell.
uniqueId();
384 info() <<
"now refine";
386 mesh()->modifier()->adapt();
397 for (Integer
j = 0,
js = CELL_NB_H_CHILDREN(cell);
j <
js; ++
j) {
399 m_cell_temperature[cells[CELL_H_CHILD(cell,
j).localId()]] = m_cell_temperature[cells[
lid]];
400 auto faces = allCells().view()[CELL_H_CHILD(cell,
j).localId()].
toCell().
faces();
402 for(
Face face : faces ){
405 m_face_temperature[face] = m_face_temperature[cell.
face(index)];
409 m_face_temperature[face] = 0;
420ARCANE_DEFINE_STANDARD_MODULE(AlephTestModule,
AlephTest);
Module de test pour Aleph.
Paramètres d'un système linéraire.
Vecteur d'un système linéaire.
Vue sur les informations des mailles.
FaceConnectedListViewType faces() const
Liste des faces de la maille.
Face face(Int32 i) const
i-ème face de la maille
Arguments de la ligne de commande.
bool isSubDomainBoundary() const
Indique si la face est au bord du sous-domaine (i.e nbCell()==1)
Node node(Int32 i) const
i-ème noeud de l'entité
Int32 nbNode() const
Nombre de noeuds de l'entité
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
Cell toCell() const
Converti l'entité en le genre Cell.
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
Int16 type() const
Type de l'entité
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Informations pour construire un module.
Classe gérant un vecteur de réel de dimension 3.
Exception lorsqu'une erreur fatale est survenue.
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.