ug4
reference_mapping.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3  * Author: Andreas Vogel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__UG__LIB_DISC__REFERENCE_ELEMENT__REFERENCE_ELEMENT_MAPPING__
34 #define __H__UG__LIB_DISC__REFERENCE_ELEMENT__REFERENCE_ELEMENT_MAPPING__
35 
36 #include <cassert>
37 #include <iostream>
38 #include <sstream>
39 #include "common/common.h"
40 #include "common/math/ugmath.h"
42 
43 namespace ug{
44 
45 extern DebugID DID_REFERENCE_MAPPING;
47 
63 template <typename TRefElem, int TWorldDim>
65 {
66  public:
68  static const int worldDim = TWorldDim;
69 
71  static const int dim = TRefElem::dim;
72 
74  static const bool isLinear = false;
75 
76  public:
79 
81  ReferenceMapping(const MathVector<worldDim>* vCornerCoord);
82 
84  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord);
85 
87  void update(const MathVector<worldDim>* vCornerCoord);
88 
90  void update(const std::vector<MathVector<worldDim> >& vCornerCoord);
91 
93  bool is_linear() const;
94 
97  const MathVector<dim>& locPos) const;
98 
101  const MathVector<dim>* vLocPos, size_t n) const;
102 
104  void local_to_global(std::vector<MathVector<worldDim> >& vGlobPos,
105  const std::vector<MathVector<dim> >& vLocPos) const;
106 
109  const MathVector<worldDim>& globPos,
110  const size_t maxIter = 1000,
111  const number tol = 1e-10) const;
112 
115  const MathVector<worldDim>* vGlobPos, size_t n,
116  const size_t maxIter = 1000,
117  const number tol = 1e-10) const;
118 
120  void global_to_local(std::vector<MathVector<dim> >& vLocPos,
121  const std::vector<MathVector<worldDim> >& vGlobPos,
122  const size_t maxIter = 1000,
123  const number tol = 1e-10) const;
124 
127  const MathVector<dim>& locPos) const;
128 
131  const MathVector<dim>* vLocPos, size_t n) const;
132 
134  void jacobian(std::vector<MathMatrix<worldDim, dim> >& J,
135  const std::vector<MathVector<dim> >& vLocPos) const;
136 
139  const MathVector<dim>& locPos) const;
140 
143  const MathVector<dim>* vLocPos, size_t n) const;
144 
147  const std::vector<MathVector<dim> >& vLocPos) const;
148 
151  const MathVector<dim>& locPos) const;
152 
155  const MathVector<dim>* vLocPos, size_t n) const;
156 
159  number* vDet,
160  const MathVector<dim>* vLocPos, size_t n) const;
161 
164  const std::vector<MathVector<dim> >& vLocPos) const;
165 
168  std::vector<number>& vDet,
169  const std::vector<MathVector<dim> >& vLocPos) const;
170 
172  number sqrt_gram_det(const MathVector<dim>& locPos) const;
173 
175  void sqrt_gram_det(number* vDet, const MathVector<dim>* vLocPos, size_t n) const;
176 
178  void sqrt_gram_det(std::vector<number> vDet,
179  const std::vector<MathVector<dim> >& vLocPos) const;
180 };
181 
182 
185 // Concrete Reference Mappings
188 
190 template <int dim, int worldDim, bool isLinear, typename TImpl>
192 {
193  public:
195  bool is_linear() const {return isLinear;}
196 
199  const MathVector<dim>* vLocPos, size_t n) const
200  {
201  for(size_t ip = 0; ip < n; ++ip)
202  getImpl().local_to_global(vGlobPos[ip], vLocPos[ip]);
203  }
204 
206  void local_to_global(std::vector<MathVector<worldDim> >& vGlobPos,
207  const std::vector<MathVector<dim> >& vLocPos) const
208  {
209  const size_t n = vLocPos.size();
210  vGlobPos.resize(n);
211  local_to_global(&vGlobPos[0], &vLocPos[0], n);
212  }
213 
216  (
217  MathVector<dim>& locPos,
218  const MathVector<worldDim>& globPos,
219  const size_t maxIter = 1000,
220  const number tol = 1e-10
221  ) const
222  {
223  // We apply the Newton's method for the transformation. We assume here that
224  // the Newton's method converges without the linesearch, and the Jacobian is
225  // non-singular in the whole iteration process. This is true in particular for
226  // the bilinear transformation of convex quadrilaterals if the initial guess
227  // is inside of the element.
230  MathVector<worldDim> dist, compGlobPos, minDist;
231  MathVector<dim> corr;
232 
233  VecScale(minDist, globPos, tol);
234 
235  for (size_t i = 0; i < maxIter; ++i) {
236 
237  // f(x) := \phi(x) - x_{glob}
238  getImpl().local_to_global(compGlobPos, locPos);
239  VecSubtract(dist, compGlobPos, globPos);
240 
241  // Floating-point cancellation protection:
242  if(VecAbsIsLess(dist, minDist))
243  return;
244  // REMARK: Note that the tolerance is specified not only to provide the
245  // sufficient accuracy for the solution but also to protect the iteration
246  // from the cancellation phenomena in the floating-point arithmetics.
247  // Computation of the distance involves subtraction which is a reason for
248  // the loss of precision phenomena. If a small element is located very far
249  // from the coordinate origin, the accuracy of the local->global transform
250  // is restricted and this cannot be overcome. After we reach this bound,
251  // the iterates will oscillate and the defect will not be reduced. We use
252  // globPos for the reference values.
253  // Note that this check may not be used as the only stopping criterion:
254  // globPos may be 0 by specification.
255 
257  "reference_mapping.h: global_to_local() Newton iteration: Iter# "
258  << i << "; fabs(VecTwoNorm(dist)) = " << fabs(VecTwoNorm(dist)) <<
259  "; dist = " << dist << "; locPos: " << locPos << std::endl);
260 
261  // compute jacobian df/dx = d \phi(x) / dx =: J
262  getImpl().jacobian(J, locPos);
263 
264  // solve c -= J^{-1} f
265  LeftInverse(JInv, J);
266  MatVecMult(corr, JInv, dist);
267 
268  // check if tol reached
269  if(VecAbsIsLess(corr, tol))
270  return;
271  // REMARK: Note that using the Euclidean or maximum norm directly to dist
272  // would need tuning of the tolerance for every particular grid: For big
273  // elements with the diameter of order 1, the tolerance 1e-10 is good accuracy,
274  // but for a refined grid with the elements of the size of order 1e-5 it
275  // can be pour. But ||corr|| = ||J^{-1} dist|| is also a norm of dist, and
276  // it is rescaled according to the element dimensions.
277  // Besides that, ||corr|| measures whether we can get any further progress
278  // in the iterations.
279 
280  // apply the correction
281  VecSubtract(locPos, locPos, corr);
282  }
283 
284  // compiler does not know that maxIter will never be 0
285  // therefore it warns that dist may be uninit'ed;
286  // as we will throw here anyway, we may as well check that
287  UG_COND_THROW(!maxIter, "Without a single iteration, local-to-global "
288  "mapping can never converge.");
289 
290  UG_DLOG(DID_REFERENCE_MAPPING_GLOB_TO_LOC, 2, "Last JInv:" << std::endl);
291  for(int i = 0; i < 3; ++i)
292  {
294  JInv(i, 0) << "; " << JInv(i, 1) << "; " << JInv(i, 2) << std::endl);
295  }
296 
297  UG_THROW("ReferenceMapping::global_to_local: Newton method did not"
298  " reach a tolerance "<<tol<<" after "<<maxIter<<" steps. "
299  "Global Pos: "<<globPos<<", dim: "<<dim<<", worldDim: "<<
300  worldDim<<", last newton defect: "<<fabs(VecTwoNorm(dist)));
301  }
302 
305  const MathVector<worldDim>* vGlobPos, size_t n,
306  const size_t maxIter = 1000,
307  const number tol = 1e-10) const
308  {
309  if(isLinear){
310  if(n == 0) return;
311 
314  MathVector<worldDim> dist, compGlobPos;
315 
316  // compute jacobian df/dx = d \phi(x) / dx =: J
317  getImpl().jacobian(J, vLocPos[0]);
318 
319  // solve x -= J^{-1} f
320  LeftInverse(JInv, J);
321 
322  for(size_t ip = 0; ip < n; ++ip)
323  {
324  // f(x) := \phi(x) - x_{glob}
325  getImpl().local_to_global(compGlobPos, vLocPos[ip]);
326  VecSubtract(dist, compGlobPos, vGlobPos[ip]);
327 
328  MatVecScaleMultAppend(vLocPos[ip], -1.0, JInv, dist);
329  }
330  }
331  else{
332  for(size_t ip = 0; ip < n; ++ip)
333  getImpl().global_to_local(vLocPos[ip], vGlobPos[ip], maxIter, tol);
334  }
335  }
336 
338  void global_to_local(std::vector<MathVector<dim> >& vLocPos,
339  const std::vector<MathVector<worldDim> >& vGlobPos,
340  const size_t maxIter = 1000,
341  const number tol = 1e-10) const
342  {
343  const size_t n = vGlobPos.size();
344  vLocPos.resize(n);
345  global_to_local(&vLocPos[0], &vGlobPos[0], n, maxIter, tol);
346  }
347 
350  const MathVector<dim>& locPos) const
351  {
353  getImpl().jacobian_transposed(JT, locPos);
354  Transpose(J, JT);
355  }
356 
359  const MathVector<dim>* vLocPos, size_t n) const
360  {
361  if(isLinear){
362  if(n == 0) return;
363  getImpl().jacobian(vJ[0], vLocPos[0]);
364  for(size_t ip = 1; ip < n; ++ip) vJ[ip] = vJ[0];
365  }
366  else {
367  for(size_t ip = 0; ip < n; ++ip)
368  getImpl().jacobian(vJ[ip], vLocPos[ip]);
369  }
370  }
371 
373  void jacobian(std::vector<MathMatrix<worldDim, dim> >& vJ,
374  const std::vector<MathVector<dim> >& vLocPos) const
375  {
376  const size_t n = vLocPos.size();
377  vJ.resize(n);
378  jacobian(&vJ[0], &vLocPos[0], n);
379  }
380 
381 
384  const MathVector<dim>* vLocPos, size_t n) const
385  {
386  if(isLinear){
387  if(n == 0) return;
388  getImpl().jacobian_transposed(vJT[0], vLocPos[0]);
389  for(size_t ip = 1; ip < n; ++ip) vJT[ip] = vJT[0];
390  }
391  else {
392  for(size_t ip = 0; ip < n; ++ip)
393  getImpl().jacobian_transposed(vJT[ip], vLocPos[ip]);
394  }
395  }
396 
399  const std::vector<MathVector<dim> >& vLocPos) const
400  {
401  const size_t n = vLocPos.size();
402  vJT.resize(n);
403  jacobian_transposed(&vJT[0], &vLocPos[0], n);
404  }
405 
408  const MathVector<dim>& locPos) const
409  {
411  getImpl().jacobian_transposed(JT, locPos);
412  UG_DLOG(DID_REFERENCE_MAPPING, 2, ">>OCT_DISC_DEBUG:: " << "reference_mapping.h: " << "jacobian_transposed_inverse(): JT " << std::endl);
413  for(int i = 0; i < 3; ++i)
414  UG_DLOG(DID_REFERENCE_MAPPING, 2, " JT:" << JT(i, 0) << "; " << JT(i, 1) << "; " << JT(i, 2) << std::endl);
415  return RightInverse(JTInv, JT);
416  }
417 
420  number* vDet,
421  const MathVector<dim>* vLocPos, size_t n) const
422  {
423  if(isLinear){
424  if(n == 0) return;
425  vDet[0] = getImpl().jacobian_transposed_inverse(vJTInv[0], vLocPos[0]);
426  for(size_t ip = 1; ip < n; ++ip) vJTInv[ip] = vJTInv[0];
427  for(size_t ip = 1; ip < n; ++ip) vDet[ip] = vDet[0];
428  }
429  else {
430  for(size_t ip = 0; ip < n; ++ip)
431  vDet[ip] = getImpl().jacobian_transposed_inverse(vJTInv[ip], vLocPos[ip]);
432  }
433  }
434 
437  const MathVector<dim>* vLocPos, size_t n) const
438  {
439  if(isLinear){
440  if(n == 0) return;
441  getImpl().jacobian_transposed_inverse(vJTInv[0], vLocPos[0]);
442  for(size_t ip = 1; ip < n; ++ip) vJTInv[ip] = vJTInv[0];
443  }
444  else {
445  for(size_t ip = 0; ip < n; ++ip)
446  getImpl().jacobian_transposed_inverse(vJTInv[ip], vLocPos[ip]);
447  }
448  }
449 
452  std::vector<number>& vDet,
453  const std::vector<MathVector<dim> >& vLocPos) const
454  {
455  const size_t n = vLocPos.size();
456  vJTInv.resize(n); vDet.resize(n);
457  jacobian_transposed_inverse(&vJTInv[0], &vDet[0], &vLocPos[0], n);
458  }
459 
462  const std::vector<MathVector<dim> >& vLocPos) const
463  {
464  const size_t n = vLocPos.size();
465  vJTInv.resize(n);
466  jacobian_transposed_inverse(&vJTInv[0], &vLocPos[0], n);
467  }
468 
470  number sqrt_gram_det(const MathVector<dim>& locPos) const
471  {
473  getImpl().jacobian_transposed(JT, locPos);
474  return SqrtGramDeterminant(JT);
475  }
476 
478  void sqrt_gram_det(number* vDet, const MathVector<dim>* vLocPos, size_t n) const
479  {
480  if(isLinear){
481  if(n == 0) return;
482  vDet[0] = sqrt_gram_det(vLocPos[0]);
483  for(size_t ip = 1; ip < n; ++ip) vDet[ip] = vDet[0];
484  }
485  else {
486  for(size_t ip = 0; ip < n; ++ip)
487  vDet[ip] = sqrt_gram_det(vLocPos[ip]);
488  }
489  }
490 
492  void sqrt_gram_det(std::vector<number>& vDet,
493  const std::vector<MathVector<dim> >& vLocPos) const
494  {
495  const size_t n = vLocPos.size();
496  vDet.resize(n);
497  sqrt_gram_det(&vDet[0], &vLocPos[0], n);
498  }
499 
500  protected:
502  TImpl& getImpl() {return static_cast<TImpl&>(*this);}
503 
505  const TImpl& getImpl() const {return static_cast<const TImpl&>(*this);}
506 };
507 
509 // Reference Mapping RegularVertex
511 
512 template <int TWorldDim>
514  : public BaseReferenceMapping<ReferenceVertex::dim, TWorldDim, true,
515  ReferenceMapping<ReferenceVertex, TWorldDim> >
516 {
517  public:
519  static const int worldDim = TWorldDim;
520 
522  static const int dim = ReferenceVertex::dim;
523 
525  static const bool isLinear = true;
526 
527  public:
528  typedef BaseReferenceMapping<ReferenceVertex::dim, TWorldDim, true,
530  using base_type::local_to_global;
531  using base_type::jacobian;
532  using base_type::jacobian_transposed;
533  using base_type::jacobian_transposed_inverse;
534  using base_type::sqrt_gram_det;
535 
536  public:
539 
542  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
543  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
545 
547  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
548  {
549  UG_ASSERT((int)vCornerCoord.size() >= ReferenceEdge::numCorners,
550  "ReferenceMapping: to few Corner Coordinates.");
551  update(&vCornerCoord[0]);
552  }
553 
555  void update(const MathVector<worldDim>* vCornerCoord)
556  {
557  co0 = vCornerCoord[0];
558  }
559 
562  const MathVector<dim>& locPos) const
563  {
564  globPos = co0;
565  }
566 
569  const MathVector<dim>& locPos) const
570  {
571  //for(int i = 0; i < worldDim; ++i) JT(0,i) = 1;
572  }
573 
574  private:
576 };
577 
579 // Reference Mapping Edge
581 template <int TWorldDim>
583  : public BaseReferenceMapping<ReferenceEdge::dim, TWorldDim, true,
584  ReferenceMapping<ReferenceEdge, TWorldDim> >
585 {
586  public:
588  static const int worldDim = TWorldDim;
589 
591  static const int dim = ReferenceEdge::dim;
592 
594  static const bool isLinear = true;
595 
596  public:
597  typedef BaseReferenceMapping<ReferenceEdge::dim, TWorldDim, true,
599  using base_type::local_to_global;
600  using base_type::jacobian;
601  using base_type::jacobian_transposed;
602  using base_type::jacobian_transposed_inverse;
603  using base_type::sqrt_gram_det;
604 
605  public:
608 
611  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
612  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
614 
616  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
617  {
618  UG_ASSERT((int)vCornerCoord.size() >= ReferenceEdge::numCorners,
619  "ReferenceMapping: to few Corner Coordinates.");
620  update(&vCornerCoord[0]);
621  }
622 
624  void update(const MathVector<worldDim>* vCornerCoord)
625  {
626  co0 = vCornerCoord[0];
627  VecSubtract(a10, vCornerCoord[1], vCornerCoord[0]);
628  }
629 
632  const MathVector<dim>& locPos) const
633  {
634  VecScaleAdd(globPos, 1.0, co0, locPos[0], a10);
635  }
636 
639  const MathVector<dim>& locPos) const
640  {
641  for(int i = 0; i < worldDim; ++i) JT(0,i) = a10[i];
642  }
643 
644  private:
646 };
647 
649 // Reference Mapping Triangle
651 template <int TWorldDim>
653  : public BaseReferenceMapping<ReferenceTriangle::dim, TWorldDim, true,
654  ReferenceMapping<ReferenceTriangle, TWorldDim> >
655 {
656  public:
658  static const int worldDim = TWorldDim;
659 
661  static const int dim = ReferenceTriangle::dim;
662 
664  static const bool isLinear = true;
665 
666  public:
667  typedef BaseReferenceMapping<ReferenceTriangle::dim, TWorldDim, true,
669  using base_type::local_to_global;
670  using base_type::jacobian;
671  using base_type::jacobian_transposed;
672  using base_type::jacobian_transposed_inverse;
673  using base_type::sqrt_gram_det;
674 
675  public:
678 
681  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
682  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
684 
686  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
687  {
688  UG_ASSERT((int)vCornerCoord.size() >= ReferenceTriangle::numCorners,
689  "ReferenceMapping: to few Corner Coordinates.");
690  update(&vCornerCoord[0]);
691  }
692 
694  void update(const MathVector<worldDim>* vCornerCoord)
695  {
696  co0 = vCornerCoord[0];
697  VecSubtract(a10, vCornerCoord[1], vCornerCoord[0]);
698  VecSubtract(a20, vCornerCoord[2], vCornerCoord[0]);
699  }
700 
703  const MathVector<dim>& locPos) const
704  {
705  VecScaleAdd(globPos, 1.0, co0, locPos[0], a10, locPos[1], a20);
706  }
707 
710  const MathVector<dim>& locPos) const
711  {
712  for(int i = 0; i < worldDim; ++i) JT(0, i) = a10[i];
713  for(int i = 0; i < worldDim; ++i) JT(1, i) = a20[i];
714  }
715 
716  private:
718 
719 };
721 // Reference Mapping Quadrilateral
723 
724 
725 template <int TWorldDim>
727  : public BaseReferenceMapping<ReferenceQuadrilateral::dim, TWorldDim, false,
728  ReferenceMapping<ReferenceQuadrilateral, TWorldDim> >
729 {
730  public:
732  static const int worldDim = TWorldDim;
733 
735  static const int dim = ReferenceQuadrilateral::dim;
736 
738  static const bool isLinear = false;
739 
740  public:
741  typedef BaseReferenceMapping<ReferenceQuadrilateral::dim, TWorldDim, false,
743  using base_type::local_to_global;
744  using base_type::jacobian;
745  using base_type::jacobian_transposed;
746  using base_type::jacobian_transposed_inverse;
747  using base_type::sqrt_gram_det;
748 
749  public:
752 
755  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
756  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
758 
760  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
761  {
762  UG_ASSERT((int)vCornerCoord.size() >= ReferenceQuadrilateral::numCorners,
763  "ReferenceMapping: to few Corner Coordinates.");
764  update(&vCornerCoord[0]);
765  }
766 
768  void update(const MathVector<worldDim>* vCornerCoord)
769  {
770  for(int co = 0; co < ReferenceQuadrilateral::numCorners; ++co)
771  x[co] = vCornerCoord[co];
772  }
773 
776  const MathVector<dim>& locPos) const
777  {
778  const number a = (1.-locPos[0]);
779  const number b = (1.-locPos[1]);
780 
781  VecScaleAdd(globPos, a*b, x[0],
782  locPos[0]*b, x[1],
783  locPos[0]*locPos[1], x[2],
784  a*locPos[1], x[3]);
785  }
786 
789  const MathVector<dim>& locPos) const
790  {
791  const number a = 1. - locPos[1];
792  const number b = 1. - locPos[0];
793 
794  for(int i = 0; i < worldDim; ++i)
795  JT(0, i) = a*(x[1][i] - x[0][i]) + locPos[1]*(x[2][i] - x[3][i]);
796 
797  for(int i = 0; i < worldDim; ++i)
798  JT(1, i) = b*(x[3][i] - x[0][i]) + locPos[0]*(x[2][i] - x[1][i]);
799  }
800 
801  private:
803 };
804 
806 // Reference Mapping Tetrahedron
808 
809 template <int TWorldDim>
811  : public BaseReferenceMapping<ReferenceTetrahedron::dim, TWorldDim, true,
812  ReferenceMapping<ReferenceTetrahedron, TWorldDim> >
813 {
814  public:
816  static const int worldDim = TWorldDim;
817 
819  static const int dim = ReferenceTetrahedron::dim;
820 
822  static const bool isLinear = true;
823 
824  public:
825  typedef BaseReferenceMapping<ReferenceTetrahedron::dim, TWorldDim, true,
827  using base_type::local_to_global;
828  using base_type::jacobian;
829  using base_type::jacobian_transposed;
830  using base_type::jacobian_transposed_inverse;
831  using base_type::sqrt_gram_det;
832 
833  public:
836 
839  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
840  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
842 
844  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
845  {
846  UG_ASSERT((int)vCornerCoord.size() >= ReferenceTetrahedron::numCorners,
847  "ReferenceMapping: to few Corner Coordinates.");
848  update(&vCornerCoord[0]);
849  }
850 
852  void update(const MathVector<worldDim>* vCornerCoord)
853  {
854  co0 = vCornerCoord[0];
855  VecSubtract(a10, vCornerCoord[1], vCornerCoord[0]);
856  VecSubtract(a20, vCornerCoord[2], vCornerCoord[0]);
857  VecSubtract(a30, vCornerCoord[3], vCornerCoord[0]);
858  }
859 
862  const MathVector<dim>& locPos) const
863  {
864  VecScaleAdd(globPos, 1.0, co0,
865  locPos[0], a10,
866  locPos[1], a20,
867  locPos[2], a30);
868  }
869 
872  const MathVector<dim>& locPos) const
873  {
874  for(int i = 0; i < worldDim; ++i) JT[0][i] = a10[i];
875  for(int i = 0; i < worldDim; ++i) JT[1][i] = a20[i];
876  for(int i = 0; i < worldDim; ++i) JT[2][i] = a30[i];
877  }
878 
879  private:
880  MathVector<worldDim> co0, a10, a20, a30;
881 };
882 
884 // Reference Mapping Pyramid
886 template <int TWorldDim>
888  : public BaseReferenceMapping<ReferencePyramid::dim, TWorldDim, false,
889  ReferenceMapping<ReferencePyramid, TWorldDim> >
890 {
891  public:
893  static const int worldDim = TWorldDim;
894 
896  static const int dim = ReferencePyramid::dim;
897 
899  static const bool isLinear = false;
900 
901  public:
902  typedef BaseReferenceMapping<ReferencePyramid::dim, TWorldDim, false,
904  using base_type::local_to_global;
905  using base_type::jacobian;
906  using base_type::jacobian_transposed;
907  using base_type::jacobian_transposed_inverse;
908  using base_type::sqrt_gram_det;
909 
910  public:
913 
916  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
917  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
919 
921  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
922  {
923  UG_ASSERT((int)vCornerCoord.size() >= ReferencePyramid::numCorners,
924  "ReferenceMapping: to few Corner Coordinates.");
925  update(&vCornerCoord[0]);
926  }
927 
929  void update(const MathVector<worldDim>* vCornerCoord)
930  {
931  for(int co = 0; co < ReferencePyramid::numCorners; ++co)
932  x[co] = vCornerCoord[co];
933  }
934 
937  const MathVector<dim>& locPos) const
938  {
939  const number a = 1.0 - locPos[0];
940  const number b = 1.0 - locPos[1];
941  if (locPos[0] > locPos[1])
942  {
943  const number a0 = a * b - locPos[2] * b;
944  const number a1 = locPos[0] * b - locPos[2]*locPos[1];
945  const number a2 = locPos[0] * locPos[1] + locPos[2]*locPos[1];
946  const number a3 = a * locPos[1] - locPos[2] * locPos[1];
947 
948  for(int d = 0; d < worldDim; ++d)
949  globPos[d] = a0*x[0][d]+a1*x[1][d]+a2*x[2][d]
950  +a3*x[3][d]+locPos[2]*x[4][d];
951  }
952  else
953  {
954  const number a0 = a * b - locPos[2] * a;
955  const number a1 = locPos[0] * b - locPos[2]*locPos[0];
956  const number a2 = locPos[0] * locPos[1] + locPos[2]*locPos[0];
957  const number a3 = a * locPos[1] - locPos[2] * locPos[0];
958  for(int d = 0; d < worldDim; ++d)
959  globPos[d] = a0*x[0][d]+a1*x[1][d]+
960  a2*x[2][d]+a3*x[3][d]+locPos[2]*x[4][d];
961  }
962  }
963 
966  const MathVector<dim>& locPos) const
967  {
968  number a[3];
969  for(int d = 0; d < worldDim; ++d)
970  a[d] = x[0][d]-x[1][d]+x[2][d]-x[3][d];
971 
972  if (locPos[0] > locPos[1])
973  {
974  for(int d = 0; d < worldDim; ++d)
975  JT(0,d) = x[1][d]-x[0][d]+locPos[1]*a[d];
976 
977  for(int d = 0; d < worldDim; ++d)
978  JT(1,d) = x[3][d]-x[0][d]+(locPos[0]+locPos[2])*a[d];
979 
980  for(int d = 0; d < worldDim; ++d)
981  JT(2,d) = x[4][d]-x[0][d]+locPos[1]*a[d];
982  }
983  else
984  {
985  for(int d = 0; d < worldDim; ++d)
986  JT(0,d) = x[1][d]-x[0][d]+(locPos[1]+locPos[2])*a[d];
987 
988  for(int d = 0; d < worldDim; ++d)
989  JT(1,d) = x[3][d]-x[0][d]+locPos[0]*a[d];
990 
991  for(int d = 0; d < worldDim; ++d)
992  JT(2,d) = x[4][d]-x[0][d]+locPos[0]*a[d];
993  }
994  }
995 
996  private:
998 };
999 
1001 // Reference Mapping Prism
1003 
1004 template <int TWorldDim>
1006  : public BaseReferenceMapping<ReferencePrism::dim, TWorldDim, false,
1007  ReferenceMapping<ReferencePrism, TWorldDim> >
1008 {
1009  public:
1011  static const int worldDim = TWorldDim;
1012 
1014  static const int dim = ReferencePrism::dim;
1015 
1017  static const bool isLinear = false;
1018 
1019  public:
1020  typedef BaseReferenceMapping<ReferencePrism::dim, TWorldDim, false,
1022  using base_type::local_to_global;
1023  using base_type::jacobian;
1024  using base_type::jacobian_transposed;
1025  using base_type::jacobian_transposed_inverse;
1026  using base_type::sqrt_gram_det;
1027 
1028  public:
1031 
1034  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
1035  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
1037 
1039  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
1040  {
1041  UG_ASSERT((int)vCornerCoord.size() >= ReferencePrism::numCorners,
1042  "ReferenceMapping: to few Corner Coordinates.");
1043  update(&vCornerCoord[0]);
1044  }
1045 
1047  void update(const MathVector<worldDim>* vCornerCoord)
1048  {
1049  for(int co = 0; co < ReferencePrism::numCorners; ++co)
1050  x[co] = vCornerCoord[co];
1051  }
1052 
1055  const MathVector<dim>& locPos) const
1056  {
1057  const number a = 1.0 - locPos[0] - locPos[1];
1058  const number b = 1.0 - locPos[2];
1059  const number a0 = a * b;
1060  const number a1 = locPos[0] * b;
1061  const number a2 = locPos[1] * b;
1062  const number a3 = a * locPos[2];
1063  const number a4 = locPos[0] * locPos[2];
1064  const number a5 = locPos[1] * locPos[2];
1065 
1066  for(int d = 0; d < worldDim; ++d)
1067  globPos[d] = a0*x[0][d]+a1*x[1][d]+a2*x[2][d]+a3*x[3][d]+a4*x[4][d]+a5*x[5][d];
1068  }
1069 
1072  const MathVector<dim>& locPos) const
1073  {
1074  number a[worldDim], b[worldDim];
1075 
1076  for(int d = 0; d < worldDim; ++d)
1077  a[d] = x[0][d]-x[1][d]-x[3][d]+x[4][d];
1078 
1079  for(int d = 0; d < worldDim; ++d)
1080  b[d] = x[0][d]-x[2][d]-x[3][d]+x[5][d];
1081 
1082  for(int d = 0; d < worldDim; ++d){
1083  JT(0,d) = x[1][d]-x[0][d]+locPos[2]*a[d];
1084  JT(1,d) = x[2][d]-x[0][d]+locPos[2]*b[d];
1085  JT(2,d) = x[3][d]-x[0][d]+locPos[0]*a[d]+locPos[1]*b[d];
1086  }
1087  }
1088 
1089  private:
1091 };
1092 
1093 
1095 // Reference Mapping Hexahedron
1097 
1098 template <int TWorldDim>
1100  : public BaseReferenceMapping<ReferenceHexahedron::dim, TWorldDim, false,
1101  ReferenceMapping<ReferenceHexahedron, TWorldDim> >
1102 {
1103  public:
1105  static const int worldDim = TWorldDim;
1106 
1108  static const int dim = ReferenceHexahedron::dim;
1109 
1111  static const bool isLinear = false;
1112 
1113  public:
1114  typedef BaseReferenceMapping<ReferenceHexahedron::dim, TWorldDim, false,
1116  using base_type::local_to_global;
1117  using base_type::jacobian;
1118  using base_type::jacobian_transposed;
1119  using base_type::jacobian_transposed_inverse;
1120  using base_type::sqrt_gram_det;
1121 
1122  public:
1125 
1128  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
1129  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
1131 
1133  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
1134  {
1135  UG_ASSERT((int)vCornerCoord.size() >= ReferenceHexahedron::numCorners,
1136  "ReferenceMapping: to few Corner Coordinates.");
1137  update(&vCornerCoord[0]);
1138  }
1139 
1141  void update(const MathVector<worldDim>* vCornerCoord)
1142  {
1143  for(int co = 0; co < ReferenceHexahedron::numCorners; ++co)
1144  x[co] = vCornerCoord[co];
1145  }
1146 
1149  const MathVector<dim>& locPos) const
1150  {
1151  const number a = 1.0 - locPos[0];
1152  const number b = 1.0 - locPos[1];
1153  const number c = 1.0 - locPos[2];
1154  const number a0 = a * b * c;
1155  const number a1 = locPos[0] * b * c;
1156  const number a2 = locPos[0] * locPos[1] * c;
1157  const number a3 = a * locPos[1] * c;
1158  const number a4 = a * b * locPos[2];
1159  const number a5 = locPos[0] * b * locPos[2];
1160  const number a6 = locPos[0] * locPos[1] * locPos[2];
1161  const number a7 = a * locPos[1] * locPos[2];
1162 
1163  for(int d = 0; d < worldDim; ++d){
1164  globPos[d] = a0*x[0][d]+a1*x[1][d]+a2*x[2][d]+a3*x[3][d]+
1165  a4*x[4][d]+a5*x[5][d]+a6*x[6][d]+a7*x[7][d];
1166  }
1167  }
1168 
1171  const MathVector<dim>& locPos) const
1172  {
1173  number a0,a1,a2,a3;
1174  const number a = 1.0 - locPos[0];
1175  const number b = 1.0 - locPos[1];
1176  const number c = 1.0 - locPos[2];
1177  a0 = b * c;
1178  a1 = locPos[1] * c;
1179  a2 = locPos[1] * locPos[2];
1180  a3 = b * locPos[2];
1181  for(int d = 0; d < worldDim; ++d)
1182  JT(0,d) = a0*(x[1][d]-x[0][d])+a1*(x[2][d]-x[3][d])
1183  + a2*(x[6][d]-x[7][d])+a3*(x[5][d]-x[4][d]);
1184 
1185  a0 = a * c;
1186  a1 = locPos[0] * c;
1187  a2 = locPos[0] * locPos[2];
1188  a3 = a * locPos[2];
1189  for(int d = 0; d < worldDim; ++d)
1190  JT(1,d) = a0*(x[3][d]-x[0][d])+a1*(x[2][d]-x[1][d])
1191  + a2*(x[6][d]-x[5][d])+a3*(x[7][d]-x[4][d]);
1192 
1193  a0 = a * b;
1194  a1 = locPos[0] * b;
1195  a2 = locPos[0] * locPos[1];
1196  a3 = a * locPos[1];
1197  for(int d = 0; d < worldDim; ++d)
1198  JT(2,d) = a0*(x[4][d]-x[0][d])+a1*(x[5][d]-x[1][d])
1199  + a2*(x[6][d]-x[2][d])+a3*(x[7][d]-x[3][d]);
1200  }
1201 
1202  private:
1204 };
1205 
1207 // Reference Mapping Octahedron
1209 template <int TWorldDim>
1211  : public BaseReferenceMapping<ReferenceOctahedron::dim, TWorldDim, false,
1212  ReferenceMapping<ReferenceOctahedron, TWorldDim> >
1213 {
1214  public:
1216  static const int worldDim = TWorldDim;
1217 
1219  static const int dim = ReferenceOctahedron::dim;
1220 
1222  static const bool isLinear = false;
1223 
1224  public:
1225  typedef BaseReferenceMapping<ReferenceOctahedron::dim, TWorldDim, false,
1227  using base_type::local_to_global;
1228  using base_type::jacobian;
1229  using base_type::jacobian_transposed;
1230  using base_type::jacobian_transposed_inverse;
1231  using base_type::sqrt_gram_det;
1232 
1233  public:
1236 
1239  ReferenceMapping(const MathVector<worldDim>* vCornerCoord) {update(vCornerCoord);}
1240  ReferenceMapping(const std::vector<MathVector<worldDim> >& vCornerCoord) {update(vCornerCoord);}
1242 
1244  void update(const std::vector<MathVector<worldDim> >& vCornerCoord)
1245  {
1246  UG_ASSERT((int)vCornerCoord.size() >= ReferenceOctahedron::numCorners,
1247  "ReferenceMapping: to few Corner Coordinates.");
1248  update(&vCornerCoord[0]);
1249  }
1250 
1252  void update(const MathVector<worldDim>* vCornerCoord)
1253  {
1254  for(int co = 0; co < ReferenceOctahedron::numCorners; ++co)
1255  x[co] = vCornerCoord[co];
1256  }
1257 
1260  const MathVector<dim>& locPos) const
1261  {
1262  // the octahedral shape functions correspond to the tetrahedral ones,
1263  // but locally piecewise linear on a subdivision of the octahedron
1264  // into 4 sub-tetrahedrons.
1265  const number z_sgn = (locPos[2] < 0) ? -1.0 : 1.0;
1266  const number a0 = (locPos[2] < 0) ? -locPos[2] : 0.0;
1267  const number a5 = (locPos[2] < 0) ? 0.0 : locPos[2];
1268 
1269  if (locPos[0] > locPos[1])
1270  {
1271  const number a1 = 1.0 - locPos[0] - z_sgn * locPos[2];
1272  const number a2 = locPos[0] - locPos[1];
1273  const number a3 = locPos[1];
1274  const number a4 = 0.0;
1275 
1276  for(int d = 0; d < worldDim; ++d)
1277  globPos[d] = a0*x[0][d]+a1*x[1][d]+a2*x[2][d]
1278  +a3*x[3][d]+a4*x[4][d]+a5*x[5][d];
1279  }
1280  else
1281  {
1282  const number a1 = 1.0 - locPos[1] - z_sgn * locPos[2];
1283  const number a2 = 0.0;
1284  const number a3 = locPos[0];
1285  const number a4 = locPos[1] - locPos[0];
1286 
1287  for(int d = 0; d < worldDim; ++d)
1288  globPos[d] = a0*x[0][d]+a1*x[1][d]+a2*x[2][d]
1289  +a3*x[3][d]+a4*x[4][d]+a5*x[5][d];
1290  }
1291  }
1292 
1295  const MathVector<dim>& locPos) const
1296  {
1297  // the octahedral shape functions correspond to the tetrahedral ones,
1298  // but locally piecewise linear on a subdivision of the octahedron
1299  // into 4 sub-tetrahedrons.
1300  const number z_sgn = (locPos[2] < 0) ? -1.0 : 1.0;
1301  const number Da0 = (locPos[2] < 0) ? -1.0 : 0.0;
1302  const number Da5 = (locPos[2] < 0) ? 0.0 : 1.0;
1303 
1304  if (locPos[0] > locPos[1])
1305  {
1306  for(int d = 0; d < worldDim; ++d)
1307  JT(0,d) = -x[1][d]+x[2][d];
1308 
1309  for(int d = 0; d < worldDim; ++d)
1310  JT(1,d) = -x[2][d]+x[3][d];
1311 
1312  for(int d = 0; d < worldDim; ++d)
1313  JT(2,d) = Da0*x[0][d] - z_sgn*x[1][d] + Da5*x[5][d];
1314  }
1315  else
1316  {
1317  for(int d = 0; d < worldDim; ++d)
1318  JT(0,d) = x[3][d]-x[4][d];
1319 
1320  for(int d = 0; d < worldDim; ++d)
1321  JT(1,d) = -x[1][d]+x[4][d];
1322 
1323  for(int d = 0; d < worldDim; ++d)
1324  JT(2,d) = Da0*x[0][d] - z_sgn*x[1][d] + Da5*x[5][d];
1325  }
1326  }
1327 
1328  private:
1330 };
1331 
1332 
1333 } // end namespace ug
1334 
1335 #endif /* __H__UG__LIB_DISC__REFERENCE_ELEMENT__REFERENCE_ELEMENT_MAPPING__ */
Base class for Reference mappings helping to implement interface.
Definition: reference_mapping.h:192
void local_to_global(std::vector< MathVector< worldDim > > &vGlobPos, const std::vector< MathVector< dim > > &vLocPos) const
map local coordinate to global coordinate for a vector of local positions
Definition: reference_mapping.h:206
void global_to_local(std::vector< MathVector< dim > > &vLocPos, const std::vector< MathVector< worldDim > > &vGlobPos, const size_t maxIter=1000, const number tol=1e-10) const
map global coordinate to local coordinate for a vector of local positions
Definition: reference_mapping.h:338
TImpl & getImpl()
access to implementation
Definition: reference_mapping.h:502
void jacobian_transposed_inverse(std::vector< MathMatrix< worldDim, dim > > &vJTInv, std::vector< number > &vDet, const std::vector< MathVector< dim > > &vLocPos) const
returns transposed of the inverse of the jacobian for a vector of positions
Definition: reference_mapping.h:451
number sqrt_gram_det(const MathVector< dim > &locPos) const
returns the determinate of the jacobian
Definition: reference_mapping.h:470
void global_to_local(MathVector< dim > &locPos, const MathVector< worldDim > &globPos, const size_t maxIter=1000, const number tol=1e-10) const
map global coordinate to local coordinate
Definition: reference_mapping.h:216
void sqrt_gram_det(std::vector< number > &vDet, const std::vector< MathVector< dim > > &vLocPos) const
returns the determinate of the jacobian for a vector of local positions
Definition: reference_mapping.h:492
void jacobian_transposed(MathMatrix< dim, worldDim > *vJT, const MathVector< dim > *vLocPos, size_t n) const
returns transposed of jacobian for n local positions
Definition: reference_mapping.h:383
void jacobian(MathMatrix< worldDim, dim > *vJ, const MathVector< dim > *vLocPos, size_t n) const
returns jacobian for n local positions
Definition: reference_mapping.h:358
void jacobian_transposed_inverse(MathMatrix< worldDim, dim > *vJTInv, const MathVector< dim > *vLocPos, size_t n) const
returns transposed of the inverse of the jacobian for n local positions
Definition: reference_mapping.h:436
void local_to_global(MathVector< worldDim > *vGlobPos, const MathVector< dim > *vLocPos, size_t n) const
map local coordinate to global coordinate for n local positions
Definition: reference_mapping.h:198
void jacobian(MathMatrix< worldDim, dim > &J, const MathVector< dim > &locPos) const
returns jacobian
Definition: reference_mapping.h:349
void jacobian_transposed_inverse(std::vector< MathMatrix< worldDim, dim > > &vJTInv, const std::vector< MathVector< dim > > &vLocPos) const
returns transposed of the inverse of the jacobian for a vector of positions
Definition: reference_mapping.h:461
bool is_linear() const
returns if mapping is affine
Definition: reference_mapping.h:195
void jacobian_transposed(std::vector< MathMatrix< dim, worldDim > > &vJT, const std::vector< MathVector< dim > > &vLocPos) const
returns transposed of jacobian for a vector of positions
Definition: reference_mapping.h:398
void jacobian_transposed_inverse(MathMatrix< worldDim, dim > *vJTInv, number *vDet, const MathVector< dim > *vLocPos, size_t n) const
returns transposed of the inverse of the jacobian for n local positions
Definition: reference_mapping.h:419
const TImpl & getImpl() const
const access to implementation
Definition: reference_mapping.h:505
number jacobian_transposed_inverse(MathMatrix< worldDim, dim > &JTInv, const MathVector< dim > &locPos) const
returns transposed of the inverse of the jacobian
Definition: reference_mapping.h:407
void global_to_local(MathVector< dim > *vLocPos, const MathVector< worldDim > *vGlobPos, size_t n, const size_t maxIter=1000, const number tol=1e-10) const
map global coordinate to local coordinate for n local positions
Definition: reference_mapping.h:304
void jacobian(std::vector< MathMatrix< worldDim, dim > > &vJ, const std::vector< MathVector< dim > > &vLocPos) const
returns jacobian for a vector of local positions
Definition: reference_mapping.h:373
void sqrt_gram_det(number *vDet, const MathVector< dim > *vLocPos, size_t n) const
returns the determinate of the jacobian for n local positions
Definition: reference_mapping.h:478
Definition: reference_element.h:345
static const int dim
dimension of reference element
Definition: reference_element.h:351
static const int numCorners
number of corners
Definition: reference_element.h:354
reference element for a hexahedron
Definition: reference_element.h:648
static const int dim
dimension of reference element
Definition: reference_element.h:654
static const int numCorners
number of corners
Definition: reference_element.h:657
Definition: reference_mapping.h:585
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:638
BaseReferenceMapping< ReferenceEdge::dim, TWorldDim, true, ReferenceMapping< ReferenceEdge, TWorldDim > > base_type
Definition: reference_mapping.h:598
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:624
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:607
MathVector< worldDim > a10
Definition: reference_mapping.h:645
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:616
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:612
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:631
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:611
Definition: reference_mapping.h:1102
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:1141
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:1128
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:1124
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:1170
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:1148
BaseReferenceMapping< ReferenceHexahedron::dim, TWorldDim, false, ReferenceMapping< ReferenceHexahedron, TWorldDim > > base_type
Definition: reference_mapping.h:1115
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:1133
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:1129
Definition: reference_mapping.h:1213
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:1244
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:1239
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:1252
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:1294
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:1259
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:1240
BaseReferenceMapping< ReferenceOctahedron::dim, TWorldDim, false, ReferenceMapping< ReferenceOctahedron, TWorldDim > > base_type
Definition: reference_mapping.h:1226
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:1235
Definition: reference_mapping.h:1008
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:1035
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:1034
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:1071
BaseReferenceMapping< ReferencePrism::dim, TWorldDim, false, ReferenceMapping< ReferencePrism, TWorldDim > > base_type
Definition: reference_mapping.h:1021
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:1054
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:1047
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:1030
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:1039
Definition: reference_mapping.h:890
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:917
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:921
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:929
BaseReferenceMapping< ReferencePyramid::dim, TWorldDim, false, ReferenceMapping< ReferencePyramid, TWorldDim > > base_type
Definition: reference_mapping.h:903
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:936
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:912
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:916
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:965
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:760
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:768
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:775
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:751
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:788
BaseReferenceMapping< ReferenceQuadrilateral::dim, TWorldDim, false, ReferenceMapping< ReferenceQuadrilateral, TWorldDim > > base_type
Definition: reference_mapping.h:742
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:756
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:755
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:852
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:835
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:871
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:840
BaseReferenceMapping< ReferenceTetrahedron::dim, TWorldDim, true, ReferenceMapping< ReferenceTetrahedron, TWorldDim > > base_type
Definition: reference_mapping.h:826
MathVector< worldDim > a10
Definition: reference_mapping.h:880
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:861
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:839
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:844
Definition: reference_mapping.h:655
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:694
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:677
MathVector< worldDim > a10
Definition: reference_mapping.h:717
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:702
BaseReferenceMapping< ReferenceTriangle::dim, TWorldDim, true, ReferenceMapping< ReferenceTriangle, TWorldDim > > base_type
Definition: reference_mapping.h:668
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:686
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:681
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:709
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:682
Definition: reference_mapping.h:516
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
Definition: reference_mapping.h:561
MathVector< worldDim > co0
Definition: reference_mapping.h:575
BaseReferenceMapping< ReferenceVertex::dim, TWorldDim, true, ReferenceMapping< ReferenceVertex, TWorldDim > > base_type
Definition: reference_mapping.h:529
void update(const MathVector< worldDim > *vCornerCoord)
update the mapping for a new set of corners
Definition: reference_mapping.h:555
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_mapping.h:568
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Definition: reference_mapping.h:542
ReferenceMapping()
Default Constructor.
Definition: reference_mapping.h:538
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
Definition: reference_mapping.h:547
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Definition: reference_mapping.h:543
Definition: reference_mapping.h:65
number sqrt_gram_det(const MathVector< dim > &locPos) const
returns the determinate of the jacobian
void local_to_global(MathVector< worldDim > &globPos, const MathVector< dim > &locPos) const
map local coordinate to global coordinate
void global_to_local(MathVector< dim > &locPos, const MathVector< worldDim > &globPos, const size_t maxIter=1000, const number tol=1e-10) const
map global coordinate to local coordinate
ReferenceMapping(const MathVector< worldDim > *vCornerCoord)
Constructor setting the corners of the element.
static const int worldDim
world dimension (range space dimension)
Definition: reference_mapping.h:68
void jacobian_transposed(MathMatrix< dim, worldDim > *vJT, const MathVector< dim > *vLocPos, size_t n) const
returns transposed of jacobian for n local positions
bool is_linear() const
returns if mapping is affine
void local_to_global(std::vector< MathVector< worldDim > > &vGlobPos, const std::vector< MathVector< dim > > &vLocPos) const
map local coordinate to global coordinate for a vector of local positions
void jacobian(std::vector< MathMatrix< worldDim, dim > > &J, const std::vector< MathVector< dim > > &vLocPos) const
returns jacobian for a vector of local positions
void jacobian_transposed_inverse(MathMatrix< worldDim, dim > *vJTInv, const MathVector< dim > *vLocPos, size_t n) const
returns transposed of the inverse of the jacobian for n local positions
void jacobian_transposed(std::vector< MathMatrix< dim, worldDim > > &vJT, const std::vector< MathVector< dim > > &vLocPos) const
returns transposed of jacobian for a vector of positions
void local_to_global(MathVector< worldDim > *vGlobPos, const MathVector< dim > *vLocPos, size_t n) const
map local coordinate to global coordinate for n local positions
void sqrt_gram_det(std::vector< number > vDet, const std::vector< MathVector< dim > > &vLocPos) const
returns the determinate of the jacobian for a vector of local positions
void jacobian_transposed_inverse(std::vector< MathMatrix< worldDim, dim > > &vJTInv, const std::vector< MathVector< dim > > &vLocPos) const
returns transposed of the inverse of the jacobian for a vector of positions
void jacobian(MathMatrix< worldDim, dim > *vJ, const MathVector< dim > *vLocPos, size_t n) const
returns jacobian for n local positions
ReferenceMapping()
Default Constructor.
void jacobian(MathMatrix< worldDim, dim > &J, const MathVector< dim > &locPos) const
returns jacobian
number jacobian_transposed_inverse(MathMatrix< worldDim, dim > &JTInv, const MathVector< dim > &locPos) const
returns transposed of the inverse of the jacobian and sqrt of gram determinante
void update(const MathVector< worldDim > *vCornerCoord)
refresh mapping for new set of corners
void global_to_local(MathVector< dim > *vLocPos, const MathVector< worldDim > *vGlobPos, size_t n, const size_t maxIter=1000, const number tol=1e-10) const
map global coordinate to local coordinate for n local positions
void jacobian_transposed_inverse(std::vector< MathMatrix< worldDim, dim > > &vJTInv, std::vector< number > &vDet, const std::vector< MathVector< dim > > &vLocPos) const
returns transposed of the inverse of the jacobian for a vector of positions
void sqrt_gram_det(number *vDet, const MathVector< dim > *vLocPos, size_t n) const
returns the determinate of the jacobian for n local positions
static const int dim
reference dimension (domain space dimension)
Definition: reference_mapping.h:71
void update(const std::vector< MathVector< worldDim > > &vCornerCoord)
refresh mapping for new set of corners
ReferenceMapping(const std::vector< MathVector< worldDim > > &vCornerCoord)
Constructor setting the corners of the element.
void global_to_local(std::vector< MathVector< dim > > &vLocPos, const std::vector< MathVector< worldDim > > &vGlobPos, const size_t maxIter=1000, const number tol=1e-10) const
map global coordinate to local coordinate for a vector of local positions
static const bool isLinear
flag if mapping is linear (i.e. Jacobian does not depend on x)
Definition: reference_mapping.h:74
void jacobian_transposed_inverse(MathMatrix< worldDim, dim > *vJTInv, number *vDet, const MathVector< dim > *vLocPos, size_t n) const
returns transposed of the inverse of the jacobian for n local positions
void jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Definition: reference_element.h:699
static const int dim
dimension of reference element
Definition: reference_element.h:705
static const int numCorners
number of corners
Definition: reference_element.h:708
Definition: reference_element.h:595
static const int numCorners
number of corners
Definition: reference_element.h:604
static const int dim
dimension of reference element
Definition: reference_element.h:601
Definition: reference_element.h:546
static const int dim
dimension of reference element
Definition: reference_element.h:552
static const int numCorners
number of corners
Definition: reference_element.h:555
Definition: reference_element.h:445
static const int numCorners
number of corners
Definition: reference_element.h:454
static const int dim
dimension of reference element
Definition: reference_element.h:451
Definition: reference_element.h:494
static const int dim
dimension of reference element
Definition: reference_element.h:500
static const int numCorners
number of corners
Definition: reference_element.h:503
Definition: reference_element.h:394
static const int dim
dimension of reference element
Definition: reference_element.h:400
static const int numCorners
number of corners
Definition: reference_element.h:403
Definition: reference_element.h:303
static const int dim
dimension of reference element
Definition: reference_element.h:309
MathMatrix< N, M, T >::value_type SqrtGramDeterminant(const MathMatrix< N, M, T > &m)
Square root of Gram Determinant of a matrix.
Definition: math_matrix_functions_common_impl.hpp:508
MathMatrix< N, M, T >::value_type RightInverse(MathMatrix< N, M, T > &mOut, const MathMatrix< M, N, T > &m)
Right-Inverse of a Matrix.
Definition: math_matrix_functions_common_impl.hpp:680
void Transpose(MathMatrix< N, M, T > &mOut, const MathMatrix< M, N, T > &m)
transpose a matrix
Definition: math_matrix_functions_common_impl.hpp:345
MathMatrix< N, M, T >::value_type LeftInverse(MathMatrix< N, M, T > &mOut, const MathMatrix< M, N, T > &m)
Left-Inverse of a Matrix.
Definition: math_matrix_functions_common_impl.hpp:716
static const int dim
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
#define UG_DLOG(__debugID__, level, msg)
Definition: log.h:298
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
double number
Definition: types.h:124
void MatVecScaleMultAppend(vector_t_out &vOut, typename vector_t_out::value_type s, const matrix_t &m, const vector_t_in &v)
Matrix - Vector Multiplication added scaled to a second vector.
Definition: math_matrix_vector_functions_common_impl.hpp:90
void MatVecMult(vector_t_out &vOut, const matrix_t &m, const vector_t_in &v)
Matrix - Vector Multiplication.
Definition: math_matrix_vector_functions_common_impl.hpp:49
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
void VecSubtract(vector_t &vOut, const vector_t &v1, const vector_t &v2)
subtracts v2 from v1 and stores the result in a vOut
Definition: math_vector_functions_common_impl.hpp:226
void VecScale(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
scales a MathVector<N>
Definition: math_vector_functions_common_impl.hpp:252
vector_t::value_type VecTwoNorm(const vector_t &v)
Definition: math_vector_functions_common_impl.hpp:577
the ug namespace
DebugID DID_REFERENCE_MAPPING
DebugID DID_REFERENCE_MAPPING_GLOB_TO_LOC
bool VecAbsIsLess(const vector_t &v1, const vector_t &v2)
component-wise comparison of two vectors (in the absolute values)
Definition: math_vector_functions_common_impl.hpp:677