Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/d3/d8b/Geometry_8h_source.html
DOLFINx  0.5.1
DOLFINx 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 <dolfinx/common/MPI.h>
10 #include <dolfinx/fem/CoordinateElement.h>
11 #include <dolfinx/graph/AdjacencyList.h>
12 #include <functional>
13 #include <memory>
14 #include <span>
15 #include <vector>
16 
17 namespace dolfinx::common
18 {
19 class IndexMap;
20 }
21 
22 namespace dolfinx::mesh
23 {
24 class Topology;
25 
27 class Geometry
28 {
29 public:
42  template <typename AdjacencyList32, typename Array, typename Vector64>
43  Geometry(const std::shared_ptr<const common::IndexMap>& index_map,
44  AdjacencyList32&& dofmap, const fem::CoordinateElement& element,
45  Array&& x, int dim, Vector64&& input_global_indices)
46  : _dim(dim), _dofmap(std::forward<AdjacencyList32>(dofmap)),
47  _index_map(index_map), _cmap(element), _x(std::forward<Array>(x)),
48  _input_global_indices(std::forward<Vector64>(input_global_indices))
49  {
50  assert(_x.size() % 3 == 0);
51  if (_x.size() / 3 != _input_global_indices.size())
52  throw std::runtime_error("Geometry size mis-match");
53  }
54 
56  Geometry(const Geometry&) = default;
57 
59  Geometry(Geometry&&) = default;
60 
62  ~Geometry() = default;
63 
65  Geometry& operator=(const Geometry&) = delete;
66 
68  Geometry& operator=(Geometry&&) = default;
69 
71  int dim() const;
72 
75 
77  std::shared_ptr<const common::IndexMap> index_map() const;
78 
83  std::span<const double> x() const;
84 
90  std::span<double> x();
91 
95  const fem::CoordinateElement& cmap() const;
96 
98  const std::vector<std::int64_t>& input_global_indices() const;
99 
100 private:
101  // Geometric dimension
102  int _dim;
103 
104  // Map per cell for extracting coordinate data
106 
107  // IndexMap for geometry 'dofmap'
108  std::shared_ptr<const common::IndexMap> _index_map;
109 
110  // The coordinate element
112 
113  // Coordinates for all points stored as a contiguous array (row-major,
114  // column size = 3)
115  std::vector<double> _x;
116 
117  // Global indices as provided on Geometry creation
118  std::vector<std::int64_t> _input_global_indices;
119 };
120 
142 create_geometry(MPI_Comm comm, const Topology& topology,
143  const fem::CoordinateElement& element,
145  const std::span<const double>& x, int dim,
146  const std::function<std::vector<int>(
147  const graph::AdjacencyList<std::int32_t>&)>& reorder_fn
148  = nullptr);
149 
150 } // namespace dolfinx::mesh
A CoordinateElement manages coordinate mappings for isoparametric cells.
Definition: CoordinateElement.h:32
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:26
Geometry stores the geometry imposed on a mesh.
Definition: Geometry.h:28
~Geometry()=default
Destructor.
Geometry(const std::shared_ptr< const common::IndexMap > &index_map, AdjacencyList32 &&dofmap, const fem::CoordinateElement &element, Array &&x, int dim, Vector64 &&input_global_indices)
Constructor.
Definition: Geometry.h:43
const graph::AdjacencyList< std::int32_t > & dofmap() const
DOF map.
Definition: Geometry.cpp:21
Geometry & operator=(Geometry &&)=default
Move Assignment.
std::shared_ptr< const common::IndexMap > index_map() const
Index map.
Definition: Geometry.cpp:26
std::span< const double > x() const
Access geometry degrees-of-freedom data (const version).
Definition: Geometry.cpp:33
Geometry(Geometry &&)=default
Move constructor.
Geometry(const Geometry &)=default
Copy constructor.
int dim() const
Return Euclidean dimension of coordinate system.
Definition: Geometry.cpp:19
const fem::CoordinateElement & cmap() const
The element that describes the geometry map.
Definition: Geometry.cpp:35
const std::vector< std::int64_t > & input_global_indices() const
Global user indices.
Definition: Geometry.cpp:37
Geometry & operator=(const Geometry &)=delete
Copy Assignment.
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:44
Miscellaneous classes, functions and types.
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:30
mesh::Geometry create_geometry(MPI_Comm comm, const Topology &topology, const fem::CoordinateElement &element, const graph::AdjacencyList< std::int64_t > &cells, const std::span< const double > &x, int dim, const std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> &reorder_fn=nullptr)
Build Geometry from input data.
Definition: Geometry.cpp:44