MAST
multiphysics_nonlinear_solver.h
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2019 Manav Bhatia
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef __mast__multiphysics_nonlinear_solver_base_h__
21 #define __mast__multiphysics_nonlinear_solver_base_h__
22 
23 // C++ includes
24 #include <vector>
25 #include <string>
26 
27 // MAST includes
28 #include "base/mast_data_types.h"
29 
30 // libMesh includes
31 #include "libmesh/parallel_object.h"
32 #include "libmesh/numeric_vector.h"
33 
34 // PETSc includes
35 #include <petscmat.h>
36 #include <petscsnes.h>
37 
38 
39 namespace MAST {
40 
41  // Forward declerations
42  class TransientAssembly;
43 
44 
46  public libMesh::ParallelObject {
47 
48  public:
49 
53  MultiphysicsNonlinearSolverBase(const libMesh::Parallel::Communicator& comm_in,
54  const std::string& nm,
55  unsigned int n);
56 
57 
62 
63 
67  const std::string name() const {
68 
69  return _name;
70  }
71 
72 
76  unsigned int n_disciplines() const {
77 
78  return _n_disciplines;
79  }
80 
81 
82 
87  void set_system_assembly(unsigned int i,
88  MAST::TransientAssembly& assembly);
89 
90 
91 
97 
98 
99 
103  std::vector<IS>& index_sets() {
104 
105  return _is;
106  }
107 
108 
112  Mat mat() {
113 
114  return _mat;
115  }
116 
121  void solve();
122 
123 
130 
131  public:
132 
133  virtual ~PreResidualUpdate() {}
134 
139  virtual void
140  update_at_solution(std::vector<libMesh::NumericVector<Real>*>& sol_vecs) = 0;
141 
147  virtual void
149  (std::vector<libMesh::NumericVector<Real>*>& sol_vecs,
150  std::vector<libMesh::NumericVector<Real>*>& dsol_vecs) = 0;
151 
152  };
153 
154 
155 
159  void
162 
163  _update = &update;
164  }
165 
166 
172 
173  return _update;
174  }
175 
176 
177  void verify_gateaux_derivatives(SNES snes);
178 
179 
180  protected:
181 
182 
186  const std::string _name;
187 
191  const unsigned int _n_disciplines;
192 
198 
203  std::vector<MAST::TransientAssembly*> _discipline_assembly;
204 
205  std::vector<IS> _is;
206  std::vector<Mat> _sub_mats; // row-major ordering
207  unsigned int _n_dofs;
208 
209  Mat _mat;
210  Vec _sol, _res;
211 
212  };
213 }
214 
215 
216 
217 #endif // __mast__multiphysics_nonlinear_solver_base_h__
MultiphysicsNonlinearSolverBase(const libMesh::Parallel::Communicator &comm_in, const std::string &nm, unsigned int n)
default constructor
std::vector< MAST::TransientAssembly * > _discipline_assembly
vector of assembly objects for each discipline in this multiphysics system
const unsigned int _n_disciplines
number of disciplines
This class provides the interface that, if provided, will be called to update any data structures bef...
const std::string _name
name of this multiphysics solution
MAST::MultiphysicsNonlinearSolverBase::PreResidualUpdate * _update
object, if provided, is called to initialize the system data before computation of residual/Jacobian ...
MAST::TransientAssembly & get_system_assembly(unsigned int i)
MAST::MultiphysicsNonlinearSolverBase::PreResidualUpdate * get_pre_residual_update_object()
returns a pointer to the update object
void set_pre_residual_update_object(MAST::MultiphysicsNonlinearSolverBase::PreResidualUpdate &update)
assigns the update object to this solver
virtual void update_at_perturbed_solution(std::vector< libMesh::NumericVector< Real > * > &sol_vecs, std::vector< libMesh::NumericVector< Real > * > &dsol_vecs)=0
sol_vecs is the vector containing the solution for each discipline in this multiphysics solution...
void solve()
solves the system using the nested matrices that uses the discipline specific solver options ...
virtual void update_at_solution(std::vector< libMesh::NumericVector< Real > * > &sol_vecs)=0
sol_vecs is the vector containing the solution for each discipline in this multiphysics solution ...
void set_system_assembly(unsigned int i, MAST::TransientAssembly &assembly)
method to set the n^th discipline of this multiphysics system assembly.