DOLFIN-X
DOLFIN-X C++ interface
MeshEntity.h
1 // Copyright (C) 2006-2011 Anders Logg
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 "Mesh.h"
10 #include "Topology.h"
11 #include <dolfinx/graph/AdjacencyList.h>
12 
13 namespace dolfinx::mesh
14 {
15 
20 
22 {
23 public:
28  MeshEntity(const Mesh& mesh, int dim, std::int32_t index)
29  : _mesh(&mesh), _dim(dim), _local_index(index)
30  {
31  // Do nothing
32  }
33 
35  MeshEntity(const MeshEntity& e) = default;
36 
38  MeshEntity(MeshEntity&& e) = default;
39 
41  ~MeshEntity() = default;
42 
44  MeshEntity& operator=(const MeshEntity& e) = default;
45 
47  MeshEntity& operator=(MeshEntity&& e) = default;
48 
51  const Mesh& mesh() const { return *_mesh; }
52 
55  int dim() const { return _dim; }
56 
59  std::int32_t index() const { return _local_index; }
60 
65  auto entities(int dim) const
66  {
67  assert(_mesh->topology().connectivity(_dim, dim));
68  return _mesh->topology().connectivity(_dim, dim)->links(_local_index);
69  }
70 
71 private:
72  // The mesh
73  Mesh const* _mesh;
74 
75  // Topological dimension
76  int _dim;
77 
78  // Local index of entity within topological dimension
79  std::int32_t _local_index;
80 };
81 
82 } // namespace dolfinx::mesh
dolfinx::mesh
Mesh data structures.
Definition: assemble_matrix_impl.h:29
dolfinx::mesh::MeshEntity::entities
auto entities(int dim) const
Return array of indices for incident mesh entities of given topological dimension.
Definition: MeshEntity.h:65
dolfinx::mesh::MeshEntity::index
std::int32_t index() const
Return index of mesh entity.
Definition: MeshEntity.h:59
dolfinx::mesh::MeshEntity::mesh
const Mesh & mesh() const
Return mesh associated with mesh entity.
Definition: MeshEntity.h:51
dolfinx::mesh::MeshEntity
A MeshEntity represents a mesh entity associated with a specific topological dimension of some Mesh....
Definition: MeshEntity.h:21
dolfinx::mesh::MeshEntity::dim
int dim() const
Return topological dimension.
Definition: MeshEntity.h:55
dolfinx::mesh::MeshEntity::MeshEntity
MeshEntity(const Mesh &mesh, int dim, std::int32_t index)
Constructor.
Definition: MeshEntity.h:28
dolfinx::mesh::Mesh
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition: Mesh.h:46
dolfinx::mesh::MeshEntity::~MeshEntity
~MeshEntity()=default
Destructor.
dolfinx::mesh::MeshEntity::operator=
MeshEntity & operator=(const MeshEntity &e)=default
Assignment operator.