33 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__ELEM_DISC__DENSITY_DRIVEN_FLOW__FV1__CONSISTENT_GRAVITY__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__ELEM_DISC__DENSITY_DRIVEN_FLOW__FV1__CONSISTENT_GRAVITY__
101 static const size_t _X_ = 0;
102 static const size_t _Y_ = 1;
103 static const size_t _Z_ = 2;
121 UG_THROW (
"StdLinConsistentGravity: Combination of the world dim " <<
dim <<
122 "and the reference element dim " << refDim <<
" is not implemented.");
136 UG_ASSERT (
m_nCo > 0,
"StdLinConsistentGravity: Object not initialized.");
139 VecSet(LocalGravity, 0.0);
142 for(
size_t sh = 0; sh < (size_t)
m_nCo; sh++)
143 for(
size_t d = 0; d < refDim; d++)
144 LocalGravity[d] += vConsGravity[sh][d] * vLocalGrad[sh][d];
147 MatVecMult(ConsistentGravity, JTInv, LocalGravity);
168 EdgeMapping.
update (vCorners);
173 MatVecMult (LocalGravity, JT, PhysicalGravity);
175 vConsGravity[0][
_X_] = 0.0;
176 vConsGravity[1][
_X_] = LocalGravity[
_X_]*(vDensity[0] + vDensity[1])*0.5;
193 TriangleMapping.
update (vCorners);
198 MatVecMult (LocalGravity, JT, PhysicalGravity);
200 vConsGravity[0][
_X_] = 0.0; vConsGravity[2][
_X_] = 0.0;
201 vConsGravity[1][
_X_] = LocalGravity[
_X_]*(vDensity[0] + vDensity[1])*0.5;
203 vConsGravity[0][
_Y_] = 0.0; vConsGravity[1][
_Y_] = 0.0;
204 vConsGravity[2][
_Y_] = LocalGravity[
_Y_]*(vDensity[0] + vDensity[2])*0.5;
221 QuadMapping.
update (vCorners);
226 MatVecMult (LocalGravityAt000, JT, PhysicalGravity);
231 MatVecMult (LocalGravityAt110, JT, PhysicalGravity);
233 vConsGravity[0][
_X_] = 0.0; vConsGravity[3][
_X_] = 0.0;
234 vConsGravity[1][
_X_] = LocalGravityAt000[
_X_]*(vDensity[0] + vDensity[1])*0.5;
235 vConsGravity[2][
_X_] = LocalGravityAt110[
_X_]*(vDensity[2] + vDensity[3])*0.5;
237 vConsGravity[0][
_Y_] = 0.0; vConsGravity[1][
_Y_] = 0.0;
238 vConsGravity[2][
_Y_] = LocalGravityAt110[
_Y_]*(vDensity[1] + vDensity[2])*0.5;
239 vConsGravity[3][
_Y_] = LocalGravityAt000[
_Y_]*(vDensity[0] + vDensity[3])*0.5;
256 TetMapping.
update (vCorners);
259 LocalPoint.x() = 0.0; LocalPoint.y() = 0.0; LocalPoint.z() = 0.0;
261 MatVecMult (LocalGravity, JT, PhysicalGravity);
263 vConsGravity[0][
_X_] = 0.0; vConsGravity[2][
_X_] = 0.0; vConsGravity[3][
_X_] = 0.0;
264 vConsGravity[1][
_X_] = LocalGravity[
_X_]*(vDensity[0] + vDensity[1])*0.5;
266 vConsGravity[0][
_Y_] = 0.0; vConsGravity[1][
_Y_] = 0.0; vConsGravity[3][
_Y_] = 0.0;
267 vConsGravity[2][
_Y_] = LocalGravity[
_Y_]*(vDensity[0] + vDensity[2])*0.5;
269 vConsGravity[0][
_Z_] = 0.0; vConsGravity[1][
_Z_] = 0.0; vConsGravity[2][
_Z_] = 0.0;
270 vConsGravity[3][
_Z_] = LocalGravity[
_Z_]*(vDensity[0] + vDensity[3])*0.5;
290 PyramidMapping.
update (vCorners);
293 LocalPoint.x() = 0.0; LocalPoint.y() = 0.0; LocalPoint.z() = 0.0;
295 MatVecMult (LocalGravityAt000, JT, PhysicalGravity);
298 LocalPoint.x() = 1.0; LocalPoint.y() = 1.0; LocalPoint.z() = 0.0;
300 MatVecMult (LocalGravityAt110, JT, PhysicalGravity);
302 vConsGravity[0][
_X_] = 0.0; vConsGravity[3][
_X_] = 0.0; vConsGravity[4][
_X_] = 0.0;
303 vConsGravity[1][
_X_] = LocalGravityAt000[
_X_]*(vDensity[0] + vDensity[1])*0.5;
304 vConsGravity[2][
_X_] = LocalGravityAt110[
_X_]*(vDensity[2] + vDensity[3])*0.5;
306 vConsGravity[0][
_Y_] = 0.0; vConsGravity[1][
_Y_] = 0.0; vConsGravity[4][
_Y_] = 0.0;
307 vConsGravity[2][
_Y_] = LocalGravityAt110[
_Y_]*(vDensity[1] + vDensity[2])*0.5;
308 vConsGravity[3][
_Y_] = LocalGravityAt000[
_Y_]*(vDensity[0] + vDensity[3])*0.5;
310 vConsGravity[0][
_Z_] = 0.0; vConsGravity[1][
_Z_] = 0.0;
311 vConsGravity[2][
_Z_] = 0.0; vConsGravity[3][
_Z_] = 0.0;
312 vConsGravity[4][
_Z_] = LocalGravityAt000[
_Z_]*(vDensity[0] + vDensity[4])*0.5;
326 MathVector<3> LocalGravityAt000, LocalGravityAt101, LocalGravityAt011;
329 PrismMapping.
update (vCorners);
332 LocalPoint.x() = 0.0; LocalPoint.y() = 0.0; LocalPoint.z() = 0.0;
334 MatVecMult (LocalGravityAt000, JT, PhysicalGravity);
337 LocalPoint.x() = 1.0; LocalPoint.y() = 0.0; LocalPoint.z() = 1.0;
339 MatVecMult (LocalGravityAt101, JT, PhysicalGravity);
342 LocalPoint.x() = 0.0; LocalPoint.y() = 1.0; LocalPoint.z() = 1.0;
344 MatVecMult (LocalGravityAt011, JT, PhysicalGravity);
346 vConsGravity[0][
_X_] = 0.0; vConsGravity[2][
_X_] = 0.0;
347 vConsGravity[3][
_X_] = 0.0; vConsGravity[5][
_X_] = 0.0;
348 vConsGravity[1][
_X_] = LocalGravityAt000[
_X_]*(vDensity[0] + vDensity[1])*0.5;
349 vConsGravity[4][
_X_] = LocalGravityAt011[
_X_]*(vDensity[3] + vDensity[4])*0.5;
351 vConsGravity[0][
_Y_] = 0.0; vConsGravity[1][
_Y_] = 0.0;
352 vConsGravity[3][
_Y_] = 0.0; vConsGravity[4][
_Y_] = 0.0;
353 vConsGravity[2][
_Y_] = LocalGravityAt000[
_Y_]*(vDensity[0] + vDensity[2])*0.5;
354 vConsGravity[5][
_Y_] = LocalGravityAt011[
_Y_]*(vDensity[3] + vDensity[5])*0.5;
356 vConsGravity[0][
_Z_] = 0.0; vConsGravity[1][
_Z_] = 0.0; vConsGravity[2][
_Z_] = 0.0;
357 vConsGravity[3][
_Z_] = LocalGravityAt000[
_Z_]*(vDensity[0] + vDensity[3])*0.5;
358 vConsGravity[4][
_Z_] = LocalGravityAt101[
_Z_]*(vDensity[1] + vDensity[4])*0.5;
359 vConsGravity[5][
_Z_] = LocalGravityAt011[
_Z_]*(vDensity[2] + vDensity[5])*0.5;
373 MathVector<3> LocalGravityAt000, LocalGravityAt110, LocalGravityAt101, LocalGravityAt011;
376 HexMapping.
update (vCorners);
379 LocalPoint.x() = 0.0; LocalPoint.y() = 0.0; LocalPoint.z() = 0.0;
381 MatVecMult (LocalGravityAt000, JT, PhysicalGravity);
384 LocalPoint.x() = 1.0; LocalPoint.y() = 1.0; LocalPoint.z() = 0.0;
386 MatVecMult (LocalGravityAt110, JT, PhysicalGravity);
389 LocalPoint.x() = 1.0; LocalPoint.y() = 0.0; LocalPoint.z() = 1.0;
391 MatVecMult (LocalGravityAt101, JT, PhysicalGravity);
394 LocalPoint.x() = 0.0; LocalPoint.y() = 1.0; LocalPoint.z() = 1.0;
396 MatVecMult (LocalGravityAt011, JT, PhysicalGravity);
398 vConsGravity[0][
_X_] = 0.0; vConsGravity[3][
_X_] = 0.0;
399 vConsGravity[4][
_X_] = 0.0; vConsGravity[7][
_X_] = 0.0;
400 vConsGravity[1][
_X_] = LocalGravityAt000[
_X_]*(vDensity[0] + vDensity[1])*0.5;
401 vConsGravity[2][
_X_] = LocalGravityAt110[
_X_]*(vDensity[2] + vDensity[3])*0.5;
402 vConsGravity[5][
_X_] = LocalGravityAt101[
_X_]*(vDensity[4] + vDensity[5])*0.5;
403 vConsGravity[6][
_X_] = LocalGravityAt011[
_X_]*(vDensity[6] + vDensity[7])*0.5;
405 vConsGravity[0][
_Y_] = 0.0; vConsGravity[1][
_Y_] = 0.0;
406 vConsGravity[4][
_Y_] = 0.0; vConsGravity[5][
_Y_] = 0.0;
407 vConsGravity[2][
_Y_] = LocalGravityAt110[
_Y_]*(vDensity[1] + vDensity[2])*0.5;
408 vConsGravity[3][
_Y_] = LocalGravityAt000[
_Y_]*(vDensity[0] + vDensity[3])*0.5;
409 vConsGravity[6][
_Y_] = LocalGravityAt101[
_Y_]*(vDensity[5] + vDensity[6])*0.5;
410 vConsGravity[7][
_Y_] = LocalGravityAt011[
_Y_]*(vDensity[4] + vDensity[7])*0.5;
412 vConsGravity[0][
_Z_] = 0.0; vConsGravity[1][
_Z_] = 0.0;
413 vConsGravity[2][
_Z_] = 0.0; vConsGravity[3][
_Z_] = 0.0;
414 vConsGravity[4][
_Z_] = LocalGravityAt000[
_Z_]*(vDensity[0] + vDensity[4])*0.5;
415 vConsGravity[5][
_Z_] = LocalGravityAt101[
_Z_]*(vDensity[1] + vDensity[5])*0.5;
416 vConsGravity[6][
_Z_] = LocalGravityAt110[
_Z_]*(vDensity[2] + vDensity[6])*0.5;
417 vConsGravity[7][
_Z_] = LocalGravityAt011[
_Z_]*(vDensity[3] + vDensity[7])*0.5;
433 UG_ASSERT (n_co == 2,
"StdLinConsistentGravity: Illegal number of corners of an edge.");
435 this->
template prepare_edge<dim> (vConsGravity, vCorners, vDensity, PhysicalGravity);
450 switch (m_nCo = n_co)
453 this->
template prepare_triangle<dim> (vConsGravity, vCorners, vDensity, PhysicalGravity);
456 this->
template prepare_quadrilateral<dim> (vConsGravity, vCorners, vDensity, PhysicalGravity);
459 UG_THROW (
"StdLinConsistentGravity: Illegal number of corners ("
460 << n_co <<
") of an element with reference dimension 2.");
476 switch (m_nCo = n_co)
479 this->
template prepare_tetrahedron<dim> (vConsGravity, vCorners, vDensity, PhysicalGravity);
482 this->
template prepare_pyramid<dim> (vConsGravity, vCorners, vDensity, PhysicalGravity);
485 this->
template prepare_prism<dim> (vConsGravity, vCorners, vDensity, PhysicalGravity);
488 this->
template prepare_hexahedron<dim> (vConsGravity, vCorners, vDensity, PhysicalGravity);
491 UG_THROW (
"StdLinConsistentGravity: Illegal number of corners ("
492 << n_co <<
") of an element with reference dimension 3.");
515 template <
int refDim>
536 base_type::template prepare<dim>
537 (vConsGravity, n_co, vCorners, vDensity, PhysicalGravity);
552 if (base_type::m_nCo > 0)
553 base_type::template compute<dim> (ConsistentGravity, LocalCoord, JTInv, vLocalGrad, vConsGravity);
557 UG_ASSERT (
dim == refDim && base_type::m_nCo == -(refDim+1),
"StdLinConsistentGravityX: Illegal initialization of the object.");
560 VecSet (LocalGravity, 0.0);
562 for (
size_t d = 0; d < refDim; d++)
563 LocalGravity[d] = vConsGravity[d+1][
dim-1];
566 MatVecMult(ConsistentGravity, JTInv, LocalGravity);
569 for (
size_t d = 0; d <
dim-1; d++)
570 for (
size_t sh = 1; sh <= refDim; sh++)
571 ConsistentGravity[d] -= vConsGravity[sh][d] * LocalCoord[sh-1];
578 template <
typename refElem,
int dim>
587 number DensityIP, Diff, gradient;
592 Mapping.
update (vCorners);
595 for (
size_t i = 1; i <
dim+1; i++)
597 VecSubtract (ShiftedGlobalPoint, vCorners[i], vCorners[0]);
598 Diff = ShiftedGlobalPoint [
dim-1];
600 ShiftedGlobalPoint [
dim-1] = 0.0;
604 for (
size_t j = 0; j <
dim; j++) DensityIP -= LocalPoint[j];
605 DensityIP *= vDensity[0];
606 for (
size_t j = 1; j <
dim+1; j++)
607 DensityIP += vDensity[j] * LocalPoint[j-1];
609 for(
size_t j = 0; j <
dim-1; ++j)
612 for (
size_t k = 0; k <
dim; k++)
613 gradient += JT[j][k] * (vDensity[k+1] - vDensity[0]);
614 vConsGravity[i][j] = Diff * PhysicalGravity[
dim-1] * gradient;
616 vConsGravity[i][
dim-1] = Diff * PhysicalGravity[
dim-1] * (vDensity[i] + DensityIP)*0.5;
633 if (
dim == 2 && n_co == 3 && PhysicalGravity[0] == 0.0)
636 this->
template prepare_simplex<ReferenceTriangle, dim>
637 (vConsGravity, vCorners, vDensity, PhysicalGravity);
640 base_type::template prepare<dim>
641 (vConsGravity, n_co, vCorners, vDensity, PhysicalGravity);
656 if (
dim == 3 && n_co == 4 && PhysicalGravity[0] == 0.0 && PhysicalGravity[1] == 0.0)
659 this->
template prepare_simplex<ReferenceTetrahedron, dim>
660 (vConsGravity, vCorners, vDensity, PhysicalGravity);
663 base_type::template prepare<dim>
664 (vConsGravity, n_co, vCorners, vDensity, PhysicalGravity);
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
a mathematical Vector with N entries.
Definition: math_vector.h:97
Definition: reference_mapping.h:65
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 jacobian_transposed(MathMatrix< dim, worldDim > &JT, const MathVector< dim > &locPos) const
returns transposed of jacobian
Class for the computation of the standard version ('Voss-Souza-type') of the consistent gravity.
Definition: consistent_gravity.h:98
static const size_t _Y_
Definition: consistent_gravity.h:102
static const size_t _X_
Definition: consistent_gravity.h:101
void prepare_triangle(MathVector< 2 > *vConsGravity, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners of a triangle
Definition: consistent_gravity.h:182
void prepare(MathVector< refDim > *vConsGravity, const int n_co, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners, cf. the specializations
Definition: consistent_gravity.h:113
StdLinConsistentGravity()
constructor (sets the 'not init.' flag)
Definition: consistent_gravity.h:108
void prepare_quadrilateral(MathVector< 2 > *vConsGravity, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners of a quadrilateral
Definition: consistent_gravity.h:210
void prepare_edge(MathVector< 1 > *vConsGravity, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners of an edge
Definition: consistent_gravity.h:157
void prepare_pyramid(MathVector< 3 > *vConsGravity, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners of a pyramid
Definition: consistent_gravity.h:279
void compute(MathVector< dim > &ConsistentGravity, const MathVector< refDim > &LocalCoord, const MathMatrix< dim, refDim > &JTInv, const MathVector< refDim > *vLocalGrad, const MathVector< refDim > *vConsGravity)
computation of the consistent gravity at a given point
Definition: consistent_gravity.h:128
int m_nCo
number of corners of the element for which the object is init. (0 if not init)
Definition: consistent_gravity.h:152
void prepare_tetrahedron(MathVector< 3 > *vConsGravity, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners of a tetrahedron
Definition: consistent_gravity.h:245
void prepare_prism(MathVector< 3 > *vConsGravity, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners of a prism
Definition: consistent_gravity.h:318
void prepare_hexahedron(MathVector< 3 > *vConsGravity, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners of a hexahedron
Definition: consistent_gravity.h:365
static const size_t _Z_
Definition: consistent_gravity.h:103
Class for the computation of the enhanced version ('Frolkovic-type') of the consistent gravity.
Definition: consistent_gravity.h:517
void prepare(MathVector< refDim > *vConsGravity, const int n_co, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the primary function for the consistent gravity at corners, cf. the specializations
Definition: consistent_gravity.h:528
StdLinConsistentGravityX()
constructor
Definition: consistent_gravity.h:523
void compute(MathVector< dim > &ConsistentGravity, const MathVector< refDim > &LocalCoord, const MathMatrix< dim, refDim > &JTInv, const MathVector< refDim > *vLocalGrad, const MathVector< refDim > *vConsGravity)
computation of the consistent gravity at a given point
Definition: consistent_gravity.h:544
void prepare_simplex(MathVector< refDim > *vConsGravity, const MathVector< dim > *vCorners, const number *vDensity, const MathVector< dim > &PhysicalGravity)
computation of the extended version of the corner consistent gravity for simplices (only in full dime...
Definition: consistent_gravity.h:580
StdLinConsistentGravity< refDim > base_type
Definition: consistent_gravity.h:518
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
void TransposedMatVecMult(vector_t_out &vOut, const matrix_t &m, const vector_t_in &v)
Transposed Matrix - Vector Muliplication.
Definition: math_matrix_vector_functions_common_impl.hpp:111
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 VecSet(vector_t &vInOut, typename vector_t::value_type s)
Set each vector component to scalar (componentwise)
Definition: math_vector_functions_common_impl.hpp:539
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