vtf-logo

shells/driverCC/PressureFunctor.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 PRESSUREFUNCTOR_H
00014 #define PRESSUREFUNCTOR_H
00015 #include "../fem/definitions.h"
00016 
00017 #include "SElementFunctors.h"
00018           
00019 #include <functional>
00020 
00021 
00022 namespace shells {
00023     template <typename OP>
00024     class ComputePressureFunctor; 
00025     class ComputeConstantPressureFunctor;
00026 } 
00027 
00028 
00029 
00030 class shells::ComputeConstantPressureFunctor : 
00031     public std::binary_function<shells::SElementS *, void, void > {
00032 public:
00033     ComputeConstantPressureFunctor(const unsigned int& numSurf, 
00034                                    const double& pressure):
00035         _numSurf(numSurf),_pressure(pressure){}
00036 
00037     void operator()(shells::SElementS  * const element);
00038     
00039 private:
00040     double                  _xref[3][MAXVAL];
00041     double                  _xcur[3][MAXVAL];
00042     double                  _loadElem[3][MAXVAL];           
00043 
00044     const unsigned int&     _numSurf;
00045     const double&           _pressure;
00046 };
00047 
00048 
00049 namespace shells {
00050 
00051 // general version build on top of the ComputeConstantPressureFunctor 
00052 template<typename OP> 
00053 class ComputePressureFunctor : 
00054     public std::binary_function<shells::SElementS *, double, void > {
00055 public:
00056     ComputePressureFunctor(const unsigned int& numSurf, const OP& pressureAt):
00057         _numSurf(numSurf), _pressureAt(pressureAt){}
00058 
00059     void operator()(shells::SElementS  * const element, const double& time) const {
00060         // compute element center
00061         SVertexCoordinate::DataType xyz[SVertexCoordinate::numVar];
00062         SElementTriangleAverage<SVertexCoordinate::DataType *, SVertexCoordinate> getCoordinate; 
00063         getCoordinate(element, xyz);
00064                         
00065         // compute element center displacements
00066         SVertexDisplacement::DataType disp[SVertexDisplacement::numVar];
00067         SElementTriangleAverage<SVertexDisplacement::DataType *, SVertexDisplacement> getDisplacement; 
00068         getDisplacement(element, disp);
00069 
00070         assert(SVertexCoordinate::numVar==SVertexDisplacement::numVar);
00071         
00072         // compute deformed position
00073         for(unsigned i=0; i<SVertexCoordinate::numVar; ++i) {
00074             xyz[i] += disp[i];
00075         }
00076 
00077         // prescribed pressure at the element center
00078         double pressure = _pressureAt(time, xyz[0], xyz[1], xyz[2]);
00079 
00080         // call the specialized version
00081         ComputeConstantPressureFunctor constantPressure(_numSurf, pressure);
00082         constantPressure(element);
00083     }
00084     
00085 private:
00086     const unsigned int&     _numSurf;
00087     const OP&               _pressureAt;
00088 };
00089 
00090 } // namespace shells
00091 
00092 #endif

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