3 #include "../../include/matrixFreePDE.h" 6 template <
int dim,
int degree>
9 computing_timer.enter_section(
"matrixFreePDE: reinitialization");
12 pcout <<
"Reinitializing matrix free object\n";
14 for(
typename std::vector<
Field<dim> >::iterator it = fields.begin(); it != fields.end(); ++it){
15 currentFieldIndex=it->index;
21 fe=FESet.at(it->index);
24 DoFHandler<dim>* dof_handler;
25 dof_handler=dofHandlersSet_nonconst.at(it->index);
27 dof_handler->distribute_dofs (*fe);
28 totalDOFs+=dof_handler->n_dofs();
31 IndexSet* locally_relevant_dofs;
32 locally_relevant_dofs=locally_relevant_dofsSet_nonconst.at(it->index);
34 locally_relevant_dofs->clear();
35 DoFTools::extract_locally_relevant_dofs (*dof_handler, *locally_relevant_dofs);
38 ConstraintMatrix *constraintsDirichlet, *constraintsOther;
40 constraintsDirichlet=constraintsDirichletSet_nonconst.at(it->index);
41 constraintsOther=constraintsOtherSet_nonconst.at(it->index);
43 constraintsDirichlet->clear(); constraintsDirichlet->reinit(*locally_relevant_dofs);
44 constraintsOther->clear(); constraintsOther->reinit(*locally_relevant_dofs);
47 DoFTools::make_hanging_node_constraints (*dof_handler, *constraintsOther);
50 std::vector<int> rigidBodyModeComponents;
51 getComponentsWithRigidBodyModes(rigidBodyModeComponents);
52 setRigidBodyModeConstraints(rigidBodyModeComponents,constraintsOther,dof_handler);
55 setPeriodicityConstraints(constraintsOther,dof_handler);
60 constraintsDirichlet->close();
61 constraintsOther->close();
64 valuesDirichletSet[it->index]->clear();
65 for (types::global_dof_index i=0; i<dof_handler->n_dofs(); i++){
66 if (locally_relevant_dofs->is_element(i)){
67 if (constraintsDirichlet->is_constrained(i)){
68 (*valuesDirichletSet[it->index])[i] = constraintsDirichlet->get_inhomogeneity(i);
73 sprintf(buffer,
"field '%2s' DOF : %u (Constraint DOF : %u)\n", \
74 it->name.c_str(), dof_handler->n_dofs(), constraintsDirichlet->n_constraints());
77 pcout <<
"total DOF : " << totalDOFs << std::endl;
80 typename MatrixFree<dim,double>::AdditionalData additional_data;
82 #if (DEAL_II_VERSION_MAJOR < 9 && DEAL_II_VERSION_MINOR < 5) 83 additional_data.mpi_communicator = MPI_COMM_WORLD;
85 additional_data.tasks_parallel_scheme = MatrixFree<dim,double>::AdditionalData::partition_partition;
88 additional_data.mapping_update_flags = (update_values | update_gradients | update_JxW_values | update_quadrature_points);
89 QGaussLobatto<1> quadrature (degree+1);
90 matrixFreeObject.clear();
91 matrixFreeObject.reinit (dofHandlersSet, constraintsOtherSet, quadrature, additional_data);
93 bool dU_scalar_init =
false;
94 bool dU_vector_init =
false;
97 pcout <<
"initializing parallel::distributed residual and solution vectors\n";
98 for(
unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
101 U=solutionSet.at(fieldIndex);
103 matrixFreeObject.initialize_dof_vector(*U, fieldIndex); *U=0;
107 if (fields[fieldIndex].type ==
SCALAR){
108 if (dU_scalar_init ==
false){
109 matrixFreeObject.initialize_dof_vector(dU_scalar, fieldIndex);
110 dU_scalar_init =
true;
114 if (dU_vector_init ==
false){
115 matrixFreeObject.initialize_dof_vector(dU_vector, fieldIndex);
116 dU_vector_init =
true;
123 if (isTimeDependentBVP){
128 for(
unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
131 soltransSet[fieldIndex]->interpolate(*solutionSet[fieldIndex]);
132 delete soltransSet[fieldIndex];
136 matrixFreeObject.initialize_dof_vector(*R, fieldIndex); *R=0;
141 for(
unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
142 soltransSet.push_back(
new parallel::distributed::SolutionTransfer<dim, vectorType>(*dofHandlersSet_nonconst[fieldIndex]));
146 if (currentIncrement == 0 && !userInputs.load_grain_structure){
147 applyInitialConditions();
151 for(
unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
152 constraintsDirichletSet[fieldIndex]->distribute(*solutionSet[fieldIndex]);
153 constraintsOtherSet[fieldIndex]->distribute(*solutionSet[fieldIndex]);
154 solutionSet[fieldIndex]->update_ghost_values();
157 computing_timer.exit_section(
"matrixFreePDE: reinitialization");
160 #include "../../include/matrixFreePDE_template_instantiations.h"
dealii::parallel::distributed::Vector< double > vectorType