FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
unit_filter_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_UNIT_FILTER_GENERIC_HPP
8#define KERNEL_LAFEM_ARCH_UNIT_FILTER_GENERIC_HPP 1
9
10#ifndef KERNEL_LAFEM_ARCH_UNIT_FILTER_HPP
11#error "Do not include this implementation-only header file directly!"
12#endif
13
15namespace FEAT
16{
17 namespace LAFEM
18 {
19 namespace Arch
20 {
21 template <typename DT_, typename IT_>
22 void UnitFilter::filter_rhs_generic(DT_ * v, const DT_ * const sv_elements, const IT_ * const sv_indices, const Index ue)
23 {
24 FEAT_PRAGMA_OMP(parallel for)
25 for(Index i = 0; i < ue ; ++i)
26 {
27 v[sv_indices[i]] = sv_elements[i];
28 }
29 }
30
31 template <typename DT_, typename IT_>
32 void UnitFilter::filter_def_generic(DT_ * v, const IT_ * const sv_indices, const Index ue)
33 {
34 FEAT_PRAGMA_OMP(parallel for)
35 for(Index i = 0; i < ue ; ++i)
36 {
37 v[sv_indices[i]] = DT_(0);
38 }
39 }
40
41 template<typename DT_, typename IT_>
42 void UnitFilter::filter_unit_mat_generic(DT_* mat, const IT_* const row_ptr, const IT_* const col_idx, const IT_ * const sv_indices, const Index ue)
43 {
44 FEAT_PRAGMA_OMP(parallel for)
45 for(Index i = 0; i < ue; ++i)
46 {
47 const IT_ ix(sv_indices[i]);
48
49 // replace by unit row
50 for(IT_ j(row_ptr[ix]); j < row_ptr[ix + 1]; ++j)
51 {
52 mat[j] = (col_idx[j] == ix) ? DT_(1) : DT_(0);
53 }
54 }
55 }
56
57 template<typename DT_, typename IT_>
58 void UnitFilter::filter_offdiag_row_mat_generic(DT_* mat, const IT_* const row_ptr, int block_width, const IT_ * const sv_indices, const Index ue)
59 {
60 FEAT_PRAGMA_OMP(parallel for)
61 for(Index i = 0; i < ue; ++i)
62 {
63 const IT_ ix(sv_indices[i]);
64
65 // replace by unit row
66 for(IT_ j(row_ptr[ix]); j < row_ptr[ix + 1]; ++j)
67 {
68 for(int l(0); l < block_width; ++l)
69 mat[j*block_width + l] = DT_(0);
70 }
71 }
72 }
73
74 template<typename DT_, typename IT_>
75 void UnitFilter::filter_weak_matrix_rows_generic(DT_* mat_a, const DT_ * const mat_m, const IT_* const row_ptr,
76 const DT_ * const sv_elements, const IT_ * const sv_indices, const Index ue)
77 {
78 FEAT_PRAGMA_OMP(parallel for)
79 for(Index i = 0; i < ue; ++i)
80 {
81 const IT_ ix(sv_indices[i]);
82
83 // replace by unit row
84 for(IT_ j(row_ptr[ix]); j < row_ptr[ix + 1]; ++j)
85 {
86 mat_a[j] = sv_elements[i] * mat_m[j];
87 }
88 }
89 }
90 } // namespace Arch
91 } // namespace LAFEM
92} // namespace FEAT
94
95#endif // KERNEL_LAFEM_ARCH_UNIT_FILTER_GENERIC_HPP
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.