fei_Filter.hpp

00001 #ifndef _Filter_hpp_
00002 #define _Filter_hpp_
00003 
00004 /*--------------------------------------------------------------------*/
00005 /*    Copyright 2005 Sandia Corporation.                              */
00006 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00007 /*    non-exclusive license for use of this work by or on behalf      */
00008 /*    of the U.S. Government.  Export of this program may require     */
00009 /*    a license from the United States Government.                    */
00010 /*--------------------------------------------------------------------*/
00011 
00012 #include <fei_fwd.hpp>
00013 #include <fei_defs.h>
00014 #include <fei_macros.hpp>
00015 #include <fei_iostream.hpp>
00016 
00027 class Filter {
00028 
00029  public:
00031   Filter(SNL_FEI_Structure* probStruct);
00032 
00034   virtual ~Filter();
00035 
00036   virtual int initialize() = 0;
00037 
00038    // set a value (usually zeros) throughout the linear system
00039    virtual int resetSystem(double s) = 0;
00040    virtual int resetMatrix(double s) = 0;
00041    virtual int resetRHSVector(double s) = 0;
00042    virtual int resetInitialGuess(double s) = 0;
00043 
00044    virtual int deleteMultCRs() = 0;
00045 
00046    virtual int loadNodeBCs(int /*numNodes*/,
00047                    const GlobalID* /*nodeIDs*/,
00048                    int /*fieldID*/,
00049                    const int* /*offsetsIntoField*/,
00050                    const double* /*prescribedValues*/)
00051    {
00052       FEI_CERR << "fei ERROR, Filter::loadNodeBCs not overridden."<<FEI_ENDL;
00053       return -1;
00054    }
00055 
00056    virtual int loadElemBCs(int numElems,
00057                    const GlobalID *elemIDs,
00058                    int fieldID,
00059                    const double *const *alpha,  
00060                    const double *const *beta,  
00061                    const double *const *gamma) = 0;
00062 
00063    virtual int sumInElem(GlobalID /*elemBlockID*/,
00064                          GlobalID /*elemID*/,
00065                          const GlobalID* /*elemConn*/,
00066                          const double* const* /*elemStiffness*/,
00067                          const double* /*elemLoad*/,
00068                            int /*elemFormat*/) { return(0); }
00069 
00070    virtual int sumInElemMatrix(GlobalID /*elemBlockID*/,
00071                                GlobalID /*elemID*/,
00072                                const GlobalID* /*elemConn*/,
00073                                const double* const* /*elemStiffness*/,
00074                                int /*elemFormat*/) { return(0); }
00075 
00076    virtual int sumInElemRHS(GlobalID /*elemBlockID*/,
00077                             GlobalID /*elemID*/,
00078                             const GlobalID* /*elemConn*/,
00079                             const double* /*elemLoad*/) { return(0); }
00080 
00081     virtual int loadCRMult(int CRMultID, 
00082                    int numCRNodes,
00083                    const GlobalID* CRNodes, 
00084                    const int* CRFields,
00085                    const double* CRWeights,
00086                    double CRValue) = 0;
00087 
00088     virtual int loadCRPen(int CRPenID, 
00089                   int numCRNodes, 
00090                   const GlobalID* CRNodes,
00091                   const int *CRFields,
00092                   const double* CRWeights,
00093                   double CRValue,
00094                   double penValue) = 0;
00095 
00096    virtual int putIntoRHS(int IDType,
00097                   int fieldID,
00098                           int numIDs,
00099                   const GlobalID* IDs,
00100                   const double* rhsEntries) = 0;
00101 
00102    virtual int sumIntoRHS(int IDType,
00103                   int fieldID,
00104                           int numIDs,
00105                   const GlobalID* IDs,
00106                   const double* rhsEntries) = 0;
00107 
00108    virtual int sumIntoMatrixDiagonal(int /* IDType*/,
00109                                      int /* fieldID*/,
00110                                      int /* numIDs*/,
00111                                      const GlobalID* /* IDs*/,
00112                                      const double* /* coefficients*/)
00113    { return -1; }
00114 
00115    virtual int loadComplete() = 0;
00116 
00117     // set parameters associated with solver choice, etc.
00118     virtual int parameters(int numParams, const char *const* paramStrings);
00119 
00120     //get residual norms
00121     virtual int residualNorm(int whichNorm, int numFields,
00122                      int* fieldIDs, double* norms, double& residTime) = 0;
00123 
00124     // start iterative solution
00125     virtual int solve(int& status, double& sTime) = 0;
00126 
00127     // query function iterations performed.
00128     virtual int iterations() const = 0;
00129 
00130 // Solution return services.......................................
00131  
00132     // return all nodal solution params on a block-by-block basis 
00133     virtual int getBlockNodeSolution(GlobalID elemBlockID,  
00134                              int numNodes, 
00135                              const GlobalID *nodeIDs, 
00136                              int *offsets,
00137                              double *results) = 0;
00138  
00139     virtual int getNodalSolution(int numNodes, 
00140                                  const GlobalID *nodeIDs, 
00141                                  int *offsets,
00142                                  double *results) = 0;
00143 
00144     // return nodal solution for one field on a block-by-block basis 
00145     virtual int getBlockFieldNodeSolution(GlobalID elemBlockID,
00146                                   int fieldID,
00147                                   int numNodes, 
00148                                   const GlobalID *nodeIDs, 
00149                                   double *results) = 0;
00150          
00151     // return element solution params on a block-by-block basis 
00152     virtual int getBlockElemSolution(GlobalID elemBlockID,  
00153                              int numElems, 
00154                              const GlobalID *elemIDs,
00155                              int& numElemDOFPerElement,
00156                              double *results) = 0;
00157 
00158    virtual int getCRMultipliers(int numCRs, const int* CRIDs,
00159                                 double* multipliers) = 0;
00160 
00161 // associated "puts" paralleling the solution return services.
00162 // 
00163 // the int sizing parameters are passed for error-checking purposes, so
00164 // that the interface implementation can tell if the passed estimate
00165 // vectors make sense -before- an attempt is made to utilize them as
00166 // initial guesses by unpacking them into the solver's native solution
00167 // vector format (these parameters include lenNodeIDList, lenElemIDList,
00168 // numElemDOF, and numMultCRs -- all other passed params are either 
00169 // vectors or block/constraint-set IDs)
00170 
00171    // put nodal-based solution guess on a block-by-block basis 
00172    virtual int putBlockNodeSolution(GlobalID elemBlockID,
00173                             int numNodes,
00174                             const GlobalID *nodeIDs, 
00175                             const int *offsets,
00176                             const double *estimates) = 0;
00177 
00178     // put nodal-based guess for one field on a block-by-block basis 
00179     virtual int putBlockFieldNodeSolution(GlobalID elemBlockID, 
00180                                   int fieldID, 
00181                                   int numNodes, 
00182                                   const GlobalID *nodeIDs, 
00183                                   const double *estimates) = 0;
00184   
00185     virtual int putBlockElemSolution(GlobalID elemBlockID,  
00186                                      int numElems, 
00187                                      const GlobalID *elemIDs, 
00188                                      int dofPerElem,
00189                                      const double *estimates) = 0;
00190   
00191     virtual int putCRMultipliers(int numMultCRs, 
00192                          const int* CRIDs,
00193                          const double *multEstimates) = 0;
00194 
00195 //===== a couple of public non-FEI functions... ================================
00196 //These are intended to be used by an 'outer-layer' class like 
00197 //FEI_Implementation.
00198 //
00199   public:
00200 
00201     virtual int getNodalFieldSolution(int fieldID,
00202                               int numNodes,
00203                               const GlobalID* nodeIDs,
00204                               double* results) = 0;
00205 
00206     virtual int putNodalFieldData(int fieldID,
00207                           int numNodes,
00208                           const GlobalID* nodeIDs,
00209                           const double* nodeData) = 0;
00210 
00211     virtual int putNodalFieldSolution(int fieldID,
00212                               int numNodes,
00213                               const GlobalID* nodeIDs,
00214                               const double* nodeData) = 0;
00215 
00216     virtual int unpackSolution() = 0;
00217 
00218     virtual void setEqnCommMgr(EqnCommMgr* eqnCommMgr) = 0;
00219 
00220    virtual EqnCommMgr* getEqnCommMgr() = 0;
00221 
00222    virtual int setNumRHSVectors(int numRHSs, int* rhsIDs) = 0;
00223    virtual int setCurrentRHS(int rhsID) = 0;
00224 
00225    virtual int exchangeRemoteEquations() { return 0; }
00226 
00227    virtual int enforceEssentialBCs(const int* eqns, const double* alpha,
00228                                   const double* gamma, int numEqns) = 0;
00229 
00230    static void copyStiffness(const double* const* elemStiff, int numRows,
00231                              int elemFormat, double** copy);
00232 
00233    void setLogStream(std::ostream* logstrm);
00234    std::ostream* logStream();
00235 
00236  protected:
00237    virtual int generalElemInput(GlobalID /*elemBlockID*/,
00238                                 GlobalID /*elemID*/,
00239                                 const GlobalID* /*elemConn*/,
00240                                 const double* const* /*elemStiffness*/,
00241                                 const double* /*elemLoad*/,
00242                                   int /*elemFormat*/) {return(-1);}
00243 
00244    int generalCoefInput(int /*patternID*/,
00245                         const int* /*rowIDTypes*/,
00246                         const GlobalID* /*rowIDs*/,
00247                         const int* /*colIDTypes*/,
00248                         const GlobalID* /*colIDs*/,
00249                         const double* const* /*matrixEntries*/,
00250                         const double* /*vectorEntries*/,
00251                           int /*numRows*/, int /*numCols*/) {return(-1);}
00252 
00253    int calculateResidualNorms(int whichNorm, int numFields,
00254                               int* fieldIDs, double* norms,
00255                               std::vector<double>& residValues);
00256 
00257    const NodeDescriptor& findNodeDescriptor(GlobalID nodeID) const;
00258 
00259    SNL_FEI_Structure* problemStructure_;
00260 
00261    bool logInput_;
00262    std::ostream* logInputStream_;
00263 
00264    int outputLevel_;
00265 
00266    int numProcs_;
00267    int localRank_;
00268 
00269  private:
00270    Filter(const Filter& /*src*/)
00271      : problemStructure_(NULL), logInput_(false), logInputStream_(NULL),
00272      outputLevel_(0), numProcs_(0), localRank_(0)
00273      {}
00274 
00275    Filter& operator=(const Filter& /*src*/)
00276      {
00277        return(*this);
00278      }
00279 };
00280 
00281 #endif
00282 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:23 2011 for FEI by  doxygen 1.6.3