vtf-logo

shells/driverCC/PrescribeVarFunctor.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 PRESCRIBEVARFUNCTOR_H
00014 #define PRESCRIBEVARFUNCTOR_H
00015 #include "../fem/definitions.h"
00016 #include "SVertexFunctors.h"
00017 #include <cstdlib>
00018 #include <functional>
00019 
00020 
00021 namespace shells {
00022     template <typename T1, typename T2>
00023     class CheckPrescribeSVtxField;
00024     template <typename EXTR>
00025     class CheckSVtxFieldInBox;
00026     template <typename EXTR>
00027     class PrescribeSVtxField;
00028     template <typename EXTR>
00029     class CheckSVtxFieldNotInBox;
00030 } 
00031 
00032 
00033 namespace shells {
00034 
00035 template <typename EXTR>
00036 class PrescribeSVtxField : 
00037     public std::unary_function<shells::SVertexS *, void> {
00038 // prescribe a vertex field (e.g. displacements) to _pVar 
00039 
00040 public:    
00041     typedef typename EXTR::DataType    _DataType;
00042 
00043     PrescribeSVtxField(const _DataType * const pVar)
00044         : _pVar(pVar){}
00045     
00046     void operator()(shells::SVertexS * const vtx) const
00047         {
00048             EXTR extract;
00049             _DataType *vtxVar = extract(vtx);
00050             
00051             for (std::size_t i=0; i<EXTR::numVar ; ++i) {
00052                 vtxVar[i] = _pVar[i]; 
00053             }     
00054         }
00055     
00056 private:
00057     const _DataType * const     _pVar; 
00058 };
00059 
00060 
00061 
00062 template <typename EXTR>
00063 class CheckSVtxFieldInBox :
00064     public std::unary_function<shells::SVertexS*, bool> {
00065 // check if a vertex field (e.g. coordinates) is in a domain 
00066 // (_low x _upp)
00067 
00068 public:
00069     typedef typename EXTR::DataType    _DataType;
00070 
00071     CheckSVtxFieldInBox(const _DataType * const low, 
00072                         const _DataType * const upp)
00073         :_low(low), _upp(upp){}
00074 
00075     bool operator()(shells::SVertex * const vtx) const 
00076         {
00077             EXTR extract;
00078             _DataType *pos = extract(vtx);
00079             
00080             for (std::size_t i=0; i<EXTR::numVar ; ++i) {
00081                 if (pos[i] < _low[i] || _upp[i] < pos[i]) return false;
00082             }       
00083             return true;
00084         }
00085 
00086 private:
00087     const _DataType * const     _low;
00088     const _DataType * const     _upp;
00089 };
00090 
00091 
00092 
00093 template <typename EXTR>
00094 class CheckSVtxFieldNotInBox  :
00095     public std::unary_function<shells::SVertexS*, bool> {
00096 // check if a vertex field (e.g. coordinates) is outside the domain 
00097 // (_low x _upp), i.e., not(CheckSVtxFieldInBox)
00098 
00099 public:
00100     typedef typename EXTR::DataType    _DataType;
00101 
00102     CheckSVtxFieldNotInBox(const _DataType * const low, 
00103                            const _DataType * const upp) 
00104         : _checker(CheckSVtxFieldInBox<EXTR>(low, upp)){}
00105     
00106     bool operator()(shells::SVertex * const vtx) const {
00107         return !(_checker(vtx));
00108     }
00109     
00110 private:
00111     const CheckSVtxFieldInBox<EXTR>     _checker;
00112 };
00113 
00114 
00115 
00116 template <typename T1, typename T2>
00117 class CheckPrescribeSVtxField :
00118     public std::unary_function<shells::SVertexS *, void>  {
00119 // this functor will be used in combination with the previous three functors
00120 
00121 public:
00122     CheckPrescribeSVtxField(const T1& setVar, const T2& check):
00123         _setVar(setVar), _check(check){}
00124     
00125     void operator()(shells::SVertexS *vtx) const
00126         {
00127             if (_check(vtx)) {
00128                 _setVar(vtx);
00129             }
00130         }
00131     
00132 private:
00133     const T1&     _setVar;
00134     const T2&     _check;
00135 };
00136 
00137 }  // namespace shells
00138 
00139 #endif

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