Programming tasks to Scientific Computing I
shellHandler.h
Go to the documentation of this file.
1 #ifndef __SHELLHANDLER_H
2 #define __SHELLHANDLER_H
3 
4 #include <configuratorsShellFE.h> // for ShellFEType
5 #include <legacyVtkWriter.h>
6 
7 namespace shellFE {
8 
10  ALLBOUNDARY = 100,
12  //Plate
13  PlateLeft = 1,
15  PlateAll = 3,
16 };
17 
19 template< typename ConfiguratorType >
20 class ShellHandler {
21 public:
28 
30  const MeshType &_mesh;
32  MaskType _DirichletMask;
34  mutable VectorType _xA;
35 
36 public:
37 
38  ShellHandler( const ConfiguratorType &conf ) :
39  _conf ( conf ),
40  _mesh( conf.getInitializer() ),
41  _numVertices ( _mesh.getNumVertices() ),
42  _numGlobalDofs ( conf.getNumGlobalDofs() ),
43  _xA ( 3 * conf.getNumGlobalDofs() )
44  {
45  generateChart_xA ( );
46  generateDirichletBoundaryMask( _DirichletMask, _numBoundaryNodes );
47  }
48 
49  void generateChart_xA() const
50  {
51  for ( int nodeIdx=0; nodeIdx < _numVertices; ++nodeIdx ) {
52  const Point3DType& coords ( _mesh.getVertex(nodeIdx) );
53 
54  for( int comp=0; comp<3; ++comp )
55  _xA[nodeIdx + _numGlobalDofs * comp] = coords[comp];
56  }
57  }
58 
59  VectorType& getChartToUndeformedShell() const
60  {
61  return _xA;
62  }
63 
64  void generateDirichletBoundaryMask ( MaskType & mask, int & numBoundaryNodes,
65  ShellBoundaryType boundaryType = ALLBOUNDARY,
66  bool clampedBoundaryCondition = false) const{
67  mask.resize( _numGlobalDofs, false );
68  numBoundaryNodes = 0;
69 
70  switch ( boundaryType ){
71  case NOBOUNDARY : {
72  } break;
73 
74  case ALLBOUNDARY : {
75  for( int ElementIndex = 0; ElementIndex < _mesh.getNumTriangs(); ++ElementIndex ){
76  for( int i = 0; i < 3; i++ ){
77  if ( _mesh.getNeighbour( ElementIndex , i ) == -1 ){
78  mask[ _mesh.getTriangNodeIdx( ElementIndex, (i+1)%3) ] = true;
79  mask[ _mesh.getTriangNodeIdx( ElementIndex, (i+2)%3) ] = true;
80  }
81  }
82  }
83  } break;
84 
85  case PlateLeft : {
86  for ( int nodeIdx=0; nodeIdx < _mesh.getNumVertices(); ++nodeIdx ) {
87  const Point3DType& coords ( _mesh.getVertex(nodeIdx) );
88  if (coords [0] == 0. ){
89  ++numBoundaryNodes;
90  mask[nodeIdx] = true;
91  }
92  }
93  } break;
94 
95  case PlateLeftTop : {
96  for ( int nodeIdx=0; nodeIdx < _mesh.getNumVertices(); ++nodeIdx ) {
97  const Point3DType& coords ( _mesh.getVertex(nodeIdx) );
98  if (coords [0] == 0. || coords[1] == 1. ){
99  ++numBoundaryNodes;
100  mask[nodeIdx] = true;
101  }
102  }
103  } break;
104 
105  case PlateAll : {
106  for ( int nodeIdx=0; nodeIdx < _mesh.getNumVertices(); ++nodeIdx ) {
107  const Point3DType& coords ( _mesh.getVertex(nodeIdx) );
108  if (coords [0] == 0. || coords [0] == 1. || coords [1] == 0. || coords[1] == 1. ){
109  ++numBoundaryNodes;
110  mask[nodeIdx] = true;
111  }
112  }
113  } break;
114 
115 
116  default :
117  throw std::invalid_argument( aol::strprintf ( "Wrong boundary condition. In File %s at line %d.", __FILE__, __LINE__ ).c_str() );
118  break;
119  }
120 
121  //clamped boundary condition
122  if( (ConfiguratorType::_ShellFEType == C1Dofs) && (clampedBoundaryCondition) ){
123  for( int i=0; i<_numVertices; ++i ){
124  if( mask[i] ){
125  mask[ i + _numVertices] = true;
126  mask[ i + 2. * _numVertices] = true;
127  }
128  }
129  }
130 
131  }
132 
133  const MaskType & getDirichletMask ( ) const { return _DirichletMask;}
134  const int & getNumBoundaryNodes() const { return _numBoundaryNodes; }
135 };
136 
137 } //end namespace
138 
139 
140 #endif //__SHANDLER_H
DataTypeContainer::MaskType MaskType
DataTypeContainer::Point3DType Point3DType
DataTypeContainer::VectorType VectorType
const MaskType & getDirichletMask() const
Definition: shellHandler.h:133
const Point3DType & getVertex(const int num) const
Definition: triangMesh.h:66
int getNumVertices() const
Definition: triangMesh.h:42
int getNeighbour(const int elementID, const int acrossLocalEdge) const
Get neighbor on edge.
Definition: triangMesh.h:76
DataTypeContainer::RealType RealType
ConfiguratorType::MaskType MaskType
Definition: shellHandler.h:24
const int _numGlobalDofs
Definition: shellHandler.h:31
const MeshType & _mesh
Definition: shellHandler.h:30
ConfiguratorType::Point3DType Point3DType
Definition: shellHandler.h:26
int getNumTriangs() const
Definition: triangMesh.h:46
ConfiguratorType::InitType MeshType
Definition: shellHandler.h:23
void generateDirichletBoundaryMask(MaskType &mask, int &numBoundaryNodes, ShellBoundaryType boundaryType=ALLBOUNDARY, bool clampedBoundaryCondition=false) const
Definition: shellHandler.h:64
ConfiguratorType::TangentVecType TangentVecType
Definition: shellHandler.h:25
Additional information about TriangleMeshes.
Definition: shellHandler.h:20
int getTriangNodeIdx(const int num, const int localNode) const
Definition: triangMesh.h:104
ShellHandler(const ConfiguratorType &conf)
Definition: shellHandler.h:38
DataTypeContainer::TangentVecType TangentVecType
string strprintf(const char *format,...)
Give back formatted string, analogously to sprintf, but save the long way &#39;round with char arrays...
Definition: aol.cpp:5
void generateChart_xA() const
Definition: shellHandler.h:49
Definition: rhs.h:14
ConfiguratorType::VectorType VectorType
Definition: shellHandler.h:27
ConfiguratorType::RealType RealType
Definition: shellHandler.h:22
const int & getNumBoundaryNodes() const
Definition: shellHandler.h:134
VectorType & getChartToUndeformedShell() const
Definition: shellHandler.h:59
ShellBoundaryType
Definition: shellHandler.h:9
Configurator for Finite Elements.
const ConfiguratorType & _conf
Definition: shellHandler.h:29