00001 // -*- C++ -*- 00002 // 00003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00004 // 00005 // Fehmi Cirak, Ralf Deiterding 00006 // California Institute of Technology 00007 // (C) 2005 All Rights Reserved 00008 // 00009 // <LicenseText> 00010 // 00011 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00012 // 00013 #ifndef SHELLENFORCEBCFUNCTOR_H 00014 #define SHELLENFORCEBCFUNCTOR_H 00015 00016 #include "shells/driverCC/SVertexFunctors.h" 00017 #include "shells/driverCC/PrescribeVarFunctor.h" 00018 00019 #include <functional> 00020 00021 00022 namespace shells { 00023 class ShellEnforceBCFunctor; 00024 } 00025 00026 00027 class shells::ShellEnforceBCFunctor : 00028 public std::unary_function<shells::SVertexS*, void> { 00029 00030 public: 00031 ShellEnforceBCFunctor(double minz, double tubeLength, double torsionAngle): 00032 _minz(minz+1.e-8), _maxz(tubeLength-1.e-8), _torsionAngle(torsionAngle){} 00033 00034 ~ShellEnforceBCFunctor() {} 00035 00036 void operator()(shells::SVertex *vtx) const { 00037 SVertexCoordinate extractC; 00038 SVertexCoordinate::DataType *coor = extractC(vtx); 00039 const double xcoor = coor[0]; 00040 const double ycoor = coor[1]; 00041 const double zcoor = coor[2]; 00042 00043 // set the velocities and accelerations to zero at the boundaries 00044 if ((zcoor<_minz)||(zcoor>_maxz)) { 00045 SVertexVelocity extractV; 00046 SVertexAcceleration extractA; 00047 00048 SVertexVelocity::DataType *vel = extractV(vtx); 00049 SVertexAcceleration::DataType *acc = extractA(vtx); 00050 for (unsigned i=0; i<SVertexVelocity::numVar; ++i) { 00051 vel[i] = 0.0; 00052 acc[i] = 0.0; 00053 } 00054 } 00055 return; 00056 } 00057 00058 private: 00059 const double _minz; 00060 const double _maxz; 00061 const double _torsionAngle; 00062 }; 00063 #endif