Class documentation of Concepts

Loading...
Searching...
No Matches
bilinearForm.hh
Go to the documentation of this file.
1
6#ifndef BilinearForm_hh
7#define BilinearForm_hh
8
9#include <memory>
11#include "basics/cloneable.hh"
12#include "space/elementPairs.hh"
14#include "basics/exceptions.hh"
15
16namespace concepts {
17
18 // forward declaration
19 template<class F>
20 class Element;
21
22 template<class F>
23 class ElementMatrix;
24
25 // ********************************************************** BilinearForm **
26
33 class BilinearForm : public Cloneable, public virtual OutputOperator {
34 public:
43 virtual void operator()(const Element<G>& elmX, const Element<G>& elmY,
44 ElementMatrix<F>& em) const = 0;
57 virtual void operator()(const Element<G>& elmX, const Element<G>& elmY,
58 ElementMatrix<F>& em, const ElementPair<G>& ep) const{
60 }
61
62 virtual BilinearForm* clone() const = 0;
63
64 protected:
65 virtual std::ostream& info(std::ostream& os) const;
66 };
67
68
69 // ****************************************************** BilinearFormLiCo **
70
78 class BilinearFormLiCo : public BilinearForm<F,G> {
79 public:
88 const F cA = 1.0, const F cB = 1.0) :
89
90 bfAptr_(nullptr), bfBptr_(nullptr),
91 bfA_(&bfA), bfB_(&bfB),
92
93 cA_(cA), cB_(cB), em_() {}
96 virtual ~BilinearFormLiCo() {}
97 virtual void operator()(const Element<G>& elmX,
98 const Element<G>& elmY,
99 ElementMatrix<F>& em) const;
100 virtual BilinearFormLiCo<F,G>* clone() const;
101 protected:
102 virtual std::ostream& info(std::ostream& os) const;
103 private:
104 std::unique_ptr<BilinearForm<F,G> > bfAptr_, bfBptr_;
106 BilinearForm<F,G>* bfA_, * bfB_;
107
108
110
112 const F cA_;
114 const F cB_;
116 mutable ElementMatrix<F> em_;
117 };
118
119 // ************************************************* BilinearFormContainer **
120
137 public:
141
145
147
148 explicit BilinearFormContainer(const BilinearForm<F,G>* frm);
149
152
153 virtual void operator()(const Element<G>& elmX,
154 const Element<G>& elmY,
155 ElementMatrix<F>& em) const;
156
159 return new BilinearFormContainer<F,G>(*this);
160 }
161
163 bool empty() const { return bf_.get() == 0; }
164
166 void transpose() {
167 transpose_ = !transpose_;
168 }
169
170 virtual ~BilinearFormContainer();
171 protected:
172 virtual std::ostream& info(std::ostream& os) const;
175 private:
177 bool transpose_;
178 };
179
180
181 // ******************************************* PointerToEmptyBilinearForm **
182
188 public:
191 {
192 errorMessage_ = "Empty RCP<BilinearForm>";
193 }
195 protected:
196 virtual std::ostream& info(std::ostream& os) const throw();
197 private:
198 std::string errorMessage_;
199 };
200
201
202
203 // ********************************************************* BilinearF_Sum **
211 class BilinearF_Sum : public BilinearForm<F,G> {
212 public:
215 : bf1_(bf1), bf2_(bf2)
216 {
217 if (bf1_.empty()) throw(PointerToEmptyBilinearForm());
218 if (bf2_.empty()) throw(PointerToEmptyBilinearForm());
219 }
220
221 virtual ~BilinearF_Sum(){};
222
224 const Element<G>& elmY,
225 ElementMatrix<F>& em) const
226 {
227 //intermediate Matrix
228 ElementMatrix<H> em_H(elmX.T().m(), elmY.T().m());
229 ElementMatrix<J> em_J(elmX.T().m(), elmY.T().m());
230 em.resize(elmX.T().m(), elmY.T().m());
231 em_H.zeros();
232 em_J.zeros();
233 em.zeros();
234
235 bf1_(elmX, elmY, em_H);
236 bf2_(elmX, elmY, em_J);
237 F* emData = (F*)em;
238
239 H* em_H_Data = (H*)em_H;
240 J* em_J_Data = (J*)em_J;
241
242 for (uint i = 0; i < elmX.T().m()*elmY.T().m(); ++i, emData++, em_H_Data++, em_J_Data++) {
244 }
245 }
246
247
248 virtual BilinearF_Sum<F,H,J,G>* clone() const {
249 return new BilinearF_Sum<F,H,J,G>(bf1_, bf2_);
250 }
251
252 protected:
253 virtual std::ostream& info(std::ostream& os) const {
254 return os << typeOf(*this) << "(" << bf1_
255 << " , " << bf2_ << ")";
256 }
257 private:
262 };
263
264
265
266
267// ********************************************************* BilinearF_W **
275 class BilinearF_W : public BilinearForm<F,G> {
276 public:
278 const J w)
279 : bf1_(bf1), w_(w)
280 {
281 if (bf1_.empty()) throw(PointerToEmptyBilinearForm());
282 }
283
284 virtual ~BilinearF_W(){};
285
287 const Element<G>& elmY,
288 ElementMatrix<F>& em) const
289 {
290 concepts::ElementMatrix<H> tmp(elmX.T().m(), elmY.T().m());
291 tmp.zeros();
292
293 bf1_(elmX, elmY, tmp);
294
295 F* emData = (F*)em;
296 H* tmpData = (H*)tmp;
297
298 for (uint i = 0; i < elmX.T().m()*elmY.T().m(); ++i, emData++, tmpData++) {
299 *emData = *tmpData * w_;
300 }
301 }
302
303
304 virtual BilinearF_W<F,H,J,G>* clone() const {
305 return new BilinearF_W<F,H,J,G>(bf1_, w_);
306 }
307
308 protected:
309 virtual std::ostream& info(std::ostream& os) const {
310 return os << typeOf(*this) << "(" << bf1_
311 << " , " << w_ << ")";
312 }
313 private:
317 J w_;
318 };
319
320
321
322
323
324
330
334
338
342
343
344
349 const Real w);
350
352 operator*(const BilinearFormContainer<Real> frm1,
353 const Cmplx w);
354
356 operator*(const BilinearFormContainer<Cmplx> frm1,
357 const Real w);
358
360 operator*(const BilinearFormContainer<Cmplx> frm1,
361 const Cmplx w);
362
363 //Multiplikation from left
365 operator*(const Real w,
367
369 operator*(const Cmplx w,
371
373 operator*(const Real w,
375
377 operator*(const Cmplx w,
379
380
381
387
391
395
399
400
401
402
403} // namespace concepts
404
405#endif // BilinearForm_hh
void operator()(const Element< G > &elmX, const Element< G > &elmY, ElementMatrix< F > &em) const
virtual BilinearF_Sum< F, H, J, G > * clone() const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void operator()(const Element< G > &elmX, const Element< G > &elmY, ElementMatrix< F > &em) const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual BilinearF_W< F, H, J, G > * clone() const
virtual BilinearFormContainer< F, G > * clone() const
Virtual copy constructor.
void transpose()
Transpose the bilinearform, i.e. interchange test and trial functions.
RCP< const BilinearForm< F, G > > bf_
bilinear form is stored as a RCP
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void operator()(const Element< G > &elmX, const Element< G > &elmY, ElementMatrix< F > &em) const
BilinearFormContainer(const BilinearForm< F, G > &bf)
bool empty() const
Returns true if no formula is stored.
BilinearFormContainer(const BilinearFormContainer< F, G > &frm)
Copy constructor.
BilinearFormLiCo(BilinearForm< F, G > &bfA, BilinearForm< F, G > &bfB, const F cA=1.0, const F cB=1.0)
BilinearFormLiCo(const BilinearFormLiCo &b)
Copy constructor. This copy constructor implements a deep copy.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void operator()(const Element< G > &elmX, const Element< G > &elmY, ElementMatrix< F > &em) const
virtual BilinearFormLiCo< F, G > * clone() const
virtual BilinearForm * clone() const =0
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void operator()(const Element< G > &elmX, const Element< G > &elmY, ElementMatrix< F > &em) const =0
virtual void operator()(const Element< G > &elmX, const Element< G > &elmY, ElementMatrix< F > &em, const ElementPair< G > &ep) const
void zeros()
Fills the matrix with zeros.
Definition element.hh:295
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
ElementFormulaContainer< Real > operator-(const ElementFormulaContainer< Real > frm, const Real a)
Simple subtracting of a element formulas and a constant via –operator.
std::string typeOf(const T &t)
Definition output.hh:43
Frm_Sum< Real > operator+(const Formula< Real > &frm, const Real a)
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition typedefs.hh:42
GenericElement< KarniadakisMixin< F > > Element
template aliases for backwards compatibility
Definition element.hh:267