3 #include "../../include/matrixFreePDE.h" 4 #include <deal.II/distributed/grid_refinement.h> 7 template <
int dim,
int degree>
9 if (userInputs.h_adaptivity ==
true){
10 if ( (currentIncrement == 0) ){
11 computing_timer.enter_section(
"matrixFreePDE: AMR");
12 unsigned int numDoF_preremesh = totalDOFs;
13 for (
unsigned int remesh_index=0; remesh_index < (userInputs.max_refinement_level-userInputs.min_refinement_level); remesh_index++){
15 adaptiveRefineCriterion();
20 if (totalDOFs == numDoF_preremesh)
break;
21 numDoF_preremesh = totalDOFs;
23 computing_timer.exit_section(
"matrixFreePDE: AMR");
25 else if ( (currentIncrement%userInputs.skip_remeshing_steps==0) ){
27 computing_timer.enter_section(
"matrixFreePDE: AMR");
30 for(
unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
31 constraintsDirichletSet[fieldIndex]->distribute(*solutionSet[fieldIndex]);
32 constraintsOtherSet[fieldIndex]->distribute(*solutionSet[fieldIndex]);
33 solutionSet[fieldIndex]->update_ghost_values();
35 adaptiveRefineCriterion();
38 computing_timer.exit_section(
"matrixFreePDE: AMR");
44 template <
int dim,
int degree>
72 std::vector<std::vector<double> > errorOutV;
75 QGaussLobatto<dim> quadrature(degree+1);
76 FEValues<dim> fe_values (*FESet[userInputs.refine_criterion_fields[0]], quadrature, update_values);
77 const unsigned int num_quad_points = quadrature.size();
79 std::vector<double> errorOut(num_quad_points);
81 typename DoFHandler<dim>::active_cell_iterator cell = dofHandlersSet_nonconst[userInputs.refine_criterion_fields[0]]->begin_active(), endc = dofHandlersSet_nonconst[userInputs.refine_criterion_fields[0]]->end();
83 typename parallel::distributed::Triangulation<dim>::active_cell_iterator t_cell = triangulation.begin_active();
85 for (;cell!=endc; ++cell){
86 if (cell->is_locally_owned()){
87 fe_values.reinit (cell);
89 for (
unsigned int field_index=0; field_index<userInputs.refine_criterion_fields.size(); field_index++){
90 fe_values.get_function_values(*solutionSet[userInputs.refine_criterion_fields[field_index]], errorOut);
91 errorOutV.push_back(errorOut);
94 bool mark_refine =
false;
96 for (
unsigned int q_point=0; q_point<num_quad_points; ++q_point){
97 for (
unsigned int field_index=0; field_index<userInputs.refine_criterion_fields.size(); field_index++){
98 if ((errorOutV[field_index][q_point]>userInputs.refine_window_min[field_index]) && (errorOutV[field_index][q_point]<userInputs.refine_window_max[field_index])){
108 unsigned int current_level = t_cell->level();
110 if ( (mark_refine && current_level < userInputs.max_refinement_level) ){
111 cell->set_refine_flag();
113 else if (!mark_refine && current_level > userInputs.min_refinement_level) {
114 cell->set_coarsen_flag();
125 template <
int dim,
int degree>
129 triangulation.prepare_coarsening_and_refinement();
130 for(
unsigned int fieldIndex=0; fieldIndex<fields.size(); fieldIndex++){
137 soltransSet[fieldIndex]->prepare_for_coarsening_and_refinement(*solutionSet[fieldIndex]);
139 triangulation.execute_coarsening_and_refinement();
143 #include "../../include/matrixFreePDE_template_instantiations.h" void adaptiveRefine(unsigned int _currentIncrement)
virtual void adaptiveRefineCriterion()