dune-fem 2.12-git
Loading...
Searching...
No Matches
twistprovider.cc
Go to the documentation of this file.
1namespace Dune
2{
3
4 namespace Fem
5 {
6
7 template <class ct, int dim>
8 TwistStorage<ct, dim>::TwistStorage(int minTwist, int maxTwist) :
9 mappers_(Traits::twistOffset_ + maxTwist),
10 points_(),
11 minTwist_(minTwist),
12 maxTwist_(maxTwist)
13 {}
14
15 template <class ct, int dim>
17 int twist)
18 {
19 mappers_[twist + Traits::twistOffset_] = mapper;
20 }
21
22 template <class ct, int dim>
24 {
25 size_t indexOfPoint = points_.size();
26 points_.push_back(point);
27
28 return indexOfPoint;
29 }
30
31 template <class ct, int dim>
34 {
35 return mappers_[twist + Traits::twistOffset_];
36 }
37
38 template <class ct, int dim>
41 {
42 return points_;
43 }
44
45 template <class ct, int dim>
48 {
49 typedef const TwistStorageType* TwistStoragePtr;
50 assert( quad.id() < MapperContainer::instance().size() );
51 TwistStoragePtr& ptr = MapperContainer::instance()[ quad.id() ];
52
53 if( ptr == 0 )
54 {
55 TwistMapperCreator<ct, dim> creator(quad);
56 ptr = creator.createStorage();
57 }
58
59 assert( ptr != 0 );
60 return *ptr ;
61 }
62
63 template <class ct, int dim>
64 const ct TwistMapperCreator<ct, dim>::eps_ = 1.0e-5;
65
66 template <class ct, int dim>
68 quad_(quad),
69 helper_( 0 )
70 {
71 const GeometryType geoType = quad.geometryType();
72 if (dim == 0) {
73 helper_ = new PointTwistMapperStrategy<ct,dim>( geoType );
74 }
75 else if (dim == 1) {
76 helper_ = new LineTwistMapperStrategy<ct, dim>( geoType );
77 }
78 else
79 {
80 assert (dim == 2);
81
82 if(geoType.isTriangle())
83 {
84 helper_ = new TriangleTwistMapperStrategy<ct, dim>( geoType );
85 return ;
86 }
87 if( geoType.isQuadrilateral())
88 {
89 helper_ = new QuadrilateralTwistMapperStrategy<ct,dim>( geoType );
90 return ;
91 }
93 "No creator for given GeometryType exists");
94 }
95 }
96
97 template <class ct, int dim>
99 {
100 delete helper_ ; helper_ = 0 ;
101 }
102
103 template <class ct, int dim>
106 {
107 TwistStorageType* storage =
108 new TwistStorageType(helper_->minTwist(), helper_->maxTwist());
109
110 // Add quadrature points
111 for (size_t i = 0; i < quad_.nop(); ++i) {
112 storage->addPoint(quad_.point(i));
113 }
114
115 // Loop over all twists
116 // and find all mapped quad points
117 for (int twist = helper_->minTwist();
118 twist < helper_->maxTwist(); ++twist)
119 {
120 MapperType mapper(quad_.nop());
121
122 const MatrixType mat = helper_->buildTransformationMatrix(twist);
123
124 for (size_t i = 0; i < quad_.nop(); ++i)
125 {
126 // get local quad point
127 PointType pFace = quad_.point(i);
128
129 // create barycentric coordinate
130 CoordinateType c(0.0);
131 c[0] = 1.0;
132 for (int d = 0; d < dim; ++d) {
133 c[0] -= pFace[d];
134 c[d+1] = pFace[d];
135 }
136
137 // apply mapping
138 PointType pRef(0.);
139 mat.umtv(c, pRef);
140
141 bool found = false;
142 // find equivalent quadrature point
143 for (size_t j = 0; j < quad_.nop(); ++j)
144 {
145 // check if | pRef - quad_j | < eps
146 if( (pRef - quad_.point(j)).infinity_norm() < eps_)
147 {
148 mapper[i] = j;
149 found = true;
150 break;
151 }
152 }
153
154 // add point if it is not one of the quadrature points
155 if (!found) {
156 //if point not found, something is wrong,
157 //could be the quadratue or the mapping
158 assert( found );
159 std::cout << "TwistMapperCreator<ct, dim>::createStorage failed! in: "<<__FILE__<<" line: " << __LINE__ <<"\n";
160 abort();
161 }
162
163 } // for all quadPoints
164 storage->addMapper(mapper, twist);
165 } // for all twists
166
167 return storage;
168 }
169
170 } // namespace Fem
171
172} // namespace Dune
Matrix & mat
size_type dim() const
#define DUNE_THROW(E,...)
constexpr bool isTriangle() const
constexpr bool isQuadrilateral() const
Definition pointmapper.hh:65
static const TwistStorageType & getTwistStorage(const QuadratureType &quad)
Delivers the PointMapper object for quadrature quad and twist twist.
Definition twistprovider.cc:47
Helper class for TwistProvider which takes care of the creation process.
Definition twistprovider.hh:196
TwistMapperCreator(const QuadratureType &quad)
Constructor.
Definition twistprovider.cc:67
~TwistMapperCreator()
Destructor.
Definition twistprovider.cc:98
const TwistStorageType * createStorage() const
Create the actual mapper for a given twist.
Definition twistprovider.cc:105
Traits::PointType PointType
Definition twistprovider.hh:200
Identifies quadrature points on faces with twists For a given quadrature type and a face with a given...
Definition twistprovider.hh:54
TwistStorage(int minTwist, int maxTwist)
Definition twistprovider.cc:8
void addMapper(const MapperType &mapper, int twist)
Add a new mapper for a given twist.
Definition twistprovider.cc:16
const MapperType & getMapper(int twist) const
Access to a mapper.
Definition twistprovider.cc:33
size_t addPoint(const PointType &points)
Add a point (in the case of asymmetric quadratures)
Definition twistprovider.cc:23
const PointVectorType & getPoints() const
Definition twistprovider.cc:40
Traits::PointType PointType
Definition twistprovider.hh:57
Definition twistprovider.hh:249
Definition twistprovider.hh:281
Definition twistprovider.hh:314
Definition twistprovider.hh:348
size_t id() const
obtain the identifier of the integration point list
Definition quadratureimp.hh:122
virtual GeometryType geometryType() const =0
obtain GeometryType for this integration point list
T size(T... args)