PRISMS-PF  v2.1
variableContainer.h
Go to the documentation of this file.
1 // This class permits the access of a subset of indexed fields and gives an error if any non-allowed fields are requested
2 #ifndef VARIBLECONTAINER_H
3 #define VARIBLECONTAINER_H
4 
5 #include "userInputParameters.h"
6 #include <deal.II/matrix_free/matrix_free.h>
7 #include <deal.II/matrix_free/fe_evaluation.h>
8 
9 // #include <deal.II/base/quadrature.h>
10 // #include <deal.II/base/timer.h>
11 #include <deal.II/lac/vector.h>
12 // #include <deal.II/lac/constraint_matrix.h>
13 // #include <deal.II/fe/fe_system.h>
14 // #include <deal.II/fe/fe_q.h>
15 // #include <deal.II/fe/fe_values.h>
16 // #include <deal.II/grid/tria.h>
17 // #include <deal.II/grid/tria_accessor.h>
18 // #include <deal.II/grid/tria_iterator.h>
19 // #include <deal.II/grid/grid_tools.h>
20 // #include <deal.II/dofs/dof_tools.h>
21 // #include <deal.II/dofs/dof_handler.h>
22 // #include <deal.II/numerics/vector_tools.h>
23 // #include <deal.II/lac/parallel_vector.h>
24 // #include <deal.II/matrix_free/matrix_free.h>
25 // #include <deal.II/matrix_free/fe_evaluation.h>
26 // #include <deal.II/base/config.h>
27 // #include <deal.II/base/exceptions.h>
28 // #include <deal.II/distributed/tria.h>
29 // #include <deal.II/distributed/solution_transfer.h>
30 // #include <deal.II/grid/manifold_lib.h>
31 
32 template <int dim, int degree, typename T>
34 {
35 public:
36  #include "typeDefs.h"
37 
38  // Constructors
39 
40  // Standard contructor, used for most situations
41  variableContainer(const dealii::MatrixFree<dim,double> &data, std::vector<variable_info> _varInfoList, std::vector<variable_info> _varChangeInfoList);
42  variableContainer(const dealii::MatrixFree<dim,double> &data, std::vector<variable_info> _varInfoList);
43  // Nonstandard constructor, used when only one index of "data" should be used, use with care!
44  variableContainer(const dealii::MatrixFree<dim,double> &data, std::vector<variable_info> _varInfoList, unsigned int fixed_index);
45 
46  // Methods to get the value/grad/hess in the residual method (this is how the user gets these values in equations.h)
47  T get_scalar_value(unsigned int global_variable_index) const;
48  dealii::Tensor<1, dim, T > get_scalar_gradient(unsigned int global_variable_index) const;
49  dealii::Tensor<2, dim, T > get_scalar_hessian(unsigned int global_variable_index) const;
50  dealii::Tensor<1, dim, T > get_vector_value(unsigned int global_variable_index) const;
51  dealii::Tensor<2, dim, T > get_vector_gradient(unsigned int global_variable_index) const;
52  dealii::Tensor<3, dim, T > get_vector_hessian(unsigned int global_variable_index) const;
53 
54  T get_change_in_scalar_value(unsigned int global_variable_index) const;
55  dealii::Tensor<1, dim, T > get_change_in_scalar_gradient(unsigned int global_variable_index) const;
56  dealii::Tensor<2, dim, T > get_change_in_scalar_hessian(unsigned int global_variable_index) const;
57  dealii::Tensor<1, dim, T > get_change_in_vector_value(unsigned int global_variable_index) const;
58  dealii::Tensor<2, dim, T > get_change_in_vector_gradient(unsigned int global_variable_index) const;
59  dealii::Tensor<3, dim, T > get_change_in_vector_hessian(unsigned int global_variable_index) const;
60 
61  // Methods to set the value residual and the gradient residual (this is how the user sets these values in equations.h)
62  void set_scalar_value_term_RHS(unsigned int global_variable_index, T val);
63  void set_scalar_gradient_term_RHS(unsigned int global_variable_index, dealii::Tensor<1, dim, T > grad);
64  void set_vector_value_term_RHS(unsigned int global_variable_index, dealii::Tensor<1, dim, T > val);
65  void set_vector_gradient_term_RHS(unsigned int global_variable_index, dealii::Tensor<2, dim, T > grad);
66 
67  void set_scalar_value_term_LHS(unsigned int global_variable_index, T val);
68  void set_scalar_gradient_term_LHS(unsigned int global_variable_index, dealii::Tensor<1, dim, T > grad);
69  void set_vector_value_term_LHS(unsigned int global_variable_index, dealii::Tensor<1, dim, T > val);
70  void set_vector_gradient_term_LHS(unsigned int global_variable_index, dealii::Tensor<2, dim, T > grad);
71 
72 
73  // Initialize, read DOFs, and set evaulation flags for each variable
74  void reinit_and_eval(const std::vector<vectorType*> &src, unsigned int cell);
75  void reinit_and_eval_change_in_solution(const vectorType &src, unsigned int cell, unsigned int var_being_solved);
76  void reinit_and_eval_LHS(const vectorType &src, const std::vector<vectorType*> solutionSet, unsigned int cell, unsigned int var_being_solved);
77 
78  // Only initialize the FEEvaluation object for each variable (used for post-processing)
79  void reinit(unsigned int cell);
80 
81  // Integrate the residuals and distribute from local to global
82  void integrate_and_distribute(std::vector<vectorType*> &dst);
83  void integrate_and_distribute_change_in_solution_LHS(vectorType &dst, const unsigned int var_being_solved);
84 
85  // The quadrature point index, a method to get the number of quadrature points per cell, and a method to get the xyz coordinates for the quadrature point
86  unsigned int q_point;
87  unsigned int get_num_q_points();
88  dealii::Point<dim,T> get_q_point_location();
89 
90  // Method to obtain JxW (the weighted Jacobian)
91  void get_JxW(dealii::AlignedVector<T> & JxW);
92 
93 private:
94  // The number of variables
95  unsigned int num_var;
96 
97  // Vectors of the actual FEEvaluation objects for each active variable, split into scalar variables and vector variables for type reasons
98  std::vector<dealii::FEEvaluation<dim,degree,degree+1,1,double> > scalar_vars;
99  std::vector<dealii::FEEvaluation<dim,degree,degree+1,dim,double> > vector_vars;
100 
101  std::vector<dealii::FEEvaluation<dim,degree,degree+1,1,double> > scalar_change_in_vars;
102  std::vector<dealii::FEEvaluation<dim,degree,degree+1,dim,double> > vector_change_in_vars;
103 
104  // Object containing some information about each variable (indices, whether the val/grad/hess is needed, etc)
105  std::vector<variable_info> varInfoList;
106  std::vector<variable_info> varChangeInfoList;
107 
108 };
109 
110 #endif
void reinit_and_eval_change_in_solution(const vectorType &src, unsigned int cell, unsigned int var_being_solved)
void set_vector_gradient_term_LHS(unsigned int global_variable_index, dealii::Tensor< 2, dim, T > grad)
void reinit(unsigned int cell)
dealii::Tensor< 2, dim, T > get_change_in_vector_gradient(unsigned int global_variable_index) const
std::vector< variable_info > varChangeInfoList
void integrate_and_distribute(std::vector< vectorType *> &dst)
std::vector< variable_info > varInfoList
void set_scalar_value_term_LHS(unsigned int global_variable_index, T val)
void integrate_and_distribute_change_in_solution_LHS(vectorType &dst, const unsigned int var_being_solved)
void set_scalar_value_term_RHS(unsigned int global_variable_index, T val)
void get_JxW(dealii::AlignedVector< T > &JxW)
void set_scalar_gradient_term_RHS(unsigned int global_variable_index, dealii::Tensor< 1, dim, T > grad)
variableContainer(const dealii::MatrixFree< dim, double > &data, std::vector< variable_info > _varInfoList, std::vector< variable_info > _varChangeInfoList)
dealii::Tensor< 1, dim, T > get_vector_value(unsigned int global_variable_index) const
dealii::Tensor< 2, dim, T > get_vector_gradient(unsigned int global_variable_index) const
dealii::Tensor< 3, dim, T > get_vector_hessian(unsigned int global_variable_index) const
std::vector< dealii::FEEvaluation< dim, degree, degree+1, dim, double > > vector_change_in_vars
void set_vector_value_term_LHS(unsigned int global_variable_index, dealii::Tensor< 1, dim, T > val)
dealii::parallel::distributed::Vector< double > vectorType
unsigned int q_point
dealii::Tensor< 2, dim, T > get_change_in_scalar_hessian(unsigned int global_variable_index) const
dealii::Tensor< 1, dim, T > get_scalar_gradient(unsigned int global_variable_index) const
dealii::Tensor< 2, dim, T > get_scalar_hessian(unsigned int global_variable_index) const
void reinit_and_eval(const std::vector< vectorType *> &src, unsigned int cell)
unsigned int get_num_q_points()
void reinit_and_eval_LHS(const vectorType &src, const std::vector< vectorType *> solutionSet, unsigned int cell, unsigned int var_being_solved)
void set_vector_value_term_RHS(unsigned int global_variable_index, dealii::Tensor< 1, dim, T > val)
dealii::Tensor< 1, dim, T > get_change_in_vector_value(unsigned int global_variable_index) const
std::vector< dealii::FEEvaluation< dim, degree, degree+1, 1, double > > scalar_change_in_vars
dealii::Tensor< 3, dim, T > get_change_in_vector_hessian(unsigned int global_variable_index) const
std::vector< dealii::FEEvaluation< dim, degree, degree+1, dim, double > > vector_vars
T get_scalar_value(unsigned int global_variable_index) const
dealii::Point< dim, T > get_q_point_location()
unsigned int num_var
T get_change_in_scalar_value(unsigned int global_variable_index) const
std::vector< dealii::FEEvaluation< dim, degree, degree+1, 1, double > > scalar_vars
dealii::Tensor< 1, dim, T > get_change_in_scalar_gradient(unsigned int global_variable_index) const
void set_scalar_gradient_term_LHS(unsigned int global_variable_index, dealii::Tensor< 1, dim, T > grad)
void set_vector_gradient_term_RHS(unsigned int global_variable_index, dealii::Tensor< 2, dim, T > grad)