fei_FEDataFilter.hpp

00001 #ifndef _fei_FEDataFilter_hpp_
00002 #define _fei_FEDataFilter_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_Filter.hpp"
00015 
00026 class FEDataFilter : public Filter {
00027 
00028  public:
00029    // Constructor.
00030    FEDataFilter(FEI_Implementation* owner, MPI_Comm comm,
00031                 SNL_FEI_Structure* probStruct,
00032                 LibraryWrapper* wrapper,
00033                 int masterRank=0);
00034 
00035    //Destructor
00036    virtual ~FEDataFilter();
00037 
00038 
00039    // set a value (usually zeros) throughout the linear system
00040    int resetSystem(double s);
00041    int resetMatrix(double s);
00042    int resetRHSVector(double s);
00043    int resetInitialGuess(double s);
00044 
00045    int deleteMultCRs();
00046 
00047    int loadNodeBCs(int numNodes,
00048                    const GlobalID *nodeIDs,
00049                    int fieldID,
00050                    const int* offsetsIntoField,
00051                    const double* prescribedValues);
00052 
00053    int loadElemBCs(int numElems,
00054                    const GlobalID *elemIDs,
00055                    int fieldID,
00056                    const double *const *alpha,  
00057                    const double *const *beta,  
00058                    const double *const *gamma);
00059 
00060    int sumInElem(GlobalID elemBlockID,
00061                  GlobalID elemID,
00062                  const GlobalID* elemConn,
00063                  const double* const* elemStiffness,
00064                  const double* elemLoad,
00065                  int elemFormat);
00066 
00067    int sumInElemMatrix(GlobalID elemBlockID,
00068                        GlobalID elemID,
00069                        const GlobalID* elemConn,
00070                        const double* const* elemStiffness,
00071                        int elemFormat);
00072 
00073    int sumInElemRHS(GlobalID elemBlockID,
00074                     GlobalID elemID,
00075                     const GlobalID* elemConn,
00076                     const double* elemLoad);
00077 
00078     int loadCRMult(int CRMultID, 
00079                    int numCRNodes,
00080                    const GlobalID* CRNodes, 
00081                    const int* CRFields,
00082                    const double* CRWeights,
00083                    double CRValue);
00084 
00085     int loadCRPen(int CRPenID, 
00086                   int numCRNodes, 
00087                   const GlobalID* CRNodes,
00088                   const int *CRFields,
00089                   const double* CRWeights,
00090                   double CRValue,
00091                   double penValue);
00092 
00093    int putIntoRHS(int IDType,
00094                   int fieldID,
00095                           int numIDs,
00096                   const GlobalID* IDs,
00097                   const double* rhsEntries);
00098 
00099    int sumIntoRHS(int IDType,
00100                   int fieldID,
00101                           int numIDs,
00102                   const GlobalID* IDs,
00103                   const double* rhsEntries);
00104 
00105    int sumIntoMatrixDiagonal(int  IDType,
00106                              int  fieldID,
00107                              int  numIDs,
00108                              const GlobalID*  IDs,
00109                              const double*  coefficients);
00110 
00111    int loadComplete();
00112 
00113     // set parameters associated with solver choice, etc.
00114     int parameters(int numParams, const char *const* paramStrings);
00115 
00116     //get residual norms
00117     int residualNorm(int whichNorm, int numFields,
00118                      int* fieldIDs, double* norms, double& residTime);
00119 
00120     // start iterative solution
00121     int solve(int& status, double& sTime);
00122 
00123     // query function iterations performed.
00124     int iterations() const {return(iterations_);};
00125 
00126 // Solution return services.......................................
00127  
00128     // return all nodal solution params on a block-by-block basis 
00129     int getBlockNodeSolution(GlobalID elemBlockID,  
00130                              int numNodes, 
00131                              const GlobalID *nodeIDs, 
00132                              int *offsets,
00133                              double *results);
00134  
00135     int getNodalSolution(int numNodes, 
00136                          const GlobalID *nodeIDs, 
00137                          int *offsets,
00138                          double *results);
00139 
00140     // return nodal solution for one field on a block-by-block basis 
00141     int getBlockFieldNodeSolution(GlobalID elemBlockID,
00142                                   int fieldID,
00143                                   int numNodes, 
00144                                   const GlobalID *nodeIDs, 
00145                                   double *results);
00146          
00147     // return element solution params on a block-by-block basis 
00148     int getBlockElemSolution(GlobalID elemBlockID,  
00149                              int numElems, 
00150                              const GlobalID *elemIDs,
00151                              int& numElemDOFPerElement,
00152                              double *results);
00153 
00154    int getCRMultipliers(int numCRs, const int* CRIDs, double* multipliers);
00155 
00156 // associated "puts" paralleling the solution return services.
00157 // 
00158 // the int sizing parameters are passed for error-checking purposes, so
00159 // that the interface implementation can tell if the passed estimate
00160 // vectors make sense -before- an attempt is made to utilize them as
00161 // initial guesses by unpacking them into the solver's native solution
00162 // vector format (these parameters include lenNodeIDList, lenElemIDList,
00163 // numElemDOF, and numMultCRs -- all other passed params are either 
00164 // vectors or block/constraint-set IDs)
00165 
00166    // put nodal-based solution guess on a block-by-block basis 
00167    int putBlockNodeSolution(GlobalID elemBlockID,
00168                             int numNodes,
00169                             const GlobalID *nodeIDs, 
00170                             const int *offsets,
00171                             const double *estimates);
00172 
00173     // put nodal-based guess for one field on a block-by-block basis 
00174     int putBlockFieldNodeSolution(GlobalID elemBlockID, 
00175                                   int fieldID, 
00176                                   int numNodes, 
00177                                   const GlobalID *nodeIDs, 
00178                                   const double *estimates);
00179          
00180     // put element-based solution guess on a block-by-block basis  
00181     int putBlockElemSolution(GlobalID elemBlockID,  
00182                              int numElems, 
00183                              const GlobalID *elemIDs, 
00184                              int dofPerElem,
00185                              const double *estimates);
00186   
00187     int putCRMultipliers(int numMultCRs, 
00188                          const int* CRIDs,
00189                          const double *multEstimates);
00190 
00191 //===== a couple of public non-FEI functions... ================================
00192 //These are intended to be used by an 'outer-layer' class like 
00193 //FEI_Implementation.
00194 //
00195   public:
00196     int getNodalFieldSolution(int fieldID,
00197                               int numNodes,
00198                               const GlobalID* nodeIDs,
00199                               double* results);
00200 
00201     int putNodalFieldData(int fieldID,
00202                           int numNodes,
00203                           const GlobalID* nodeIDs,
00204                           const double* nodeData);
00205 
00206     int putNodalFieldSolution(int fieldID,
00207                               int numNodes,
00208                               const GlobalID* nodeIDs,
00209                               const double* nodeData);
00210 
00211     int unpackSolution();
00212 
00213     void setEqnCommMgr(EqnCommMgr* eqnCommMgr);
00214 
00215    EqnCommMgr* getEqnCommMgr() {return(eqnCommMgr_);};
00216 
00217    int setNumRHSVectors(int numRHSs, int* rhsIDs);
00218    int setCurrentRHS(int rhsID);
00219 
00220    int enforceEssentialBCs(const int* eqns, const double* alpha,
00221                                   const double* gamma, int numEqns);
00222 
00223    int initialize();
00224 
00225 //==============================================================================
00226 //private functions for internal implementation of FEDataFilter.
00227 //==============================================================================
00228   private:
00229    FEDataFilter(const FEDataFilter& src);
00230    FEDataFilter& operator=(const FEDataFilter& src);
00231 
00232    int initLinSysCore();
00233 
00234    int loadFEDataMultCR(int CRID,
00235                         int numCRNodes,
00236                         const GlobalID* CRNodes, 
00237                         const int* CRFields,
00238                         const double* CRWeights,
00239                         double CRValue);
00240 
00241    int loadFEDataPenCR(int CRID,
00242                        int numCRNodes,
00243                        const GlobalID* CRNodes, 
00244                        const int* CRFields,
00245                        const double* CRWeights,
00246                        double CRValue,
00247                        double penValue);
00248 
00249    int generalElemInput(GlobalID elemBlockID,
00250                         GlobalID elemID,
00251                         const double* const* elemStiffness,
00252                         const double* elemLoad,
00253                         int elemFormat);
00254 
00255    int generalElemInput(GlobalID elemBlockID,
00256                         GlobalID elemID,
00257                         const GlobalID* elemConn,
00258                         const double* const* elemStiffness,
00259                         const double* elemLoad,
00260                         int elemFormat);
00261 
00262    void allocElemStuff();
00263 
00264    int giveToMatrix(int numPtRows, const int* ptRows,
00265                     int numPtCols, const int* ptCols,
00266                     const double* const* values,
00267                     int mode);
00268 
00269    int giveToLocalReducedMatrix(int numPtRows, const int* ptRows,
00270                                 int numPtCols, const int* ptCols,
00271                                 const double* const* values,
00272                                 int mode);
00273 
00274    int getFromMatrix(int numPtRows, const int* ptRows,
00275                      const int* rowColOffsets, const int* ptCols,
00276                      int numColsPerRow, double** values);
00277 
00278    int getEqnsFromMatrix(ProcEqns& procEqns, EqnBuffer& eqnData);
00279 
00280    int getEqnsFromRHS(ProcEqns& procEqns, EqnBuffer& eqnData);
00281 
00282    int giveToRHS(int num, const double* values,
00283                  const int* indices, int mode);
00284 
00285    int giveToLocalReducedRHS(int num, const double* values,
00286                              const int* indices, int mode);
00287 
00288    int getFromRHS(int num, double* values, const int* indices);
00289 
00290    int getEqnSolnEntry(int eqnNumber, double& solnValue);
00291 
00292    int getSharedRemoteSolnEntry(int eqnNumber, double& solnValue);
00293 
00294    int getReducedSolnEntry(int eqnNumber, double& solnValue);
00295 
00296    int formResidual(double* residValues, int numLocalEqns);
00297 
00298    int getRemoteSharedEqns(int numPtRows, const int* ptRows,
00299                            ProcEqns& remoteProcEqns);
00300 
00301    int resetTheMatrix(double s);
00302    int resetTheRHSVector(double s);
00303 
00304    int assembleEqns(int numPtRows, 
00305                     int numPtCols,
00306                     const int* rowNumbers,
00307                     const int* colIndices,
00308                     const double* const* coefs,
00309                     bool structurallySymmetric,
00310                     int mode);
00311 
00312    int assembleRHS(int numValues, const int* indices, const double* coefs, int mode);
00313 
00314    void debugOutput(const char* mesg);
00315 
00316    int createEqnCommMgr_put();
00317 
00318 //==============================================================================
00319 //private FEDataFilter variables
00320 //==============================================================================
00321   private:
00322 
00323     LibraryWrapper* wrapper_;
00324     fei::SharedPtr<FiniteElementData> feData_;
00325     bool useLookup_;
00326 
00327     int internalFei_;
00328 
00329     bool newData_;
00330 
00331     int localStartRow_, localEndRow_, numGlobalEqns_;
00332     int reducedStartRow_, reducedEndRow_, numReducedRows_;
00333 
00334     int iterations_;
00335     int numRHSs_;
00336     int currentRHS_;
00337     std::vector<int> rhsIDs_;
00338 
00339     int outputLevel_;
00340 
00341     MPI_Comm comm_;
00342     int masterRank_;
00343 
00344     SNL_FEI_Structure* problemStructure_;
00345 
00346     std::vector<GlobalID> penCRIDs_;
00347 
00348     std::vector<int> rowIndices_;
00349     std::vector<int> rowColOffsets_, colIndices_;
00350 
00351     EqnCommMgr* eqnCommMgr_; //equation communication manager
00352     EqnCommMgr* eqnCommMgr_put_; //only created if users call
00353                                  // the 'put' functions
00354 
00355     int maxElemRows_;
00356 
00357     double** eStiff_;
00358     double* eStiff1D_;
00359     double* eLoad_;
00360 
00361     int numRegularElems_;
00362     std::vector<int> constraintBlocks_;
00363     std::vector<int> constraintNodeOffsets_;
00364     std::vector<int> packedFieldSizes_;
00365 };
00366 
00367 #endif
00368 
 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