www.mooseframework.org
DisplacedProblem.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef DISPLACEDPROBLEM_H
16 #define DISPLACEDPROBLEM_H
17 
18 #include "SubProblem.h"
19 #include "DisplacedSystem.h"
20 #include "GeometricSearchData.h"
21 
22 // libMesh
23 #include "libmesh/equation_systems.h"
24 #include "libmesh/enum_quadrature_type.h"
25 
26 // Forward declarations
27 class MooseVariable;
28 class AssemblyData;
29 class DisplacedProblem;
30 class MooseMesh;
31 class Assembly;
32 class FEProblemBase;
33 
34 // libMesh forward declarations
35 namespace libMesh
36 {
37 template <typename T>
38 class NumericVector;
39 }
40 
41 template <>
43 
45 {
46 public:
47  DisplacedProblem(const InputParameters & parameters);
48 
49  virtual EquationSystems & es() override { return _eq; }
50  virtual MooseMesh & mesh() override { return _mesh; }
51  MooseMesh & refMesh();
52 
53  DisplacedSystem & nlSys() { return _displaced_nl; }
54  DisplacedSystem & auxSys() { return _displaced_aux; }
55 
56  // Return a constant reference to the vector of variable names.
57  const std::vector<std::string> & getDisplacementVarNames() const { return _displacements; }
58 
59  virtual void createQRules(QuadratureType type, Order order, Order volume_order, Order face_order);
60 
66  virtual void useFECache(bool fe_cache) override;
67 
68  virtual void init() override;
69  virtual void solve() override;
70  virtual bool converged() override;
71 
75  virtual void saveOldSolutions();
76 
80  virtual void restoreOldSolutions();
81 
85  virtual void syncSolutions();
86 
90  virtual void syncSolutions(const NumericVector<Number> & soln,
91  const NumericVector<Number> & aux_soln);
92 
97  virtual void updateMesh();
98 
103  virtual void updateMesh(const NumericVector<Number> & soln,
104  const NumericVector<Number> & aux_soln);
105 
106  virtual bool isTransient() const override;
107  virtual Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) override;
108 
109  // Variables /////
110  virtual bool hasVariable(const std::string & var_name) override;
111  virtual MooseVariable & getVariable(THREAD_ID tid, const std::string & var_name) override;
112  virtual bool hasScalarVariable(const std::string & var_name) override;
113  virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid,
114  const std::string & var_name) override;
115  virtual System & getSystem(const std::string & var_name) override;
116 
117  virtual void addVariable(const std::string & var_name,
118  const FEType & type,
119  Real scale_factor,
120  const std::set<SubdomainID> * const active_subdomains = NULL);
121  virtual void addAuxVariable(const std::string & var_name,
122  const FEType & type,
123  const std::set<SubdomainID> * const active_subdomains = NULL);
124  virtual void addScalarVariable(const std::string & var_name,
125  Order order,
126  Real scale_factor = 1.,
127  const std::set<SubdomainID> * const active_subdomains = NULL);
128  virtual void addAuxScalarVariable(const std::string & var_name,
129  Order order,
130  Real scale_factor = 1.,
131  const std::set<SubdomainID> * const active_subdomains = NULL);
132 
133  // Adaptivity /////
134  virtual void initAdaptivity();
135  virtual void meshChanged() override;
136 
137  // reinit /////
138  virtual void prepare(const Elem * elem, THREAD_ID tid) override;
139  virtual void prepareNonlocal(THREAD_ID tid);
140  virtual void prepareFace(const Elem * elem, THREAD_ID tid) override;
141  virtual void prepare(const Elem * elem,
142  unsigned int ivar,
143  unsigned int jvar,
144  const std::vector<dof_id_type> & dof_indices,
145  THREAD_ID tid) override;
146  virtual void setCurrentSubdomainID(const Elem * elem, THREAD_ID tid) override;
147  virtual void setNeighborSubdomainID(const Elem * elem, unsigned int side, THREAD_ID tid) override;
148  virtual void prepareBlockNonlocal(unsigned int ivar,
149  unsigned int jvar,
150  const std::vector<dof_id_type> & idof_indices,
151  const std::vector<dof_id_type> & jdof_indices,
152  THREAD_ID tid);
153  virtual void prepareAssembly(THREAD_ID tid) override;
154  virtual void prepareAssemblyNeighbor(THREAD_ID tid);
155 
156  virtual bool reinitDirac(const Elem * elem, THREAD_ID tid) override;
157  virtual void reinitElem(const Elem * elem, THREAD_ID tid) override;
158  virtual void
159  reinitElemPhys(const Elem * elem, std::vector<Point> phys_points_in_elem, THREAD_ID tid) override;
160  virtual void
161  reinitElemFace(const Elem * elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid) override;
162  virtual void reinitNode(const Node * node, THREAD_ID tid) override;
163  virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, THREAD_ID tid) override;
164  virtual void reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid) override;
165  virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid) override;
166  virtual void reinitNeighbor(const Elem * elem, unsigned int side, THREAD_ID tid) override;
167  virtual void reinitNeighborPhys(const Elem * neighbor,
168  unsigned int neighbor_side,
169  const std::vector<Point> & physical_points,
170  THREAD_ID tid) override;
171  virtual void reinitNeighborPhys(const Elem * neighbor,
172  const std::vector<Point> & physical_points,
173  THREAD_ID tid) override;
174  virtual void reinitNodeNeighbor(const Node * node, THREAD_ID tid) override;
175  virtual void reinitScalars(THREAD_ID tid) override;
176  virtual void reinitOffDiagScalars(THREAD_ID tid) override;
177 
179  virtual void getDiracElements(std::set<const Elem *> & elems) override;
180  virtual void clearDiracInfo() override;
181 
182  virtual void addResidual(THREAD_ID tid) override;
183  virtual void addResidualNeighbor(THREAD_ID tid) override;
184 
185  virtual void cacheResidual(THREAD_ID tid) override;
186  virtual void cacheResidualNeighbor(THREAD_ID tid) override;
187  virtual void addCachedResidual(THREAD_ID tid) override;
188 
189  virtual void addCachedResidualDirectly(NumericVector<Number> & residual, THREAD_ID tid);
190 
191  virtual void setResidual(NumericVector<Number> & residual, THREAD_ID tid) override;
192  virtual void setResidualNeighbor(NumericVector<Number> & residual, THREAD_ID tid) override;
193 
194  virtual void addJacobian(SparseMatrix<Number> & jacobian, THREAD_ID tid) override;
195  virtual void addJacobianNonlocal(SparseMatrix<Number> & jacobian, THREAD_ID tid);
196  virtual void addJacobianNeighbor(SparseMatrix<Number> & jacobian, THREAD_ID tid) override;
197  virtual void addJacobianBlock(SparseMatrix<Number> & jacobian,
198  unsigned int ivar,
199  unsigned int jvar,
200  const DofMap & dof_map,
201  std::vector<dof_id_type> & dof_indices,
202  THREAD_ID tid) override;
203  virtual void addJacobianBlockNonlocal(SparseMatrix<Number> & jacobian,
204  unsigned int ivar,
205  unsigned int jvar,
206  const DofMap & dof_map,
207  const std::vector<dof_id_type> & idof_indices,
208  const std::vector<dof_id_type> & jdof_indices,
209  THREAD_ID tid);
210  virtual void addJacobianNeighbor(SparseMatrix<Number> & jacobian,
211  unsigned int ivar,
212  unsigned int jvar,
213  const DofMap & dof_map,
214  std::vector<dof_id_type> & dof_indices,
215  std::vector<dof_id_type> & neighbor_dof_indices,
216  THREAD_ID tid) override;
217 
218  virtual void cacheJacobian(THREAD_ID tid) override;
219  virtual void cacheJacobianNonlocal(THREAD_ID tid);
220  virtual void cacheJacobianNeighbor(THREAD_ID tid) override;
221  virtual void addCachedJacobian(SparseMatrix<Number> & jacobian, THREAD_ID tid) override;
222 
223  virtual void prepareShapes(unsigned int var, THREAD_ID tid) override;
224  virtual void prepareFaceShapes(unsigned int var, THREAD_ID tid) override;
225  virtual void prepareNeighborShapes(unsigned int var, THREAD_ID tid) override;
226 
227  virtual Assembly & assembly(THREAD_ID tid) override { return *_assembly[tid]; }
228 
229  // Geom Search /////
230  virtual void updateGeomSearch(
232  virtual GeometricSearchData & geomSearchData() override { return _geometric_search_data; }
233 
234  virtual bool computingInitialResidual() override;
235 
236  virtual void onTimestepBegin() override;
237  virtual void onTimestepEnd() override;
238 
243  virtual std::set<dof_id_type> & ghostedElems() override;
244 
248  virtual void addGhostedElem(dof_id_type elem_id) override;
249 
254  virtual void addGhostedBoundary(BoundaryID boundary_id) override;
255 
259  virtual void ghostGhostedBoundaries() override;
260 
265  void undisplaceMesh();
266 
267 protected:
270  EquationSystems _eq;
273  std::vector<std::string> _displacements;
274 
277 
278  const NumericVector<Number> * _nl_solution;
279  const NumericVector<Number> * _aux_solution;
280 
281  std::vector<std::unique_ptr<Assembly>> _assembly;
282 
284 
285 private:
287  friend class Restartable;
288 };
289 
290 #endif /* DISPLACEDPROBLEM_H */
virtual MooseMesh & mesh() override
GeometricSearchData _geometric_search_data
InputParameters validParams< DisplacedProblem >()
const std::vector< std::string > & getDisplacementVarNames() const
A class for creating restricted objects.
Definition: Restartable.h:31
virtual GeometricSearchData & geomSearchData() override
Keeps track of stuff related to assembling.
Definition: Assembly.h:63
Class for stuff related to variables.
Definition: MooseVariable.h:43
subdomain_id_type SubdomainID
Definition: MooseTypes.h:77
FEProblemBase & _mproblem
virtual EquationSystems & es() override
std::vector< std::unique_ptr< Assembly > > _assembly
DisplacedSystem _displaced_aux
DisplacedSystem _displaced_nl
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
EquationSystems _eq
MooseMesh & _ref_mesh
reference mesh
DofMap & dof_map
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
std::vector< std::string > _displacements
const NumericVector< Number > * _aux_solution
virtual Assembly & assembly(THREAD_ID tid) override
GeometricSearchType
Used to select groups of geometric search objects to update.
CoordinateSystemType
Definition: MooseTypes.h:212
DisplacedSystem & nlSys()
MatType type
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:53
DisplacedSystem & auxSys()
Class for scalar variables (they are different).
const NumericVector< Number > * _nl_solution
boundary_id_type BoundaryID
Definition: MooseTypes.h:75
unsigned int THREAD_ID
Definition: MooseTypes.h:79