2 #include "../../include/variableContainer.h" 4 template <
int dim,
int degree,
typename T>
7 varInfoList = _varInfoList;
8 varChangeInfoList = _varChangeInfoList;
10 num_var = varInfoList.size();
12 for (
unsigned int i=0; i < num_var; i++){
13 if (varInfoList[i].var_needed){
14 if (varInfoList[i].is_scalar){
15 dealii::FEEvaluation<dim,degree,degree+1,1,double> var(data, i);
16 scalar_vars.push_back(var);
19 dealii::FEEvaluation<dim,degree,degree+1,dim,double> var(data, i);
20 vector_vars.push_back(var);
24 if (varChangeInfoList[i].var_needed){
25 if (varChangeInfoList[i].is_scalar){
26 dealii::FEEvaluation<dim,degree,degree+1,1,double> var(data, i);
27 scalar_change_in_vars.push_back(var);
30 dealii::FEEvaluation<dim,degree,degree+1,dim,double> var(data, i);
31 vector_change_in_vars.push_back(var);
37 template <
int dim,
int degree,
typename T>
40 varInfoList = _varInfoList;
42 num_var = varInfoList.size();
44 for (
unsigned int i=0; i < num_var; i++){
45 if (varInfoList[i].var_needed){
46 if (varInfoList[i].is_scalar){
47 dealii::FEEvaluation<dim,degree,degree+1,1,double> var(data, i);
48 scalar_vars.push_back(var);
51 dealii::FEEvaluation<dim,degree,degree+1,dim,double> var(data, i);
52 vector_vars.push_back(var);
59 template <
int dim,
int degree,
typename T>
62 varInfoList = _varInfoList;
64 num_var = varInfoList.size();
66 for (
unsigned int i=0; i < num_var; i++){
67 if (varInfoList[i].var_needed){
68 if (varInfoList[i].is_scalar){
69 dealii::FEEvaluation<dim,degree,degree+1,1,double> var(data, fixed_index);
70 scalar_vars.push_back(var);
73 dealii::FEEvaluation<dim,degree,degree+1,dim,double> var(data, fixed_index);
74 vector_vars.push_back(var);
80 template <
int dim,
int degree,
typename T>
83 if (scalar_vars.size() > 0){
84 scalar_vars[0].fill_JxW_values(JxW);
86 else if (vector_vars.size() > 0){
87 scalar_change_in_vars[0].fill_JxW_values(JxW);
89 else if (scalar_change_in_vars.size() > 0){
90 vector_vars[0].fill_JxW_values(JxW);
93 vector_change_in_vars[0].fill_JxW_values(JxW);
97 template <
int dim,
int degree,
typename T>
99 if (scalar_vars.size() > 0){
100 return scalar_vars[0].n_q_points;
102 else if (vector_vars.size() > 0){
103 return vector_vars[0].n_q_points;
105 else if (scalar_change_in_vars.size() > 0){
106 return scalar_change_in_vars[0].n_q_points;
109 return vector_change_in_vars[0].n_q_points;
113 template <
int dim,
int degree,
typename T>
116 if (scalar_vars.size() > 0){
117 return scalar_vars[0].quadrature_point(q_point);
119 else if (vector_vars.size() > 0){
120 return vector_vars[0].quadrature_point(q_point);
122 else if (scalar_change_in_vars.size() > 0){
123 return scalar_change_in_vars[0].quadrature_point(q_point);
126 return vector_change_in_vars[0].quadrature_point(q_point);
130 template <
int dim,
int degree,
typename T>
133 for (
unsigned int i=0; i<num_var; i++){
134 if (varInfoList[i].var_needed){
135 if (varInfoList[i].is_scalar) {
136 scalar_vars[varInfoList[i].scalar_or_vector_index].reinit(cell);
137 scalar_vars[varInfoList[i].scalar_or_vector_index].read_dof_values(*src[i]);
138 scalar_vars[varInfoList[i].scalar_or_vector_index].evaluate(varInfoList[i].need_value, varInfoList[i].need_gradient, varInfoList[i].need_hessian);
141 vector_vars[varInfoList[i].scalar_or_vector_index].reinit(cell);
142 vector_vars[varInfoList[i].scalar_or_vector_index].read_dof_values(*src[i]);
143 vector_vars[varInfoList[i].scalar_or_vector_index].evaluate(varInfoList[i].need_value, varInfoList[i].need_gradient, varInfoList[i].need_hessian);
153 template <
int dim,
int degree,
typename T>
156 if (varChangeInfoList[var_being_solved].is_scalar) {
157 scalar_change_in_vars[0].reinit(cell);
158 scalar_change_in_vars[0].read_dof_values(src);
159 scalar_change_in_vars[0].evaluate(varChangeInfoList[var_being_solved].need_value, varChangeInfoList[var_being_solved].need_gradient, varChangeInfoList[var_being_solved].need_hessian);
162 vector_change_in_vars[0].reinit(cell);
163 vector_change_in_vars[0].read_dof_values(src);
164 vector_change_in_vars[0].evaluate(varChangeInfoList[var_being_solved].need_value, varChangeInfoList[var_being_solved].need_gradient, varChangeInfoList[var_being_solved].need_hessian);
170 template <
int dim,
int degree,
typename T>
173 for (
unsigned int i=0; i<num_var; i++){
174 if (varInfoList[i].var_needed){
175 if (varInfoList[i].is_scalar) {
176 scalar_vars[varInfoList[i].scalar_or_vector_index].reinit(cell);
177 if (i == var_being_solved ){
178 scalar_vars[varInfoList[i].scalar_or_vector_index].read_dof_values(src);
181 scalar_vars[varInfoList[i].scalar_or_vector_index].read_dof_values(*solutionSet[i]);
183 scalar_vars[varInfoList[i].scalar_or_vector_index].evaluate(varInfoList[i].need_value, varInfoList[i].need_gradient, varInfoList[i].need_hessian);
186 vector_vars[varInfoList[i].scalar_or_vector_index].reinit(cell);
187 if (i == var_being_solved){
188 vector_vars[varInfoList[i].scalar_or_vector_index].read_dof_values(src);
191 vector_vars[varInfoList[i].scalar_or_vector_index].read_dof_values(*solutionSet[i]);
193 vector_vars[varInfoList[i].scalar_or_vector_index].evaluate(varInfoList[i].need_value, varInfoList[i].need_gradient, varInfoList[i].need_hessian);
200 template <
int dim,
int degree,
typename T>
203 for (
unsigned int i=0; i<num_var; i++){
204 if (varInfoList[i].var_needed){
205 if (varInfoList[i].is_scalar) {
206 scalar_vars[varInfoList[i].scalar_or_vector_index].reinit(cell);
209 vector_vars[varInfoList[i].scalar_or_vector_index].reinit(cell);
216 template <
int dim,
int degree,
typename T>
219 for (
unsigned int i=0; i<num_var; i++){
220 if (varInfoList[i].value_residual || varInfoList[i].gradient_residual){
221 if (varInfoList[i].is_scalar) {
222 scalar_vars[varInfoList[i].scalar_or_vector_index].integrate(varInfoList[i].value_residual, varInfoList[i].gradient_residual);
223 scalar_vars[varInfoList[i].scalar_or_vector_index].distribute_local_to_global(*dst[i]);
226 vector_vars[varInfoList[i].scalar_or_vector_index].integrate(varInfoList[i].value_residual, varInfoList[i].gradient_residual);
227 vector_vars[varInfoList[i].scalar_or_vector_index].distribute_local_to_global(*dst[i]);
233 template <
int dim,
int degree,
typename T>
237 if (varChangeInfoList[var_being_solved].is_scalar) {
238 scalar_change_in_vars[0].integrate(varChangeInfoList[var_being_solved].value_residual, varChangeInfoList[var_being_solved].gradient_residual);
239 scalar_change_in_vars[0].distribute_local_to_global(dst);
242 vector_change_in_vars[0].integrate(varChangeInfoList[var_being_solved].value_residual, varChangeInfoList[var_being_solved].gradient_residual);
243 vector_change_in_vars[0].distribute_local_to_global(dst);
248 template <
int dim,
int degree,
typename T>
251 if (varInfoList[global_variable_index].need_value){
252 return scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index].get_value(q_point);
255 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
260 template <
int dim,
int degree,
typename T>
263 if (varInfoList[global_variable_index].need_gradient){
264 return scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index].get_gradient(q_point);
267 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
272 template <
int dim,
int degree,
typename T>
275 if (varInfoList[global_variable_index].need_hessian){
276 return scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index].get_hessian(q_point);
279 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
284 template <
int dim,
int degree,
typename T>
287 if (varInfoList[global_variable_index].need_value){
288 return vector_vars[varInfoList[global_variable_index].scalar_or_vector_index].get_value(q_point);
291 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
296 template <
int dim,
int degree,
typename T>
299 if (varInfoList[global_variable_index].need_gradient){
300 return vector_vars[varInfoList[global_variable_index].scalar_or_vector_index].get_gradient(q_point);
303 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
308 template <
int dim,
int degree,
typename T>
311 if (varInfoList[global_variable_index].need_hessian){
312 return vector_vars[varInfoList[global_variable_index].scalar_or_vector_index].get_hessian(q_point);
315 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
321 template <
int dim,
int degree,
typename T>
324 if (varChangeInfoList[global_variable_index].need_value){
325 return scalar_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].get_value(q_point);
328 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
333 template <
int dim,
int degree,
typename T>
336 if (varChangeInfoList[global_variable_index].need_gradient){
337 return scalar_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].get_gradient(q_point);
340 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
345 template <
int dim,
int degree,
typename T>
348 if (varChangeInfoList[global_variable_index].need_hessian){
349 return scalar_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].get_hessian(q_point);
352 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
357 template <
int dim,
int degree,
typename T>
360 if (varChangeInfoList[global_variable_index].need_value){
361 return vector_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].get_value(q_point);
364 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
369 template <
int dim,
int degree,
typename T>
372 if (varChangeInfoList[global_variable_index].need_gradient){
373 return vector_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].get_gradient(q_point);
376 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
381 template <
int dim,
int degree,
typename T>
384 if (varChangeInfoList[global_variable_index].need_hessian){
385 return vector_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].get_hessian(q_point);
388 std::cerr <<
"PRISMS-PF Error: Attempted access of a variable value that was not marked as needed in 'parameters.in'. Double-check the indices in user functions where a variable value is requested." << std::endl;
394 template <
int dim,
int degree,
typename T>
396 scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index].submit_value(val,q_point);
399 template <
int dim,
int degree,
typename T>
401 scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index].submit_gradient(grad,q_point);
404 template <
int dim,
int degree,
typename T>
406 vector_vars[varInfoList[global_variable_index].scalar_or_vector_index].submit_value(val,q_point);
408 template <
int dim,
int degree,
typename T>
410 vector_vars[varInfoList[global_variable_index].scalar_or_vector_index].submit_gradient(grad,q_point);
413 template <
int dim,
int degree,
typename T>
415 scalar_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].submit_value(val,q_point);
418 template <
int dim,
int degree,
typename T>
420 scalar_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].submit_gradient(grad,q_point);
423 template <
int dim,
int degree,
typename T>
425 vector_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].submit_value(val,q_point);
427 template <
int dim,
int degree,
typename T>
429 vector_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index].submit_gradient(grad,q_point);
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
void integrate_and_distribute(std::vector< vectorType *> &dst)
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
void set_vector_value_term_LHS(unsigned int global_variable_index, dealii::Tensor< 1, dim, T > val)
dealii::parallel::distributed::Vector< double > vectorType
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
dealii::Tensor< 3, dim, T > get_change_in_vector_hessian(unsigned int global_variable_index) const
T get_scalar_value(unsigned int global_variable_index) const
dealii::Point< dim, T > get_q_point_location()
T get_change_in_scalar_value(unsigned int global_variable_index) const
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)