FEApp_InitPostOps.hpp

Go to the documentation of this file.
00001 // $Id: FEApp_InitPostOps.hpp,v 1.7 2008/08/01 22:57:12 etphipp Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/example/FEApp/FEApp_InitPostOps.hpp,v $ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #ifndef FEAPP_INITPOSTOPS_HPP
00033 #define FEAPP_INITPOSTOPS_HPP
00034 
00035 #include "Teuchos_RCP.hpp"
00036 #include "Teuchos_SerialDenseMatrix.hpp"
00037 #include "Epetra_Vector.h"
00038 #include "Epetra_CrsMatrix.h"
00039 
00040 #include "FEApp_AbstractInitPostOp.hpp"
00041 #include "FEApp_TemplateTypes.hpp"
00042 #include "Sacado_ScalarParameterVector.hpp"
00043 
00044 #if SG_ACTIVE
00045 #include "EpetraExt_BlockVector.h"
00046 #include "Stokhos_OrthogPolyBasis.hpp"
00047 #endif
00048 
00049 #if SGFAD_ACTIVE
00050 #include "EpetraExt_BlockCrsMatrix.h"
00051 #endif
00052 
00053 namespace FEApp {
00054 
00056   class ResidualOp : public FEApp::AbstractInitPostOp<double> {
00057   public:
00058     
00060 
00063     ResidualOp(
00064       const Teuchos::RCP<const Epetra_Vector>& overlapped_xdot,
00065       const Teuchos::RCP<const Epetra_Vector>& overlapped_x,
00066       const Teuchos::RCP<Epetra_Vector>& overlapped_f);
00067 
00069     virtual ~ResidualOp();
00070     
00072     virtual void elementInit(const FEApp::AbstractElement& e,
00073            unsigned int neqn,
00074            std::vector<double>* elem_xdot,
00075            std::vector<double>& elem_x);
00076 
00078     virtual void elementPost(const FEApp::AbstractElement& e,
00079            unsigned int neqn,
00080            std::vector<double>& elem_f);
00081 
00083     virtual void nodeInit(const FEApp::NodeBC& bc,
00084         unsigned int neqn,
00085         std::vector<double>* node_xdot,
00086         std::vector<double>& node_x);
00087 
00089     virtual void nodePost(const FEApp::NodeBC& bc,
00090         unsigned int neqn,
00091         std::vector<double>& node_f);
00092 
00094     virtual void finalizeFill() {}
00095 
00096   private:
00097     
00099     ResidualOp(const ResidualOp&);
00100 
00102     ResidualOp& operator=(const ResidualOp&);
00103 
00104   protected:
00105 
00107     Teuchos::RCP<const Epetra_Vector> xdot;
00108 
00110     Teuchos::RCP<const Epetra_Vector> x;
00111 
00113     Teuchos::RCP<Epetra_Vector> f;
00114 
00115   };
00116 
00118   class JacobianOp : 
00119     public FEApp::AbstractInitPostOp< FadType > {
00120   public:
00121 
00123 
00126     JacobianOp(
00127       double alpha, double beta,
00128       const Teuchos::RCP<const Epetra_Vector>& overlapped_xdot,
00129       const Teuchos::RCP<const Epetra_Vector>& overlapped_x,
00130       const Teuchos::RCP<Epetra_Vector>& overlapped_f,
00131       const Teuchos::RCP<Epetra_CrsMatrix>& overlapped_jac);
00132 
00134     virtual ~JacobianOp();
00135 
00137     virtual void elementInit(
00138        const FEApp::AbstractElement& e,
00139        unsigned int neqn,
00140        std::vector< FadType >* elem_xdot,
00141        std::vector< FadType >& elem_x);
00142 
00144     virtual void elementPost(const FEApp::AbstractElement& e,
00145            unsigned int neqn,
00146            std::vector< FadType >& elem_f);
00147 
00149     virtual void nodeInit(const FEApp::NodeBC& bc,
00150         unsigned int neqn,
00151         std::vector< FadType >* node_xdot,
00152         std::vector< FadType >& node_x);
00153 
00155     virtual void nodePost(const FEApp::NodeBC& bc,
00156         unsigned int neqn,
00157         std::vector< FadType >& node_f);
00158 
00160     virtual void finalizeFill() {}
00161 
00162   private:
00163     
00165     JacobianOp(const JacobianOp&);
00166     
00168     JacobianOp& operator=(const JacobianOp&);
00169 
00170   protected:
00171 
00173     double m_coeff;
00174 
00176     double j_coeff;
00177 
00179     Teuchos::RCP<const Epetra_Vector> xdot;
00180 
00182     Teuchos::RCP<const Epetra_Vector> x;
00183 
00185     Teuchos::RCP<Epetra_Vector> f;
00186 
00188     Teuchos::RCP<Epetra_CrsMatrix> jac;
00189 
00190   };
00191 
00196   class TangentOp : 
00197     public FEApp::AbstractInitPostOp< FadType > {
00198   public:
00199 
00201 
00204     TangentOp(
00205   double alpha, double beta, bool sum_derivs,
00206   const Teuchos::RCP<const Epetra_Vector>& overlapped_xdot,
00207   const Teuchos::RCP<const Epetra_Vector>& overlapped_x,
00208   const Teuchos::RCP<Sacado::ScalarParameterVector>& p,
00209   const Teuchos::RCP<const Epetra_MultiVector>& overlapped_Vx,
00210   const Teuchos::RCP<const Epetra_MultiVector>& overlapped_Vxdot,
00211   const Teuchos::RCP<const Teuchos::SerialDenseMatrix<int,double> >& Vp,
00212   const Teuchos::RCP<Epetra_Vector>& overlapped_f,
00213   const Teuchos::RCP<Epetra_MultiVector>& overlapped_JV,
00214   const Teuchos::RCP<Epetra_MultiVector>& overlapped_fp);
00215 
00217     virtual ~TangentOp();
00218 
00220     virtual void elementInit(
00221        const FEApp::AbstractElement& e,
00222        unsigned int neqn,
00223        std::vector< FadType >* elem_xdot,
00224        std::vector< FadType >& elem_x);
00225 
00227     virtual void elementPost(const FEApp::AbstractElement& e,
00228            unsigned int neqn,
00229            std::vector< FadType >& elem_f);
00230 
00232     virtual void nodeInit(const FEApp::NodeBC& bc,
00233         unsigned int neqn,
00234         std::vector< FadType >* node_xdot,
00235         std::vector< FadType >& node_x);
00236 
00238     virtual void nodePost(const FEApp::NodeBC& bc,
00239         unsigned int neqn,
00240         std::vector< FadType >& node_f);
00241 
00243     virtual void finalizeFill() {}
00244 
00245   private:
00246     
00248     TangentOp(const TangentOp&);
00249     
00251     TangentOp& operator=(const TangentOp&);
00252 
00253   protected:
00254 
00256     double m_coeff;
00257 
00259     double j_coeff;
00260 
00262     bool sum_derivs;
00263 
00265     Teuchos::RCP<const Epetra_Vector> xdot;
00266 
00268     Teuchos::RCP<const Epetra_Vector> x;
00269 
00271     Teuchos::RCP<Sacado::ScalarParameterVector> params;
00272 
00274     Teuchos::RCP<const Epetra_MultiVector> Vx;
00275 
00277     Teuchos::RCP<const Epetra_MultiVector> Vxdot;
00278 
00280     Teuchos::RCP<const Teuchos::SerialDenseMatrix<int,double> > Vp;
00281 
00283     Teuchos::RCP<Epetra_Vector> f;
00284 
00286     Teuchos::RCP<Epetra_MultiVector> JV;
00287     
00289     Teuchos::RCP<Epetra_MultiVector> fp;
00290 
00292     int num_cols_x;
00293 
00295     int num_cols_p;
00296 
00298     int num_cols_tot;
00299 
00301     int param_offset;
00302 
00303   };
00304 
00305 #if SG_ACTIVE
00306 
00308   class SGResidualOp : public FEApp::AbstractInitPostOp<SGType> {
00309   public:
00310     
00312 
00315     SGResidualOp(
00316    const Teuchos::RCP<const Epetra_Map>& base_map,
00317    const Teuchos::RCP<const Stokhos::OrthogPolyBasis<double> >& sg_basis,
00318    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_xdot,
00319    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_x,
00320    const Teuchos::RCP<EpetraExt::BlockVector>& sg_overlapped_f);
00321 
00323     virtual ~SGResidualOp();
00324 
00326     virtual void reset(
00327    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_xdot,
00328    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_x);
00329     
00331     virtual void elementInit(const FEApp::AbstractElement& e,
00332            unsigned int neqn,
00333            std::vector<SGType>* elem_xdot,
00334            std::vector<SGType>& elem_x);
00335 
00337     virtual void elementPost(const FEApp::AbstractElement& e,
00338            unsigned int neqn,
00339            std::vector<SGType>& elem_f);
00340 
00342     virtual void nodeInit(const FEApp::NodeBC& bc,
00343         unsigned int neqn,
00344         std::vector<SGType>* node_xdot,
00345         std::vector<SGType>& node_x);
00346 
00348     virtual void nodePost(const FEApp::NodeBC& bc,
00349         unsigned int neqn,
00350         std::vector<SGType>& node_f);
00351 
00353     virtual void finalizeFill();
00354 
00355   private:
00356     
00358     SGResidualOp(const SGResidualOp&);
00359 
00361     SGResidualOp& operator=(const SGResidualOp&);
00362 
00363   protected:
00364 
00366     unsigned int nblock;
00367 
00369     Teuchos::RCP<const Epetra_Map> map;
00370 
00372     Teuchos::RCP<const Stokhos::OrthogPolyBasis<double> > sg_basis;
00373 
00375     Teuchos::RCP<const EpetraExt::BlockVector> sg_xdot;
00376 
00378     Teuchos::RCP<const EpetraExt::BlockVector> sg_x;
00379 
00381     Teuchos::RCP<EpetraExt::BlockVector> sg_f;
00382 
00384     std::vector< Teuchos::RCP<Epetra_Vector> > xdot;
00385 
00387     std::vector< Teuchos::RCP<Epetra_Vector> > x;
00388 
00389   };
00390 
00391 #endif // SG_ACTIVE
00392 
00393 #if SGFAD_ACTIVE
00394 
00396   class SGJacobianOp : 
00397     public FEApp::AbstractInitPostOp< SGFadType > {
00398   public:
00399 
00400     typedef SGType::expansion_type::tp_type tp_type;
00401 
00403 
00406     SGJacobianOp(
00407          const Teuchos::RCP<const Epetra_Map>& base_map,
00408    const Teuchos::RCP<const Epetra_CrsGraph>& base_graph,
00409    const Teuchos::RCP<const Stokhos::OrthogPolyBasis<double> >& sg_basis,
00410    const Teuchos::RCP<const tp_type >& Cijk,
00411    double alpha, double beta,
00412    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_xdot,
00413    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_x,
00414    const Teuchos::RCP<EpetraExt::BlockVector>& sg_overlapped_f,
00415    const Teuchos::RCP<EpetraExt::BlockCrsMatrix>& sg_overlapped_jac);
00416 
00418     virtual ~SGJacobianOp();
00419 
00421     virtual void reset(
00422    double alpha, double beta,
00423    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_xdot,
00424    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_x);
00425 
00427     virtual void elementInit(
00428        const FEApp::AbstractElement& e,
00429        unsigned int neqn,
00430        std::vector< SGFadType >* elem_xdot,
00431        std::vector< SGFadType >& elem_x);
00432 
00434     virtual void elementPost(const FEApp::AbstractElement& e,
00435            unsigned int neqn,
00436            std::vector< SGFadType >& elem_f);
00437 
00439     virtual void nodeInit(const FEApp::NodeBC& bc,
00440         unsigned int neqn,
00441         std::vector< SGFadType >* node_xdot,
00442         std::vector< SGFadType >& node_x);
00443 
00445     virtual void nodePost(const FEApp::NodeBC& bc,
00446         unsigned int neqn,
00447         std::vector< SGFadType >& node_f);
00448 
00450     virtual void finalizeFill();
00451 
00452   private:
00453     
00455     SGJacobianOp(const SGJacobianOp&);
00456     
00458     SGJacobianOp& operator=(const SGJacobianOp&);
00459 
00460   protected:
00461 
00463     unsigned int nblock;
00464 
00466     Teuchos::RCP<const Epetra_Map> map;
00467 
00469     Teuchos::RCP<const Epetra_CrsGraph> graph;
00470 
00472     Teuchos::RCP<const Stokhos::OrthogPolyBasis<double> > sg_basis;
00473 
00475     Teuchos::RCP<const tp_type> Cijk;
00476 
00478     double m_coeff;
00479 
00481     double j_coeff;
00482 
00484     Teuchos::RCP<const EpetraExt::BlockVector> sg_xdot;
00485 
00487     Teuchos::RCP<const EpetraExt::BlockVector> sg_x;
00488 
00490     Teuchos::RCP<EpetraExt::BlockVector> sg_f;
00491 
00493     Teuchos::RCP<EpetraExt::BlockCrsMatrix> sg_jac;
00494 
00496     std::vector< Teuchos::RCP<Epetra_Vector> > xdot;
00497 
00499     std::vector< Teuchos::RCP<Epetra_Vector> > x;
00500 
00501   };
00502 
00504   class SGMatrixFreeJacobianOp : 
00505     public FEApp::AbstractInitPostOp< SGFadType > {
00506   public:
00507 
00508     typedef SGType::expansion_type::tp_type tp_type;
00509 
00511 
00514     SGMatrixFreeJacobianOp(
00515          const Teuchos::RCP<const Epetra_Map>& base_map,
00516    const Teuchos::RCP<const Epetra_CrsGraph>& base_graph,
00517    const Teuchos::RCP<const Stokhos::OrthogPolyBasis<double> >& sg_basis,
00518    double alpha, double beta,
00519    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_xdot,
00520    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_x,
00521    const Teuchos::RCP<EpetraExt::BlockVector>& sg_overlapped_f);
00522 
00524     virtual ~SGMatrixFreeJacobianOp();
00525 
00527     virtual void reset(
00528    double alpha, double beta,
00529    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_xdot,
00530    const Teuchos::RCP<const EpetraExt::BlockVector>& sg_overlapped_x);
00531 
00533     virtual std::vector< Teuchos::RCP<Epetra_CrsMatrix> >&
00534     getJacobianBlocks();
00535 
00537     virtual void elementInit(
00538        const FEApp::AbstractElement& e,
00539        unsigned int neqn,
00540        std::vector< SGFadType >* elem_xdot,
00541        std::vector< SGFadType >& elem_x);
00542 
00544     virtual void elementPost(const FEApp::AbstractElement& e,
00545            unsigned int neqn,
00546            std::vector< SGFadType >& elem_f);
00547 
00549     virtual void nodeInit(const FEApp::NodeBC& bc,
00550         unsigned int neqn,
00551         std::vector< SGFadType >* node_xdot,
00552         std::vector< SGFadType >& node_x);
00553 
00555     virtual void nodePost(const FEApp::NodeBC& bc,
00556         unsigned int neqn,
00557         std::vector< SGFadType >& node_f);
00558 
00560     virtual void finalizeFill();
00561 
00562   private:
00563     
00565     SGMatrixFreeJacobianOp(const SGMatrixFreeJacobianOp&);
00566     
00568     SGMatrixFreeJacobianOp& operator=(const SGMatrixFreeJacobianOp&);
00569 
00570   protected:
00571 
00573     unsigned int nblock;
00574 
00576     Teuchos::RCP<const Epetra_Map> map;
00577 
00579     Teuchos::RCP<const Epetra_CrsGraph> graph;
00580 
00582     Teuchos::RCP<const Stokhos::OrthogPolyBasis<double> > sg_basis;
00583 
00585     double m_coeff;
00586 
00588     double j_coeff;
00589 
00591     Teuchos::RCP<const EpetraExt::BlockVector> sg_xdot;
00592 
00594     Teuchos::RCP<const EpetraExt::BlockVector> sg_x;
00595 
00597     Teuchos::RCP<EpetraExt::BlockVector> sg_f;
00598 
00600     Teuchos::RCP<EpetraExt::BlockCrsMatrix> sg_jac;
00601 
00603     std::vector< Teuchos::RCP<Epetra_Vector> > xdot;
00604 
00606     std::vector< Teuchos::RCP<Epetra_Vector> > x;
00607 
00609     std::vector< Teuchos::RCP<Epetra_CrsMatrix> > jac;
00610 
00611   };
00612 
00613 #endif // SGFAD_ACTIVE
00614 
00615 }
00616 
00617 #endif // FEAPP_INITPOSTOPS_HPP

Generated on Wed May 12 21:59:03 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7