DOLFIN
DOLFIN C++ interface
RegularCutRefinement.h
1 // Copyright (C) 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 // First added: 2011-02-07
19 // Last changed: 2011-02-09
20 
21 #ifndef __REGULAR_CUT_REFINEMENT_H
22 #define __REGULAR_CUT_REFINEMENT_H
23 
24 #include <vector>
25 
26 namespace dolfin
27 {
28 
29  class Cell;
30  class Mesh;
31  template<typename T> class MeshFunction;
32  class IndexSet;
33 
37 
39  {
40  public:
41 
50  static void refine(Mesh& refined_mesh,
51  const Mesh& mesh,
52  const MeshFunction<bool>& cell_markers);
53 
54  private:
55 
56  // Refinement markers
57  enum class marker_type : int { no_refinement=-1, regular_refinement=-2,
58  backtrack_bisection=-3, backtrack_bisection_refine=-4 };
59 
60  // Compute refinement markers based on initial markers
61  static void compute_markers(std::vector<int>& refinement_markers,
62  IndexSet& marked_edges,
63  const Mesh& mesh,
64  const MeshFunction<bool>& cell_markers);
65 
66  // Refine mesh based on computed markers
67  static void refine_marked(Mesh& refined_mesh,
68  const Mesh& mesh,
69  const std::vector<int>& refinement_markers,
70  const IndexSet& marked_edges);
71 
72  // Count the number of marked entries
73  static std::size_t count_markers(const std::vector<bool>& markers);
74 
75  // Extract index of first marked entry
76  static std::size_t extract_edge(const std::vector<bool>& markers);
77 
78  // Check whether suggested refinement will produce too thin cells
79  static bool too_thin(const Cell& cell,
80  const std::vector<bool>& edge_markers);
81 
82  // Find local indices for common edge relative to cell and twin
83  static std::pair<std::size_t, std::size_t> find_common_edges(const Cell& cell,
84  const Mesh& mesh,
85  std::size_t bisection_twin);
86 
87  // Find local indices for bisection edge relative to cell and twin
88  static std::pair<std::size_t, std::size_t> find_bisection_edges(const Cell& cell,
89  const Mesh& mesh,
90  std::size_t bisection_twin);
91 
92  // Find local indices for bisection vertex relative to cell and twin
93  static std::pair<std::size_t, std::size_t> find_bisection_vertices(const Cell& cell,
94  const Mesh& mesh,
95  std::size_t bisection_twin,
96  const std::pair<std::size_t, std::size_t>& bisection_edges);
97 
98  };
99 
100 }
101 
102 #endif
Definition: adapt.h:41
Definition: adapt.h:29
Definition: IndexSet.h:34
static void refine(Mesh &refined_mesh, const Mesh &mesh, const MeshFunction< bool > &cell_markers)
Definition: RegularCutRefinement.cpp:37
A Cell is a MeshEntity of topological codimension 0.
Definition: Cell.h:42
Definition: Mesh.h:82
Definition: RegularCutRefinement.h:38