DOLFIN
DOLFIN C++ interface
MeshData.h
1// Copyright (C) 2008-2011 Anders Logg
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// Modified by Niclas Jansson, 2008.
19// Modified by Garth N. Wells, 2011.
20//
21// First added: 2008-05-19
22// Last changed: 2011-09-15
23
24#ifndef __MESH_DATA_H
25#define __MESH_DATA_H
26
27#include <map>
28#include <memory>
29#include <string>
30#include <vector>
31#include <dolfin/common/Variable.h>
32
33namespace dolfin
34{
35
36 class Mesh;
37
57
58 class MeshData : public Variable
59 {
60 public:
61
63 MeshData();
64
66 ~MeshData();
67
72 const MeshData& operator= (const MeshData& data);
73
75 void clear();
76
77 //--- Query of data ---
78
87 bool exists(std::string name, std::size_t dim) const;
88
89 //--- Creation of data ---
90
100 std::vector<std::size_t>& create_array(std::string name, std::size_t dim);
101
102 //--- Retrieval of data ---
103
113 std::vector<std::size_t>& array(std::string name, std::size_t dim);
114
125 const std::vector<std::size_t>& array(std::string name,
126 std::size_t dim) const;
127
128 //--- Removal of data ---
129
136 void erase_array(const std::string name, std::size_t dim);
137
138 //--- Misc ---
139
147 std::string str(bool verbose) const;
148
150 friend class XMLMesh;
151
152 private:
153
154 // Check if name is deprecated
155 void check_deprecated(std::string name) const;
156
157 // A map from named mesh array data to vector for dim
158 std::vector<std::map<std::string, std::vector<std::size_t> > > _arrays;
159
160 // List of deprecated named data
161 std::vector<std::string> _deprecated_names;
162
163 };
164
165}
166
167#endif
Definition: MeshData.h:59
std::vector< std::size_t > & array(std::string name, std::size_t dim)
Definition: MeshData.cpp:105
std::vector< std::size_t > & create_array(std::string name, std::size_t dim)
Definition: MeshData.cpp:78
void clear()
Clear all data.
Definition: MeshData.cpp:73
~MeshData()
Destructor.
Definition: MeshData.cpp:47
void erase_array(const std::string name, std::size_t dim)
Definition: MeshData.cpp:137
bool exists(std::string name, std::size_t dim) const
Definition: MeshData.cpp:60
MeshData()
Constructor.
Definition: MeshData.cpp:35
const MeshData & operator=(const MeshData &data)
Definition: MeshData.cpp:52
std::string str(bool verbose) const
Definition: MeshData.cpp:147
Common base class for DOLFIN variables.
Definition: Variable.h:36
std::string name() const
Return name.
Definition: Variable.cpp:71
I/O of XML representation of a Mesh.
Definition: XMLMesh.h:46
Definition: adapt.h:30