atlas
ElementType.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2013 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation
8  * nor does it submit to any jurisdiction.
9  */
10 
14 
15 #pragma once
16 
17 #include <string>
18 
19 #include "atlas/library/config.h"
20 #include "atlas/util/Object.h"
21 
22 namespace atlas {
23 namespace mesh {
24 
29 class ElementType : public util::Object {
30 public: // methods
31  static ElementType* create( const std::string& );
32 
33  //-- Constructors
34 
35  ElementType();
36  ~ElementType() = 0;
37 
38  //-- Accessors
39 
40  virtual const std::string& name() const = 0;
41  // virtual idx_t dimensionality() const = 0;
42 
43  // virtual idx_t nb_vertices() const = 0;
44  virtual idx_t nb_edges() const = 0;
45  // virtual idx_t nb_faces() const = 0;
46 
47  virtual idx_t nb_nodes() const = 0;
48 
49  virtual bool parametric() const = 0;
50 };
51 
52 namespace temporary {
53 
54 class Volume : public ElementType {
55 public:
56  enum
57  {
58  DIMENSIONALITY = 3
59  };
60 };
61 
62 class Face : public ElementType {
63 public:
64  enum
65  {
66  DIMENSIONALITY = 2
67  };
68  enum
69  {
70  FACES = 1
71  };
72  virtual idx_t nb_faces() const { return FACES; }
73 };
74 
75 class Edge : public ElementType {
76 public:
77  enum
78  {
79  DIMENSIONALITY = 1
80  };
81  enum
82  {
83  FACES = 0
84  };
85  enum
86  {
87  EDGES = 1
88  };
89  virtual idx_t nb_faces() const { return FACES; }
90  virtual idx_t nb_edges() const { return EDGES; }
91 };
92 
93 class Vertex : public ElementType {
94 public:
95  enum
96  {
97  DIMENSIONALITY = 0
98  };
99  enum
100  {
101  FACES = 0
102  };
103  enum
104  {
105  EDGES = 0
106  };
107  enum
108  {
109  VERTICES = 1
110  };
111  virtual idx_t nb_faces() const { return FACES; }
112  virtual idx_t nb_edges() const { return EDGES; }
113  virtual idx_t nb_vertices() const { return VERTICES; }
114 };
115 
116 class Quadrilateral : public Face {
117 public:
118  enum
119  {
120  EDGES = 4
121  };
122  enum
123  {
124  VERTICES = 4
125  };
126  enum
127  {
128  FACETS = EDGES
129  };
130  enum
131  {
132  RIDGES = VERTICES
133  };
134  virtual ~Quadrilateral() {}
135  virtual bool parametric() const { return true; }
136  virtual idx_t nb_vertices() const { return VERTICES; }
137  virtual idx_t nb_edges() const { return EDGES; }
138  virtual idx_t nb_nodes() const { return VERTICES; }
139  virtual idx_t nb_facets() const { return FACETS; }
140  virtual idx_t nb_ridges() const { return RIDGES; }
141  virtual const std::string& name() const {
142  static std::string s( "Quadrilateral" );
143  return s;
144  }
145 };
146 
147 class Triangle : public Face {
148 public:
149  enum
150  {
151  EDGES = 3
152  };
153  enum
154  {
155  VERTICES = 3
156  };
157  enum
158  {
159  FACETS = EDGES
160  };
161  enum
162  {
163  RIDGES = VERTICES
164  };
165  virtual ~Triangle() {}
166  virtual bool parametric() const { return true; }
167  virtual idx_t nb_vertices() const { return VERTICES; }
168  virtual idx_t nb_edges() const { return EDGES; }
169  virtual idx_t nb_nodes() const { return VERTICES; }
170  virtual idx_t nb_facets() const { return FACETS; }
171  virtual idx_t nb_ridges() const { return RIDGES; }
172  virtual const std::string& name() const {
173  static std::string s( "Triangle" );
174  return s;
175  }
176 };
177 
178 class Line : public Edge {
179 public:
180  enum
181  {
182  VERTICES = 2
183  };
184  enum
185  {
186  FACETS = VERTICES
187  };
188  enum
189  {
190  RIDGES = 0
191  };
192  virtual ~Line() {}
193  virtual bool parametric() const { return true; }
194  virtual idx_t nb_vertices() const { return VERTICES; }
195  virtual idx_t nb_edges() const { return EDGES; }
196  virtual idx_t nb_nodes() const { return VERTICES; }
197  virtual idx_t nb_facets() const { return FACETS; }
198  virtual const std::string& name() const {
199  static std::string s( "Line" );
200  return s;
201  }
202 };
203 } // namespace temporary
204 
205 extern "C" {
206 ElementType* atlas__mesh__Triangle__create();
207 ElementType* atlas__mesh__Quadrilateral__create();
208 ElementType* atlas__mesh__Line__create();
209 
210 void atlas__mesh__ElementType__delete( ElementType* This );
211 idx_t atlas__mesh__ElementType__nb_nodes( const ElementType* This );
212 idx_t atlas__mesh__ElementType__nb_edges( const ElementType* This );
213 int atlas__mesh__ElementType__parametric( const ElementType* This );
214 const char* atlas__mesh__ElementType__name( const ElementType* This );
215 }
216 
217 //------------------------------------------------------------------------------------------------------
218 
219 } // namespace mesh
220 } // namespace atlas
Definition: ElementType.h:178
Definition: ElementType.h:62
Definition: ElementType.h:75
Definition: Object.h:18
Definition: ElementType.h:93
Definition: ElementType.h:54
Definition: ElementType.h:116
ElementType class (abstract) that provides access to geometric information of an element.
Definition: ElementType.h:29
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
long idx_t
Integer type for indices in connectivity tables.
Definition: config.h:42
Definition: ElementType.h:147