3 #include <Caribou/config.h>
4 #include <Caribou/macros.h>
5 #include <Caribou/constants.h>
6 #include <Caribou/Topology/BaseDomain.h>
7 #include <Caribou/Topology/BarycentricContainer.h>
8 #include <Caribou/Geometry/Element.h>
13 namespace caribou::topology {
20 template <
typename Element>
21 class DomainStorage {};
74 template <
typename Mesh,
typename Element,
typename NodeIndex = UNSIGNED_INTEGER_TYPE>
80 using ElementType = Element;
81 using NodeIndexType = NodeIndex;
89 using ElementsIndices = Eigen::Matrix<NodeIndex, Eigen::Dynamic, geometry::traits<Element>::NumberOfNodesAtCompileTime, Eigen::RowMajor>;
94 using ElementIndices = Eigen::Matrix<NodeIndex, geometry::traits<Element>::NumberOfNodesAtCompileTime, 1>;
144 template<typename EigenMatrix>
145 inline auto
element(const UNSIGNED_INTEGER_TYPE & element_id, const Eigen::DenseBase<EigenMatrix> & positions) const -> Element;
152 inline auto
element(const UNSIGNED_INTEGER_TYPE & element_id) const -> Element;
160 inline auto
element_indices(const UNSIGNED_INTEGER_TYPE & index) const;
176 template <
typename Derived>
178 return {
this, points};
183 friend void swap(
Domain & first,
Domain& second) noexcept
187 swap(first.p_buffer, second.p_buffer);
188 swap(first.p_elements, second.p_elements);
244 Eigen::Map<const ElementsIndices, Eigen::Unaligned, Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>>
p_elements;
253 template <
typename Mesh,
typename Element,
typename NodeIndex>
255 return p_elements.cols();
258 template <
typename Mesh,
typename Element,
typename NodeIndex>
260 return p_elements.rows();
263 template <
typename Mesh,
typename Element,
typename NodeIndex>
265 caribou_assert(index < number_of_elements() and
"Trying to get an element that does not exists.");
267 return Eigen::Map<const Eigen::Matrix<NodeIndex, geometry::traits<Element>::NumberOfNodesAtCompileTime, 1>, Eigen::Unaligned, Eigen::Stride<1, Eigen::Dynamic>>(
268 p_elements.row(index).data(), {1, p_elements.innerStride()}
272 template <
typename Mesh,
typename Element,
typename NodeIndex>
273 template<
typename EigenMatrix>
275 caribou_assert(element_id < number_of_elements() &&
276 "Trying to get the element #"+std::to_string(element_id) +
", but the domain only has " +
277 std::to_string(number_of_elements()) +
" elements."
281 NodeMatrix node_positions;
283 node_positions.resize(number_of_nodes_per_elements(), Dimension);
286 const auto node_indices = element_indices(element_id);
287 for (std::size_t i = 0; i < node_indices.size(); ++i) {
288 node_positions.row(i) = positions.row(node_indices[i]);
291 return Element(node_positions);
294 template <
typename Mesh,
typename Element,
typename NodeIndex>
296 caribou_assert(element_id < number_of_elements() &&
297 (
"Trying to get the element #"+std::to_string(element_id) +
", but the domain only has " +
298 std::to_string(number_of_elements()) +
" elements.").c_str()
301 return Element(mesh().positions(element_indices(element_id)));