DOLFIN-X
DOLFIN-X C++ interface
Geometry.h
1 // Copyright (C) 2006-2020 Anders Logg and Garth N. Wells
2 //
3 // This file is part of DOLFINX (https://www.fenicsproject.org)
4 //
5 // SPDX-License-Identifier: LGPL-3.0-or-later
6 
7 #pragma once
8 
9 #include <Eigen/Core>
10 #include <dolfinx/common/MPI.h>
11 #include <dolfinx/fem/CoordinateElement.h>
12 #include <dolfinx/graph/AdjacencyList.h>
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 namespace dolfinx
18 {
19 namespace common
20 {
21 class IndexMap;
22 }
23 
24 namespace fem
25 {
26 class CoordinateElement;
27 } // namespace fem
28 
29 namespace mesh
30 {
31 class Topology;
32 
37 
38 class Geometry
39 {
40 public:
42  template <typename AdjacencyList32, typename Vector64>
43  Geometry(const std::shared_ptr<const common::IndexMap>& index_map,
44  AdjacencyList32&& dofmap, const fem::CoordinateElement& element,
45  const Eigen::Ref<const Eigen::Array<
46  double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>& x,
47  Vector64&& input_global_indices)
48  : _dim(x.cols()), _dofmap(std::forward<AdjacencyList32>(dofmap)),
49  _index_map(index_map), _cmap(element),
50  _input_global_indices(std::forward<Vector64>(input_global_indices))
51  {
52  if (x.rows() != (int)_input_global_indices.size())
53  throw std::runtime_error("Size mis-match");
54 
55  // Make all geometry 3D
56  if (_dim == 3)
57  _x = x;
58  else if (_dim != 3)
59  {
60  _x.resize(x.rows(), 3);
61  _x.setZero();
62  _x.block(0, 0, x.rows(), x.cols()) = x;
63  }
64  }
65 
67  Geometry(const Geometry&) = default;
68 
70  Geometry(Geometry&&) = default;
71 
73  ~Geometry() = default;
74 
76  Geometry& operator=(const Geometry&) = delete;
77 
79  Geometry& operator=(Geometry&&) = default;
80 
82  int dim() const;
83 
86 
88  std::shared_ptr<const common::IndexMap> index_map() const;
89 
91  Eigen::Array<double, Eigen::Dynamic, 3, Eigen::RowMajor>& x();
92 
94  const Eigen::Array<double, Eigen::Dynamic, 3, Eigen::RowMajor>& x() const;
95 
98  const fem::CoordinateElement& cmap() const;
99 
101  const std::vector<std::int64_t>& input_global_indices() const;
102 
103 private:
104  // Geometric dimension
105  int _dim;
106 
107  // Map per cell for extracting coordinate data
109 
110  // IndexMap for geometry 'dofmap'
111  std::shared_ptr<const common::IndexMap> _index_map;
112 
113  // The coordinate element
115 
116  // Coordinates for all points stored as a contiguous array
117  Eigen::Array<double, Eigen::Dynamic, 3, Eigen::RowMajor> _x;
118 
119  // Global indices as provided on Geometry creation
120  std::vector<std::int64_t> _input_global_indices;
121 };
122 
126  MPI_Comm comm, const Topology& topology,
127  const fem::CoordinateElement& coordinate_element,
129  const Eigen::Ref<const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic,
130  Eigen::RowMajor>>& x);
131 
132 } // namespace mesh
133 } // namespace dolfinx
This class manages coordinate mappings for isoparametric cells.
Definition: CoordinateElement.h:26
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:46
Geometry stores the geometry imposed on a mesh.
Definition: Geometry.h:39
const graph::AdjacencyList< std::int32_t > & dofmap() const
DOF map.
Definition: Geometry.cpp:22
Geometry(const std::shared_ptr< const common::IndexMap > &index_map, AdjacencyList32 &&dofmap, const fem::CoordinateElement &element, const Eigen::Ref< const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor >> &x, Vector64 &&input_global_indices)
Constructor.
Definition: Geometry.h:43
~Geometry()=default
Destructor.
Geometry & operator=(Geometry &&)=default
Move Assignment.
const fem::CoordinateElement & cmap() const
The element that describes the geometry map.
Definition: Geometry.cpp:43
std::shared_ptr< const common::IndexMap > index_map() const
Index map.
Definition: Geometry.cpp:27
const std::vector< std::int64_t > & input_global_indices() const
Global user indices.
Definition: Geometry.cpp:45
Geometry & operator=(const Geometry &)=delete
Copy Assignment.
Geometry(Geometry &&)=default
Move constructor.
Geometry(const Geometry &)=default
Copy constructor.
Eigen::Array< double, Eigen::Dynamic, 3, Eigen::RowMajor > & x()
Geometry degrees-of-freedom.
Definition: Geometry.cpp:32
int dim() const
Return Euclidean dimension of coordinate system.
Definition: Geometry.cpp:20
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:57
mesh::Geometry create_geometry(MPI_Comm comm, const Topology &topology, const fem::CoordinateElement &coordinate_element, const graph::AdjacencyList< std::int64_t > &cells, const Eigen::Ref< const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor >> &x)
Build Geometry FIXME: document.
Definition: Geometry.cpp:52