FEI Version of the Day
snl_fei_LinearSystem_General.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 _snl_fei_LinearSystem_General_hpp_
00045 #define _snl_fei_LinearSystem_General_hpp_
00046 
00047 #include <fei_macros.hpp>
00048 #include <fei_mpi.h>
00049 #include <fei_CSVec.hpp>
00050 #include <fei_LinearSystem.hpp>
00051 #include <fei_Matrix.hpp>
00052 #include <fei_Vector.hpp>
00053 #include <fei_fwd.hpp>
00054 #include <fei_Logger.hpp>
00055 
00056 namespace fei {
00057   class DirichletBCManager;
00058 }
00059 
00060 namespace snl_fei {
00062   class LinearSystem_General : public fei::LinearSystem,
00063                                private fei::Logger {
00064   public:
00066     LinearSystem_General(fei::SharedPtr<fei::MatrixGraph>& matrixGraph);
00067 
00069     virtual ~LinearSystem_General();
00070 
00073     int loadEssentialBCs(int numIDs,
00074                          const int* IDs,
00075                          int idType,
00076                          int fieldID,
00077                          int offsetIntoField,
00078                          const double* prescribedValues);
00079 
00082     int loadEssentialBCs(int numIDs,
00083                          const int* IDs,
00084                          int idType,
00085                          int fieldID,
00086                          const int* offsetIntoField,
00087                          const double* prescribedValues);
00088 
00090     int loadLagrangeConstraint(int constraintID,
00091              const double *weights,
00092              double rhsValue);
00093 
00095     int loadPenaltyConstraint(int constraintID,
00096             const double *weights,
00097             double penaltyValue,
00098             double rhsValue);
00099 
00103     int loadComplete(bool applyBCs=true,
00104                      bool globalAssemble=true);
00105 
00112     int parameters(int numParams,
00113        const char* const* paramStrings);
00114 
00116     int parameters(const fei::ParameterSet& params);
00117 
00119     int setBCValuesOnVector(fei::Vector* vector);
00120 
00122     bool eqnIsEssentialBC(int globalEqnIndex) const;
00123 
00125     void getEssentialBCs(std::vector<int>& bcEqns,
00126                          std::vector<double>& bcVals) const;
00127 
00129     void getConstrainedEqns(std::vector<int>& crEqns) const;
00130 
00131   private:
00132     void setName(const char* name);
00133 
00134     int fill_EssBCValues();
00135 
00136     int implementBCs(bool applyBCs);
00137 
00138     int enforceEssentialBC_LinSysCore();
00139 
00140     void enforceEssentialBC_step_1(fei::CSVec& essBCs);
00141 
00142     void enforceEssentialBC_step_2(fei::CSVec& essBCs);
00143 
00144     int getMatrixRow(fei::Matrix* matrix, int row,
00145          std::vector<double>& coefs,
00146          std::vector<int>& indices);
00147 
00148     MPI_Comm comm_;
00149 
00150     fei::CSVec* essBCvalues_;
00151     fei::CSVec* allEssBCs_;
00152 
00153     bool resolveConflictRequested_;
00154     bool bcs_trump_slaves_;
00155     bool explicitBCenforcement_;
00156     bool BCenforcement_no_column_mod_;
00157 
00158     int localProc_;
00159     int numProcs_;
00160 
00161     int firstLocalOffset_;
00162     int lastLocalOffset_;
00163 
00164     std::string name_;
00165     std::map<std::string, unsigned> named_loadcomplete_counter_;
00166 
00167     std::vector<int> iwork_;
00168     std::vector<double> dwork_;
00169     std::string dbgprefix_;
00170   };//class LinearSystem_General
00171 }//namespace snl_fei
00172 
00173 #endif // _snl_fei_LinearSystem_General_hpp_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends