PRISMS-PF  v2.1
computeIntegral.cc
Go to the documentation of this file.
1 
2 #include "../../include/matrixFreePDE.h"
3 
4 template <int dim, int degree>
5 void MatrixFreePDE<dim,degree>::computeIntegral(double& integratedField, int index, std::vector<vectorType*> variableSet) {
6  QGauss<dim> quadrature_formula(degree+1);
7  FE_Q<dim> FE (QGaussLobatto<1>(degree+1));
8  FEValues<dim> fe_values (FE, quadrature_formula, update_values | update_JxW_values | update_quadrature_points);
9  const unsigned int n_q_points = quadrature_formula.size();
10  std::vector<double> cVal(n_q_points);
11 
12  // constraintsDirichletSet[index]->distribute(*variableSet[index]);
13  // constraintsOtherSet[index]->distribute(*variableSet[index]);
14  // variableSet[index]->update_ghost_values();
15 
16  typename DoFHandler<dim>::active_cell_iterator cell= this->dofHandlersSet[0]->begin_active(), endc = this->dofHandlersSet[0]->end();
17 
18  double value = 0.0;
19 
20  for (; cell!=endc; ++cell) {
21  if (cell->is_locally_owned()){
22  fe_values.reinit (cell);
23 
24  fe_values.get_function_values(*variableSet[index], cVal);
25 
26  for (unsigned int q=0; q<n_q_points; ++q){
27  value+=(cVal[q])*fe_values.JxW(q);
28  }
29  }
30  }
31 
32  value=Utilities::MPI::sum(value, MPI_COMM_WORLD);
33 
34  // if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0){
35  // std::cout<<"Integrated field: "<<value<<std::endl;
36  // }
37 
38  integratedField = value;
39 }
40 
41 //-----------------------------------
42 
43 //update RHS of each field
44 template <int dim, int degree>
45 void MatrixFreePDE<dim,degree>::computeIntegralMF(double& integratedField, int index, const std::vector<vectorType*> variableSet){
46  //log time
47  computing_timer.enter_section("matrixFreePDE: computeIntegralMF");
48 
49  integrated_var = 0.0;
50  integral_index = index;
51 
52  //call to integrate and assemble
53  matrixFreeObject.cell_loop (&MatrixFreePDE<dim,degree>::getIntegralMF, this, residualSet, variableSet);
54 
55  integratedField=Utilities::MPI::sum(integrated_var, MPI_COMM_WORLD);
56 
57  //end log
58  computing_timer.exit_section("matrixFreePDE: computeIntegralMF");
59 }
60 
61 template <int dim, int degree>
62 void MatrixFreePDE<dim,degree>::getIntegralMF(const MatrixFree<dim,double> &data,
63  std::vector<vectorType*> &dst,
64  const std::vector<vectorType*> &src,
65  const std::pair<unsigned int,unsigned int> &cell_range) {
66 
67  dealii::FEEvaluation<dim,degree,degree+1,1,double> var(data,0);
68 
69  //loop over cells
70  for (unsigned int cell=cell_range.first; cell<cell_range.second; ++cell){
71  var.reinit(cell);
72  var.read_dof_values_plain(*src[0]);
73  var.evaluate(true, false, false);
74 
75  unsigned int num_q_points = var.n_q_points;
76 
77  dealii::AlignedVector<dealii::VectorizedArray<double> > JxW(num_q_points);
78  var.fill_JxW_values(JxW);
79 
80  //loop over quadrature points
81  for (unsigned int q=0; q<num_q_points; ++q){
82 
83 
84  dealii::VectorizedArray<double> val = var.get_value(q);
85  assembler_lock.acquire ();
86  for (unsigned i=0; i<val.n_array_elements;i++){
87  integrated_var += val[i]*JxW[q][i];
88  }
89  assembler_lock.release ();
90 
91  }
92 
93 
94  }
95 }
96 
97 #include "../../include/matrixFreePDE_template_instantiations.h"
void getIntegralMF(const MatrixFree< dim, double > &data, std::vector< vectorType *> &dst, const std::vector< vectorType *> &src, const std::pair< unsigned int, unsigned int > &cell_range)
void computeIntegral(double &integratedField, int index, std::vector< vectorType *> postProcessedSet)
void computeIntegralMF(double &integratedField, int index, const std::vector< vectorType *> postProcessedSet)