www.mooseframework.org
SubProblem.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 SUBPROBLEM_H
16 #define SUBPROBLEM_H
17 
18 #include "Problem.h"
19 #include "DiracKernelInfo.h"
20 #include "GeometricSearchData.h"
21 #include "MooseTypes.h"
22 
23 #include "libmesh/coupling_matrix.h"
24 
25 class MooseMesh;
26 class SubProblem;
27 class Factory;
28 class Assembly;
29 class MooseVariable;
32 
33 // libMesh forward declarations
34 namespace libMesh
35 {
36 class EquationSystems;
37 class DofMap;
38 class CouplingMatrix;
39 template <typename T>
40 class SparseMatrix;
41 template <typename T>
42 class NumericVector;
43 class System;
44 }
45 
46 template <>
48 
53 class SubProblem : public Problem
54 {
55 public:
56  SubProblem(const InputParameters & parameters);
57  virtual ~SubProblem();
58 
59  virtual EquationSystems & es() = 0;
60  virtual MooseMesh & mesh() = 0;
61 
62  virtual bool checkNonlocalCouplingRequirement() { return _requires_nonlocal_coupling; }
63 
69  virtual void useFECache(bool fe_cache) = 0;
70 
71  virtual void solve() = 0;
72  virtual bool converged() = 0;
73 
74  virtual void onTimestepBegin() = 0;
75  virtual void onTimestepEnd() = 0;
76 
77  virtual bool isTransient() const = 0;
78 
79  // Variables /////
80  virtual bool hasVariable(const std::string & var_name) = 0;
81 
83  virtual MooseVariable & getVariable(THREAD_ID tid, const std::string & var_name) = 0;
84 
86  virtual bool hasScalarVariable(const std::string & var_name) = 0;
87 
89  virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string & var_name) = 0;
90 
92  virtual System & getSystem(const std::string & var_name) = 0;
93 
100  virtual void setActiveElementalMooseVariables(const std::set<MooseVariable *> & moose_vars,
101  THREAD_ID tid);
102 
108  virtual const std::set<MooseVariable *> & getActiveElementalMooseVariables(THREAD_ID tid);
109 
115  virtual bool hasActiveElementalMooseVariables(THREAD_ID tid);
116 
124  virtual void clearActiveElementalMooseVariables(THREAD_ID tid);
125 
132  virtual void setActiveMaterialProperties(const std::set<unsigned int> & mat_prop_ids,
133  THREAD_ID tid);
134 
140  virtual const std::set<unsigned int> & getActiveMaterialProperties(THREAD_ID tid);
141 
150  virtual bool hasActiveMaterialProperties(THREAD_ID tid);
151 
157  virtual void clearActiveMaterialProperties(THREAD_ID tid);
158 
159  virtual Assembly & assembly(THREAD_ID tid) = 0;
160  virtual void prepareShapes(unsigned int var, THREAD_ID tid) = 0;
161  virtual void prepareFaceShapes(unsigned int var, THREAD_ID tid) = 0;
162  virtual void prepareNeighborShapes(unsigned int var, THREAD_ID tid) = 0;
163  virtual Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) = 0;
164 
169  unsigned int getAxisymmetricRadialCoord();
170 
171  virtual DiracKernelInfo & diracKernelInfo();
172  virtual Real finalNonlinearResidual();
173  virtual unsigned int nNonlinearIterations();
174  virtual unsigned int nLinearIterations();
175 
176  virtual void addResidual(THREAD_ID tid) = 0;
177  virtual void addResidualNeighbor(THREAD_ID tid) = 0;
178 
179  virtual void cacheResidual(THREAD_ID tid) = 0;
180  virtual void cacheResidualNeighbor(THREAD_ID tid) = 0;
181  virtual void addCachedResidual(THREAD_ID tid) = 0;
182 
183  virtual void setResidual(NumericVector<Number> & residual, THREAD_ID tid) = 0;
184  virtual void setResidualNeighbor(NumericVector<Number> & residual, THREAD_ID tid) = 0;
185 
186  virtual void addJacobian(SparseMatrix<Number> & jacobian, THREAD_ID tid) = 0;
187  virtual void addJacobianNeighbor(SparseMatrix<Number> & jacobian, THREAD_ID tid) = 0;
188  virtual void addJacobianBlock(SparseMatrix<Number> & jacobian,
189  unsigned int ivar,
190  unsigned int jvar,
191  const DofMap & dof_map,
192  std::vector<dof_id_type> & dof_indices,
193  THREAD_ID tid) = 0;
194  virtual void addJacobianNeighbor(SparseMatrix<Number> & jacobian,
195  unsigned int ivar,
196  unsigned int jvar,
197  const DofMap & dof_map,
198  std::vector<dof_id_type> & dof_indices,
199  std::vector<dof_id_type> & neighbor_dof_indices,
200  THREAD_ID tid) = 0;
201 
202  virtual void cacheJacobian(THREAD_ID tid) = 0;
203  virtual void cacheJacobianNeighbor(THREAD_ID tid) = 0;
204  virtual void addCachedJacobian(SparseMatrix<Number> & jacobian, THREAD_ID tid) = 0;
205 
206  virtual void prepare(const Elem * elem, THREAD_ID tid) = 0;
207  virtual void prepareFace(const Elem * elem, THREAD_ID tid) = 0;
208  virtual void prepare(const Elem * elem,
209  unsigned int ivar,
210  unsigned int jvar,
211  const std::vector<dof_id_type> & dof_indices,
212  THREAD_ID tid) = 0;
213  virtual void setCurrentSubdomainID(const Elem * elem, THREAD_ID tid) = 0;
214  virtual void setNeighborSubdomainID(const Elem * elem, unsigned int side, THREAD_ID tid) = 0;
215  virtual void prepareAssembly(THREAD_ID tid) = 0;
216 
217  virtual void reinitElem(const Elem * elem, THREAD_ID tid) = 0;
218  virtual void
219  reinitElemPhys(const Elem * elem, std::vector<Point> phys_points_in_elem, THREAD_ID tid) = 0;
220  virtual void
221  reinitElemFace(const Elem * elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid) = 0;
222  virtual void reinitNode(const Node * node, THREAD_ID tid) = 0;
223  virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, THREAD_ID tid) = 0;
224  virtual void reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid) = 0;
225  virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid) = 0;
226  virtual void reinitNeighbor(const Elem * elem, unsigned int side, THREAD_ID tid) = 0;
227  virtual void reinitNeighborPhys(const Elem * neighbor,
228  unsigned int neighbor_side,
229  const std::vector<Point> & physical_points,
230  THREAD_ID tid) = 0;
231  virtual void reinitNeighborPhys(const Elem * neighbor,
232  const std::vector<Point> & physical_points,
233  THREAD_ID tid) = 0;
234  virtual void reinitNodeNeighbor(const Node * node, THREAD_ID tid) = 0;
235  virtual void reinitScalars(THREAD_ID tid) = 0;
236  virtual void reinitOffDiagScalars(THREAD_ID tid) = 0;
237 
241  virtual bool reinitDirac(const Elem * elem, THREAD_ID tid) = 0;
245  virtual void getDiracElements(std::set<const Elem *> & elems) = 0;
250  virtual void clearDiracInfo() = 0;
251 
252  // Geom Search
253  virtual void
255 
256  virtual GeometricSearchData & geomSearchData() = 0;
257 
258  virtual void meshChanged();
259 
268  virtual void storeMatPropName(SubdomainID block_id, const std::string & name);
269 
278  virtual void storeMatPropName(BoundaryID boundary_id, const std::string & name);
279 
288  virtual void storeZeroMatProp(SubdomainID block_id, const MaterialPropertyName & name);
289 
298  virtual void storeZeroMatProp(BoundaryID boundary_id, const MaterialPropertyName & name);
299 
306  virtual void storeDelayedCheckMatProp(const std::string & requestor,
307  SubdomainID block_id,
308  const std::string & name);
309 
317  virtual void storeDelayedCheckMatProp(const std::string & requestor,
318  BoundaryID boundary_id,
319  const std::string & name);
320 
326  virtual void checkBlockMatProps();
327 
333  virtual void checkBoundaryMatProps();
334 
338  virtual void markMatPropRequested(const std::string &);
339 
343  virtual bool isMatPropRequested(const std::string & prop_name) const;
344 
348  virtual void addGhostedElem(dof_id_type elem_id) = 0;
349 
353  virtual void addGhostedBoundary(BoundaryID boundary_id) = 0;
354 
358  virtual void ghostGhostedBoundaries() = 0;
359 
363  virtual std::set<SubdomainID> getMaterialPropertyBlocks(const std::string & prop_name);
364 
368  virtual std::vector<SubdomainName> getMaterialPropertyBlockNames(const std::string & prop_name);
369 
373  virtual bool hasBlockMaterialProperty(SubdomainID block_id, const std::string & prop_name);
374 
378  virtual std::set<BoundaryID> getMaterialPropertyBoundaryIDs(const std::string & prop_name);
379 
383  virtual std::vector<BoundaryName> getMaterialPropertyBoundaryNames(const std::string & prop_name);
384 
388  virtual bool hasBoundaryMaterialProperty(BoundaryID boundary_id, const std::string & prop_name);
389 
394  virtual bool computingInitialResidual() = 0;
395 
400  virtual std::set<dof_id_type> & ghostedElems() { return _ghosted_elems; }
401 
410  virtual void
411  registerRestartableData(std::string name, RestartableDataValue * data, THREAD_ID tid);
412 
413  std::map<std::string, std::vector<dof_id_type>> _var_dof_map;
414  const CouplingMatrix & nonlocalCouplingMatrix() const { return _nonlocal_cm; }
415 
416 protected:
419 
420  CouplingMatrix _nonlocal_cm;
421 
423  std::map<SubdomainID, Moose::CoordinateSystemType> _coord_sys;
424 
426 
428  std::map<SubdomainID, std::set<std::string>> _map_block_material_props;
429 
431  std::map<BoundaryID, std::set<std::string>> _map_boundary_material_props;
432 
434  std::map<SubdomainID, std::set<MaterialPropertyName>> _zero_block_material_props;
435  std::map<BoundaryID, std::set<MaterialPropertyName>> _zero_boundary_material_props;
436 
438  std::set<std::string> _material_property_requested;
439 
441 
446  std::map<SubdomainID, std::multimap<std::string, std::string>> _map_block_material_props_check;
447  std::map<BoundaryID, std::multimap<std::string, std::string>> _map_boundary_material_props_check;
449 
451  std::vector<std::set<MooseVariable *>> _active_elemental_moose_variables;
452 
454  /* This needs to remain <unsigned int> for threading purposes */
455  std::vector<unsigned int> _has_active_elemental_moose_variables;
456 
458  std::vector<std::set<unsigned int>> _active_material_property_ids;
459 
462 
464  std::set<dof_id_type> _ghosted_elems;
465 
467  unsigned int _rz_coord_axis;
468 
469 private:
478  template <typename T>
479  void checkMatProps(std::map<T, std::set<std::string>> & props,
480  std::map<T, std::multimap<std::string, std::string>> & check_props,
481  std::map<T, std::set<MaterialPropertyName>> & zero_props);
482 
493  virtual void registerRecoverableData(std::string name);
494 
496  template <typename T>
497  std::string restrictionTypeName();
498  std::string restrictionCheckName(SubdomainID check_id);
499  std::string restrictionCheckName(BoundaryID check_id);
501 
502  friend class Restartable;
503 };
504 
505 namespace Moose
506 {
507 
508 void initial_condition(EquationSystems & es, const std::string & system_name);
509 
510 } // namespace Moose
511 
512 #endif /* SUBPROBLEM_H */
bool _requires_nonlocal_coupling
nonlocal coupling requirement flag
Definition: SubProblem.h:461
std::map< BoundaryID, std::multimap< std::string, std::string > > _map_boundary_material_props_check
Definition: SubProblem.h:447
A class for creating restricted objects.
Definition: Restartable.h:31
The DiracKernelInfo object is a place where all the Dirac points added by different DiracKernels are ...
Factory & _factory
The Factory for building objects.
Definition: SubProblem.h:418
unsigned int _rz_coord_axis
Storage for RZ axis selection.
Definition: SubProblem.h:467
void initial_condition(EquationSystems &es, const std::string &system_name)
Keeps track of stuff related to assembling.
Definition: Assembly.h:63
Class for stuff related to variables.
Definition: MooseVariable.h:43
std::map< SubdomainID, Moose::CoordinateSystemType > _coord_sys
nonlocal coupling matrix;
Definition: SubProblem.h:423
Generic factory class for build all sorts of objects.
Definition: Factory.h:152
const CouplingMatrix & nonlocalCouplingMatrix() const
Definition: SubProblem.h:414
subdomain_id_type SubdomainID
Definition: MooseTypes.h:77
Class that hold the whole problem being solved.
Definition: Problem.h:29
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...
std::set< dof_id_type > _ghosted_elems
Elements that should have Dofs ghosted to the local processor.
Definition: SubProblem.h:464
std::map< BoundaryID, std::set< MaterialPropertyName > > _zero_boundary_material_props
Definition: SubProblem.h:435
InputParameters validParams< SubProblem >()
Definition: SubProblem.C:26
std::map< BoundaryID, std::set< std::string > > _map_boundary_material_props
Map for boundary material properties (boundary_id -> list of properties)
Definition: SubProblem.h:431
std::map< std::string, std::vector< dof_id_type > > _var_dof_map
Definition: SubProblem.h:413
std::vector< std::set< MooseVariable * > > _active_elemental_moose_variables
This is the set of MooseVariables that will actually get reinited by a call to reinit(elem) ...
Definition: SubProblem.h:451
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::set< unsigned int > > _active_material_property_ids
Set of material property ids that determine whether materials get reinited.
Definition: SubProblem.h:458
virtual bool checkNonlocalCouplingRequirement()
Definition: SubProblem.h:62
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition: SubProblem.h:400
GeometricSearchType
Used to select groups of geometric search objects to update.
CoordinateSystemType
Definition: MooseTypes.h:212
MatType type
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:53
std::map< SubdomainID, std::set< MaterialPropertyName > > _zero_block_material_props
Set of properties returned as zero properties.
Definition: SubProblem.h:434
std::vector< unsigned int > _has_active_elemental_moose_variables
Whether or not there is currently a list of active elemental moose variables.
Definition: SubProblem.h:455
Class for scalar variables (they are different).
std::set< std::string > _material_property_requested
set containing all material property names that have been requested by getMaterialProperty* ...
Definition: SubProblem.h:438
Definition: Moose.h:84
std::map< SubdomainID, std::multimap< std::string, std::string > > _map_block_material_props_check
Data structures of the requested material properties.
Definition: SubProblem.h:446
DiracKernelInfo _dirac_kernel_info
Definition: SubProblem.h:425
std::map< SubdomainID, std::set< std::string > > _map_block_material_props
Map of material properties (block_id -> list of properties)
Definition: SubProblem.h:428
CouplingMatrix _nonlocal_cm
Definition: SubProblem.h:420
Abstract definition of a RestartableData value.
boundary_id_type BoundaryID
Definition: MooseTypes.h:75
unsigned int THREAD_ID
Definition: MooseTypes.h:79