FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
copy_comp_set.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
8// includes, FEAT
9#include <kernel/geometry/index_set.hpp>
10#include <kernel/geometry/target_set.hpp>
11#include <kernel/geometry/vertex_set.hpp>
12
13// includes, CSL
14#include <cmath>
15
16namespace FEAT
17{
18 namespace Geometry
19 {
21 namespace TestAux
22 {
23 template<int num_idx_>
24 void copy_idx(IndexSet<num_idx_>& idx, const Index jdx[])
25 {
26 Index n = idx.get_num_entities();
27 size_t k = 0;
28 for(Index i(0); i < n; ++i)
29 {
30 for(int j(0); j < num_idx_; ++j)
31 {
32 idx[i][j] = jdx[k++];
33 }
34 }
35 }
36
37 template<int num_idx_>
38 bool comp_idx(const IndexSet<num_idx_>& idx, const Index jdx[])
39 {
40 Index n = idx.get_num_entities();
41 size_t k = 0;
42 for(Index i(0); i < n; ++i)
43 {
44 for(int j(0); j < num_idx_; ++j)
45 {
46 if(idx[i][j] != jdx[k++])
47 {
48 return false;
49 }
50 }
51 }
52 return true;
53 }
54
55 template<typename VertexSet_>
56 void copy_vtx(VertexSet_& vtx, const Real wtx[])
57 {
58 Index n = vtx.get_num_vertices();
59 int num_coords = vtx.get_num_coords();
60 size_t k = 0;
61 for(Index i(0); i < n; ++i)
62 {
63 for(int j(0); j < num_coords; ++j)
64 {
65 vtx[i][j] = wtx[k++];
66 }
67 }
68 }
69
70 template<typename VertexSet_>
71 bool comp_vtx(const VertexSet_& vtx, const Real wtx[], Real tol = 1e-8)
72 {
73 Index n = vtx.get_num_vertices();
74 int num_coords = vtx.get_num_coords();
75 size_t k = 0;
76 for(Index i(0); i < n; ++i)
77 {
78 for(int j(0); j < num_coords; ++j)
79 {
80 if(std::fabs(vtx[i][j] - wtx[k++]) > tol)
81 {
82 return false;
83 }
84 }
85 }
86 return true;
87 }
88
89 inline void copy_trg(TargetSet& trg, const Index jdx[])
90 {
91 Index n = trg.get_num_entities();
92 for(Index i(0); i < n; ++i)
93 {
94 trg[i] = jdx[i];
95 }
96 }
97
98 inline bool comp_trg(const TargetSet& trg, const Index jdx[])
99 {
100 Index n = trg.get_num_entities();
101 for(Index i(0); i < n; ++i)
102 {
103 if(trg[i] != jdx[i])
104 {
105 return false;
106 }
107 }
108 return true;
109 }
110
111 template<typename AttribSet_>
112 void copy_attr(AttribSet_& attr, const Real wtx[])
113 {
114 Index n = attr.get_num_values();
115 int num_coords = attr.get_dimension();
116 size_t k = 0;
117 for(Index i(0); i < n; ++i)
118 {
119 for(int j(0); j < num_coords; ++j, ++k)
120 {
121 attr(i,j) = wtx[k];
122 }
123 }
124 }
125
126 template<typename AttribSet_>
127 bool comp_attr(const AttribSet_& attr, const Real wtx[], Real tol = 1e-8)
128 {
129 Index n = attr.get_num_values();
130 int num_coords = attr.get_dimension();
131 size_t k = 0;
132 for(Index i(0); i < n; ++i)
133 {
134 for(int j(0); j < num_coords; ++j, ++k)
135 {
136 if(std::fabs(attr(i,j) - wtx[k]) > tol)
137 {
138 return false;
139 }
140 }
141 }
142 return true;
143 }
144 } // namespace TestAux
146 } // namespace Geometry
147} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12
double Real
Real data type.
std::uint64_t Index
Index data type.