// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root // SPDX-License-Identifier: LGPL-2.1-or-later /****************************************************************************/ /* */ /* File: shapes.c */ /* */ /* Purpose: shape functions for triangles and quadrilaterals */ /* */ /* Author: Peter Bastian */ /* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */ /* Universitaet Heidelberg */ /* Im Neuenheimer Feld 368 */ /* 6900 Heidelberg */ /* internet: ug@ica3.uni-stuttgart.de */ /* */ /* History: 08.04.92 begin, ug version 2.0 */ /* 20.11.94 moved shapes.c from ug to cd folder */ /* */ /* Remarks: */ /* */ /****************************************************************************/ /****************************************************************************/ /* */ /* include files */ /* system include files */ /* application include files */ /* */ /****************************************************************************/ #include #include #include #include #include #include #include #include #include #include "gm.h" #include "evm.h" #include "shapes.h" USING_UG_NAMESPACE USING_UGDIM_NAMESPACE /****************************************************************************/ /* */ /* defines in the following order */ /* */ /* compile time constants defining static data size (i.e. arrays) */ /* other constants */ /* macros */ /* */ /****************************************************************************/ #define SMALL_DIFF 1e-20 #define MAX_ITER 20 /****************************************************************************/ /* */ /* data structures used in this source file (exported data structures are */ /* in the corresponding include file!) */ /* */ /****************************************************************************/ /****************************************************************************/ /* */ /* definition of exported global variables */ /* */ /****************************************************************************/ /****************************************************************************/ /* */ /* forward declarations of functions used before they are defined */ /* */ /****************************************************************************/ /****************************************************************************/ /** \brief Transform global coordinates to local \param n - number of corners \param Corners - coordinates of corners \param EvalPoint - global coordinates \param LocalCoord - local coordinates This function transforms global coordinates to local in an evaluated point in 3D. \return
  • 0 if ok
  • 1 if error occurred.
*/ /****************************************************************************/ INT NS_DIM_PREFIX UG_GlobalToLocal (INT n, const DOUBLE **Corners, const FieldVector& EvalPoint, FieldVector& LocalCoord) { DOUBLE_VECTOR tmp,diff,M[DIM],IM[DIM]; DOUBLE s,IMdet; INT i; V_DIM_SUBTRACT(EvalPoint,Corners[0],diff); if (n == DIM+1) { TRANSFORMATION(DIM+1,Corners,LocalCoord,M); M_DIM_INVERT(M,IM,IMdet); if (IMdet==0) return (2); MT_TIMES_V_DIM(IM,diff,LocalCoord); return(0); } V_DIM_CLEAR(LocalCoord); TRANSFORMATION(n,Corners,LocalCoord,M); M_DIM_INVERT(M,IM,IMdet); if (IMdet==0) return (3); MT_TIMES_V_DIM(IM,diff,LocalCoord); for (i=0; i
  • 0 if ok
  • 1 if error occurred.
  • */ /****************************************************************************/ #ifdef UG_DIM_3 INT NS_DIM_PREFIX TetraSideNormals (ELEMENT *theElement, DOUBLE **theCorners, DOUBLE_VECTOR theNormals[MAX_SIDES_OF_ELEM]) { DOUBLE_VECTOR a, b; DOUBLE h; INT j; for (j=0; j<4; j++) { INT k = element_descriptors[TETRAHEDRON]->side_opp_to_corner[j]; V3_SUBTRACT(theCorners[(j+1)%4],theCorners[(j+2)%4],a) V3_SUBTRACT(theCorners[(j+1)%4],theCorners[(j+3)%4],b) V3_VECTOR_PRODUCT(a,b,theNormals[k]) V3_Normalize(theNormals[k]); V3_SUBTRACT(theCorners[j],theCorners[(j+1)%4],a) V3_SCALAR_PRODUCT(theNormals[k],a,h); if (std::abs(h)
  • 0 if ok
  • 1 if error occurred.
  • */ /****************************************************************************/ #ifdef UG_DIM_3 INT NS_DIM_PREFIX TetMaxSideAngle (ELEMENT *theElement, const DOUBLE **theCorners, DOUBLE *MaxAngle) { DOUBLE_VECTOR theNormal[MAX_SIDES_OF_ELEM]; DOUBLE max,help; INT i; if (TetraSideNormals (theElement,(DOUBLE **)theCorners,theNormal)) return (1); max = -1.0; for (i=0; i::pi()*acos(-max); return (0); } #endif /****************************************************************************/ /** \brief Calculates side angle and length of edge of Tetrahedron \param theCorners - list of pointers to phys corner vectors \param Angle - side angle \param Length - sidelength This function calculates the side angle of a tetrahedron and the lengths of the edges belonging to this side. \return
    • 0 if ok
    • 1 if error occurred.
    */ /****************************************************************************/ #ifdef UG_DIM_3 INT NS_DIM_PREFIX TetAngleAndLength (ELEMENT *theElement, const DOUBLE **theCorners, DOUBLE *Angle, DOUBLE *Length) { DOUBLE_VECTOR theNormals[MAX_SIDES_OF_ELEM],theEdge[MAX_EDGES_OF_ELEM]; DOUBLE h; INT j,k; for (j=0; j0.0 && CORNER_OF_EDGE(theElement,k,0)==CORNER_OPP_TO_SIDE(theElement,j)) ) V3_SCALE(-1.0,theNormals[j]); } for (j=0; j