36 ASSERT(!( ele == NULL ),
"NULL as argument of function local_matrix()\n");
38 double scale = 1/ conductivity.
value( ele->centre(), ele->element_accessor() ) / cross_section.
value( ele->centre(), ele->element_accessor() );
39 switch( ele->dim() ) {
55 xprintf(
Warn,
"Singular local matrix of the element %d\n",ele.
id());
76 switch( ele->dim() ) {
80 arma::vec3 line_vec = ele->node[1]->point() - ele->node[0]->point();
82 return - arma::norm( point - ele->node[1]->point(), 2) * line_vec / arma::dot( line_vec, line_vec) ;
84 return arma::norm( point - ele->node[0]->point(), 2) * line_vec / arma::dot( line_vec, line_vec) ;
90 arma::vec3 ex(ele->node[1]->point() - ele->node[0]->point());
93 arma::vec3 ac(ele->node[2]->point() - ele->node[0]->point());
105 (dot(u, ex) -
bas_alfa[ face ] ) * ex
106 +(dot(u, ey) -
bas_beta[ face ] ) * ey
116 return bas_delta[ face ]*(point - RT0_Y);
137 arma::vec3 line_vec = ele->node[1]->point() - ele->node[0]->point();
138 line_vec /= arma::norm(line_vec,2);
142 val = scale * arma::dot(line_vec,
143 (anisotropy.
value(ele->centre(), ele->element_accessor() )).i() * line_vec
144 ) * ele->measure() / 3.0;
148 loc[0][1] = - val / 2.0;
149 loc[1][0] = - val / 2.0;
162 double midpoint[ 3 ][ 2 ];
169 double nod_coor[ 3 ][ 2 ];
173 arma::vec3 ex(ele->node[1]->point() - ele->node[0]->point());
174 ex /= arma::norm(ex,2);
176 arma::vec3 ac(ele->node[2]->point() - ele->node[0]->point());
181 ey /= arma::norm(ey, 2);
189 arma::mat resistance_tensor = r.t() * ((anisotropy.
value(ele->centre(), ele->element_accessor() )).i() * r);
194 for( i = 0; i < 3; i++ )
195 for( j = i; j < 3; j++ ) {
197 alfa[ j ], beta[ j ],
198 resistance_tensor, poly );
202 loc[i][j] = scale * gama[i] * gama[j] * ele->measure() *
203 ( p[0] + p[1] + p[2] ) / 3.0;
204 loc[j][i] = loc[i][j];
206 for(i = 0; i < 3; i++) {
220 double u[ 3 ], v[ 3 ];
225 u[ 0 ] = ele->node[ 1 ]->getX() - ele->node[ 0 ]->getX();
226 u[ 1 ] = ele->node[ 1 ]->getY() - ele->node[ 0 ]->getY();
227 u[ 2 ] = ele->node[ 1 ]->getZ() - ele->node[ 0 ]->getZ();
228 v[ 0 ] = ele->node[ 2 ]->getX() - ele->node[ 0 ]->getX();
229 v[ 1 ] = ele->node[ 2 ]->getY() - ele->node[ 0 ]->getY();
230 v[ 2 ] = ele->node[ 2 ]->getZ() - ele->node[ 0 ]->getZ();
255 midpoint[ 0 ][ 0 ] = ( nod[ 0 ][ 0 ] + nod[ 1 ][ 0 ] ) / 2.0;
256 midpoint[ 0 ][ 1 ] = ( nod[ 0 ][ 1 ] + nod[ 1 ][ 1 ] ) / 2.0;
257 midpoint[ 1 ][ 0 ] = ( nod[ 1 ][ 0 ] + nod[ 2 ][ 0 ] ) / 2.0;
258 midpoint[ 1 ][ 1 ] = ( nod[ 1 ][ 1 ] + nod[ 2 ][ 1 ] ) / 2.0;
259 midpoint[ 2 ][ 0 ] = ( nod[ 2 ][ 0 ] + nod[ 0 ][ 0 ] ) / 2.0;
260 midpoint[ 2 ][ 1 ] = ( nod[ 2 ][ 1 ] + nod[ 0 ][ 1 ] ) / 2.0;
269 double beta[],
double gama[] )
272 nod[ 1 ][ 0 ], nod[ 1 ][ 1 ],
273 nod[ 2 ][ 0 ], nod[ 2 ][ 1 ],
276 nod[ 2 ][ 0 ], nod[ 2 ][ 1 ],
277 nod[ 0 ][ 0 ], nod[ 0 ][ 1 ],
278 alfa + 1, beta + 1, gama + 1 );
280 nod[ 0 ][ 0 ], nod[ 0 ][ 1 ],
281 nod[ 1 ][ 0 ], nod[ 1 ][ 1 ],
282 alfa + 2, beta + 2, gama + 2 );
288 double x1,
double y1,
289 double x2,
double y2,
290 double *alfa,
double *beta,
double *gama)
294 *gama = 1.0 / fabs( ( x0 - x2 ) * ( y1 - y0 ) + ( y0 - y2 ) * ( x0 - x1 ) );
300 arma::mat::fixed<2,2> a,
double poly[] )
302 poly[ 0 ] = a( 0,0 ) * al_i * al_j +
303 a( 0,1 ) * be_i * al_j +
304 a( 1,0 ) * al_i * be_j +
305 a( 1,1 ) * be_i * be_j;
307 poly[ 1 ] = ( a( 0,0 ) * al_i +
310 a( 1,0 ) * be_j ) * -1.0;
312 poly[ 2 ] = ( a( 1,1 ) * be_i +
315 a( 0,1) * al_j ) * -1.0;
316 poly[ 3 ] = a( 0,0 );
317 poly[ 4 ] = a( 0,1 ) + a( 1,0 );
318 poly[ 5 ] = a( 1,1 );
328 poly[ 1 ] * point[ 0 ] +
329 poly[ 2 ] * point[ 1 ] +
330 poly[ 3 ] * point[ 0 ] * point[ 0 ] +
331 poly[ 4 ] * point[ 0 ] * point[ 1 ] +
332 poly[ 5 ] * point[ 1 ] * point[ 1 ];
350 arma::mat resistance_tensor = (anisotropy.
value(ele->centre(), ele->element_accessor() )).i();
360 for( i = 0; i < 4; i++ )
361 for( j = i; j < 4; j++ ) {
363 alfa[ i ], beta[ i ], gama[ i ],
364 alfa[ j ], beta[ j ], gama[ j ],
365 resistance_tensor, poly );
367 loc[j][i] = loc[i][j];
369 for(i = 0; i < 4; i++) {
384 for( li = 0; li < 4; li++ ) {
385 alfa[ li ] = ele->node[ li ]->getX();
386 beta[ li ] = ele->node[ li ]->getY();
387 gama[ li ] = ele->node[ li ]->getZ();
388 pSid = ele->side( li );
389 delta[ li ] = 1.0 / ( pSid->
measure() *
393 pSid->
normal()[ 0 ] * alfa[ li ] -
394 pSid->
normal()[ 1 ] * beta[ li ] -
395 pSid->
normal()[ 2 ] * gama[ li ] ) );
402 double al_j,
double be_j,
double ga_j,
403 arma::mat::fixed<3,3> a,
double poly[] )
406 poly[ 0 ] = a( 0,0 ) * al_i * al_j +
407 a( 0,1 ) * be_i * al_j +
408 a( 0,2 ) * ga_i * al_j +
409 a( 1,0 ) * al_i * be_j +
410 a( 1,1 ) * be_i * be_j +
411 a( 1,2 ) * ga_i * be_j +
412 a( 2,0 ) * al_i * ga_j +
413 a( 2,1 ) * be_i * ga_j +
414 a( 2,2 ) * ga_i * ga_j;
416 poly[ 1 ] = ( a( 0,0 ) * al_i +
421 a( 2,0 ) * ga_j ) * -1.0;
423 poly[ 2 ] = ( a( 1,0 ) * al_i +
428 a( 2,1 ) * ga_j ) * -1.0;
430 poly[ 3 ] = ( a( 2,0 ) * al_i +
435 a( 2,2 ) * ga_j ) * -1.0;
437 poly[ 4 ] = a( 0,1 ) + a( 1,0 );
439 poly[ 5 ] = a( 0,2 ) + a( 2,0 );
441 poly[ 6 ] = a( 1,2 ) + a( 2,1 );
443 poly[ 7 ] = a( 0,0 );
445 poly[ 8 ] = a( 1,1 );
447 poly[ 9 ] = a( 2,2 );
460 t[ 0 ] = ele->centre()[ 0 ];
461 t[ 1 ] = ele->centre()[ 1 ];
462 t[ 2 ] = ele->centre()[ 2 ];
466 rc += poly[ 1 ] * v * t[ 0 ];
468 rc += poly[ 2 ] * v * t[ 1 ];
470 rc += poly[ 3 ] * v * t[ 2 ];
472 rc += poly[ 4 ] * v * ( t[ 0 ] * t[ 1 ] + 1.0 / 20.0 * (
473 ( ele->node[ 0 ]->getX() - t[ 0 ] ) * ( ele->node[ 0 ]->getY() - t[ 1 ] ) +
474 ( ele->node[ 1 ]->getX() - t[ 0 ] ) * ( ele->node[ 1 ]->getY() - t[ 1 ] ) +
475 ( ele->node[ 2 ]->getX() - t[ 0 ] ) * ( ele->node[ 2 ]->getY() - t[ 1 ] ) +
476 ( ele->node[ 3 ]->getX() - t[ 0 ] ) * ( ele->node[ 3 ]->getY() - t[ 1 ] )
479 rc += poly[ 5 ] * v * ( t[ 0 ] * t[ 2 ] + 1.0 / 20.0 * (
480 ( ele->node[ 0 ]->getX() - t[ 0 ] ) * ( ele->node[ 0 ]->getZ() - t[ 2 ] ) +
481 ( ele->node[ 1 ]->getX() - t[ 0 ] ) * ( ele->node[ 1 ]->getZ() - t[ 2 ] ) +
482 ( ele->node[ 2 ]->getX() - t[ 0 ] ) * ( ele->node[ 2 ]->getZ() - t[ 2 ] ) +
483 ( ele->node[ 3 ]->getX() - t[ 0 ] ) * ( ele->node[ 3 ]->getZ() - t[ 2 ] )
486 rc += poly[ 6 ] * v * ( t[ 1 ] * t[ 2 ] + 1.0 / 20.0 * (
487 ( ele->node[ 0 ]->getY() - t[ 1 ] ) * ( ele->node[ 0 ]->getZ() - t[ 2 ] ) +
488 ( ele->node[ 1 ]->getY() - t[ 1 ] ) * ( ele->node[ 1 ]->getZ() - t[ 2 ] ) +
489 ( ele->node[ 2 ]->getY() - t[ 1 ] ) * ( ele->node[ 2 ]->getZ() - t[ 2 ] ) +
490 ( ele->node[ 3 ]->getY() - t[ 1 ] ) * ( ele->node[ 3 ]->getZ() - t[ 2 ] )
493 rc += poly[ 7 ] * v * ( t[ 0 ] * t[ 0 ] + 1.0 / 20.0 * (
494 ( ele->node[ 0 ]->getX() - t[ 0 ] ) * ( ele->node[ 0 ]->getX() - t[ 0 ] ) +
495 ( ele->node[ 1 ]->getX() - t[ 0 ] ) * ( ele->node[ 1 ]->getX() - t[ 0 ] ) +
496 ( ele->node[ 2 ]->getX() - t[ 0 ] ) * ( ele->node[ 2 ]->getX() - t[ 0 ] ) +
497 ( ele->node[ 3 ]->getX() - t[ 0 ] ) * ( ele->node[ 3 ]->getX() - t[ 0 ] )
500 rc += poly[ 8 ] * v * ( t[ 1 ] * t[ 1 ] + 1.0 / 20.0 * (
501 ( ele->node[ 0 ]->getY() - t[ 1 ] ) * ( ele->node[ 0 ]->getY() - t[ 1 ] ) +
502 ( ele->node[ 1 ]->getY() - t[ 1 ] ) * ( ele->node[ 1 ]->getY() - t[ 1 ] ) +
503 ( ele->node[ 2 ]->getY() - t[ 1 ] ) * ( ele->node[ 2 ]->getY() - t[ 1 ] ) +
504 ( ele->node[ 3 ]->getY() - t[ 1 ] ) * ( ele->node[ 3 ]->getY() - t[ 1 ] )
507 rc += poly[ 9 ] * v * ( t[ 2 ] * t[ 2 ] + 1.0 / 20.0 * (
508 ( ele->node[ 0 ]->getZ() - t[ 2 ] ) * ( ele->node[ 0 ]->getZ() - t[ 2 ] ) +
509 ( ele->node[ 1 ]->getZ() - t[ 2 ] ) * ( ele->node[ 1 ]->getZ() - t[ 2 ] ) +
510 ( ele->node[ 2 ]->getZ() - t[ 2 ] ) * ( ele->node[ 2 ]->getZ() - t[ 2 ] ) +
511 ( ele->node[ 3 ]->getZ() - t[ 2 ] ) * ( ele->node[ 3 ]->getZ() - t[ 2 ] )
void calc_polynom_tetrahedron(double al_i, double be_i, double ga_i, double al_j, double be_j, double ga_j, arma::mat::fixed< 3, 3 > a, double poly[])
void vector_product(double u[], double v[], double x[])
void node_coordinates_triangle(ElementFullIter ele, double nod[3][2])
double polynom_value_triangle(double poly[], double point[])
void local_matrix_tetrahedron(ElementFullIter ele, FieldType &cond_anisothropy, double scale)
double polynom_integral_tetrahedron(ElementFullIter ele, double poly[])
void bas_func_0_triangle(double x0, double y0, double x1, double y1, double x2, double y2, double *alfa, double *beta, double *gama)
void basis_functions_triangle(double nod[3][2], double alfa[], double beta[], double gama[])
arma::vec3 centre() const
void local_matrix_line(ElementFullIter ele, FieldType &cond_anisothropy, double scale)
void basis_functions_tetrahedron(ElementFullIter ele, double alfa[], double beta[], double gama[], double delta[])
void normalize_vector(double u[])
int id()
Returns id of the iterator. See VectorId documentation.
void update(ElementFullIter ele, FieldType &cond_anisothropy, FieldType_Scalar &cross_section, FieldType_Scalar &conductivity)
double * inv_local_matrix()
double scalar_product(double u[], double v[])
void PrintSmallMatrix(double *mtx, int size)
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
void side_midpoint_triangle(double nod[3][2], double midpoint[3][2])
#define NUM_ZERO
Numerical helpers.
void calc_polynom_triangle(double al_i, double be_i, double al_j, double be_j, arma::mat::fixed< 2, 2 > a, double poly[])
double MatrixInverse(double *a, double *b, int size)
arma::vec3 RT0_value(ElementFullIter ele, arma::vec3 point, unsigned int face)
void local_matrix_triangle(ElementFullIter ele, FieldType &cond_anisothropy, double scale)
arma::vec3 normal() const