www.mooseframework.org
SolutionUserObject.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 SOLUTIONUSEROBJECT_H
16 #define SOLUTIONUSEROBJECT_H
17 
18 // MOOSE includes
19 #include "GeneralUserObject.h"
20 
21 // Forward declarations
22 namespace libMesh
23 {
24 class ExodusII_IO;
25 class EquationSystems;
26 class System;
27 class MeshFunction;
28 template <class T>
29 class NumericVector;
30 }
31 
32 // Forward declarations
33 class SolutionUserObject;
34 
35 template <>
37 
43 {
44 public:
45  SolutionUserObject(const InputParameters & parameters);
46  virtual ~SolutionUserObject(); // empty dtor required for unique_ptr with forward declarations
47 
51  virtual void timestepSetup() override;
52 
58  unsigned int getLocalVarIndex(const std::string & var_name) const;
59 
70  Real pointValueWrapper(Real t,
71  const Point & p,
72  const std::string & var_name,
73  const MooseEnum & weighting_type = weightingType()) const;
74 
83  Real pointValue(Real t, const Point & p, const unsigned int local_var_index) const;
84 
93  Real pointValue(Real t, const Point & p, const std::string & var_name) const;
94 
106  std::map<const Elem *, Real>
107  discontinuousPointValue(Real t, Point pt, const unsigned int local_var_index) const;
108 
120  std::map<const Elem *, Real>
121  discontinuousPointValue(Real t, const Point & p, const std::string & var_name) const;
122 
133  RealGradient pointValueGradientWrapper(Real t,
134  const Point & p,
135  const std::string & var_name,
136  const MooseEnum & weighting_type = weightingType()) const;
137 
146  RealGradient pointValueGradient(Real t, const Point & p, const std::string & var_name) const;
147 
156  RealGradient pointValueGradient(Real t, Point pt, const unsigned int local_var_index) const;
157 
169  std::map<const Elem *, RealGradient>
170  discontinuousPointValueGradient(Real t, const Point & p, const std::string & var_name) const;
171 
183  std::map<const Elem *, RealGradient>
184  discontinuousPointValueGradient(Real t, Point pt, const unsigned int local_var_index) const;
185 
192  Real directValue(const Node * node, const std::string & var_name) const;
193 
200  Real directValue(const Elem * elem, const std::string & var_name) const;
201 
202  // Required pure virtual function (not used)
203  virtual void initialize() override;
204 
205  // Required pure virtual function (not used)
206  virtual void finalize() override;
207 
208  // Required pure virtual function (not used)
209  virtual void execute() override;
210 
212  virtual void initialSetup() override;
213 
214  const std::vector<std::string> & variableNames() const;
215 
216  bool isVariableNodal(const std::string & var_name) const;
217 
219  {
220  return MooseEnum("found_first=1 average=2 smallest_element_id=4 largest_element_id=8",
221  "found_first");
222  }
223 
228  unsigned int getMeshFileDimension() const { return _mesh->spatial_dimension(); }
229 
230 protected:
236  void readXda();
237 
242  void readExodusII();
243 
251  virtual Real directValue(dof_id_type dof_index) const;
252 
257  MooseEnum getSolutionFileType();
258 
263  void updateExodusTimeInterpolation(Real time);
264 
269  bool updateExodusBracketingTimeIndices(Real time);
270 
277  Real evalMeshFunction(const Point & p,
278  const unsigned int local_var_index,
279  unsigned int func_num) const;
280 
288  std::map<const Elem *, Real> evalMultiValuedMeshFunction(const Point & p,
289  const unsigned int local_var_index,
290  unsigned int func_num) const;
291 
298  RealGradient evalMeshFunctionGradient(const Point & p,
299  const unsigned int local_var_index,
300  unsigned int func_num) const;
301 
310  std::map<const Elem *, RealGradient> evalMultiValuedMeshFunctionGradient(
311  const Point & p, const unsigned int local_var_index, unsigned int func_num) const;
312 
315 
317  std::string _mesh_file;
318 
320  std::string _es_file;
321 
323  std::string _system_name;
324 
326  std::vector<std::string> _system_variables;
327 
329  std::map<std::string, unsigned int> _local_variable_index;
330 
332  std::map<std::string, bool> _local_variable_nodal;
333 
336 
339 
341  std::unique_ptr<MeshBase> _mesh;
342 
344  std::unique_ptr<EquationSystems> _es;
345 
347  System * _system;
348 
350  std::unique_ptr<MeshFunction> _mesh_function;
351 
353  std::unique_ptr<ExodusII_IO> _exodusII_io;
354 
356  std::unique_ptr<NumericVector<Number>> _serialized_solution;
357 
359  std::unique_ptr<EquationSystems> _es2;
360 
362  System * _system2;
363 
365  std::unique_ptr<MeshFunction> _mesh_function2;
366 
368  std::unique_ptr<NumericVector<Number>> _serialized_solution2;
369 
372 
375 
377  const std::vector<Real> * _exodus_times;
378 
381 
384 
386  std::vector<Real> _scale;
387 
389  std::vector<Real> _scale_multiplier;
390 
392  std::vector<Real> _translation;
393 
396 
399 
402 
405 
408 
411 
414 
417 
418 private:
419  static Threads::spin_mutex _solution_user_object_mutex;
420 };
421 
422 #endif // SOLUTIONUSEROBJECT_H
RealVectorValue RealGradient
Definition: Assembly.h:43
std::unique_ptr< ExodusII_IO > _exodusII_io
Pointer to the libMesh::ExodusII used to read the files.
unsigned int getMeshFileDimension() const
Return the spatial dimension of the mesh file.
VectorValue< Real > RealVectorValue
Definition: Assembly.h:40
std::vector< Real > _scale_multiplier
scale_multiplier parameter
std::unique_ptr< NumericVector< Number > > _serialized_solution
Pointer to the serial solution vector.
std::vector< std::string > _system_variables
A list of variables to extract from the read system.
std::string _es_file
The XDA file that contians the EquationSystems data (xda only)
std::unique_ptr< EquationSystems > _es
Pointer to the libmesh::EquationSystems object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
RealVectorValue _rotation1_vector
vector about which to rotate
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const std::vector< Real > * _exodus_times
The times available in the ExodusII file.
RealVectorValue _rotation0_vector
vector about which to rotate
InputParameters validParams< SolutionUserObject >()
int _exodus_index1
Time index 1, used for interpolation.
int _exodus_time_index
Current ExodusII time index.
Real _rotation0_angle
angle (in degrees) which to rotate through about vector _rotation0_vector
RealTensorValue _r0
Rotation matrix that performs the "_rotation0_angle about rotation0_vector".
std::string _system_name
The system name to extract from the XDA file (xda only)
std::unique_ptr< NumericVector< Number > > _serialized_solution2
Pointer to second serial solution, used for interpolation.
RealTensorValue _r1
Rotation matrix that performs the "_rotation1_angle about rotation1_vector".
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
std::unique_ptr< MeshFunction > _mesh_function2
Pointer to second libMesh::MeshFuntion, used for interpolation.
Real _interpolation_time
Interpolation time.
static Threads::spin_mutex _solution_user_object_mutex
System * _system2
Pointer to a second libMesh::System object, used for interpolation.
std::map< std::string, unsigned int > _local_variable_index
Stores the local index need by MeshFunction.
bool _initialized
True if initial_setup has executed.
MultiMooseEnum _transformation_order
transformations (rotations, translation, scales) are performed in this order
std::unique_ptr< MeshFunction > _mesh_function
Pointer the libMesh::MeshFunction object that the read data is stored.
std::vector< Real > _scale
Scale parameter.
bool _interpolate_times
Flag for triggering interpolation of ExodusII data.
Real _interpolation_factor
Interpolation weight factor.
std::unique_ptr< EquationSystems > _es2
Pointer to second libMesh::EquationSystems object, used for interpolation.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
User object that reads an existing solution from an input file and uses it in the current simulation...
TensorValue< Real > RealTensorValue
Definition: Assembly.h:45
MooseEnum _file_type
File type to read (0 = xda; 1 = ExodusII)
int _exodus_index2
Time index 2, used for interpolation.
std::map< std::string, bool > _local_variable_nodal
Stores flag indicating if the variable is nodal.
std::string _mesh_file
The XDA or ExodusII file that is being read.
System * _system
Pointer libMesh::System class storing the read solution.
static MooseEnum weightingType()
std::unique_ptr< MeshBase > _mesh
Pointer the libmesh::mesh object.
Real _rotation1_angle
angle (in degrees) which to rotate through about vector _rotation1_vector
std::vector< Real > _translation
Translation.