DOLFIN
DOLFIN C++ interface
MeshView.h
1 // Copyright (C) 2017 Chris Richardson
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 
19 #ifndef __MESH_VIEW_H
20 #define __MESH_VIEW_H
21 
22 namespace dolfin
23 {
24  // Forward declarations
25  class Mesh;
26  template <typename T> class MeshFunction;
27 
28  class MeshView
29  {
32 
33  public:
34 
36  MeshView(std::shared_ptr<const Mesh> parent_mesh,
37  std::vector<std::size_t>& vertex_map,
38  std::vector<std::size_t>& cell_map)
39  : _mesh(parent_mesh), _vertex_map(vertex_map), _cell_map(cell_map)
40  {
41  // Do nothing
42  }
43 
45  std::shared_ptr<const Mesh> mesh() const
46  {
47  return _mesh;
48  }
49 
51  const std::vector<std::size_t>& vertex_map() const
52  {
53  return _vertex_map;
54  }
55 
57  const std::vector<std::size_t>& cell_map() const
58  {
59  return _cell_map;
60  }
61 
65  static Mesh create(const MeshFunction<std::size_t>& marker, std::size_t tag);
66 
67  private:
68 
69  // The parent mesh which this mapping points to
70  std::shared_ptr<const Mesh> _mesh;
71 
72  // Map to vertices in _mesh
73  std::vector<std::size_t> _vertex_map;
74 
75  // Map to cells in _mesh
76  std::vector<std::size_t> _cell_map;
77 
78  };
79 
80 }
81 
82 #endif
Definition: MeshView.h:29
MeshView(std::shared_ptr< const Mesh > parent_mesh, std::vector< std::size_t > &vertex_map, std::vector< std::size_t > &cell_map)
Constructor.
Definition: MeshView.h:36
std::shared_ptr< const Mesh > mesh() const
Access parent mesh.
Definition: MeshView.h:45
const std::vector< std::size_t > & cell_map() const
Map to cells of parent mesh.
Definition: MeshView.h:57
static Mesh create(const MeshFunction< std::size_t > &marker, std::size_t tag)
Definition: MeshView.cpp:28
const std::vector< std::size_t > & vertex_map() const
Map to vertices of parent mesh.
Definition: MeshView.h:51
Definition: Mesh.h:84
Definition: adapt.h:30