mesh_refinement.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_MESH_REFINEMENT_H
21 #define LIBMESH_MESH_REFINEMENT_H
22 
23 
24 
25 #include "libmesh/libmesh_config.h"
26 
27 #ifdef LIBMESH_ENABLE_AMR
28 
29 // Local Includes -----------------------------------
30 #include "libmesh/libmesh_common.h"
31 #include "libmesh/libmesh.h" // libMesh::invalid_uint
32 #include "libmesh/location_maps.h"
33 #include "libmesh/elem.h"
36 
37 // C++ Includes -----------------------------------
38 #include <vector>
39 
40 namespace libMesh
41 {
42 
43 // Forward Declarations -----------------------------
44 class MeshBase;
45 class Point;
46 class Node;
47 class ErrorVector;
48 class PeriodicBoundaries;
49 
50 
51 
60 // ------------------------------------------------------------
61 // MeshRefinement class definition
63 {
64 public:
65 
69  explicit
71 
72 private:
73  // Both the copy ctor and the assignment operator are
74  // declared private but not implemented. This is the
75  // standard practice to prevent them from being used.
78 
79 public:
80 
90  {
91  public:
95  virtual ~ElementFlagging () {}
96 
100  virtual void flag_elements () = 0;
101  };
102 
107 
111  ~MeshRefinement ();
112 
116  void clear ();
117 
129  void flag_elements_by_error_fraction (const ErrorVector& error_per_cell,
130  const Real refine_fraction = 0.3,
131  const Real coarsen_fraction = 0.0,
132  const unsigned int max_level = libMesh::invalid_uint);
133 
148  void flag_elements_by_error_tolerance (const ErrorVector& error_per_cell);
149 
163  bool flag_elements_by_nelem_target (const ErrorVector& error_per_cell);
164 
178  void flag_elements_by_elem_fraction (const ErrorVector& error_per_cell,
179  const Real refine_fraction = 0.3,
180  const Real coarsen_fraction = 0.0,
181  const unsigned int max_level = libMesh::invalid_uint);
182 
196  void flag_elements_by_mean_stddev (const ErrorVector& error_per_cell,
197  const Real refine_fraction = 1.0,
198  const Real coarsen_fraction = 0.0,
199  const unsigned int max_level = libMesh::invalid_uint);
200 
205  void flag_elements_by (ElementFlagging &element_flagging);
206 
212 
217  void add_p_to_h_refinement();
218 
230  bool refine_and_coarsen_elements (const bool maintain_level_one=true);
231 
243  bool coarsen_elements (const bool maintain_level_one=true);
244 
255  bool refine_elements (const bool maintain_level_one=true);
256 
260  void uniformly_refine (unsigned int n=1);
261 
265  void uniformly_coarsen (unsigned int n=1);
266 
270  void uniformly_p_refine (unsigned int n=1);
271 
275  void uniformly_p_coarsen (unsigned int n=1);
276 
281  void clean_refinement_flags ();
282 
289  bool test_level_one (bool libmesh_assert_yes = false);
290 
298  bool test_unflagged (bool libmesh_assert_yes = false);
299 
307  Node* add_point (const Point& p,
309  const Real tol);
310 
314  Elem* add_elem (Elem* elem);
315 
320  const MeshBase& get_mesh () const { return _mesh; }
321 
326  MeshBase& get_mesh () { return _mesh; }
327 
335  bool& coarsen_by_parents();
336 
345 
354 
361  unsigned int& max_h_level();
362 
372 
381 
392 
403  unsigned char& face_level_mismatch_limit();
404 
414  unsigned char& edge_level_mismatch_limit();
415 
425  unsigned char& node_level_mismatch_limit();
426 
432 
433 private:
434 
449  bool _coarsen_elements ();
450 
459  bool _refine_elements ();
460 
461 
462 
463  //------------------------------------------------------
464  // "Smoothing" algorthms for refined meshes
465 
530  bool limit_level_mismatch_at_node (const unsigned int max_mismatch);
531 
532  /*
533  * This algorithm restricts the maximum level mismatch
534  * at any edge in the mesh. See the ASCII art in the comment of
535  * limit_level_mismatch_at_node, and pretend they're hexes.
536  */
537  bool limit_level_mismatch_at_edge (const unsigned int max_mismatch);
538 
592 
593 
594  //---------------------------------------------
595  // Utility algorithms
596 
602  void create_parent_error_vector (const ErrorVector& error_per_cell,
603  ErrorVector& error_per_parent,
604  Real &parent_error_min,
605  Real &parent_error_max);
606 
610  void update_nodes_map ();
611 
616  bool make_coarsening_compatible (const bool);
617 
622  bool make_refinement_compatible (const bool);
623 
629  const PointLocatorBase* point_locator,
630  const unsigned int side);
631 
636  bool has_topological_neighbor (Elem* elem,
637  const PointLocatorBase* point_locator,
638  Elem* neighbor);
639 
644 
649 
656 
662 
664 
666 
667  unsigned int _max_h_level;
668 
670 
672 
674 
677 
678 #ifdef LIBMESH_ENABLE_PERIODIC
680 #endif
681 };
682 
683 
684 
685 // ------------------------------------------------------------
686 // MeshRefinement class inline members
687 
689 {
690  _use_member_parameters = true;
691  return _coarsen_by_parents;
692 }
693 
695 {
696  _use_member_parameters = true;
697  return _refine_fraction;
698 }
699 
701 {
702  _use_member_parameters = true;
703  return _coarsen_fraction;
704 }
705 
706 inline unsigned int& MeshRefinement::max_h_level()
707 {
708  _use_member_parameters = true;
709  return _max_h_level;
710 }
711 
713 {
714  _use_member_parameters = true;
715  return _coarsen_threshold;
716 }
717 
719 {
720  _use_member_parameters = true;
721  return _nelem_target;
722 }
723 
725 {
726  _use_member_parameters = true;
728 }
729 
731 {
733 }
734 
736 {
738 }
739 
741 {
743 }
744 
745 
746 } // namespace libMesh
747 
748 #endif // end #ifdef LIBMESH_ENABLE_AMR
749 #endif // LIBMESH_MESH_REFINEMENT_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo