FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
lumping_generic.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7#ifndef KERNEL_LAFEM_ARCH_LUMPING_GENERIC_HPP
8#define KERNEL_LAFEM_ARCH_LUMPING_GENERIC_HPP 1
9
10#ifndef KERNEL_LAFEM_ARCH_LUMPING_HPP
11#error "Do not include this implementation-only header file directly!"
12#endif
13
14namespace FEAT
15{
16 namespace LAFEM
17 {
18 namespace Arch
19 {
20 template <typename DT_, typename IT_>
21 void Lumping::csr_generic(DT_ * lump, const DT_ * const val, const IT_ * const /*col_ind*/,
22 const IT_ * const row_ptr, const Index rows)
23 {
24 FEAT_PRAGMA_OMP(parallel for)
25 for (Index row = 0; row < rows; row++)
26 {
27 Index end = row_ptr[row + 1];
28 DT_ sum(0);
29 for (Index col = row_ptr[row]; col < end; col++)
30 {
31 sum += val[col];
32 }
33 lump[row] = sum;
34 }
35 }
36
37 template <typename DT_, typename IT_>
38 void Lumping::bcsr_generic(DT_ * lump, const DT_ * const val, const IT_ * const /*col_ind*/,
39 const IT_ * const row_ptr, const Index rows, const int BlockHeight, const int BlockWidth)
40 {
41 Index block_height = Index(BlockHeight);
42 Index block_width = Index(BlockWidth);
43
44 FEAT_PRAGMA_OMP(parallel for)
45 for (Index row = 0; row < rows; row++)
46 {
47 Index end = row_ptr[row + 1];
48
49 for(Index i(0); i < block_height; ++i)
50 {
51 lump[block_height*row + i] = DT_(0);
52 }
53
54 for (Index col = row_ptr[row]; col < end; col++)
55 {
56 for(Index i(0); i < block_height; ++i)
57 {
58 for(Index j(0); j < block_width; ++j)
59 {
60 lump[block_height*row + i] += val[block_height*block_width*col + i*block_width + j];
61 }
62 }
63 }
64 }
65 }
66 } // namespace Arch
67 } // namespace LAFEM
68} // namespace FEAT
69
70#endif // KERNEL_LAFEM_ARCH_LUMPING_GENERIC_HPP
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.