1#ifndef DUNE_SPGRID_GRIDLEVEL_HH
2#define DUNE_SPGRID_GRIDLEVEL_HH
24 template<
int mydim,
int cdim,
class Gr
id >
25 class SPLocalGeometry;
32 template<
class Gr
id >
34 :
public SPGeometricGridLevel< typename std::remove_const< Grid >::type::ctype, std::remove_const< Grid >::type::dimension >
49 typedef typename std::remove_const< Grid >::type::Traits
Traits;
51 typedef typename Traits::Domain
Domain;
68 typedef typename Traits::template Codim< 0 >::LocalGeometry
LocalGeometry;
82 const Grid &
grid ()
const {
return *grid_; }
83 int level ()
const {
return level_; }
90 template< PartitionIteratorType pitype >
104 const unsigned int partitionNumber,
105 const int face )
const;
112 void buildLocalGeometry ();
113 void buildBoundaryPartitions ();
127 std::vector< Mesh > decomposition_;
132 LocalGeometryImpl **geometryInFather_;
142 template<
class Gr
id >
143 inline SPGridLevel< Grid >
145 :
Base( grid.refCubes_, meshWidth( grid.domain(), decomposition.mesh() ) ),
149 macroFactor_( coarseMacroFactor() ),
150 domain_( grid.domain() ),
151 decomposition_( decomposition.subMeshes() ),
152 localMesh_( decomposition_[ grid.comm().rank() ] ),
153 partitionPool_( localMesh_, decomposition.mesh(), overlap(), domain_.topology() ),
154 linkage_( grid.comm().rank(), partitionPool_, decomposition_ )
156 buildLocalGeometry();
157 buildBoundaryPartitions();
161 template<
class Gr
id >
163 :
Base( father.grid().refCubes_, meshWidth( father.domain(), father.globalMesh().refine(
Refinement( father.refinement(), policy ) ) ) ),
164 grid_( father.grid_ ),
165 level_( father.level() + 1 ),
166 refinement_( father.refinement(), policy ),
167 macroFactor_( refineWidth( father.macroFactor_, refinement_ ) ),
168 domain_( father.domain() ),
169 decomposition_(
transform( father.decomposition_, [ this ]( const
Mesh &mesh ) {
return mesh.refine( refinement_ ); } ) ),
170 localMesh_( father.localMesh().refine( refinement_ ) ),
171 partitionPool_( localMesh_, father.globalMesh().refine( refinement_ ), overlap(), domain_.topology() ),
172 linkage_( father.grid().comm().rank(), partitionPool_, decomposition_ )
174 buildLocalGeometry();
175 buildBoundaryPartitions();
179 template<
class Gr
id >
182 grid_( other.grid_ ),
183 refinement_( other.refinement_ ),
184 macroFactor_( other.macroFactor_ ),
185 domain_( other.domain_ ),
186 decomposition_( other.decomposition_ ),
187 localMesh_( other.localMesh_ ),
188 partitionPool_( other.partitionPool_ ),
189 linkage_( other.linkage_ )
191 buildLocalGeometry();
192 buildBoundaryPartitions();
196 template<
class Gr
id >
199 if( geometryInFather_ )
201 unsigned int numChildren = refinement().numChildren();
202 for(
unsigned int index = 0; index < numChildren; ++index )
203 delete geometryInFather_[ index ];
204 delete geometryInFather_;
208 template<
class Gr
id >
212 return partitionPool_.globalMesh();
216 template<
class Gr
id >
224 template<
class Gr
id >
225 template< PartitionIteratorType pitype >
229 return partitionPool_.template get< pitype >();
233 template<
class Gr
id >
237 assert( (face >= 0) && (face <= numFaces) );
238 return boundaryPartition_[ face ];
242 template<
class Gr
id >
243 template<
int codim >
247 return partitionPool_.template partitionType< codim >(
id, partitionNumber );
251 template<
class Gr
id >
255 return linkage_.interface( iftype );
259 template<
class Gr
id >
264 for(
int i = 0; i < dimension; ++i )
265 macroId[ i ] = (((
id[ i ] >> 1) / macroFactor_[ i ]) << 1) | (
id[ i ] & 1);
270 template<
class Gr
id >
273 const unsigned int partitionNumber,
274 const int face )
const
279 for(
int i = 0; i < dimension; ++i )
280 macroId[ i ] =
id[ i ] / macroFactor_[ i ];
281 return grid().boundaryIndex( macroId, partitionNumber, face );
285 template<
class Gr
id >
289 assert( (level() > 0) && (geometryInFather_ != 0) );
290 return LocalGeometry( *(geometryInFather_[ refinement().childIndex(
id ) ]) );
294 template<
class Gr
id >
297 return globalMesh().volume();
301 template<
class Gr
id >
304 geometryInFather_ = 0;
307 const unsigned int numChildren = refinement().numChildren();
308 geometryInFather_ =
new LocalGeometryImpl *[ numChildren ];
309 const GlobalVector hInFather = refinement().template hInFather< ctype >();
311 const typename Base::template Codim< 0 >::GeometryCache cacheInFather( hInFather, *dirIt );
312 for(
unsigned int index = 0; index < numChildren; ++index )
314 const GlobalVector origin = refinement().template originInFather< ctype >( index );
315 geometryInFather_[ index ] =
new LocalGeometryImpl( cacheInFather, origin );
321 template<
class Gr
id >
322 inline void SPGridLevel< Grid >::buildBoundaryPartitions ()
324 const Mesh &globalMesh = This::globalMesh();
326 for(
int face = 0; face < numFaces; ++face )
328 const int i = face >> 1;
331 const PartitionList &plist = partition< All_Partition >();
332 const typename PartitionList::Iterator end = plist.end();
333 for(
typename PartitionList::Iterator it = plist.begin(); it != end; ++it )
336 typedef typename PartitionList::Partition Partition;
337 const Partition &partition = *it;
340 MultiIndex bound[ 2 ];
341 bound[ 0 ] = partition.begin();
342 bound[ 1 ] = partition.end();
345 int bnd = (face & 1)*bound[ 1 ][ i ] + (1 - (face & 1))*bound[ 0 ][ i ];
346 bound[ 0 ][ i ] = bnd;
347 bound[ 1 ][ i ] = bnd;
350 if( bnd == 2*globalMesh.bound( face & 1 )[ i ] )
351 boundaryPartition_[ face ] += Partition( bound[ 0 ], bound[ 1 ], partition.number() );
357 template<
class Gr
id >
359 SPGridLevel< Grid >::coarseMacroFactor ()
361 MultiIndex macroFactor;
362 for(
int i = 0; i < dimension; ++i )
363 macroFactor[ i ] = 1;
368 template<
class Gr
id >
370 SPGridLevel< Grid >::meshWidth (
const Domain &domain,
const Mesh &mesh )
372 GlobalVector h = domain.cube().width();
373 const MultiIndex meshWidth = mesh.width();
374 for(
int i = 0; i < dimension; ++i )
375 h[ i ] /= ctype( meshWidth[ i ] );
380 template<
class Gr
id >
382 SPGridLevel< Grid >::refineWidth (
const MultiIndex &
id,
const Refinement &refinement )
385 for(
int i = 0; i < dimension; ++i )
386 result[ i ] =
id[ i ] * refinement.factor( i );
391 template<
class Gr
id >
393 SPGridLevel< Grid >::overlap ()
const
396 for(
int i = 0; i < dimension; ++i )
397 overlap[ i ] = macroFactor_[ i ] * grid().overlap()[ i ];
description of computational domain
miscellaneous helper functions
Definition: iostream.hh:7
std::vector< decltype(std::declval< Op >()(std::declval< T >())) > transform(const std::vector< T > &in, Op op)
copy a vector, performing an operation on each element
Definition: misc.hh:24
Definition: decomposition.hh:17
Definition: direction.hh:157
Definition: geometricgridlevel.hh:24
const ReferenceCube & referenceCube() const
Definition: geometricgridlevel.hh:53
static const unsigned int numDirections
Definition: geometricgridlevel.hh:37
ReferenceCube::ctype ctype
Definition: geometricgridlevel.hh:32
static const int dimension
Definition: geometricgridlevel.hh:33
Definition: geometry.hh:161
Definition: gridlevel.hh:35
Traits::Domain Domain
Definition: gridlevel.hh:51
Base::ctype ctype
Definition: gridlevel.hh:43
const Mesh & globalMesh() const
Definition: gridlevel.hh:210
Traits::Refinement Refinement
Definition: gridlevel.hh:52
const Refinement & refinement() const
Definition: gridlevel.hh:85
PartitionType partitionType(const MultiIndex &id, const unsigned int partitionNumber) const
Definition: gridlevel.hh:245
Decomposition::Mesh Mesh
Definition: gridlevel.hh:62
static const int dimension
Definition: gridlevel.hh:45
const Mesh & localMesh() const
Definition: gridlevel.hh:218
SPGridLevel< Grid > GridLevel
Definition: gridlevel.hh:40
Traits::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: gridlevel.hh:68
static const unsigned int numDirections
Definition: gridlevel.hh:46
static const int numFaces
Definition: gridlevel.hh:47
std::remove_const< Grid >::type::Traits Traits
Definition: gridlevel.hh:49
Base::ReferenceCube ReferenceCube
Definition: gridlevel.hh:42
Linkage::Interface CommInterface
Definition: gridlevel.hh:66
int level() const
Definition: gridlevel.hh:83
const PartitionList & boundaryPartition(int face) const
Definition: gridlevel.hh:235
ReferenceCube::GlobalVector GlobalVector
Definition: gridlevel.hh:55
SPDecomposition< dimension > Decomposition
Definition: gridlevel.hh:58
MultiIndex macroId(const MultiIndex &id) const
Definition: gridlevel.hh:261
int size() const
Definition: gridlevel.hh:295
const PartitionList & partition() const
Definition: gridlevel.hh:227
Traits::RefinementPolicy RefinementPolicy
Definition: gridlevel.hh:53
SPGridLevel(const Grid &grid, const Decomposition &decomposition)
Definition: gridlevel.hh:144
size_t boundaryIndex(const MultiIndex &id, const unsigned int partitionNumber, const int face) const
Definition: gridlevel.hh:272
const CommInterface & commInterface(const InterfaceType iftype) const
Definition: gridlevel.hh:253
SPPartitionPool< dimension > PartitionPool
Definition: gridlevel.hh:59
const Grid & grid() const
Definition: gridlevel.hh:82
const Domain & domain() const
Definition: gridlevel.hh:84
~SPGridLevel()
Definition: gridlevel.hh:197
ReferenceCube::MultiIndex MultiIndex
Definition: gridlevel.hh:56
PartitionPool::PartitionList PartitionList
Definition: gridlevel.hh:64
SPLinkage< dimension > Linkage
Definition: gridlevel.hh:60
LocalGeometry geometryInFather(const MultiIndex &id) const
Definition: gridlevel.hh:287
Definition: linkage.hh:54
Definition: referencecube.hh:43
static const int numFaces
Definition: referencecube.hh:55
FieldVector< ctype, dimension > GlobalVector
Definition: referencecube.hh:51