MatrixFreeActiveMatrix mf_system_matrix;
VectorType solution;
VectorType right_hand_side;
- Vector<double> estimated_error_per_cell;
+ Vector<double> estimated_error_square_per_cell;
MGLevelObject<MatrixType> mg_matrix;
MGLevelObject<MatrixType> mg_interface_in;
const Coefficient<dim> coefficient;
- estimated_error_per_cell.reinit(triangulation.n_active_cells());
+ estimated_error_square_per_cell.reinit(triangulation.n_active_cells());
using Iterator = typename DoFHandler<dim>::active_cell_iterator;
- // Assembler for cell residual $h \| f + \epsilon \triangle u \|_K$
+ // Assembler for cell residual $h^2 \| f + \epsilon \triangle u \|_K^2$
auto cell_worker = [&](const Iterator & cell,
ScratchData<dim> &scratch_data,
CopyData & copy_data) {
residual_norm_square += residual * residual * fe_values.JxW(k);
}
- copy_data.value = cell->diameter() * std::sqrt(residual_norm_square);
+ copy_data.value =
+ cell->diameter() * cell->diameter() * residual_norm_square;
};
// Assembler for face term $\sum_F h_F \| \jump{\epsilon \nabla u \cdot n}
}
const double h = cell->face(f)->measure();
- copy_data_face.values[0] = 0.5 * h * std::sqrt(jump_norm_square);
+ copy_data_face.values[0] = 0.5 * h * jump_norm_square;
copy_data_face.values[1] = copy_data_face.values[0];
};
auto copier = [&](const CopyData ©_data) {
if (copy_data.cell_index != numbers::invalid_unsigned_int)
- estimated_error_per_cell[copy_data.cell_index] += copy_data.value;
+ estimated_error_square_per_cell[copy_data.cell_index] += copy_data.value;
for (auto &cdf : copy_data.face_data)
for (unsigned int j = 0; j < 2; ++j)
- estimated_error_per_cell[cdf.cell_indices[j]] += cdf.values[j];
+ estimated_error_square_per_cell[cdf.cell_indices[j]] += cdf.values[j];
};
const unsigned int n_gauss_points = degree + 1;
const double refinement_fraction = 1. / (std::pow(2.0, dim) - 1.);
parallel::distributed::GridRefinement::refine_and_coarsen_fixed_number(
- triangulation, estimated_error_per_cell, refinement_fraction, 0.0);
+ triangulation, estimated_error_square_per_cell, refinement_fraction, 0.0);
triangulation.execute_coarsening_and_refinement();
}
level(cell->active_cell_index()) = cell->level();
data_out.add_data_vector(level, "level");
- if (estimated_error_per_cell.size() > 0)
- data_out.add_data_vector(estimated_error_per_cell,
- "estimated_error_per_cell");
+ if (estimated_error_square_per_cell.size() > 0)
+ data_out.add_data_vector(estimated_error_square_per_cell,
+ "estimated_error_square_per_cell");
data_out.build_patches();