Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

formula/matrixElementFormula.hh
Go to the documentation of this file.
00001 
00004 #ifndef matrixelementformula_hh
00005 #define matrixelementformula_hh
00006 
00007 #include <vector>
00008 #include "toolbox/sharedPointer.hh"
00009 #include "elementFormula.hh"
00010 
00011 namespace concepts {
00012 
00013 
00014   // ************************************************** MatrixElementFormula **
00015 
00020   template<typename F, int dim, typename G = typename Realtype<F>::type>
00021   class MatrixElementFormula : public ElementFormula< Mapping<F, dim>, G >
00022   {
00023   public:
00024     typedef Mapping<F, dim> value_type;
00025 
00026     MatrixElementFormula<F,dim,G>() : formulas_() 
00027     {
00028       for(int i=0; i < dim*dim; ++i)
00029         formulas_.push_back(ElementFormulaContainer<F>());
00030     }
00031 
00032 
00039     MatrixElementFormula<F,dim,G>(const std::vector< ElementFormulaContainer<F> >& formulas) 
00040      : formulas_(formulas)
00041     { 
00042       conceptsAssert(formulas_.size() == dim * dim, concepts::Assertion());
00043     }
00044 
00050     Mapping<F, dim> operator() (const ElementWithCell<G>& elm, const Real p,
00051                                 const Real t = 0.0) const
00052     {
00053       Mapping<F, dim> ret;
00054       for (int i=0; i < dim; ++i) {
00055         for (int j=0; j < dim; ++j) 
00056           ret(i,j) = 
00057             !formulas_[i*dim + j].empty() ? formulas_[i*dim + j](elm, p, t) : F(0);
00058       }
00059       return ret;
00060     }
00061 
00062     Mapping<F, dim> operator() (const ElementWithCell<G>& elm, const Real2d& p,
00063                                 const Real t = 0.0) const
00064     {
00065       Mapping<F, dim> ret;
00066       for (int i=0; i < dim; ++i) {
00067         for (int j=0; j < dim; ++j)
00068           ret(i,j) = 
00069             !formulas_[i*dim + j].empty() ? formulas_[i*dim + j](elm, p, t) : F(0);
00070       }
00071       return ret;
00072     }
00073 
00074     Mapping<F, dim> operator() (const ElementWithCell<G>& elm, const Real3d& p,
00075                                 const Real t = 0.0) const
00076     {
00077       Mapping<F, dim> ret;
00078       for (int i=0; i < dim; ++i) {
00079         for (int j=0; j < dim; ++j)
00080           ret(i,j) = 
00081             !formulas_[i*dim + j].empty() ? formulas_[i*dim + j](elm, p, t) : F(0);
00082       }
00083       return ret;
00084     }
00085 
00087     virtual MatrixElementFormula<F,dim,G>* clone() const
00088     {
00089       return new MatrixElementFormula<F, dim, G>(*this);
00090     }
00091 
00092 #if 0
00093     MatrixElementFormula<F,dim,G>( const MatrixElementFormula<F,dim,G>& other) 
00094       : formulas_(other.formulas_)
00095     { }
00096 #endif
00097 
00098     virtual ~MatrixElementFormula() { }
00099 
00100     const std::vector< ElementFormulaContainer<F> >& getFormulas() 
00101     {
00102       return formulas_;
00103     }
00104 
00105     ElementFormulaContainer<F>& operator()(int i, int j)
00106     {
00107       conceptsAssert(i < dim*dim, concepts::Assertion());
00108 
00109       return formulas_[i*dim +j];
00110     }
00111   protected:
00112     std::vector< ElementFormulaContainer<F> > formulas_;
00113   };
00114 
00115 
00116 } // namespace concepts
00117 
00118 
00119 #endif // matrixelementformula_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)