dune-fem 2.12-git
Loading...
Searching...
No Matches
uniquefacetorientation.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_SPACE_COMMON_UNIQUEFACETORIENTATION_HH
2#define DUNE_FEM_SPACE_COMMON_UNIQUEFACETORIENTATION_HH
3
4#include <type_traits>
5#include <utility>
6
8
15
16namespace Dune
17{
18
19 namespace Fem
20 {
21
22 // DefaultUniqueFacetOrientation
23 // -----------------------------
24
25 template< class GridPart >
27 {
28 typedef GridPart GridPartType;
29 typedef typename GridPartType::GridType GridType;
31
32 typedef typename GridPartType::template Codim< 0 >::EntityType EntityType;
33 typedef typename EntityType::Geometry::GlobalCoordinate GlobalCoordinateType;
34
35 //typedef FunctionSpace< double, int, GridPartType::dimensionworld, 1 > FunctionSpaceType;
36 // typedef FiniteVolumeSpace< FunctionSpaceType, GridPartType, 0, SimpleStorage > SpaceType;
37
38 //typedef ParallelDofMapper< GridPartType, typename SpaceType::BlockMapperType > ParallelMapperType;
39 //typedef typename ParallelMapperType :: GlobalKeyType GlobalKeyType;
40
41 static const int dimensionworld = GridPartType::dimensionworld;
42
45 dofManager_( DofManagerType::instance( gridPart_.grid() ) ),
46 uniqueDirection_( M_PI ),
47 sequence_( -1 )
48 {
49 if constexpr ( dimensionworld > 1 )
50 uniqueDirection_[ 1 ] = M_LN2;
51 if constexpr ( dimensionworld > 2 )
52 uniqueDirection_[ 2 ] = M_E;
53 }
54
55 void update() const
56 {
58 {
59 orientations_.resize( gridPart().indexSet().size(0) );
60 const auto& indexSet = gridPart().indexSet();
61 for( const auto& entity : elements( gridPart(), Partitions::all ) )
62 {
63 unsigned int orientations = 0;
64 for( auto intersection : intersections( gridPart(), entity ) )
65 {
66 if( intersection.neighbor() )
67 {
68 // make sure that the normal is not orthogonal to the uniqueDirection_
69 assert( std::abs(intersection.centerUnitOuterNormal() * uniqueDirection_) > 0 );
70
71 if( (intersection.centerUnitOuterNormal() * uniqueDirection_) > 0 )
72 {
73 orientations |= (1 << intersection.indexInInside());
74 }
75 }
76 }
77 orientations_[ indexSet.index( entity ) ] = orientations;
78 }
80 }
81 }
82
83 unsigned int operator() ( const EntityType &entity ) const
84 {
85 update();
86 return orientations_[ gridPart().indexSet().index( entity ) ];
87 }
88
89 /*
90 unsigned int orientations = 0;
91 for( auto intersection : intersections( gridPart(), entity ) )
92 {
93 if( intersection.neighbor() && (globallyUniqueIndex( entity ) < globallyUniqueIndex( intersection.outside() )) )
94 orientations |= (1 << intersection.indexInInside());
95 }
96 return orientations;
97 */
98
99 /*
100 template <class Entity>
101 GlobalKeyType globallyUniqueIndex( const Entity& entity ) const
102 {
103 retu
104 GlobalKeyType index = -1;
105 // parallelMapper_.mapEach( entity, [ &index ] ( auto local, auto global ) { assert( local == 0 ); index = global; } );
106 return gridPart().indexSet().index(entity);
107 return index;
108 }
109 */
110
111 const GridPartType &gridPart () const { return gridPart_; }
112
113 protected:
118 //SpaceType space_; // works without this
119 // mutable ParallelMapperType parallelMapper_;
120 mutable int sequence_;
121 };
122
123
124
125 // CartesianUniqueFacetOrientation
126 // -------------------------------
127
128 template< class GridPart >
130 {
131 typedef GridPart GridPartType;
132 typedef typename GridPart::template Codim< 0 >::EntityType EntityType;
133
135 : gridPart_( gridPart )
136 {}
137
138 unsigned int operator() ( const EntityType &entity ) const
139 {
141 }
142
143 const GridPartType &gridPart () const { return gridPart_; }
144
145 private:
146 template< std::size_t... i >
147 static constexpr unsigned int orientations ( std::index_sequence< i... > )
148 {
149 return Std::sum( (1u << 2*i)... );
150 }
151
152 const GridPartType &gridPart_;
153 };
154
155
156
157 // UniqueFacetOrientation
158 // ----------------------
159
160 template< class GP >
165
166 } // namespace Fem
167
168} // namespace Dune
169
170#endif // #ifndef DUNE_FEM_SPACE_COMMON_UNIQUEFACETORIENTATION_HH
int size() const
virtual void operator()()=0
static constexpr std::decay_t< T > sum(T a)
Definition utility.hh:33
constexpr All all
int sequence() const
return number of sequence, if dofmanagers memory was changed by calling some method like resize,...
Definition dofmanager.hh:1007
Dune::Fem::Double abs(const Dune::Fem::Double &a)
Definition double.hh:942
typename std::conditional< GridPartCapabilities::isCartesian< GP >::v, CartesianUniqueFacetOrientation< GP >, DefaultUniqueFacetOrientation< GP > >::type UniqueFacetOrientation
Definition uniquefacetorientation.hh:164
IndexType index(const typename Traits::template Codim< cc >::Entity &e) const
Definition dofmanager.hh:786
Definition uniquefacetorientation.hh:27
GridPartType::GridType GridType
Definition uniquefacetorientation.hh:29
void update() const
Definition uniquefacetorientation.hh:55
DofManager< GridType > DofManagerType
Definition uniquefacetorientation.hh:30
EntityType::Geometry::GlobalCoordinate GlobalCoordinateType
Definition uniquefacetorientation.hh:33
GlobalCoordinateType uniqueDirection_
Definition uniquefacetorientation.hh:116
const GridPartType & gridPart_
Definition uniquefacetorientation.hh:114
std::vector< unsigned int > orientations_
Definition uniquefacetorientation.hh:117
DefaultUniqueFacetOrientation(const GridPartType &gridPart)
Definition uniquefacetorientation.hh:43
const GridPartType & gridPart() const
Definition uniquefacetorientation.hh:111
const DofManagerType & dofManager_
Definition uniquefacetorientation.hh:115
GridPartType::template Codim< 0 >::EntityType EntityType
Definition uniquefacetorientation.hh:32
int sequence_
Definition uniquefacetorientation.hh:120
static const int dimensionworld
Definition uniquefacetorientation.hh:41
GridPart GridPartType
Definition uniquefacetorientation.hh:28
Definition uniquefacetorientation.hh:130
GridPart GridPartType
Definition uniquefacetorientation.hh:131
GridPart::template Codim< 0 >::EntityType EntityType
Definition uniquefacetorientation.hh:132
const GridPartType & gridPart() const
Definition uniquefacetorientation.hh:143
CartesianUniqueFacetOrientation(const GridPartType &gridPart)
Definition uniquefacetorientation.hh:134
T resize(T... args)