DOLFIN
DOLFIN C++ interface
RectangleMesh.h
1// Copyright (C) 2005-2017 Anders Logg and Garth N. Wells
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#ifndef __RECTANGLE_MESH_H
19#define __RECTANGLE_MESH_H
20
21#include <array>
22#include <string>
23#include <dolfin/common/MPI.h>
24#include <dolfin/log/log.h>
25#include <dolfin/mesh/CellType.h>
26#include <dolfin/mesh/Mesh.h>
27
28namespace dolfin
29{
30
35
36 class RectangleMesh : public Mesh
37 {
38 public:
39
57 static Mesh create(const std::array<Point, 2>& p,
58 std::array<std::size_t, 2> n,
59 CellType::Type cell_type,
60 std::string diagonal="right")
61 { return create(MPI_COMM_WORLD, p, n, cell_type, diagonal); }
62
82 static Mesh create(MPI_Comm comm, const std::array<Point, 2>& p,
83 std::array<std::size_t, 2> n,
84 CellType::Type cell_type,
85 std::string diagonal="right")
86 {
87 Mesh mesh(comm);
88 if (cell_type == CellType::Type::triangle)
89 build_tri(mesh, p, n, diagonal);
90 else if (cell_type == CellType::Type::quadrilateral)
91 build_quad(mesh, p, n);
92 else
93 {
94 dolfin_error("RectangleMesh.h",
95 "generate rectangle mesh",
96 "Wrong cell type '%d'", cell_type);
97 }
98
99 return mesh;
100 }
101
102 // Deprecated
122 RectangleMesh(const Point& p0, const Point& p1,
123 std::size_t nx, std::size_t ny,
124 std::string diagonal="right");
125
126 // Deprecated
148 RectangleMesh(MPI_Comm comm,
149 const Point& p0, const Point& p1,
150 std::size_t nx, std::size_t ny,
151 std::string diagonal="right");
152
153 private:
154
155 // Build mesh
156 static void build_tri(Mesh& mesh, const std::array<Point, 2>& p,
157 std::array<std::size_t, 2> n,
158 std::string diagonal="right");
159
160
161 static void build_quad(Mesh& mesh, const std::array<Point, 2>& p,
162 std::array<std::size_t, 2> n);
163 };
164
165}
166
167#endif
Type
Enum for different cell types.
Definition: CellType.h:51
Definition: Mesh.h:84
Definition: Point.h:41
Definition: RectangleMesh.h:37
static Mesh create(const std::array< Point, 2 > &p, std::array< std::size_t, 2 > n, CellType::Type cell_type, std::string diagonal="right")
Definition: RectangleMesh.h:57
static Mesh create(MPI_Comm comm, const std::array< Point, 2 > &p, std::array< std::size_t, 2 > n, CellType::Type cell_type, std::string diagonal="right")
Definition: RectangleMesh.h:82
RectangleMesh(const Point &p0, const Point &p1, std::size_t nx, std::size_t ny, std::string diagonal="right")
Definition: RectangleMesh.cpp:30
Definition: adapt.h:30
void dolfin_error(std::string location, std::string task, std::string reason,...)
Definition: log.cpp:129