implicit_system.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_IMPLICIT_SYSTEM_H 00021 #define LIBMESH_IMPLICIT_SYSTEM_H 00022 00023 // Local Includes 00024 #include "libmesh/explicit_system.h" 00025 00026 // C++ includes 00027 #include <cstddef> 00028 00029 namespace libMesh 00030 { 00031 00032 // Forward declarations 00033 template <typename T> class LinearSolver; 00034 template <typename T> class SparseMatrix; 00035 00036 00037 00046 // ------------------------------------------------------------ 00047 // ImplicitSystem class definition 00048 00049 class ImplicitSystem : public ExplicitSystem 00050 { 00051 public: 00052 00057 ImplicitSystem (EquationSystems& es, 00058 const std::string& name, 00059 const unsigned int number); 00060 00064 virtual ~ImplicitSystem (); 00065 00069 typedef ImplicitSystem sys_type; 00070 00074 sys_type & system () { return *this; } 00075 00079 typedef ExplicitSystem Parent; 00080 00085 virtual void clear (); 00086 00091 virtual void reinit (); 00092 00098 virtual void assemble (); 00099 00100 // /** 00101 // * Assembles & solves the linear system Ax=b. 00102 // */ 00103 // virtual void solve (); 00104 00105 00110 virtual void disable_cache (); 00111 00116 virtual std::string system_type () const { return "Implicit"; } 00117 00126 virtual LinearSolver<Number> *get_linear_solver() const; 00127 00133 virtual std::pair<unsigned int, Real> 00134 get_linear_solve_parameters() const; 00135 00140 virtual void release_linear_solver(LinearSolver<Number> *) const; 00141 00149 virtual void assembly(bool /* get_residual */ , bool /* get_jacobian */) 00150 { libmesh_error(); } 00151 00163 virtual void assemble_residual_derivatives (const ParameterVector& parameters); 00164 00172 virtual std::pair<unsigned int, Real> 00173 sensitivity_solve (const ParameterVector& parameters); 00174 00183 virtual std::pair<unsigned int, Real> 00184 weighted_sensitivity_solve (const ParameterVector& parameters, 00185 const ParameterVector& weights); 00186 00196 virtual std::pair<unsigned int, Real> 00197 adjoint_solve (const QoISet& qoi_indices = QoISet()); 00198 00211 virtual std::pair<unsigned int, Real> 00212 weighted_sensitivity_adjoint_solve (const ParameterVector& parameters, 00213 const ParameterVector& weights, 00214 const QoISet& qoi_indices = QoISet()); 00215 00227 virtual void adjoint_qoi_parameter_sensitivity (const QoISet& qoi_indices, 00228 const ParameterVector& parameters, 00229 SensitivityData& sensitivities); 00230 00242 virtual void forward_qoi_parameter_sensitivity (const QoISet& qoi_indices, 00243 const ParameterVector& parameters, 00244 SensitivityData& sensitivities); 00245 00254 virtual void qoi_parameter_hessian(const QoISet& qoi_indices, 00255 const ParameterVector& parameters, 00256 SensitivityData& hessian); 00257 00268 virtual void qoi_parameter_hessian_vector_product(const QoISet& qoi_indices, 00269 const ParameterVector& parameters, 00270 const ParameterVector& vector, 00271 SensitivityData& product); 00272 00276 typedef std::map<std::string, SparseMatrix<Number>* >::iterator matrices_iterator; 00277 typedef std::map<std::string, SparseMatrix<Number>* >::const_iterator const_matrices_iterator; 00278 00287 SparseMatrix<Number> & add_matrix (const std::string& mat_name); 00288 00293 bool have_matrix (const std::string& mat_name) const; 00294 00300 const SparseMatrix<Number> * request_matrix (const std::string& mat_name) const; 00301 00307 SparseMatrix<Number> * request_matrix (const std::string& mat_name); 00308 00315 const SparseMatrix<Number> & get_matrix (const std::string& mat_name) const; 00316 00323 SparseMatrix<Number> & get_matrix (const std::string& mat_name); 00324 00328 virtual unsigned int n_matrices () const; 00329 00335 SparseMatrix<Number> * matrix; 00336 00337 00338 00339 protected: 00340 00345 virtual void init_data (); 00346 00350 virtual void init_matrices (); 00351 00352 00353 00354 private: 00355 00360 void add_system_matrix (); 00361 00365 std::map<std::string, SparseMatrix<Number>* > _matrices; 00366 00370 bool _can_add_matrices; 00371 }; 00372 00373 00374 00375 // ------------------------------------------------------------ 00376 // ImplicitSystem inline methods 00377 inline 00378 bool ImplicitSystem::have_matrix (const std::string& mat_name) const 00379 { 00380 return (_matrices.count(mat_name)); 00381 } 00382 00383 00384 inline 00385 unsigned int ImplicitSystem::n_matrices () const 00386 { 00387 return libmesh_cast_int<unsigned int>(_matrices.size()); 00388 } 00389 00390 } // namespace libMesh 00391 00392 #endif // LIBMESH_IMPLICIT_SYSTEM_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:47 UTC
Hosted By: