FEI Version of the Day
FEData.hpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 #ifndef _FEData_h_
00044 #define _FEData_h_
00045 
00046 
00047 #include <fei_iostream.hpp>
00048 #include <fei_fstream.hpp>
00049 
00050 #include <fei_mpi.h>
00051 
00052 #define dbgOut() if (debugOutputLevel_ > 0) *dbgOStreamPtr_
00053 
00054 #include <fei_defs.h>
00055 #include <fei_FiniteElementData.hpp>
00056 
00057 #include <snl_fei_Utils.hpp>
00058 
00063 class FEData : public virtual FiniteElementData {
00064  public:
00066   FEData(MPI_Comm comm)
00067     :
00068     comm_(comm), numProcs_(1), localProc_(0),
00069     debugOutputLevel_(0),
00070     dbgPath_(NULL),
00071     dbgOStreamPtr_(NULL),
00072     dbgFileOpened_(false)
00073     {
00074 #ifndef FEI_SER
00075       if (MPI_Comm_rank(comm_, &localProc_) != MPI_SUCCESS) MPI_Abort(comm_,-1);
00076       if (MPI_Comm_size(comm_, &numProcs_) != MPI_SUCCESS) MPI_Abort(comm_,-1);
00077 #endif
00078       setDebugLog(0, ".");
00079     }
00080 
00081   virtual ~FEData()
00082     {
00083       if (dbgFileOpened_ == true) { dbgFStreamPtr_->close(); }
00084 
00085       delete [] dbgPath_;
00086       delete dbgOStreamPtr_;
00087     }
00088 
00094   int parameters(int numParams, char** params);
00095 
00103   int setLookup(Lookup& lookup)
00104     {
00105       dbgOut() << "setLookup" << FEI_ENDL;
00106       return(0);
00107     }
00108 
00109 
00113   int describeStructure(int numElemBlocks,
00114       const int* numElemsPerBlock,
00115       const int* numNodesPerElem,
00116       const int* elemMatrixSizePerBlock,
00117       int totalNumNodes,
00118       int numSharedNodes,
00119       int numMultCRs)
00120     {
00121       dbgOut() << "describeStructure" << FEI_ENDL
00122   << "   numElemBlocks: " << numElemBlocks << FEI_ENDL;
00123       for(int i=0; i<numElemBlocks; i++) {
00124   dbgOut() << "   elem-block " << i << ": " << FEI_ENDL
00125     << "      number of elements: " << numElemsPerBlock[i] << FEI_ENDL
00126     << "      nodes per element:  " << numNodesPerElem[i] << FEI_ENDL;
00127   dbgOut() << "         elemMatrixSizePerBlock: "
00128       << elemMatrixSizePerBlock[i] << FEI_ENDL;
00129       }
00130       return(0);
00131     }
00132 
00135    int setConnectivity(int elemBlockID,
00136            int elemID,
00137            int numNodes,
00138            const int* nodeNumbers,
00139            const int* numDofPerNode,
00140            const int* dof_ids)
00141      {
00142        dbgOut() << "setConnectivity" << FEI_ENDL
00143    << "   elemBlockID: " << elemBlockID << ", elemID: " << elemID 
00144     << ", numNodes: " << numNodes << FEI_ENDL
00145    << "   nodeNumbers: ";
00146        for(int i=0; i<numNodes; i++) {
00147    dbgOut() << nodeNumbers[i] << " ";
00148        }
00149        dbgOut() << FEI_ENDL;
00150 
00151        dbgOut() << "   numDOFPerNode: ";
00152        for(int j=0; j<numNodes; j++) {
00153    dbgOut() << numDofPerNode[j] << " ";
00154        }
00155        dbgOut() << FEI_ENDL;
00156 
00157        return(0);
00158      }
00159 
00160 
00161    int setElemMatrix(int elemBlockID,
00162          int elemID,
00163          int numNodes,
00164          const int* nodeNumbers,
00165          const int* dofPerNode,
00166          const int* dof_ids,
00167          const double *const * coefs)
00168      {
00169        dbgOut() << "setElemMatrix" << FEI_ENDL
00170    << "   elemBlockID: " << elemBlockID << ", elemID: " << elemID << FEI_ENDL
00171    << "   numNodes: " << numNodes << FEI_ENDL;
00172        int i;
00173        dbgOut() << "   nodeNumbers: ";
00174        for(i=0; i<numNodes; i++) {
00175    dbgOut() << nodeNumbers[i] << " ";
00176        }
00177        dbgOut() << FEI_ENDL << "   dofPerNode: ";
00178        int numRows = 0;
00179        for(i=0; i<numNodes; i++) {
00180    dbgOut() << dofPerNode[i] << " ";
00181    numRows += dofPerNode[i];
00182        }
00183        dbgOut() << FEI_ENDL << "   coefs:" << FEI_ENDL;
00184        for(i=0; i<numRows; i++) {
00185    dbgOut() << "      ";
00186    for(int j=0; j<numRows; j++) {
00187      dbgOut() << coefs[i][j] << " ";
00188    }
00189    dbgOut() << FEI_ENDL;
00190        }
00191 
00192        return(0);
00193      }
00194 
00195 
00196    int setElemVector(int elemBlockID,
00197          int elemID,
00198          int numNodes,
00199          const int* nodeNumbers,
00200          const int* dofPerNode,
00201          const int* dof_ids,
00202          const double* coefs)
00203      {
00204        dbgOut() << "setElemVector" << FEI_ENDL
00205    << "   elemBlockID: " << elemBlockID << ", elemID: " << elemID << FEI_ENDL
00206    << "   numNodes: " << numNodes << FEI_ENDL;
00207        int i;
00208        dbgOut() << "   nodeNumbers: ";
00209        for(i=0; i<numNodes; i++) {
00210    dbgOut() << nodeNumbers[i] << " ";
00211        }
00212        dbgOut() << FEI_ENDL << "   dofPerNode: ";
00213        int numRows = 0;
00214        for(i=0; i<numNodes; i++) {
00215    dbgOut() << dofPerNode[i] << " ";
00216    numRows += dofPerNode[i];
00217        }
00218        dbgOut() << FEI_ENDL << "   coefs:" << FEI_ENDL << "      ";
00219        for(i=0; i<numRows; i++) {
00220    dbgOut() << coefs[i] << " ";
00221        }
00222        dbgOut() << FEI_ENDL;
00223        return(0);
00224      }
00225 
00226    int setDirichletBCs(int numBCs,
00227            const int* nodeNumbers,
00228            const int* dofOffsets,
00229            const double* values)
00230      {
00231        dbgOut() << "setDirichletBCs" << FEI_ENDL
00232    << "   numBCs: " << numBCs << FEI_ENDL;
00233        for(int i=0; i<numBCs; i++) {
00234    dbgOut() << "     nodeNumber: " << nodeNumbers[i] << ", "
00235      << "dof-offset: " << dofOffsets[i] << ", value: " << values[i]<<FEI_ENDL;
00236        }
00237 
00238        return(0);
00239      }
00240 
00241    int sumIntoMatrix(int numRowNodes,
00242          const int* rowNodeNumbers,
00243          const int* rowDofOffsets,
00244          const int* numColNodesPerRow,
00245          const int* colNodeNumbers,
00246          const int* colDofOffsets,
00247          const double* coefs)
00248      {
00249        dbgOut() << "sumIntoMatrix, numRowNodes: " << numRowNodes << FEI_ENDL;
00250        int offset = 0;
00251        for(int i=0; i<numRowNodes; i++) {
00252    dbgOut() << "   rowNodeNumber " << rowNodeNumbers[i]
00253      << ", rowDofOffset " << rowDofOffsets[i] << FEI_ENDL;
00254    for(int j=0; j<numColNodesPerRow[i]; j++) {
00255      dbgOut() << "      colNodeNumber " << colNodeNumbers[offset]
00256         << ", colDofOffset " << colDofOffsets[offset]
00257         << ", value: " << coefs[offset]<<FEI_ENDL;
00258      offset++;
00259    }
00260        }
00261 
00262        return(0);
00263      }
00264 
00265    int sumIntoRHSVector(int numNodes,
00266          const int* nodeNumbers,
00267          const int* dofOffsets,
00268          const double* coefs)
00269      {
00270        dbgOut() << "sumIntoRHSVector, numNodes: " << numNodes << FEI_ENDL;
00271        for(int i=0; i<numNodes; i++) {
00272    dbgOut() << "   nodeNumber " << nodeNumbers[i]
00273      << ", dof-offset " << dofOffsets[i] << ", value: " << coefs[i]<<FEI_ENDL;
00274        }
00275 
00276        return(0);
00277      }
00278 
00279    int putIntoRHSVector(int numNodes,
00280          const int* nodeNumbers,
00281          const int* dofOffsets,
00282          const double* coefs)
00283      {
00284        dbgOut() << "putIntoRHSVector, numNodes: " << numNodes << FEI_ENDL;
00285        for(int i=0; i<numNodes; i++) {
00286    dbgOut() << "   nodeNumber " << nodeNumbers[i]
00287      << ", dof-offset " << dofOffsets[i] << ", value: " << coefs[i]<<FEI_ENDL;
00288        }
00289 
00290        return(0);
00291      }
00292 
00293    int loadComplete()
00294      {
00295        dbgOut() << "loadComplete" << FEI_ENDL;
00296 
00297        return(0);
00298      }
00299 
00309    int launchSolver(int& solveStatus, int& iterations)
00310      {
00311        dbgOut() << "launchSolver" << FEI_ENDL;
00312 
00313        solveStatus = 0;
00314        iterations = 0;
00315 
00316        return(0);
00317      }
00318 
00319    int reset()
00320      {
00321        dbgOut() << "reset" << FEI_ENDL;
00322        return(0);
00323      }
00324 
00325    int resetRHSVector()
00326      {
00327        dbgOut() << "resetRHSVector" << FEI_ENDL;
00328        return(0);
00329      }
00330 
00331    int resetMatrix()
00332      {
00333        dbgOut() << "resetMatrix" << FEI_ENDL;
00334        return(0);
00335      }
00336 
00337    int deleteConstraints()
00338      {
00339        dbgOut() << "deleteConstraints" << FEI_ENDL;
00340        return(0);
00341      }
00342 
00343    int getSolnEntry(int nodeNumber,
00344         int dofOffset,
00345         double& value)
00346      {
00347        dbgOut() << "getSolnEntry, nodeNumber: " << nodeNumber 
00348    << ", dofOffset: " << dofOffset << FEI_ENDL;
00349 
00350        value = -999.99;
00351 
00352        return(0);
00353     }
00354 
00355    int getMultiplierSoln(int CRID, double& lagrangeMultiplier)
00356      {
00357        lagrangeMultiplier = -999.99;
00358        return(0);
00359      }
00360 
00372    int putNodalFieldData(int fieldID,
00373        int fieldSize,
00374        int numNodes,
00375        const int* nodeNumbers,
00376        const double* coefs)
00377      {
00378        dbgOut() << "putNodalFieldData, fieldID: " << fieldID << ", fieldSize: "
00379    << fieldSize << FEI_ENDL;
00380        int offset = 0;
00381        for(int i=0; i<numNodes; i++) {
00382    dbgOut() << "   nodeNumber " << nodeNumbers[i] << ", coefs: ";
00383    for(int j=0; j<fieldSize; j++) {
00384      dbgOut() << coefs[offset++] << " ";
00385    }
00386    dbgOut() << FEI_ENDL;
00387        }
00388        
00389        return(0);
00390      }
00391 
00392    int setMultiplierCR(int CRID,
00393            int numNodes,
00394            const int* nodeNumbers,
00395            const int* dofOffsets,
00396            const double* coefWeights,
00397            double rhsValue)
00398      {
00399        dbgOut() << "setMultiplierCR, CRID: " << CRID << ", numNodes: " << numNodes << FEI_ENDL;
00400        for(int i=0; i<numNodes; i++) {
00401    dbgOut() << "   nodeNumber " << nodeNumbers[i] << ", dof-offset "
00402       << dofOffsets[i] << ", coefWeight: " << coefWeights[i] <<FEI_ENDL;
00403        }
00404 
00405        dbgOut() << "   rhsValue: " << rhsValue << FEI_ENDL;
00406 
00407        return(0);
00408      }
00409 
00410    int setPenaltyCR(int CRID,
00411         int numNodes,
00412         const int* nodeNumbers,
00413         const int* dofOffsets,
00414         const double* coefWeights,
00415         double penaltyValue,
00416         double rhsValue)
00417      {
00418        dbgOut() << "setPenaltyCR, CRID: " << CRID << ", numNodes: " << numNodes << FEI_ENDL;
00419        for(int i=0; i<numNodes; i++) {
00420    dbgOut() << "   nodeNumber " << nodeNumbers[i] << ", dof-offset "
00421       << dofOffsets[i] << ", coefWeight: " << coefWeights[i] <<FEI_ENDL;
00422        }
00423 
00424        dbgOut() << "   penaltyValue: " << penaltyValue << FEI_ENDL;
00425        dbgOut() << "   rhsValue: " << rhsValue << FEI_ENDL;
00426 
00427        return(0);
00428      }
00429 
00430  private:
00431    int setDebugLog(int debugOutputLevel, const char* path);
00432 
00433    MPI_Comm comm_;
00434    int numProcs_, localProc_;
00435 
00436    int debugOutputLevel_;
00437    char* dbgPath_;
00438    FEI_OSTREAM* dbgOStreamPtr_;
00439    bool dbgFileOpened_;
00440    FEI_OFSTREAM* dbgFStreamPtr_;
00441 };
00442 
00443 #endif // _FEData_h_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends