Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
BaseBlockVectorReader.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#pragma once
20
21#include <alien/utils/Precomp.h>
22
23#include <arccore/base/FatalErrorException.h>
24#include <arccore/base/TraceInfo.h>
25
28#include <alien/data/IVector.h>
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34namespace Alien
35{
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40template <typename T>
41class SimpleCSRVector;
42
43/*---------------------------------------------------------------------------*/
44/*---------------------------------------------------------------------------*/
45
46namespace Common
47{
48
49 template <typename ValueT, typename Parameters>
50 class BlockVectorReaderT
51 {
52 public:
53 using ValueType = ValueT;
54
55 private:
56 using Indexer = typename Parameters::Indexer;
57
58 public:
59 explicit BlockVectorReaderT(const IVector& vector);
60
61 virtual ~BlockVectorReaderT() = default;
62
63 ConstArrayView<ValueT> operator[](Integer iIndex) const
64 {
65 const Integer id = Indexer::index(iIndex, m_local_offset);
66 if (this->m_block)
67 return this->m_values.subConstView(
68 id * this->m_block->size(), this->m_block->size());
69 else if (this->m_vblock) {
70 const VBlock* block_sizes = this->m_vblock;
71 const Integer size = block_sizes->size(id);
72 const Integer offset = this->m_vector_impl->vblockImpl().offset(id);
73 return this->m_values.subConstView(offset, size);
74 }
75 else
76 throw FatalErrorException(A_FUNCINFO, "No block info");
77 }
78
79 private:
80 ConstArrayView<ValueT> m_values;
81 const SimpleCSRVector<ValueT>* m_vector_impl;
82 const Block* m_block;
83 const VBlock* m_vblock;
84 Integer m_local_offset;
85 };
86
87 /*---------------------------------------------------------------------------*/
88 /*---------------------------------------------------------------------------*/
89
90} // namespace Common
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95} // namespace Alien
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100#include "BlockVectorReaderT.h"
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
Block.h.
IVector.h.
Parameters.h.
VBlock.h.
Block elements for block matrices.
Definition Block.h:45
Interface for all vectors.
Definition IVector.h:51
Variable size block elements for block matrices.
Definition VBlock.h:46
Arccore::Integer size(Arccore::Integer index) const
Get the size of a block.
Definition VBlock.cc:162
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17