FEI Version of the Day
fei_LinearSystem.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 
00044 #ifndef _fei_LinearSystem_hpp_
00045 #define _fei_LinearSystem_hpp_
00046 
00047 #include <fei_macros.hpp>
00048 #include <fei_SharedPtr.hpp>
00049 #include <fei_MatrixGraph.hpp>
00050 #include <fei_Matrix.hpp>
00051 #include <fei_Vector.hpp>
00052 #include <fei_DirichletBCManager.hpp>
00053 
00054 namespace fei {
00055   class Factory;
00056   class ParameterSet;
00057 
00061   class LinearSystem {
00062   public:
00064     class Factory {
00065     public:
00067       virtual ~Factory(){}
00068 
00070       virtual fei::SharedPtr<fei::LinearSystem>
00071   createLinearSystem(fei::SharedPtr<fei::MatrixGraph>& matrixGraph);
00072     };
00073 
00075     LinearSystem(fei::SharedPtr<fei::MatrixGraph>& matrixGraph);
00076 
00078     virtual ~LinearSystem();
00079 
00086     virtual int parameters(int numParams,
00087                            const char* const* paramStrings) = 0;
00088 
00091     virtual int parameters(const fei::ParameterSet& params) = 0;
00092 
00094     virtual void setMatrix(fei::SharedPtr<fei::Matrix>& matrix);
00095 
00097     virtual fei::SharedPtr<fei::Matrix> getMatrix()
00098       { return(matrix_); }
00099 
00101     virtual fei::SharedPtr<const fei::Matrix> getMatrix() const
00102       { fei::SharedPtr<const fei::Matrix> const_mat(matrix_);
00103         return(const_mat); }
00104 
00106     virtual void setRHS(fei::SharedPtr<fei::Vector>& rhs)
00107       { rhs_ = rhs; }
00108 
00110     virtual fei::SharedPtr<fei::Vector> getRHS()
00111       { return(rhs_); }
00112 
00114     virtual fei::SharedPtr<const fei::Vector> getRHS() const
00115       { fei::SharedPtr<const fei::Vector> const_rhs(rhs_);
00116         return(const_rhs); }
00117 
00119     virtual void setSolutionVector(fei::SharedPtr<fei::Vector>& soln)
00120       { soln_ = soln; }
00121 
00123     virtual fei::SharedPtr<fei::Vector> getSolutionVector()
00124       { return(soln_); }
00125 
00127     virtual fei::SharedPtr<const fei::Vector> getSolutionVector() const
00128       { fei::SharedPtr<const fei::Vector> const_soln(soln_);
00129       return(const_soln); }
00130 
00133     virtual int putAttribute(const char* name,
00134                              void* attribute);
00135 
00137     virtual int getAttribute(const char* name,
00138                              void*& attribute);
00139 
00155     virtual int loadEssentialBCs(int numIDs,
00156                                  const int* IDs,
00157                                  int idType,
00158                                  int fieldID,
00159                                  int offsetIntoField,
00160                                  const double* prescribedValues);
00161 
00178     virtual int loadEssentialBCs(int numIDs,
00179                                  const int* IDs,
00180                                  int idType,
00181                                  int fieldID,
00182                                  const int* offsetsIntoField,
00183                                  const double* prescribedValues);
00184 
00193     virtual int loadLagrangeConstraint(int constraintID,
00194                const double *weights,
00195                double rhsValue) = 0;
00196 
00206     virtual int loadPenaltyConstraint(int constraintID,
00207               const double *weights,
00208               double penaltyValue,
00209               double rhsValue) = 0;
00210 
00214     virtual int loadComplete(bool applyBCs=true,
00215                              bool globalAssemble=true) = 0;
00216 
00220     virtual int setBCValuesOnVector(fei::Vector* vector) = 0;
00221 
00225     virtual bool eqnIsEssentialBC(int globalEqnIndex) const = 0;
00226 
00231     virtual void getEssentialBCs(std::vector<int>& bcEqns,
00232                                  std::vector<double>& bcVals) const = 0;
00233 
00237     virtual void getConstrainedEqns(std::vector<int>& crEqns) const = 0;
00238 
00239    protected:
00240     fei::SharedPtr<fei::Matrix> matrix_;
00241     fei::SharedPtr<fei::Vector> soln_;
00242     fei::SharedPtr<fei::Vector> rhs_;
00243 
00244     fei::SharedPtr<fei::MatrixGraph> matrixGraph_;
00245     fei::DirichletBCManager* dbcManager_;
00246 
00247     std::vector<char*> attributeNames_;
00248     std::vector<void*> attributes_;
00249   };//class LinearSystem
00250 }//namespace fei
00251 
00252 #endif // _fei_LinearSystem_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends