Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AlephMatrix.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* AlephMatrix.h (C) 2000-2024 */
9/* */
10/*---------------------------------------------------------------------------*/
11#ifndef ARCANE_ALEPH_MATRIX_H
12#define ARCANE_ALEPH_MATRIX_H
13/*---------------------------------------------------------------------------*/
14/*---------------------------------------------------------------------------*/
15
16#include "arcane/aleph/AlephGlobal.h"
17
18#include <map>
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
31class ARCANE_ALEPH_EXPORT AlephMatrix
32: public TraceAccessor
33{
34 public:
35
36 explicit AlephMatrix(AlephKernel*);
37 ~AlephMatrix();
38
39 public:
40
41 void create(void);
42 void create(IntegerConstArrayView, bool = false);
43 void create_really(void);
44 void reset(void);
46 void reSetValuesIn(AlephMatrix*, Array<Int32*>&);
47 void reAddValuesIn(AlephMatrix*, Array<Int32*>&);
48 void updateKnownRowCol(Integer, Integer, Real);
49 void rowMapMapCol(Integer, Integer, Real);
50 void addValue(const VariableRef&, const Item&,
51 const VariableRef&, const Item&, const Real);
52 void addValue(const VariableRef&, const ItemEnumerator&,
53 const VariableRef&, const ItemEnumerator&, const Real);
54 void setValue(const VariableRef&, const Item&,
55 const VariableRef&, const Item&, const Real);
56 void setValue(const VariableRef&, const ItemEnumerator&,
57 const VariableRef&, const ItemEnumerator&, const Real);
58 void addValue(Integer, Integer, Real);
60 void writeToFile(const String);
61 void startFilling();
62 void assemble();
64 void reassemble(Integer&, Real*);
66 void solve(AlephVector*, AlephVector*, Integer&, Real*, AlephParams*, bool = false);
68
69 private:
70
71 AlephKernel* m_kernel = nullptr;
72 Integer m_index;
73 ArrayView<Integer> m_ranks;
74 bool m_participating_in_solver = false;
75 IAlephMatrix* m_implementation = nullptr;
76
77 private:
78
79 // Matrix used when we are the solver
80 MultiArray2<AlephInt> m_aleph_matrix_buffer_rows;
81 MultiArray2<AlephInt> m_aleph_matrix_buffer_cols;
82 MultiArray2<Real> m_aleph_matrix_buffer_vals;
83 // Buffers for setValues
84 Integer m_setValue_idx;
85 UniqueArray<AlephInt> m_setValue_row;
86 UniqueArray<AlephInt> m_setValue_col;
87 UniqueArray<Real> m_setValue_val;
88
89 private:
90
91 // Buffers for addValues
92 typedef std::map<Integer, Integer> colMap;
93 typedef std::map<Integer, colMap*> rowColMap;
94 rowColMap m_row_col_map;
95 Integer m_addValue_idx;
96 UniqueArray<Integer> m_addValue_row;
97 UniqueArray<Integer> m_addValue_col;
98 UniqueArray<Real> m_addValue_val;
99
100 private: // Arrays of requests
101
102 UniqueArray<Parallel::Request> m_aleph_matrix_mpi_data_requests;
103 UniqueArray<Parallel::Request> m_aleph_matrix_mpi_results_requests;
104
105 private: // Results. Placed here to keep them outside the scope of the functions using them
106
107 UniqueArray<Int32> m_aleph_matrix_buffer_n_iteration;
108 UniqueArray<Real> m_aleph_matrix_buffer_residual_norm;
109};
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
114} // End namespace Arcane
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
118
119#endif
void solve(AlephVector *, AlephVector *, Integer &, Real *, AlephParams *, bool=false)
'Post' the solver to the scheduler asynchronously or not
void reSetValuesIn(AlephMatrix *, Array< Int32 * > &)
reSetValuesIn re-plays the setValue with the indexes calculated via the AlephIndexing
void startFilling()
Allows specifying the start of a filling phase.
void solveNow(AlephVector *, AlephVector *, AlephVector *, Integer &, Real *, AlephParams *)
Solves the linear system.
void create_really(void)
create_really transmits the creation order to the external library
void setValue(const VariableRef &, const Item &, const VariableRef &, const Item &, const Real)
setValue from arguments in IVariables, Items, and Real
void reset(void)
reset to flush the [set&add]Value arrays
void reassemble(Integer &, Real *)
Triggers the order of retrieving results.
void reAddValuesIn(AlephMatrix *, Array< Int32 * > &)
reAddValuesIn re-plays the addValue with the indexes calculated via the AlephIndexing
void assemble()
assemble the matrices before resolution
void writeToFile(const String)
Triggers the writing of the matrix to a file.
Integer reIdx(Integer, Array< Int32 * > &)
reIdx searches for the correspondence of the AlephIndexing
void reassemble_waitAndFill(Integer &, Real *)
Synchronizes the reception of results.
void assemble_waitAndFill()
assemble_waitAndFill waits for the previously posted requests to be processed
Parameters of a linear system.
Definition AlephParams.h:32
Vector of a linear system.
Definition AlephVector.h:33
Modifiable view of an array of type T.
Base class for 1D data vectors.
Enumerator over a list of entities.
Base class for a mesh element.
Definition Item.h:84
Base class for multi-sized 2D arrays.
Definition MultiArray2.h:60
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
Reference to a variable.
Definition VariableRef.h:56
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
ConstArrayView< Integer > IntegerConstArrayView
C equivalent of a 1D array of integers.
Definition UtilsTypes.h:486