12#include "AlephArcane.h"
15#include "arcane/IMesh.h"
16#include "arcane/VariableInfo.h"
17#include "arcane/ArcaneTypes.h"
18#include "arcane/utils/String.h"
19#include <arcane/IVariable.h>
20#include <arcane/IVariableMng.h>
22#include <arcane/utils/ArcanePrecomp.h>
24#define ALEPH_INDEX_NOT_USED (-1)
39AlephIndexing(AlephKernel* kernel)
40: TraceAccessor(kernel->parallel()->traceMng())
42, m_sub_domain(kernel->subDomain())
46 debug() <<
"\33[1;33m[AlephIndexing::AlephIndexing] NEW"
48 m_known_items_all_address.resize(0);
55updateKnownItems(VariableItemInt32* var_idx,
59 m_known_items_all_address.add(&(*var_idx)[itm]);
63 (*var_idx)[itm] = m_current_idx;
64 m_known_items_own += 1;
68 (*var_idx)[itm] = m_current_idx;
74 return m_current_idx - 1;
81findWhichLidFromMapMap(IVariable* var,
89 VarMapIdx::const_iterator iVarMap = m_var_map_idx.find(var);
92 if (iVarMap == m_var_map_idx.end()) {
95 String var_idx_name(var->name());
96 var_idx_name = var_idx_name + String(
"_idx");
99 var_idx_name,IVariable::PSubDomainDepend),
102 m_var_map_idx.insert(std::make_pair(var, var_idx));
104 var_idx->fill(ALEPH_INDEX_NOT_USED);
105 return updateKnownItems(var_idx, itm);
109 if ((*var_idx)[itm] == ALEPH_INDEX_NOT_USED) {
112 return updateKnownItems(var_idx, itm);
116 return (*var_idx)[itm];
123get(
const VariableRef& variable,
124 const ItemEnumerator& itm)
126 return get(variable, *itm);
128Int32 AlephIndexing::get(
const VariableRef& variable,
131 IVariable* var = variable.variable();
132 if (m_kernel->isInitialized()){
133 auto x = m_var_map_idx.find(var);
134 if (x==m_var_map_idx.end())
136 return (*x->second)[itm] - m_kernel->topology()->part()[m_kernel->rank()];
139 if (var->dimension() != 1)
140 throw ArgumentException(A_FUNCINFO,
"cannot get non-scalar variables!");
142 if (var->itemKind() >= IK_Unknown)
143 throw ArgumentException(A_FUNCINFO,
"Unknown Item Kind!");
145 return findWhichLidFromMapMap(var, itm);
152buildIndexesFromAddress(
void)
154 const Integer topology_row_offset = m_kernel->topology()->part()[m_kernel->rank()];
155 VarMapIdx::const_iterator iVarIdx = m_var_map_idx.begin();
156 debug() <<
"\33[1;7;33m[buildIndexesFromAddress] Re-inexing variables with offset " << topology_row_offset <<
"\33[m";
158 for (; iVarIdx != m_var_map_idx.end(); ++iVarIdx) {
159 ItemGroup group = iVarIdx->first->itemGroup();
163 if ((*var_idx)[itm] == ALEPH_INDEX_NOT_USED)
166 (*var_idx)[itm] += topology_row_offset;
168 debug() <<
"\t\33[1;7;33m[buildIndexesFromAddress] Synchronizing idx for variable " << iVarIdx->second->
name() <<
"\33[m";
169 iVarIdx->second->synchronize();
180 return m_known_items_own;
187nowYouCanBuildTheTopology(AlephMatrix* fromThisMatrix,
188 AlephVector* fromThisX,
189 AlephVector* fromThisB)
192 Integer lki = localKnownItems();
194 Integer gki = m_kernel->parallel()->reduce(Parallel::ReduceSum, lki);
195 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] Working with lki="
196 << lki <<
", gki=" << gki <<
"\33[m";
198 m_kernel->initialize(gki, lki);
201 debug() <<
"\33[1;7;33m[AlephIndexing::nowYouCanBuildTheTopology] Kernel is now initialized, rewinding Aleph operations!\33[m";
203 if (m_kernel->isParallel())
204 buildIndexesFromAddress();
206 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] asking kernel for a Matrix\33[m";
207 AlephMatrix* firstMatrix = m_kernel->createSolverMatrix();
208 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] asking kernel for a RHS Vector\33[m";
209 AlephVector* firstRhsVector = m_kernel->createSolverVector();
210 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] asking kernel for a LHS Vector\33[m";
211 AlephVector* firstLhsVector = m_kernel->createSolverVector();
212 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] firstMatrix->create()\33[m";
213 firstMatrix->create();
214 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] firstRhsVector->create()\33[m";
215 firstRhsVector->create();
216 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] firstLhsVector->create()\33[m";
217 firstLhsVector->create();
219 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] reSetValues fromThisMatrix\33[m";
220 fromThisMatrix->reSetValuesIn(firstMatrix,
221 m_known_items_all_address);
223 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] reAddValues fromThisMatrix\33[m";
224 fromThisMatrix->reAddValuesIn(firstMatrix,
225 m_known_items_all_address);
227 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] firstMatrix->assemble()\33[m";
228 firstMatrix->assemble();
230 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] firstRhsVector reSetLocalComponents/assemble\33[m";
231 firstRhsVector->reSetLocalComponents(fromThisB);
232 firstRhsVector->assemble();
233 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] firstLhsVector reSetLocalComponents/assemble\33[m";
234 firstLhsVector->reSetLocalComponents(fromThisX);
235 firstLhsVector->assemble();
236 debug() <<
"\33[1;33m[AlephIndexing::nowYouCanBuildTheTopology] nothing more to do here!\33[m";
245 debug() <<
"\t\33[1;33m[AlephIndexing::~AlephIndexing] deleting each new'ed VarMapIdx..."
247 VarMapIdx::const_iterator iVarIdx = m_var_map_idx.begin();
248 for (; iVarIdx != m_var_map_idx.end(); ++iVarIdx)
249 delete iVarIdx->second;
250 debug() <<
"\t\33[1;33m[AlephIndexing::~AlephIndexing] done!"
Fichier de configuration d'Arcane.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
String name() const
Nom de la variable.
ItemVariableScalarRefT< Int32 > VariableItemInt32
Grandeur de type entier 32 bits.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.