SurfaceAssembler.h 4.35 KB
Newer Older
1
2
3
4
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
6
7
// ==                                                                        ==
// ============================================================================
8
9
10
11
12
13
14
15
16
17
18
19
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

/** \file SurfaceAssembler.h */

#ifndef AMDIS_SURFACEASSEMBLER_H
#define AMDIS_SURFACEASSEMBLER_H

#include "FiniteElemSpace.h"
#include "Mesh.h"
#include "Assembler.h"
#include "SubQuadrature.h"
#include "QPInfo.h"

namespace AMDiS {

  /** 
   * \ingroup Integration
   *
   * \brief
   */
  class SurfaceAssembler : public Assembler
  {
  public:
42
    /// Creates a SurfaceAssembler conforming to operate for the given \ref coords.
43
    SurfaceAssembler(Operator *operat,
44
45
		     const FiniteElemSpace *rowFeSpace,
		     const FiniteElemSpace *colFeSpace,
46
		     VectorOfFixVecs<DimVec<double> > &coords) 
47
      : Assembler(operat, rowFeSpace, colFeSpace, -1), 
48
49
50
51
52
53
	coords_(coords)
    {
      TEST_EXIT(rowDim_ == colDim_)("rowDim_ != colDim_\n");

      SubQuadrature *subQuadrature;

54
      if (rowQuad11_) {
Thomas Witkowski's avatar
Thomas Witkowski committed
55
	subQuadrature = new SubQuadrature(rowQuad11_, rowDim_);
56
57
58
59
	rowQuad11_ = colQuad11_ = subQuadrature;
	subQuadrature->scaleQuadrature(coords_);
	rowQPInfo11_ = colQPInfo11_ = QPInfo::provideQPInfo(rowQuad11_, NULL);
      }
60
      if (rowQuad10_) {
Thomas Witkowski's avatar
Thomas Witkowski committed
61
	subQuadrature = new SubQuadrature(rowQuad10_, rowDim_);
62
63
64
65
	rowQuad10_ = colQuad10_ = subQuadrature;
	subQuadrature->scaleQuadrature(coords_);
	rowQPInfo10_ = colQPInfo10_ = QPInfo::provideQPInfo(rowQuad10_, NULL);
      }
66
      if (rowQuad01_) {
Thomas Witkowski's avatar
Thomas Witkowski committed
67
	subQuadrature = new SubQuadrature(rowQuad01_, rowDim_);
68
69
70
71
	rowQuad01_ = colQuad01_ = subQuadrature;
	subQuadrature->scaleQuadrature(coords_);
	rowQPInfo01_ = colQPInfo01_ = QPInfo::provideQPInfo(rowQuad01_, NULL);
      }
72
      if (rowQuad00_) {
Thomas Witkowski's avatar
Thomas Witkowski committed
73
	subQuadrature = new SubQuadrature(rowQuad00_, rowDim_);
74
75
76
77
	rowQuad00_ = colQuad00_ = subQuadrature;
	subQuadrature->scaleQuadrature(coords_);
	rowQPInfo00_ = colQPInfo00_ = QPInfo::provideQPInfo(rowQuad00_, NULL);
      }
78
    }
79

Thomas Witkowski's avatar
Thomas Witkowski committed
80
    /// Destructor
81
82
    ~SurfaceAssembler()
    {
83
84
85
86
87
88
89
90
      if (rowQuad11_) 
	delete rowQuad11_;
      if (rowQuad10_) 
	delete rowQuad10_;
      if (rowQuad01_) 
	delete rowQuad01_;
      if (rowQuad00_) 
	delete rowQuad00_;
Thomas Witkowski's avatar
Thomas Witkowski committed
91
    }
92

Thomas Witkowski's avatar
Thomas Witkowski committed
93
    /// Adapt surface quadratures to \ref coords.
94
95
96
    void adaptSurfaceAssembler(VectorOfFixVecs<DimVec<double> > &coords)
    {
      coords_ = coords;
Thomas Witkowski's avatar
Thomas Witkowski committed
97
      if (rowQuad11_) 
98
	dynamic_cast<SubQuadrature*>(rowQuad11_)->scaleQuadrature(coords_);
Thomas Witkowski's avatar
Thomas Witkowski committed
99
      if (rowQuad10_) 
100
	dynamic_cast<SubQuadrature*>(rowQuad10_)->scaleQuadrature(coords_);
Thomas Witkowski's avatar
Thomas Witkowski committed
101
      if (rowQuad01_) 
102
	dynamic_cast<SubQuadrature*>(rowQuad01_)->scaleQuadrature(coords_);
Thomas Witkowski's avatar
Thomas Witkowski committed
103
      if (rowQuad00_) 
104
	dynamic_cast<SubQuadrature*>(rowQuad00_)->scaleQuadrature(coords_);
Thomas Witkowski's avatar
Thomas Witkowski committed
105
    }
106
107


Thomas Witkowski's avatar
Thomas Witkowski committed
108
    ///
109
110
111
112
    bool initElementMatrix(const ElInfo *elInfo1,
			   const ElInfo *elInfo2,
			   const ElInfo *smaller)
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
113
114
      if (Assembler::initElementMatrix(elInfo1, elInfo2, smaller)) {
	FixVec<WorldVector<double>, VERTEX> worldCoords(rowDim_ - 1, NO_INIT);
115
116

	// transform barycentric coords to world coords
117
	for (int i = 0; i < rowDim_; i++)
118
119
120
	  elInfo1->coordToWorld(coords_[i], &worldCoords[i]);
      
	// set determinant for world coords of the side
Thomas Witkowski's avatar
Thomas Witkowski committed
121
	det_ = elInfo1->calcDet(worldCoords);
122
123
124
125
126

	return true;
      } else {
	return false;
      }
Thomas Witkowski's avatar
Thomas Witkowski committed
127
    }
128

Thomas Witkowski's avatar
Thomas Witkowski committed
129
    ///
130
131
    bool initElementVector(const ElInfo *elInfo)
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
132
133
      if (Assembler::initElementVector(elInfo)) {
	FixVec<WorldVector<double>, VERTEX> worldCoords(rowDim_ - 1, NO_INIT);
134
135

	// transform barycentric coords to world coords
136
	for (int i = 0; i < rowDim_; i++)
137
138
139
	  elInfo->coordToWorld(coords_[i], &worldCoords[i]);

	// set determinant for world coords of the side
Thomas Witkowski's avatar
Thomas Witkowski committed
140
	det_ = elInfo->calcDet(worldCoords);
141
142
143
144
145

	return true;
      } else {
	return false;
      }
Thomas Witkowski's avatar
Thomas Witkowski committed
146
    }
147
148
149
150
151
152
153
154

  protected:
    VectorOfFixVecs<DimVec<double> > coords_;
  };

}

#endif