1 #pragma once // Ensure that file is included only once in a single compilation.
20 template <
unsigned int n_dofs_per_nodeT,
typename hyNode_index_t =
unsigned int>
88 template <
typename dof_index_t = hyNode_index_t>
103 template <
typename SmallVecT>
104 SmallVecT&
get_dof_indices(
const hyNode_index_t hyNode_index, SmallVecT& dof_indices)
const
106 const typename SmallVecT::value_type initial_dof_index = hyNode_index * n_dofs_per_nodeT;
107 hy_assert(dof_indices.size() == n_dofs_per_nodeT,
108 "The size of the local dof vector is "
109 << dof_indices.size()
110 <<
", but should be equal to the amount of local dofs, which is "
111 << n_dofs_per_nodeT <<
".");
112 if constexpr (n_dofs_per_nodeT > 0)
113 for (
unsigned int i = 0; i < n_dofs_per_nodeT; ++i)
114 dof_indices[i] = initial_dof_index + i;
124 template <
typename dof_index_t>
128 return dof_index / n_dofs_per_nodeT;
144 template <
typename dof_index_t = hyNode_index_t,
typename SmallVecT,
typename LargeVecT>
146 const LargeVecT& global_dof_vector,
147 SmallVecT& local_dof_values)
const
149 using dof_value_t =
typename LargeVecT::value_type;
150 static_assert(std::is_same<typename SmallVecT::value_type, dof_value_t>::value,
151 "Both vectors must have same type!");
152 hy_assert(local_dof_values.size() == n_dofs_per_nodeT,
153 "The size of the local dof vector is "
154 << local_dof_values.size()
155 <<
", but should be equal to the amount of local dofs, which is "
156 << n_dofs_per_nodeT <<
".");
157 dof_index_t initial_dof_index = hyNode_index * n_dofs_per_nodeT;
159 initial_dof_index + n_dofs_per_nodeT <= global_dof_vector.size(),
160 "The initial dof index = "
161 << initial_dof_index <<
", should be non-negative. "
162 <<
" Moreover, the final index = " << initial_dof_index + n_dofs_per_nodeT
163 <<
" must not exceed the size of the vector of global degrees of freedom.");
164 if constexpr (n_dofs_per_nodeT > 0)
166 local_dof_values[
index] = global_dof_vector[initial_dof_index +
index];
167 return local_dof_values;
186 template <
typename dof_index_t = hyNode_index_t,
typename SmallVecT,
typename LargeVecT>
188 LargeVecT& global_dof_vector,
189 const SmallVecT& local_dof_vector)
const
192 std::is_same<typename SmallVecT::value_type, typename LargeVecT::value_type>::value,
193 "Both vectors must have same type!");
194 dof_index_t initial_dof_index = hyNode_index * n_dofs_per_nodeT;
195 hy_assert(local_dof_vector.size() == n_dofs_per_nodeT,
196 "The size of the local dof vector is "
197 << local_dof_vector.size() <<
", but should"
198 <<
" be equal to the amount of local dofs, which is " << n_dofs_per_nodeT <<
".");
200 initial_dof_index + n_dofs_per_nodeT <= global_dof_vector.size(),
201 "The initial dof index = "
202 << initial_dof_index <<
"should be non-negative. "
203 <<
"Moreover, the final index = " << initial_dof_index + n_dofs_per_nodeT
204 <<
" must not exceed the size of the vector of global degrees of freedom.");
206 if constexpr (n_dofs_per_nodeT > 0)
208 global_dof_vector[initial_dof_index +
index] += local_dof_vector[
index];
209 return global_dof_vector;
228 template <
typename dof_index_t = hyNode_index_t,
typename SmallVecT,
typename LargeVecT>
230 LargeVecT& global_dof_vector,
231 const SmallVecT& local_dof_vector)
const
234 std::is_same<typename SmallVecT::value_type, typename LargeVecT::value_type>::value,
235 "Both vectors must have same type!");
236 dof_index_t initial_dof_index = hyNode_index * n_dofs_per_nodeT;
237 hy_assert(local_dof_vector.size() == n_dofs_per_nodeT,
238 "The size of the local dof vector is "
239 << local_dof_vector.size() <<
", but should"
240 <<
" be equal to the amount of local dofs, which is " << n_dofs_per_nodeT <<
".");
242 initial_dof_index + n_dofs_per_nodeT <= global_dof_vector.size(),
243 "The initial dof index = "
244 << initial_dof_index <<
"should be non-negative. "
245 <<
"Moreover, the final index = " << initial_dof_index + n_dofs_per_nodeT
246 <<
" must not exceed the size of the vector of global degrees of freedom.");
247 if constexpr (n_dofs_per_nodeT > 0)
249 global_dof_vector[initial_dof_index +
index] = local_dof_vector[
index];
250 return global_dof_vector;
263 template <
typename dof_index_t = hyNode_index_t,
typename LargeVecT>
265 LargeVecT& global_dof_vector,
266 const typename LargeVecT::value_type value)
const
268 dof_index_t initial_dof_index = hyNode_index * n_dofs_per_nodeT;
270 initial_dof_index + n_dofs_per_nodeT <= global_dof_vector.size(),
271 "The initial dof index = "
272 << initial_dof_index <<
"should be non-negative. "
273 <<
"Moreover, the final index = " << initial_dof_index + n_dofs_per_nodeT
274 <<
" must not exceed the size of the vector of global degrees of freedom.");
275 if constexpr (n_dofs_per_nodeT > 0)
277 global_dof_vector[initial_dof_index +
index] = value;
278 return global_dof_vector;