MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / CalcShape

Method CalcShape

comp/globalinterfacespace.cpp:109–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107
108 ELEMENT_TYPE ElementType() const { return et; }
109 void CalcShape(const BaseMappedIntegrationPoint& mip,
110 BareSliceVector<double> shapes) const
111 {
112 int order = fes->GetOrder();
113 if constexpr(DIM ==1)
114 {
115 if(fes->polar)
116 throw Exception("Polar coordinates need 2 dimensional mapping!");
117 double phi = fes->mapping -> Evaluate(mip);
118 if(fes->periodic[0])
119 {
120 shapes(0) = 1;
121 for (int i = 1; i <= order; i++)
122 {
123 shapes(2*i-1) = cos(i*phi);
124 shapes(2*i ) = sin(i*phi);
125 }
126 }
127 else
128 {
129 LegendrePolynomial (order, -1 + 2 * phi, shapes);
130 }
131 }
132 else // DIM == 2
133 {
134 Vec<2, double> phi;
135 fes->mapping->Evaluate(mip, FlatVector<double>(2, &phi[0]));
136 if(fes->polar)
137 {
138 ArrayMem<double, 20> shapeu(order/2+1), shapev(2*order);
139 LegendrePolynomial(order/2, -1 + 2 * phi[0]*phi[0],
140 shapeu);
141 for(auto i : Range(1, order+1))
142 {
143 shapev[2*(i-1)] = cos(i*phi[1]);
144 shapev[2*(i-1)+1] = sin(i*phi[1]);
145 }
146 int j = 0;
147 for(auto k : Range(order/2 + 1))
148 shapes(j++) = shapeu[k];
149 for(auto k : Range(1, order+1))
150 {
151 JacobiPolynomialAlpha jac(k);
152 jac.Eval(order/2, 1 - 2 * phi[0]*phi[0], shapeu);
153
154 for(auto p : Range((order-k)/2+1))
155 {
156 shapes(j++) = shapev[2*(k-1)] * pow(phi[0], k) * shapeu[p];
157 shapes(j++) = shapev[2*(k-1)+1] * pow(phi[0], k) * shapeu[p];
158 }
159 }
160 }
161 else
162 {
163 int ndof1 = fes->periodic[0] ? 2*order+1 : order+1;
164 int ndof2 = fes->periodic[1] ? 2*order+1 : order+1;
165 ArrayMem<double, 20> shapeu(ndof1), shapev(ndof2);
166

Callers 1

CalcMatrixMethod · 0.45

Calls 8

LegendrePolynomialFunction · 0.85
cosFunction · 0.50
sinFunction · 0.50
RangeFunction · 0.50
GetOrderMethod · 0.45
EvaluateMethod · 0.45
EvalMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected