Dune Core Modules (2.9.0)

alugrid.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALU3DGRID_ALUGRID_HH
2 #define DUNE_ALU3DGRID_ALUGRID_HH
3 
4 #include <type_traits>
5 
6 // 3d version
8 #include <dune/alugrid/3d/alu3dinclude.hh>
9 #include <dune/alugrid/3d/indexsets.hh>
10 #include <dune/alugrid/3d/iterator.hh>
11 #include <dune/alugrid/3d/entity.hh>
12 #include <dune/alugrid/3d/geometry.hh>
13 #include <dune/alugrid/3d/grid.hh>
14 
20 namespace Dune
21 {
22 
23  template <class Comm>
24  static const char* ALUGridParallelSerial()
25  {
26  return ( std::is_same< Comm, ALUGridNoComm >::value ) ? "serial" : "parallel";
27  }
28 
29  template< int dim, int dimworld, ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
30  class ALUGrid
31  : public ALUGridBaseGrid< dim, dimworld, elType, Comm > :: BaseGrid
32  {
33  typedef ::ALUGrid::ALUGridExternalParameters ALUGridExternalParameters;
34 
35  // the cube version of ALUGrid only works with nonconforming refinement
36  static_assert( elType == cube ? refineType == nonconforming : true, "cube only works with nonconforming refinement");
37 
39  typedef typename ALUGridBaseGrid< dim, dimworld, elType, Comm > :: BaseGrid BaseType;
40 
41  ALUGridRefinementType getRefinementType( const ALUGridRefinementType defaultRefType )
42  {
43  // for simplex grid we allow to dynamically switch to conforming refinement (experimental)
44  if constexpr ( elType == Dune::simplex && refineType == nonconforming )
45  {
46  // if environment var has been set (mainly from Python side)
47  if( getenv("ALUGRID_CONFORMING_REFINEMENT") )
48  {
49  const int conformingRefinement = atoi(getenv("ALUGRID_CONFORMING_REFINEMENT"));
50  if( bool(ALUGridExternalParameters::verbosityLevel()) )
51  std::cout << "ALUGrid: setting conforming refinement in constructor!" <<std::endl;
52  return conformingRefinement ? Dune::conforming : Dune::nonconforming;
53  }
54  }
55 
56  return defaultRefType;
57  }
58 
59  public:
60  typedef typename BaseType::MPICommunicatorType MPICommunicatorType;
61 
63  typedef typename BaseType :: ALUGridVertexProjectionPairType ALUGridVertexProjectionPairType;
64 
65  enum { dimension=BaseType::dimension, dimensionworld=BaseType::dimensionworld};
66  static const ALUGridRefinementType refinementType = refineType;
67  typedef typename BaseType::ctype ctype;
68  typedef typename BaseType::GridFamily GridFamily;
69  typedef typename GridFamily::Traits Traits;
70  typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
71  typedef typename Traits :: GlobalIdSet GlobalIdSet;
72  typedef typename Traits :: LocalIdSet LocalIdSet;
73  typedef typename GridFamily :: LevelIndexSetImp LevelIndexSetImp;
74  typedef typename GridFamily :: LeafIndexSetImp LeafIndexSetImp;
75  typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
76  typedef typename Traits:: template Codim<0>::LeafIterator LeafIteratorType;
77  typedef typename Traits:: template Codim<0>::LeafIterator LeafIterator;
78 
89  ALUGrid(const std::string macroName,
90  const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
92  const bool verb = true ) :
93  BaseType(macroName, mpiComm, bndPrj, getRefinementType(refinementType) )
94  {
95  const bool verbose = verb && (this->comm().rank() == 0) && bool(ALUGridExternalParameters::verbosityLevel());
96  if( verbose )
97  {
98  std::cout << "\nCreated " << ALUGridParallelSerial< Comm >() << " " << name() << nameSuffix( this->conformingRefinement() )
99  << " from macro grid file '" << macroName << "'. \n\n";
100  }
101  }
102 
103  static std::string name () { return std::string("ALUGrid"); }
104 
105  static std::string nameSuffix( const bool conformingRefinement = false )
106  {
107  std::string elt ( elType == cube ? "cube>" : "simplex>" );
108  std::string ref ( conformingRefinement ? " (conforming)": "" );
109  std::stringstream suffix;
110  suffix << "<"<< dimension <<","<< dimensionworld <<"," << elt << ref;
111  return suffix.str();
112  }
113 
114 
124  ALUGrid(const MPICommunicatorType mpiComm,
125  const ALUGridVertexProjectionPairType& bndPrj,
126  const std::string macroName,
127  const bool verb = true ) :
128  BaseType("", mpiComm, bndPrj, getRefinementType(refinementType) )
129  {
130  const bool verbose = verb && (this->comm().rank() == 0) && bool(ALUGridExternalParameters::verbosityLevel());
131  if( verbose )
132  {
133  std::cout << "\nCreated " << ALUGridParallelSerial< Comm >() << " " << name() << nameSuffix( this->conformingRefinement() );
134  if( macroName.empty() )
135  std::cout << " from input stream. \n";
136  else
137  std::cout << " from macro grid file '" << macroName << "'. \n";
138  std::cout << std::endl;
139  }
140  }
141 
143  ALUGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
144  BaseType("", mpiComm, ALUGridVertexProjectionPairType(), getRefinementType(refinementType) )
145  {
146  if(this->comm().rank() == 0 && bool(ALUGridExternalParameters::verbosityLevel()) )
147  {
148  std::cout << "\nCreated empty " << ALUGridParallelSerial< Comm >() << " "
149  << name() << nameSuffix( this->conformingRefinement() ) << "." << std::endl << std::endl;
150  }
151  }
152 
153  // ALUGrid only typedefs
154  typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
155  typedef typename BaseType::ObjectStreamType ObjectStreamType;
156 
157  template< PartitionIteratorType pitype >
158  struct Partition
159  {
162  };
163 
164  typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
165  typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
166 
167  // old grid view methods
168  template< PartitionIteratorType pitype >
169  typename Partition< pitype >::LevelGridView levelView ( int level ) const { return levelGridView< pitype >( level ); }
170 
171  template< PartitionIteratorType pitype >
172  typename Partition< pitype >::LeafGridView leafView () const { return leafGridView< pitype >(); }
173 
174  LevelGridView levelView ( int level ) const { return levelGridView( level ); }
175 
176  LeafGridView leafView () const { return leafGridView(); }
177 
178  // new grid view methods
179  template< PartitionIteratorType pitype >
180  typename Partition< pitype >::LevelGridView levelGridView ( int level ) const
181  {
182  typedef typename Partition< pitype >::LevelGridView LevelGridView;
183  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
184  return LevelGridView( LevelGridViewImp( *this, level ) );
185  }
186 
187  template< PartitionIteratorType pitype >
188  typename Partition< pitype >::LeafGridView leafGridView () const
189  {
190  typedef typename Partition< pitype >::LeafGridView LeafGridView;
191  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
192  return LeafGridView( LeafGridViewImp( *this ) );
193  }
194 
195  LevelGridView levelGridView ( int level ) const
196  {
197  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
198  return LevelGridView( LevelGridViewImp( *this, level ) );
199  }
200 
201  LeafGridView leafGridView () const
202  {
203  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
204  return LeafGridView( LeafGridViewImp( *this ) );
205  }
206 
207  private:
208  template< class > friend class ALU3dGridFactory;
209 
211  ALUGrid( const ALUGrid & g ); // : BaseType(g) {}
212 
214  This& operator = (const ALUGrid& g);
215  };
216 
217  //template< int dim, int dimworld, ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
218  //using ALUGrid = ALUGrid< dim, dimworld, elType, Comm >;
219 
220 } //end namespace Dune
221 
222 //#undef alu_inline
223 #endif // #ifndef DUNE_ALU3DGRID_ALUGRID_HH
unstructured parallel implementation of the DUNE grid interface
Definition: alugrid.hh:32
ALUGrid(const MPICommunicatorType mpiComm=BaseType::defaultCommunicator())
constructor creating empty grid, empty string creates empty grid
Definition: alugrid.hh:143
BaseType ::ALUGridVertexProjectionPairType ALUGridVertexProjectionPairType
type of boundary projection
Definition: alugrid.hh:63
ALUGrid(const MPICommunicatorType mpiComm, const ALUGridVertexProjectionPairType &bndPrj, const std::string macroName, const bool verb=true)
constructor called from ALUGridFactory for creating ALUConformGrid from given macro grid file
Definition: alugrid.hh:124
ALUGrid(const std::string macroName, const MPICommunicatorType mpiComm=BaseType::defaultCommunicator(), const ALUGridVertexProjectionPairType &bndPrj=ALUGridVertexProjectionPairType(), const bool verb=true)
constructor for creating ALUGrid from given macro grid file
Definition: alugrid.hh:89
Grid view abstract base class.
Definition: gridview.hh:66
Capabilities for ALUGrid.
Dune namespace.
Definition: alignedallocator.hh:13
@ simplex
use only simplex elements (i.e., triangles or tetrahedra)
Definition: declaration.hh:18
@ cube
use only cube elements (i.e., quadrilaterals or hexahedra)
Definition: declaration.hh:19
ALUGridRefinementType
available refinement types for ALUGrid
Definition: declaration.hh:24
@ nonconforming
Definition: declaration.hh:26
@ conforming
use only conforming bisection refinement
Definition: declaration.hh:25
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 5, 22:29, 2024)