initlog();
deal_II_exceptions::disable_abort_on_exception();
-#ifdef DEBUG
- // Asserts should be triggered
- const bool expected_result = false;
-#else
- // User beware: Asserts ignored
- const bool expected_result = true;
-#endif
+ bool expected_result;
+ if constexpr (running_in_debug_mode())
+ {
+ // Asserts should be triggered
+ expected_result = false;
+ }
+ else
+ {
+ // User beware: Asserts ignored
+ expected_result = true;
+ }
const unsigned int dim = 2;
AssertThrow(
initlog();
deal_II_exceptions::disable_abort_on_exception();
-#ifdef DEBUG
- // Asserts should be triggered
- const bool expected_result = false;
-#else
- // User beware: Asserts ignored
- const bool expected_result = true;
-#endif
+ bool expected_result;
+ if constexpr (running_in_debug_mode())
+ {
+ // Asserts should be triggered
+ expected_result = false;
+ }
+ else
+ {
+ // User beware: Asserts ignored
+ expected_result = true;
+ }
const unsigned int dim = 2;
AssertThrow(
initlog();
deal_II_exceptions::disable_abort_on_exception();
-#ifdef DEBUG
- // Asserts should be triggered
- const bool expected_result = false;
-#else
- // User beware: Asserts ignored
- const bool expected_result = true;
-#endif
+ bool expected_result;
+ if constexpr (running_in_debug_mode())
+ {
+ // Asserts should be triggered
+ expected_result = false;
+ }
+ else
+ {
+ // User beware: Asserts ignored
+ expected_result = true;
+ }
const unsigned int dim = 2;
AssertThrow(
initlog();
deal_II_exceptions::disable_abort_on_exception();
-#ifdef DEBUG
- // Asserts should be triggered
- const bool expected_result_taped = false;
- const bool expected_result_tapeless = false;
-#else
- // User beware: Asserts ignored
- const bool expected_result_taped = true;
- const bool expected_result_tapeless = false;
-#endif
+ bool expected_result_taped;
+ bool expected_result_tapeless;
+ if constexpr (running_in_debug_mode())
+ {
+ // Asserts should be triggered
+ expected_result_taped = false;
+ expected_result_tapeless = false;
+ }
+ else
+ {
+ // User beware: Asserts ignored
+ expected_result_taped = true;
+ expected_result_tapeless = false;
+ }
const unsigned int dim = 2;
AssertThrow((test_incorrect_no_of_ind_vars<dim,
initlog();
deal_II_exceptions::disable_abort_on_exception();
-#ifdef DEBUG
- // Asserts should be triggered
- const bool expected_result = false;
-#else
- // User beware: Asserts ignored
- const bool expected_result = true;
-#endif
+ bool expected_result;
+ if constexpr (running_in_debug_mode())
+ {
+ // Asserts should be triggered
+ expected_result = false;
+ }
+ else
+ {
+ // User beware: Asserts ignored
+ expected_result = true;
+ }
const unsigned int dim = 2;
AssertThrow(
#include "../tests.h"
-#undef DEBUG
-
-#ifdef DEBUG
// used only for debugging
template <int dim>
void
deallog << "...finished plotting shape functions" << std::endl;
}
-#endif
constraints.print(deallog.get_file_stream());
-#ifdef DEBUG
- plot_shape_function(dof_handler);
-#endif
+ // plot_shape_function(dof_handler);
dof_handler.clear();
return 0;
using namespace ConvergenceTest;
- const unsigned int refinements = 1;
- const unsigned int poly_degree = 2;
-#ifdef DEBUG
- const unsigned int n_iterations = 2;
-#else
- const unsigned int n_iterations = 3;
-#endif
+ const unsigned int refinements = 1;
+ const unsigned int poly_degree = 2;
+ const unsigned int n_iterations = (running_in_debug_mode ? 2 : 3);
MaxwellProblem<2> maxwell_2d(refinements, poly_degree, n_iterations);
maxwell_2d.run();
const hp::QCollection<dim> &q_collection,
const Function<dim> &function)
{
-#ifdef DEBUG
- Assert(fe_collection.size() == 2, ExcInternalError());
- Assert(q_collection.size() == 2, ExcInternalError());
- for (unsigned int f = 0; f < fe_collection.size(); ++f)
- Assert(fe_collection[f].n_components() == function.n_components,
- ExcInternalError());
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ Assert(fe_collection.size() == 2, ExcInternalError());
+ Assert(q_collection.size() == 2, ExcInternalError());
+ for (unsigned int f = 0; f < fe_collection.size(); ++f)
+ Assert(fe_collection[f].n_components() == function.n_components,
+ ExcInternalError());
+ }
// setup
// +---+---+
count[cell->active_fe_index()]++;
deallog << "fe count:" << count << std::endl;
-#ifdef DEBUG
- // check each cell's active FE index by its distance from the center
- for (const auto &cell : dofh.active_cell_iterators())
+ if constexpr (running_in_debug_mode())
{
- const double distance = cell->center().distance(center_cell->center());
- const unsigned int expected_level =
- (sequence.size() - 1) -
- max_difference * static_cast<unsigned int>(std::round(distance));
-
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
+ // check each cell's active FE index by its distance from the center
+ for (const auto &cell : dofh.active_cell_iterators())
+ {
+ const double distance =
+ cell->center().distance(center_cell->center());
+ const unsigned int expected_level =
+ (sequence.size() - 1) -
+ max_difference * static_cast<unsigned int>(std::round(distance));
+
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
}
-#endif
deallog << "OK" << std::endl;
}
}
Assert(center_cell->active_fe_index() == sequence.back(), ExcInternalError());
-#ifdef DEBUG
- // check each cell's active FE index by its distance from the center
- for (const auto &cell : dofh.active_cell_iterators())
+ if constexpr (running_in_debug_mode())
{
- const double distance = cell->center().distance(Point<dim>());
- const unsigned int expected_level =
- (sequence.size() - 1) -
- max_difference * static_cast<unsigned int>(std::round(distance));
-
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
+ // check each cell's active FE index by its distance from the center
+ for (const auto &cell : dofh.active_cell_iterators())
+ {
+ const double distance = cell->center().distance(Point<dim>());
+ const unsigned int expected_level =
+ (sequence.size() - 1) -
+ max_difference * static_cast<unsigned int>(std::round(distance));
+
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
}
-#endif
deallog << "OK" << std::endl;
}
(void)fe_indices_changed;
Assert(fe_indices_changed, ExcInternalError());
-#ifdef DEBUG
- // check each cell's active FE by its h-level
- for (unsigned int l = 0; l < tria.n_levels(); ++l)
- for (const auto &cell : dofh.cell_iterators_on_level(l))
- if (cell->is_active())
- {
- const unsigned int expected_level = std::max(
- 0, static_cast<int>(sequence.size() - 1 - l * max_difference));
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
- }
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // check each cell's active FE by its h-level
+ for (unsigned int l = 0; l < tria.n_levels(); ++l)
+ for (const auto &cell : dofh.cell_iterators_on_level(l))
+ if (cell->is_active())
+ {
+ const unsigned int expected_level = std::max(
+ 0, static_cast<int>(sequence.size() - 1 - l * max_difference));
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
+ }
deallog << "OK" << std::endl;
}
else
this->data = this->shape_info_base;
-#ifdef DEBUG
- this->is_reinitialized = true;
- this->dof_values_initialized = false;
- this->values_quad_initialized = false;
- this->gradients_quad_initialized = false;
- this->hessians_quad_initialized = false;
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ this->is_reinitialized = true;
+ this->dof_values_initialized = false;
+ this->values_quad_initialized = false;
+ this->gradients_quad_initialized = false;
+ this->hessians_quad_initialized = false;
+ }
}
template <int dim,
else
this->data = this->shape_info_base;
-#ifdef DEBUG
- this->is_reinitialized = true;
- this->dof_values_initialized = false;
- this->values_quad_initialized = false;
- this->gradients_quad_initialized = false;
- this->hessians_quad_initialized = false;
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ this->is_reinitialized = true;
+ this->dof_values_initialized = false;
+ this->values_quad_initialized = false;
+ this->gradients_quad_initialized = false;
+ this->hessians_quad_initialized = false;
+ }
}
} // namespace dealii
deallog << " Cumulative dofs per cell: " << dof_counter << std::endl;
}
-#ifdef DEBUG
- parallel::distributed::Triangulation<dim> other_tria(MPI_COMM_WORLD);
- GridGenerator::hyper_cube(other_tria);
- other_tria.refine_global(2);
-
- dh.reinit(other_tria);
- dh.distribute_dofs(fe_collection);
-
- try
+ if constexpr (running_in_debug_mode())
{
- tria.repartition();
+ parallel::distributed::Triangulation<dim> other_tria(MPI_COMM_WORLD);
+ GridGenerator::hyper_cube(other_tria);
+ other_tria.refine_global(2);
+
+ dh.reinit(other_tria);
+ dh.distribute_dofs(fe_collection);
+
+ try
+ {
+ tria.repartition();
+ }
+ catch (const ExceptionBase &e)
+ {
+ deallog << e.get_exc_name() << std::endl;
+ }
}
- catch (const ExceptionBase &e)
+ else
{
- deallog << e.get_exc_name() << std::endl;
+ deallog
+ << "ExcMessage(\"Triangulation associated with the DoFHandler has changed!\")"
+ << std::endl;
}
-#else
- deallog
- << "ExcMessage(\"Triangulation associated with the DoFHandler has changed!\")"
- << std::endl;
-#endif
// make sure no processor is hanging
MPI_Barrier(MPI_COMM_WORLD);
deallog << " Cumulative dofs per cell: " << dof_counter << std::endl;
}
-#ifdef DEBUG
- parallel::distributed::Triangulation<dim> other_tria(MPI_COMM_WORLD);
- GridGenerator::hyper_cube(other_tria);
- other_tria.refine_global(3);
-
- dh.reinit(other_tria);
- dh.distribute_dofs(fe_collection);
-
- try
+ if constexpr (running_in_debug_mode())
{
- tria.repartition();
+ parallel::distributed::Triangulation<dim> other_tria(MPI_COMM_WORLD);
+ GridGenerator::hyper_cube(other_tria);
+ other_tria.refine_global(3);
+
+ dh.reinit(other_tria);
+ dh.distribute_dofs(fe_collection);
+
+ try
+ {
+ tria.repartition();
+ }
+ catch (const ExceptionBase &e)
+ {
+ deallog << e.get_exc_name() << std::endl;
+ }
}
- catch (const ExceptionBase &e)
+ else
{
- deallog << e.get_exc_name() << std::endl;
+ deallog
+ << "ExcMessage(\"Triangulation associated with the DoFHandler has changed!\")"
+ << std::endl;
}
-#else
- deallog
- << "ExcMessage(\"Triangulation associated with the DoFHandler has changed!\")"
- << std::endl;
-#endif
// make sure no processor is hanging
MPI_Barrier(MPI_COMM_WORLD);
deallog << " Cumulative dofs per cell: " << dof_counter << std::endl;
}
-#ifdef DEBUG
- parallel::shared::Triangulation<dim> other_tria(
- MPI_COMM_WORLD,
- ::Triangulation<dim>::none,
- false,
- parallel::shared::Triangulation<dim>::Settings::partition_metis);
- GridGenerator::hyper_cube(other_tria);
- other_tria.refine_global(3);
-
- dh.reinit(other_tria);
- dh.distribute_dofs(fe_collection);
-
- try
+ if constexpr (running_in_debug_mode())
{
- tria.execute_coarsening_and_refinement();
- deallog << "Error: we did not throw an exception when we should have"
- << std::endl;
- std::abort();
+ parallel::shared::Triangulation<dim> other_tria(
+ MPI_COMM_WORLD,
+ ::Triangulation<dim>::none,
+ false,
+ parallel::shared::Triangulation<dim>::Settings::partition_metis);
+ GridGenerator::hyper_cube(other_tria);
+ other_tria.refine_global(3);
+
+ dh.reinit(other_tria);
+ dh.distribute_dofs(fe_collection);
+
+ try
+ {
+ tria.execute_coarsening_and_refinement();
+ deallog << "Error: we did not throw an exception when we should have"
+ << std::endl;
+ std::abort();
+ }
+ catch (const ExceptionBase &e)
+ {
+ deallog << e.get_exc_name() << std::endl;
+ }
}
- catch (const ExceptionBase &e)
+ else
{
- deallog << e.get_exc_name() << std::endl;
+ deallog
+ << "ExcMessage(\"Triangulation associated with the DoFHandler has changed!\")"
+ << std::endl;
}
-#else
- deallog
- << "ExcMessage(\"Triangulation associated with the DoFHandler has changed!\")"
- << std::endl;
-#endif
// make sure no processor is hanging
MPI_Barrier(MPI_COMM_WORLD);
deallog << " Cumulative dofs per cell: " << dof_counter << std::endl;
}
-#ifdef DEBUG
- parallel::shared::Triangulation<dim> other_tria(
- MPI_COMM_WORLD,
- ::Triangulation<dim>::none,
- false,
- parallel::shared::Triangulation<dim>::Settings::partition_metis);
- GridGenerator::hyper_cube(other_tria);
- other_tria.refine_global(3);
-
- dh.reinit(other_tria);
- dh.distribute_dofs(fe_collection);
-
- try
+ if constexpr (running_in_debug_mode())
{
- tria.execute_coarsening_and_refinement();
- deallog << "Error: we did not throw an exception when we should have"
- << std::endl;
- std::abort();
+ parallel::shared::Triangulation<dim> other_tria(
+ MPI_COMM_WORLD,
+ ::Triangulation<dim>::none,
+ false,
+ parallel::shared::Triangulation<dim>::Settings::partition_metis);
+ GridGenerator::hyper_cube(other_tria);
+ other_tria.refine_global(3);
+
+ dh.reinit(other_tria);
+ dh.distribute_dofs(fe_collection);
+
+ try
+ {
+ tria.execute_coarsening_and_refinement();
+ deallog << "Error: we did not throw an exception when we should have"
+ << std::endl;
+ std::abort();
+ }
+ catch (const ExceptionBase &e)
+ {
+ deallog << e.get_exc_name() << std::endl;
+ }
}
- catch (const ExceptionBase &e)
+ else
{
- deallog << e.get_exc_name() << std::endl;
+ deallog
+ << "ExcMessage(\"Triangulation associated with the DoFHandler has changed!\")"
+ << std::endl;
}
-#else
- deallog
- << "ExcMessage(\"Triangulation associated with the DoFHandler has changed!\")"
- << std::endl;
-#endif
// make sure no processor is hanging
MPI_Barrier(MPI_COMM_WORLD);
// set different FE on center cell
cell->set_active_fe_index(1);
-#ifdef DEBUG
- // verify that our scenario is initialized correctly
- // by checking the number of neighbors of the center cell
- unsigned int n_neighbors = 0;
- for (const unsigned int i : GeometryInfo<dim>::face_indices())
- if (static_cast<unsigned int>(cell->neighbor_index(i)) !=
- numbers::invalid_unsigned_int)
- ++n_neighbors;
- Assert(n_neighbors == 3, ExcInternalError());
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // verify that our scenario is initialized correctly
+ // by checking the number of neighbors of the center cell
+ unsigned int n_neighbors = 0;
+ for (const unsigned int i : GeometryInfo<dim>::face_indices())
+ if (static_cast<unsigned int>(cell->neighbor_index(i)) !=
+ numbers::invalid_unsigned_int)
+ ++n_neighbors;
+ Assert(n_neighbors == 3, ExcInternalError());
+ }
}
dh.distribute_dofs(fe_collection);
// set different FE on center cell
cell->set_active_fe_index(1);
-#ifdef DEBUG
- // verify that our scenario is initialized correctly
- // by checking the number of neighbors of the center cell
- unsigned int n_neighbors = 0;
- for (const unsigned int i : GeometryInfo<dim>::face_indices())
- if (static_cast<unsigned int>(cell->neighbor_index(i)) !=
- numbers::invalid_unsigned_int)
- ++n_neighbors;
- Assert(n_neighbors == 3, ExcInternalError());
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // verify that our scenario is initialized correctly
+ // by checking the number of neighbors of the center cell
+ unsigned int n_neighbors = 0;
+ for (const unsigned int i : GeometryInfo<dim>::face_indices())
+ if (static_cast<unsigned int>(cell->neighbor_index(i)) !=
+ numbers::invalid_unsigned_int)
+ ++n_neighbors;
+ Assert(n_neighbors == 3, ExcInternalError());
+ }
}
dh.distribute_dofs(fe_collection);
// set different FE on center cell
cell->set_active_fe_index(1);
-#ifdef DEBUG
- // verify that our scenario is initialized correctly
- // by checking the number of neighbors of the center cell
- unsigned int n_neighbors = 0;
- for (const unsigned int i : GeometryInfo<dim>::face_indices())
- if (static_cast<unsigned int>(cell->neighbor_index(i)) !=
- numbers::invalid_unsigned_int)
- ++n_neighbors;
- Assert(n_neighbors == 3, ExcInternalError());
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // verify that our scenario is initialized correctly
+ // by checking the number of neighbors of the center cell
+ unsigned int n_neighbors = 0;
+ for (const unsigned int i : GeometryInfo<dim>::face_indices())
+ if (static_cast<unsigned int>(cell->neighbor_index(i)) !=
+ numbers::invalid_unsigned_int)
+ ++n_neighbors;
+ Assert(n_neighbors == 3, ExcInternalError());
+ }
}
else if (cell->id().to_string() == "0_0:")
{
DoFTools::make_zero_boundary_constraints(dof_handler, constraints);
-#ifdef DEBUG
- // We did not think about hp-constraints on ghost cells yet.
- // Thus, we are content with verifying their consistency for now.
- const std::vector<IndexSet> locally_owned_dofs_per_processor =
- Utilities::MPI::all_gather(communicator,
- dof_handler.locally_owned_dofs());
-
- const IndexSet locally_active_dofs =
- DoFTools::extract_locally_active_dofs(dof_handler);
-
- AssertThrow(
- constraints.is_consistent_in_parallel(locally_owned_dofs_per_processor,
- locally_active_dofs,
- communicator,
- /*verbose=*/true),
- ExcMessage("AffineConstraints object contains inconsistencies!"));
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // We did not think about hp-constraints on ghost cells yet.
+ // Thus, we are content with verifying their consistency for now.
+ const std::vector<IndexSet> locally_owned_dofs_per_processor =
+ Utilities::MPI::all_gather(communicator,
+ dof_handler.locally_owned_dofs());
+
+ const IndexSet locally_active_dofs =
+ DoFTools::extract_locally_active_dofs(dof_handler);
+
+ AssertThrow(constraints.is_consistent_in_parallel(
+ locally_owned_dofs_per_processor,
+ locally_active_dofs,
+ communicator,
+ /*verbose=*/true),
+ ExcMessage(
+ "AffineConstraints object contains inconsistencies!"));
+ }
constraints.close();
Utilities::MPI::sum(count, tria.get_mpi_communicator(), count);
deallog << "fe count:" << count << std::endl;
-#ifdef DEBUG
- // check each cell's active FE index by its distance from the center
- for (const auto &cell :
- dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ if constexpr (running_in_debug_mode())
{
- const double distance = cell->center().distance(Point<dim>());
- const unsigned int expected_level =
- (sequence.size() - 1) -
- max_difference * static_cast<unsigned int>(std::round(distance));
-
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
+ // check each cell's active FE index by its distance from the center
+ for (const auto &cell :
+ dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ {
+ const double distance = cell->center().distance(Point<dim>());
+ const unsigned int expected_level =
+ (sequence.size() - 1) -
+ max_difference * static_cast<unsigned int>(std::round(distance));
+
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
}
-#endif
deallog << "OK" << std::endl;
}
deallog << "cycle:" << i << ", fe count:" << count << std::endl;
}
-#ifdef DEBUG
- // check each cell's active FE index by its distance from the center
- for (const auto &cell :
- dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ if constexpr (running_in_debug_mode())
{
- const double distance = cell->center().distance(Point<dim>());
- const unsigned int expected_level =
- (sequence.size() - 1) -
- max_difference * static_cast<unsigned int>(std::round(distance));
-
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
+ // check each cell's active FE index by its distance from the center
+ for (const auto &cell :
+ dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ {
+ const double distance = cell->center().distance(Point<dim>());
+ const unsigned int expected_level =
+ (sequence.size() - 1) -
+ max_difference * static_cast<unsigned int>(std::round(distance));
+
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
}
-#endif
deallog << "OK" << std::endl;
}
Assert(fe_indices_changed, ExcInternalError());
-#ifdef DEBUG
- // check each cell's active FE by its h-level
- for (unsigned int l = 0; l < tria.n_global_levels(); ++l)
- for (const auto &cell : dofh.cell_iterators_on_level(l))
- if (cell->is_active() && cell->is_locally_owned())
- {
- const unsigned int expected_level = std::max(
- 0, static_cast<int>(sequence.size() - 1 - l * max_difference));
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
- }
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // check each cell's active FE by its h-level
+ for (unsigned int l = 0; l < tria.n_global_levels(); ++l)
+ for (const auto &cell : dofh.cell_iterators_on_level(l))
+ if (cell->is_active() && cell->is_locally_owned())
+ {
+ const unsigned int expected_level = std::max(
+ 0, static_cast<int>(sequence.size() - 1 - l * max_difference));
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
+ }
deallog << "OK" << std::endl;
}
0,
Functions::ZeroFunction<dim>(),
constraints);
-#ifdef DEBUG
- // We have not dealt with chains of constraints on ghost cells yet.
- // Thus, we are content with verifying their consistency for now.
- std::vector<IndexSet> locally_owned_dofs_per_processor =
- Utilities::MPI::all_gather(dof_handler.get_mpi_communicator(),
- dof_handler.locally_owned_dofs());
-
- const IndexSet locally_active_dofs =
- DoFTools::extract_locally_active_dofs(dof_handler);
-
- AssertThrow(
- constraints.is_consistent_in_parallel(locally_owned_dofs_per_processor,
- locally_active_dofs,
- mpi_communicator,
- /*verbose=*/true),
- ExcMessage("AffineConstraints object contains inconsistencies!"));
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // We have not dealt with chains of constraints on ghost cells yet.
+ // Thus, we are content with verifying their consistency for now.
+ std::vector<IndexSet> locally_owned_dofs_per_processor =
+ Utilities::MPI::all_gather(dof_handler.get_mpi_communicator(),
+ dof_handler.locally_owned_dofs());
+
+ const IndexSet locally_active_dofs =
+ DoFTools::extract_locally_active_dofs(dof_handler);
+
+ AssertThrow(constraints.is_consistent_in_parallel(
+ locally_owned_dofs_per_processor,
+ locally_active_dofs,
+ mpi_communicator,
+ /*verbose=*/true),
+ ExcMessage(
+ "AffineConstraints object contains inconsistencies!"));
+ }
constraints.close();
DynamicSparsityPattern dsp(locally_relevant_dofs);
0,
Functions::ZeroFunction<dim>(),
constraints);
-#ifdef DEBUG
- // We did not think about hp-constraints on ghost cells yet.
- // Thus, we are content with verifying their consistency for now.
- std::vector<IndexSet> locally_owned_dofs_per_processor =
- Utilities::MPI::all_gather(dof_handler.get_mpi_communicator(),
- dof_handler.locally_owned_dofs());
-
- const IndexSet locally_active_dofs =
- DoFTools::extract_locally_active_dofs(dof_handler);
-
- AssertThrow(
- constraints.is_consistent_in_parallel(locally_owned_dofs_per_processor,
- locally_active_dofs,
- mpi_communicator,
- /*verbose=*/true),
- ExcMessage("AffineConstraints object contains inconsistencies!"));
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // We did not think about hp-constraints on ghost cells yet.
+ // Thus, we are content with verifying their consistency for now.
+ std::vector<IndexSet> locally_owned_dofs_per_processor =
+ Utilities::MPI::all_gather(dof_handler.get_mpi_communicator(),
+ dof_handler.locally_owned_dofs());
+
+ const IndexSet locally_active_dofs =
+ DoFTools::extract_locally_active_dofs(dof_handler);
+
+ AssertThrow(constraints.is_consistent_in_parallel(
+ locally_owned_dofs_per_processor,
+ locally_active_dofs,
+ mpi_communicator,
+ /*verbose=*/true),
+ ExcMessage(
+ "AffineConstraints object contains inconsistencies!"));
+ }
constraints.close();
DynamicSparsityPattern dsp(locally_relevant_dofs);
Utilities::MPI::sum(count, tria.get_mpi_communicator(), count);
deallog << "fe count:" << count << std::endl;
-#ifdef DEBUG
- // check each cell's active FE index by its distance from the center
- for (const auto &cell :
- dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ if constexpr (running_in_debug_mode())
{
- const double distance = cell->center().distance(Point<dim>());
- const unsigned int expected_level =
- (sequence.size() - 1) -
- max_difference * static_cast<unsigned int>(std::round(distance));
-
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
+ // check each cell's active FE index by its distance from the center
+ for (const auto &cell :
+ dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ {
+ const double distance = cell->center().distance(Point<dim>());
+ const unsigned int expected_level =
+ (sequence.size() - 1) -
+ max_difference * static_cast<unsigned int>(std::round(distance));
+
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
}
-#endif
deallog << "OK" << std::endl;
}
deallog << "cycle:" << i << ", fe count:" << count << std::endl;
}
-#ifdef DEBUG
- // check each cell's active FE index by its distance from the center
- for (const auto &cell :
- dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ if constexpr (running_in_debug_mode())
{
- const double distance = cell->center().distance(Point<dim>());
- const unsigned int expected_level =
- (sequence.size() - 1) -
- max_difference * static_cast<unsigned int>(std::round(distance));
-
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
+ // check each cell's active FE index by its distance from the center
+ for (const auto &cell :
+ dofh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ {
+ const double distance = cell->center().distance(Point<dim>());
+ const unsigned int expected_level =
+ (sequence.size() - 1) -
+ max_difference * static_cast<unsigned int>(std::round(distance));
+
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
}
-#endif
deallog << "OK" << std::endl;
}
(void)fe_indices_changed;
Assert(fe_indices_changed, ExcInternalError());
-#ifdef DEBUG
- // check each cell's active FE by its h-level
- for (unsigned int l = 0; l < tria.n_global_levels(); ++l)
- for (const auto &cell : dofh.cell_iterators_on_level(l))
- if (cell->is_active() && cell->is_locally_owned())
- {
- const unsigned int expected_level = std::max(
- 0, static_cast<int>(sequence.size() - 1 - l * max_difference));
- Assert(cell->active_fe_index() == sequence[expected_level],
- ExcInternalError());
- }
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // check each cell's active FE by its h-level
+ for (unsigned int l = 0; l < tria.n_global_levels(); ++l)
+ for (const auto &cell : dofh.cell_iterators_on_level(l))
+ if (cell->is_active() && cell->is_locally_owned())
+ {
+ const unsigned int expected_level = std::max(
+ 0, static_cast<int>(sequence.size() - 1 - l * max_difference));
+ Assert(cell->active_fe_index() == sequence[expected_level],
+ ExcInternalError());
+ }
+ }
deallog << "OK" << std::endl;
}
tria.execute_coarsening_and_refinement();
}
-#ifdef DEBUG
- for (const auto &cell : tria.active_cell_iterators())
+ if constexpr (running_in_debug_mode())
{
- const unsigned int coarse_cell_id = cell->id().get_coarse_cell_id();
+ for (const auto &cell : tria.active_cell_iterators())
+ {
+ const unsigned int coarse_cell_id = cell->id().get_coarse_cell_id();
- AssertDimension(cell->level(), n_refinements[coarse_cell_id]);
+ AssertDimension(cell->level(), n_refinements[coarse_cell_id]);
+ }
}
-#endif
}
// add simplex cell in coordinate direction
const unsigned int coordinate = face_no / 2;
-#ifdef DEBUG
- // all vertices should be in a plane
- for (const auto &vertex : vertices)
- Assert(midpoint[coordinate] == vertex[coordinate], ExcInternalError());
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ // all vertices should be in a plane
+ for (const auto &vertex : vertices)
+ Assert(midpoint[coordinate] == vertex[coordinate],
+ ExcInternalError());
+ }
// add another vertex as tip of triangle/pyramid
Point<spacedim> tip = midpoint;
SD::Utilities::print_substitution_map(deallog, substitution_map);
-#ifdef DEBUG
- // Check that exceptions are raised when duplicate symbols
- // are found in a substitution map
- deal_II_exceptions::disable_abort_on_exception();
- try
+ if constexpr (running_in_debug_mode())
{
- SD::add_to_substitution_map(substitution_map,
- std::make_pair(SD::Expression("x14"), 14));
+ // Check that exceptions are raised when duplicate symbols
+ // are found in a substitution map
+ deal_II_exceptions::disable_abort_on_exception();
+ try
+ {
+ SD::add_to_substitution_map(substitution_map,
+ std::make_pair(SD::Expression("x14"),
+ 14));
- deallog << "Duplicate symbol in map did not raise an error." << std::endl;
+ deallog << "Duplicate symbol in map did not raise an error."
+ << std::endl;
+ }
+ catch (const ExcMessage &)
+ {}
}
- catch (const ExcMessage &)
- {}
-#endif
deallog << "OK" << std::endl;
}
SD::merge_substitution_maps(substitution_map, substitution_map_1);
}
-#ifdef DEBUG
- // Check that exceptions are raised when duplicate symbols
- // associated with unequal values are found in a substitution map
- deal_II_exceptions::disable_abort_on_exception();
- try
+ if constexpr (running_in_debug_mode())
{
- {
- SD::types::substitution_map substitution_map;
- SD::add_to_substitution_map(substitution_map,
- SD::Expression("x1"),
- SD::Expression(1));
-
- SD::types::substitution_map substitution_map_1;
- SD::add_to_substitution_map(substitution_map_1,
- SD::Expression("x1"),
- SD::Expression(2));
-
- SD::merge_substitution_maps(substitution_map, substitution_map_1);
- }
-
- deallog
- << "Duplicate symbol with non-equal value in map did not raise an error."
- << std::endl;
+ // Check that exceptions are raised when duplicate symbols
+ // associated with unequal values are found in a substitution map
+ deal_II_exceptions::disable_abort_on_exception();
+ try
+ {
+ {
+ SD::types::substitution_map substitution_map;
+ SD::add_to_substitution_map(substitution_map,
+ SD::Expression("x1"),
+ SD::Expression(1));
+
+ SD::types::substitution_map substitution_map_1;
+ SD::add_to_substitution_map(substitution_map_1,
+ SD::Expression("x1"),
+ SD::Expression(2));
+
+ SD::merge_substitution_maps(substitution_map, substitution_map_1);
+ }
+
+ deallog
+ << "Duplicate symbol with non-equal value in map did not raise an error."
+ << std::endl;
+ }
+ catch (const ExcMessage &)
+ {}
}
- catch (const ExcMessage &)
- {}
-#endif
deallog << "OK" << std::endl;
}
symb_d2psi_ds_x_dv = SD::differentiate(symb_dpsi_ds, symb_v);
symb_d2psi_ds_x_ds = SD::differentiate(symb_dpsi_ds, symb_s);
-#ifdef DEBUG
- print(std::cout, "symb_st", symb_st);
- print(std::cout, "symb_t", symb_t);
- print(std::cout, "symb_v", symb_v);
- print(std::cout, "symb_s", symb_s);
-
- print(std::cout, "symb_psi", symb_psi);
-
- print(std::cout, "symb_dpsi_dst", symb_dpsi_dst);
- print(std::cout, "symb_dpsi_dt", symb_dpsi_dt);
- print(std::cout, "symb_dpsi_dv", symb_dpsi_dv);
- print(std::cout, "symb_dpsi_ds", symb_dpsi_ds);
-
- print(std::cout, "symb_d2psi_dst_x_dst", symb_d2psi_dst_x_dst);
- print(std::cout, "symb_d2psi_dst_x_dt", symb_d2psi_dst_x_dt);
- print(std::cout, "symb_d2psi_dst_x_dv", symb_d2psi_dst_x_dv);
- print(std::cout, "symb_d2psi_dst_x_ds", symb_d2psi_dst_x_ds);
-
- print(std::cout, "symb_d2psi_dt_x_dst", symb_d2psi_dt_x_dst);
- print(std::cout, "symb_d2psi_dt_x_dt", symb_d2psi_dt_x_dt);
- print(std::cout, "symb_d2psi_dt_x_dv", symb_d2psi_dt_x_dv);
- print(std::cout, "symb_d2psi_dt_x_ds", symb_d2psi_dt_x_ds);
-
- print(std::cout, "symb_d2psi_dv_x_dst", symb_d2psi_dv_x_dst);
- print(std::cout, "symb_d2psi_dv_x_dt", symb_d2psi_dv_x_dt);
- print(std::cout, "symb_d2psi_dv_x_dv", symb_d2psi_dv_x_dv);
- print(std::cout, "symb_d2psi_dv_x_ds", symb_d2psi_dv_x_ds);
-
- print(std::cout, "symb_d2psi_ds_x_dst", symb_d2psi_ds_x_dst);
- print(std::cout, "symb_d2psi_ds_x_dt", symb_d2psi_ds_x_dt);
- print(std::cout, "symb_d2psi_ds_x_dv", symb_d2psi_ds_x_dv);
- print(std::cout, "symb_d2psi_ds_x_ds", symb_d2psi_ds_x_ds);
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ print(std::cout, "symb_st", symb_st);
+ print(std::cout, "symb_t", symb_t);
+ print(std::cout, "symb_v", symb_v);
+ print(std::cout, "symb_s", symb_s);
+
+ print(std::cout, "symb_psi", symb_psi);
+
+ print(std::cout, "symb_dpsi_dst", symb_dpsi_dst);
+ print(std::cout, "symb_dpsi_dt", symb_dpsi_dt);
+ print(std::cout, "symb_dpsi_dv", symb_dpsi_dv);
+ print(std::cout, "symb_dpsi_ds", symb_dpsi_ds);
+
+ print(std::cout, "symb_d2psi_dst_x_dst", symb_d2psi_dst_x_dst);
+ print(std::cout, "symb_d2psi_dst_x_dt", symb_d2psi_dst_x_dt);
+ print(std::cout, "symb_d2psi_dst_x_dv", symb_d2psi_dst_x_dv);
+ print(std::cout, "symb_d2psi_dst_x_ds", symb_d2psi_dst_x_ds);
+
+ print(std::cout, "symb_d2psi_dt_x_dst", symb_d2psi_dt_x_dst);
+ print(std::cout, "symb_d2psi_dt_x_dt", symb_d2psi_dt_x_dt);
+ print(std::cout, "symb_d2psi_dt_x_dv", symb_d2psi_dt_x_dv);
+ print(std::cout, "symb_d2psi_dt_x_ds", symb_d2psi_dt_x_ds);
+
+ print(std::cout, "symb_d2psi_dv_x_dst", symb_d2psi_dv_x_dst);
+ print(std::cout, "symb_d2psi_dv_x_dt", symb_d2psi_dv_x_dt);
+ print(std::cout, "symb_d2psi_dv_x_dv", symb_d2psi_dv_x_dv);
+ print(std::cout, "symb_d2psi_dv_x_ds", symb_d2psi_dv_x_ds);
+
+ print(std::cout, "symb_d2psi_ds_x_dst", symb_d2psi_ds_x_dst);
+ print(std::cout, "symb_d2psi_ds_x_dt", symb_d2psi_ds_x_dt);
+ print(std::cout, "symb_d2psi_ds_x_dv", symb_d2psi_ds_x_dv);
+ print(std::cout, "symb_d2psi_ds_x_ds", symb_d2psi_ds_x_ds);
+ }
// It pains me to do this manually...
// This is why we have utility functions to create substitution maps
{
GridGenerator::hyper_shell(
triangulation, Point<dim>(), 0.5, 1., (dim == 3) ? 96 : 12, false);
-#ifdef DEBUG
- triangulation.refine_global(3);
-#else
- triangulation.refine_global(5);
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ triangulation.refine_global(3);
+ }
+ else
+ {
+ triangulation.refine_global(5);
+ }
}
setup_system();
{
GridGenerator::hyper_shell(
triangulation, Point<dim>(), 0.5, 1., (dim == 3) ? 96 : 12, false);
-#ifdef DEBUG
- triangulation.refine_global(3);
-#else
- triangulation.refine_global(5);
-#endif
+ if constexpr (running_in_debug_mode())
+ {
+ triangulation.refine_global(3);
+ }
+ else
+ {
+ triangulation.refine_global(5);
+ }
}
setup_system();