Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
BaseProfiledMatrixBuilder.h
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19// -*- C++ -*-
20#ifndef ALIEN_COMMON_SCALAR_PROFILEDMATRIXBUILDER_H
21#define ALIEN_COMMON_SCALAR_PROFILEDMATRIXBUILDER_H
22/* Author : havep at Tue Aug 28 13:56:24 2012
23 * Generated by createNew
24 */
25
26#include <alien/data/IMatrix.h>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Alien
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38template <typename Scalar>
39class SimpleCSRMatrix;
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
45{
46 enum ResetFlag
47 {
48 eKeepValues,
49 eResetValues
50 };
51};
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
56namespace Common
57{
58
59 /*---------------------------------------------------------------------------*/
60 /*---------------------------------------------------------------------------*/
61
62 class ALIEN_EXPORT ProfiledMatrixBuilder
63 {
64 public:
65 using ResetFlag = ProfiledMatrixOptions::ResetFlag;
66
67 public:
68 using MatrixElement = MatrixElementT<ProfiledMatrixBuilder>;
69
70 public:
71 ProfiledMatrixBuilder(IMatrix& matrix, ResetFlag reset_values);
72
73 virtual ~ProfiledMatrixBuilder();
74
75 ProfiledMatrixBuilder(const ProfiledMatrixBuilder&) = delete;
76 ProfiledMatrixBuilder(ProfiledMatrixBuilder&&) = delete;
77 ProfiledMatrixBuilder& operator=(const ProfiledMatrixBuilder&) = delete;
78 ProfiledMatrixBuilder& operator=(ProfiledMatrixBuilder&&) = delete;
79
80 public:
81 inline MatrixElement operator()(const Integer iIndex, const Integer jIndex)
82 {
83 return MatrixElement(iIndex, jIndex, *this);
84 }
85
86 Arccore::Real getData(Arccore::Integer iIndex, Arccore::Integer jIndex) const;
87
88 void addData(Arccore::Integer iIndex, Arccore::Integer jIndex, Arccore::Real value);
89
90 void addData(Arccore::Integer iIndex, Arccore::Real factor,
91 Arccore::ConstArrayView<Arccore::Integer> jIndexes,
92 Arccore::ConstArrayView<Arccore::Real> jValues);
93
94 void setData(Arccore::Integer iIndex, Arccore::Integer jIndex, Arccore::Real value);
95
96 void setData(Arccore::Integer iIndex, Arccore::Real factor,
97 Arccore::ConstArrayView<Arccore::Integer> jIndexes,
98 Arccore::ConstArrayView<Arccore::Real> jValues);
99
100 void finalize();
101
102 private:
103 bool isLocal(Integer jIndex) const
104 {
105 return (jIndex >= m_local_offset) && (jIndex < m_next_offset);
106 }
107
108 void _startTimer() {}
109 void _stopTimer() {}
110
111 private:
112 IMatrix& m_matrix;
113 SimpleCSRMatrix<Real>* m_matrix_impl;
114
115 Integer m_local_offset;
116 Integer m_local_size;
117 Integer m_next_offset;
118 ConstArrayView<Integer> m_row_starts;
119 ConstArrayView<Integer> m_cols;
120 ConstArrayView<Integer> m_local_row_size;
121 ArrayView<Real> m_values;
122 bool m_finalized;
123 };
124
125 /*---------------------------------------------------------------------------*/
126 /*---------------------------------------------------------------------------*/
127
128} // namespace Common
129
130/*---------------------------------------------------------------------------*/
131/*---------------------------------------------------------------------------*/
132
133} // namespace Alien
134
135/*---------------------------------------------------------------------------*/
136/*---------------------------------------------------------------------------*/
137
138#endif /* ALIEN_COMMON_SCALAR_PROFILEDMATRIXBUILDER_H */
IMatrix.h.
MatrixElement.h.
Interface for all matrices.
Definition IMatrix.h:51
Tool to manipulate a matrix entry while building the matrix.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17