|
EpetraExt
Development
|
00001 /* 00002 //@HEADER 00003 // *********************************************************************** 00004 // 00005 // EpetraExt: Epetra Extended - Linear Algebra Services Package 00006 // Copyright (2011) Sandia Corporation 00007 // 00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00009 // the U.S. Government retains certain rights in this software. 00010 // 00011 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are 00013 // met: 00014 // 00015 // 1. Redistributions of source code must retain the above copyright 00016 // notice, this list of conditions and the following disclaimer. 00017 // 00018 // 2. Redistributions in binary form must reproduce the above copyright 00019 // notice, this list of conditions and the following disclaimer in the 00020 // documentation and/or other materials provided with the distribution. 00021 // 00022 // 3. Neither the name of the Corporation nor the names of the 00023 // contributors may be used to endorse or promote products derived from 00024 // this software without specific prior written permission. 00025 // 00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 // 00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00039 // 00040 // *********************************************************************** 00041 //@HEADER 00042 */ 00043 00044 #ifndef GLPAPP_GLPYUEPETRADATAPOOL_H 00045 #define GLPAPP_GLPYUEPETRADATAPOOL_H 00046 00047 //#include "Epetra_config.h" 00048 00049 #include <iostream> 00050 00051 #include "Epetra_Map.h" 00052 #include "Epetra_MultiVector.h" 00053 #include "Epetra_Vector.h" 00054 #include "Epetra_Import.h" 00055 #include "Epetra_Export.h" 00056 #include "Epetra_CrsMatrix.h" 00057 #include "Epetra_FECrsMatrix.h" 00058 #include "Epetra_LinearProblem.h" 00059 #include "Epetra_LAPACK.h" 00060 #include "Epetra_FEVector.h" 00061 #include "Epetra_IntSerialDenseVector.h" 00062 #include "Epetra_SerialDenseMatrix.h" 00063 #include "Epetra_SerialDenseVector.h" 00064 #include "GenSQP_DataPool.hpp" 00065 #include "GenSQP_YUEpetraVector.hpp" 00066 #include "Epetra_SerialDenseMatrix.h" 00067 #include "Epetra_SerialDenseVector.h" 00068 00069 #ifdef HAVE_MPI 00070 # include "Epetra_MpiComm.h" 00071 #else 00072 # include "Epetra_SerialComm.h" 00073 #endif 00074 00075 namespace GLpApp { 00076 00077 class GLpYUEpetraDataPool : public GenSQP::DataPool 00078 { 00079 public: 00080 00081 GLpYUEpetraDataPool( 00082 Teuchos::RefCountPtr<const Epetra_Comm> const& commptr 00083 ,const double beta 00084 ,const double len_x // Ignored if myfile is *not* empty 00085 ,const double len_y // Ignored if myfile is *not* empty 00086 ,const int local_nx // Ignored if myfile is *not* empty 00087 ,const int local_ny // Ignored if myfile is *not* empty 00088 ,const char myfile[] 00089 ,const bool trace 00090 ); 00091 00095 void computeAll( const GenSQP::Vector &x ); 00096 00098 int solveAugsys( const Teuchos::RefCountPtr<const Epetra_MultiVector> & rhsy, 00099 const Teuchos::RefCountPtr<const Epetra_MultiVector> & rhsu, 00100 const Teuchos::RefCountPtr<const Epetra_MultiVector> & rhsp, 00101 const Teuchos::RefCountPtr<Epetra_MultiVector> & y, 00102 const Teuchos::RefCountPtr<Epetra_MultiVector> & u, 00103 const Teuchos::RefCountPtr<Epetra_MultiVector> & p, 00104 double tol ); 00105 00106 Teuchos::RefCountPtr<const Epetra_Comm> getCommPtr(); 00107 00108 Teuchos::RefCountPtr<Epetra_FECrsMatrix> getA(); 00109 Teuchos::RefCountPtr<Epetra_FECrsMatrix> getB(); 00110 Teuchos::RefCountPtr<Epetra_FECrsMatrix> getH(); 00111 Teuchos::RefCountPtr<Epetra_FECrsMatrix> getR(); 00112 Teuchos::RefCountPtr<Epetra_CrsMatrix> getAugmat(); 00113 Teuchos::RefCountPtr<Epetra_FECrsMatrix> getNpy(); 00114 00115 Teuchos::RefCountPtr<Epetra_FEVector> getb(); 00116 Teuchos::RefCountPtr<Epetra_FEVector> getq(); 00117 Teuchos::RefCountPtr<Epetra_FEVector> getNy(); 00118 00120 void computeNy(const Teuchos::RefCountPtr<const Epetra_MultiVector> & y); 00121 00123 void computeNpy(const Teuchos::RefCountPtr<const Epetra_MultiVector> & y); 00124 00126 void computeAugmat(); 00127 00128 Teuchos::RefCountPtr<const Epetra_SerialDenseMatrix> getipcoords(); 00129 Teuchos::RefCountPtr<const Epetra_IntSerialDenseVector> getipindx(); 00130 Teuchos::RefCountPtr<const Epetra_SerialDenseMatrix> getpcoords(); 00131 Teuchos::RefCountPtr<const Epetra_IntSerialDenseVector> getpindx(); 00132 Teuchos::RefCountPtr<const Epetra_IntSerialDenseMatrix> gett(); 00133 Teuchos::RefCountPtr<const Epetra_IntSerialDenseMatrix> gete(); 00134 00135 double getbeta(); 00136 00138 void PrintVec( const Teuchos::RefCountPtr<const Epetra_Vector> & x ); 00139 00140 private: 00141 00142 Teuchos::RefCountPtr<const Epetra_Comm> commptr_; 00143 00145 Teuchos::RefCountPtr<Epetra_SerialDenseMatrix> ipcoords_; 00147 Teuchos::RefCountPtr<Epetra_IntSerialDenseVector> ipindx_; 00149 Teuchos::RefCountPtr<Epetra_SerialDenseMatrix> pcoords_; 00151 Teuchos::RefCountPtr<Epetra_IntSerialDenseVector> pindx_; 00153 Teuchos::RefCountPtr<Epetra_IntSerialDenseMatrix> t_; 00155 Teuchos::RefCountPtr<Epetra_IntSerialDenseMatrix> e_; 00156 00158 Teuchos::RefCountPtr<Epetra_FECrsMatrix> A_; 00160 Teuchos::RefCountPtr<Epetra_FECrsMatrix> B_; 00162 Teuchos::RefCountPtr<Epetra_FECrsMatrix> H_; 00164 Teuchos::RefCountPtr<Epetra_FECrsMatrix> R_; 00165 00167 Teuchos::RefCountPtr<Epetra_MultiVector> B_bar_; 00168 00173 Teuchos::RefCountPtr<Epetra_CrsMatrix> Augmat_; 00174 00176 Teuchos::RefCountPtr<Epetra_FECrsMatrix> Npy_; 00177 00179 Teuchos::RefCountPtr<Epetra_FEVector> b_; 00181 Teuchos::RefCountPtr<Epetra_FEVector> q_; 00182 00183 Teuchos::RefCountPtr<Epetra_FEVector> Ny_; 00184 00186 double beta_; 00187 00188 }; 00189 00190 class Usr_Par { 00191 public: 00192 00193 Usr_Par(); 00194 00195 Epetra_SerialDenseMatrix Nodes; 00196 Epetra_SerialDenseVector Weights; 00197 00198 Epetra_SerialDenseMatrix N; 00199 00200 Epetra_SerialDenseMatrix Nx1; 00201 00202 Epetra_SerialDenseMatrix Nx2; 00203 00204 Epetra_SerialDenseMatrix S1; 00205 Epetra_SerialDenseMatrix S2; 00206 Epetra_SerialDenseMatrix S3; 00207 00208 Epetra_SerialDenseVector Nw; 00209 00210 Epetra_SerialDenseMatrix NNw; 00211 00212 Epetra_SerialDenseMatrix * NNNw; 00213 00214 Epetra_SerialDenseMatrix * NdNdx1Nw; 00215 00216 Epetra_SerialDenseMatrix * NdNdx2Nw; 00217 00218 ~Usr_Par() { 00219 delete [] NNNw; 00220 delete [] NdNdx1Nw; 00221 delete [] NdNdx2Nw; 00222 } 00223 00224 void Print(std::ostream& os) const; 00225 }; 00226 00227 } // namespace GLpApp 00228 00229 #endif // GLPAPP_GLPYUEPETRADATAPOOL_H
1.7.6.1