vtf-logo

shells/driverCC/SVertexFunctors.h

Go to the documentation of this file.
00001 // -*- C++ -*- 
00002 //
00003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 //                                   Fehmi Cirak
00006 //                        California Institute of Technology
00007 //                           (C) 2004 All Rights Reserved
00008 //
00009 // <LicenseText>
00010 //
00011 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00012 //
00013 #ifndef SVERTEXFUNCTORS_H
00014 #define SVERTEXFUNCTORS_H
00015 #include "../fem/svertex.h"
00016 
00017 #include <functional>
00018 #include <cassert>
00019 #include <cstdlib>
00020 
00021 namespace shells {
00022     struct SVertexCoordinate;
00023     struct SVertexDisplacement;
00024     struct SVertexVelocity;
00025     struct SVertexAcceleration;
00026     struct SVertexMass;
00027     struct SVertexResidual;
00028     struct SVertexNodeID;
00029 
00030     template <typename Inserter, typename OP>
00031     struct SVertexCollector;
00032     template <typename IT, typename OP>
00033     class SVertexDistributor;
00034 }
00035 
00036 
00037 
00038 struct shells::SVertexCoordinate : 
00039     public std::unary_function<shells::SVertex *, double *> {
00040       
00041     typedef double DataType;
00042 #if defined(_AIX)
00043     static const std::size_t numVar; // IBM compiler workaround
00044 #else
00045     static const std::size_t numVar = 3;
00046 #endif
00047 
00048     double * operator()(shells::SVertex* const vtx) const 
00049         {
00050             return vtx->xyz;
00051         }
00052 };
00053 
00054 #if defined(_AIX)
00055 // IBM compiler workaround
00056 const std::size_t shells::SVertexCoordinate::numVar = 3;
00057 #endif
00058 
00059 
00060 
00061 struct shells::SVertexDisplacement : 
00062     public std::unary_function<shells::SVertex *, double *> {
00063       
00064     typedef double DataType;
00065 #if defined(_AIX)
00066     static const std::size_t numVar; // IBM compiler workaround
00067 #else
00068     static const std::size_t numVar = 3;
00069 #endif
00070 
00071     double * operator()(shells::SVertex* const vtx) const 
00072         {
00073             return vtx->disp;
00074         }
00075 };
00076 
00077 #if defined(_AIX)
00078 // IBM compiler workaround
00079 const std::size_t shells::SVertexDisplacement::numVar = 3;
00080 #endif
00081 
00082 
00083 
00084 struct shells::SVertexVelocity : 
00085     public std::unary_function<shells::SVertex *, double *> {
00086       
00087     typedef double DataType;
00088 #if defined(_AIX)
00089     static const std::size_t numVar; // IBM compiler workaround
00090 #else
00091     static const std::size_t numVar = 3;
00092 #endif
00093 
00094     double * operator()(shells::SVertex* const vtx) const 
00095         {
00096             return vtx->vel;
00097         }
00098 };
00099 
00100 #if defined(_AIX)
00101 // IBM compiler workaround
00102 const std::size_t shells::SVertexVelocity::numVar = 3;
00103 #endif
00104 
00105 
00106 
00107 struct shells::SVertexAcceleration : 
00108     public std::unary_function<shells::SVertex *, double *> {
00109       
00110     typedef double DataType;
00111 #if defined(_AIX)
00112     static const std::size_t numVar; // IBM compiler workaround
00113 #else
00114     static const std::size_t numVar = 3;
00115 #endif
00116 
00117     double * operator()(shells::SVertex* const vtx) const 
00118         {
00119             return vtx->acc;
00120         }
00121 };
00122 
00123 #if defined(_AIX)
00124 // IBM compiler workaround
00125 const std::size_t shells::SVertexAcceleration::numVar = 3;
00126 #endif
00127 
00128 
00129 
00130 struct shells::SVertexMass : 
00131     public std::unary_function<shells::SVertex *, double *> {
00132     
00133     typedef double DataType;
00134 #if defined(_AIX)
00135     static const std::size_t numVar; // IBM compiler workaround
00136 #else
00137     static const std::size_t numVar = 1;
00138 #endif
00139 
00140     double * operator()(shells::SVertex* const vtx) const 
00141         {
00142             return &(vtx->mass);
00143         }
00144 };
00145 
00146 #if defined(_AIX)
00147 // IBM compiler workaround
00148 const std::size_t shells::SVertexMass::numVar = 1;
00149 #endif
00150 
00151 
00152 
00153 struct shells::SVertexResidual : 
00154     public std::unary_function<shells::SVertex*, double *> {
00155       
00156     typedef double DataType;
00157 #if defined(_AIX)
00158     static const std::size_t numVar; // IBM compiler workaround
00159 #else
00160     static const std::size_t numVar = 3;
00161 #endif
00162 
00163     double * operator()(shells::SVertex* const vtx) const 
00164         {
00165             return vtx->resi;
00166         }
00167 };
00168 
00169 #if defined(_AIX)
00170 // IBM compiler workaround
00171 const std::size_t shells::SVertexResidual::numVar = 3;
00172 #endif
00173 
00174 
00175 
00176 struct shells::SVertexNodeID : 
00177     public std::unary_function<shells::SVertex *, int> {
00178     
00179     typedef int DataType;
00180 #if defined(_AIX)
00181     static const std::size_t numVar; // IBM compiler workaround
00182 #else
00183     static const std::size_t numVar = 1;
00184 #endif
00185 
00186     int * operator()(shells::SVertex* const vtx) const 
00187         {
00188             return &(vtx->number);
00189         }
00190 };
00191 
00192 #if defined(_AIX)
00193 // IBM compiler workaround
00194 const std::size_t shells::SVertexNodeID::numVar = 1;
00195 #endif
00196 
00197 
00198 
00199 namespace shells {
00200 
00201 template <typename Inserter, typename OP>
00202 struct SVertexCollector : 
00203     public std::binary_function<shells::SVertex *, Inserter, void > {
00204     
00205     void operator()(shells::SVertex * vtx, Inserter ins) const
00206         {
00207             OP op;
00208             typename OP::DataType *vtxVar = op(vtx);
00209             
00210             for (std::size_t i=0; i< OP::numVar; ++i) 
00211                 {
00212                     *ins++ = *vtxVar++;
00213                 }
00214         }
00215 };
00216 
00217 
00218 
00219 template <typename IT, typename OP>
00220 class SVertexDistributor : 
00221     public std::unary_function<shells::SVertex *, void > {
00222 public:    
00223     SVertexDistributor(IT begin, IT end):_begin(begin), _end(end) {}
00224 
00225     void operator()(shells::SVertex * vtx)
00226         {
00227             OP op;
00228             typename OP::DataType *vtxVar = op(vtx);
00229             
00230             for (std::size_t i=0; i< OP::numVar; ++i) 
00231                 {
00232                     assert(_begin!=_end);
00233                     *vtxVar++ = *_begin++;
00234                 }
00235         }
00236     
00237 private:
00238     IT              _begin;
00239     const IT        _end;
00240 };
00241 
00242 } // namespace shells
00243 
00244 #endif

Generated on Fri Aug 24 13:00:24 2007 for SFC Thin-Shell Finite Element Solver by  doxygen 1.4.7