PRISMS-PF  v2.1
initForTests.cc
Go to the documentation of this file.
1 //initForTests() method for MatrixFreePDE class
2 
3 #include "../../include/matrixFreePDE.h"
4 #include <deal.II/grid/grid_generator.h>
5 
6 template <int dim, int degree>
8 
9  //creating mesh
10  std::vector<unsigned int> subdivisions;
11  subdivisions.push_back(10);
12  if (dim>1){
13  subdivisions.push_back(10);
14  if (dim>2){
15  subdivisions.push_back(10);
16  }
17  }
18 
19  if (dim == 3){
20  GridGenerator::subdivided_hyper_rectangle (triangulation, subdivisions, Point<dim>(), Point<dim>(1,1,1));
21  }
22  else if (dim == 2){
23  GridGenerator::subdivided_hyper_rectangle (triangulation, subdivisions, Point<dim>(), Point<dim>(1,1));
24  }
25  else {
26  GridGenerator::subdivided_hyper_rectangle (triangulation, subdivisions, Point<dim>(), Point<dim>(1));
27  }
28 
29  //setup system
30  //create FESystem
31  FESystem<dim>* fe;
32  fe=new FESystem<dim>(FE_Q<dim>(QGaussLobatto<1>(degree+1)),1);
33  FESet.push_back(fe);
34 
35  //distribute DOFs
36  DoFHandler<dim>* dof_handler;
37  dof_handler=new DoFHandler<dim>(triangulation);
38  dofHandlersSet.push_back(dof_handler);
39  dofHandlersSet_nonconst.push_back(dof_handler);
40  dof_handler->distribute_dofs (*fe);
41 
42  //extract locally_relevant_dofs
43  IndexSet* locally_relevant_dofs;
44  locally_relevant_dofs=new IndexSet;
45  locally_relevant_dofsSet.push_back(locally_relevant_dofs);
46  locally_relevant_dofsSet_nonconst.push_back(locally_relevant_dofs);
47  locally_relevant_dofs->clear();
48  DoFTools::extract_locally_relevant_dofs (*dof_handler, *locally_relevant_dofs);
49 
50  // //create constraints
51  ConstraintMatrix *constraintsOther;
52  constraintsOther=new ConstraintMatrix; constraintsOtherSet.push_back(constraintsOther);
53  constraintsOtherSet_nonconst.push_back(constraintsOther);
54  constraintsOther->clear(); constraintsOther->reinit(*locally_relevant_dofs);
55  DoFTools::make_hanging_node_constraints (*dof_handler, *constraintsOther);
56  //constraintsOther->close(); // I actually don't want to close them since I'll be adding to them in test_setRigidBodyModeConstraints
57  //
58  // //setup the matrix free object
59  typename MatrixFree<dim,double>::AdditionalData additional_data;
60  // The member "mpi_communicator" was removed in deal.II version 8.5 but is required before it
61  #if (DEAL_II_VERSION_MAJOR < 9 && DEAL_II_VERSION_MINOR < 5)
62  additional_data.mpi_communicator = MPI_COMM_WORLD;
63  #endif
64  additional_data.tasks_parallel_scheme = MatrixFree<dim,double>::AdditionalData::partition_partition;
65  additional_data.mapping_update_flags = (update_values | update_gradients | update_JxW_values | update_quadrature_points);
66  QGaussLobatto<1> quadrature (degree+1);
67  matrixFreeObject.clear();
68  matrixFreeObject.reinit (dofHandlersSet, constraintsOtherSet, quadrature, additional_data);
69 
70  //setup problem vectors
71  vectorType *U, *R;
72  U=new vectorType; R=new vectorType;
73  solutionSet.push_back(U); residualSet.push_back(R);
74  matrixFreeObject.initialize_dof_vector(*R, 0); *R=0;
75  matrixFreeObject.initialize_dof_vector(*U, 0); *U=0;
76 
77 
78 }
79 
80 #include "../../include/matrixFreePDE_template_instantiations.h"
dealii::parallel::distributed::Vector< double > vectorType
Definition: FloodFiller.h:15
void initForTests()
Definition: initForTests.cc:7