From 4aa785f6316dd7fa9f3019f0994be5e55acb30a2 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 1 Oct 2015 15:02:51 -0500 Subject: [PATCH] Further simplify code. Since MappingQ is now no longer derived from MappingQ1, we can simplify the implementation of the MappingQ::transform functions. --- source/fe/mapping_q.cc | 85 ++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/source/fe/mapping_q.cc b/source/fe/mapping_q.cc index e2162e64f6..ed051a5ad4 100644 --- a/source/fe/mapping_q.cc +++ b/source/fe/mapping_q.cc @@ -311,18 +311,17 @@ transform (const VectorSlice > > input, VectorSlice > > output) const { AssertDimension (input.size(), output.size()); - Assert ((dynamic_cast::InternalData *> (&mapping_data) + Assert ((dynamic_cast::InternalData *> (&mapping_data) != 0), ExcInternalError()); + const InternalData *data = dynamic_cast(&mapping_data); - // If it is a genuine MappingQ::InternalData, we have to test further - // whether we should in fact work on the Q1 portion of it - if (const InternalData *data = dynamic_cast(&mapping_data)) - if (data->use_mapping_q1_on_current_cell) - return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); - - // otherwise just stick with what we already had - MappingQGeneric::transform(input, mapping_type, mapping_data, output); + // check whether we should in fact work on the Q1 portion of it + if (data->use_mapping_q1_on_current_cell) + return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); + else + // otherwise use the full mapping + MappingQGeneric::transform(input, mapping_type, mapping_data, output); } @@ -336,18 +335,17 @@ transform (const VectorSlice VectorSlice > > output) const { AssertDimension (input.size(), output.size()); - Assert ((dynamic_cast::InternalData *> (&mapping_data) + Assert ((dynamic_cast::InternalData *> (&mapping_data) != 0), ExcInternalError()); + const InternalData *data = dynamic_cast(&mapping_data); - // If it is a genuine MappingQ::InternalData, we have to test further - // whether we should in fact work on the Q1 portion of it - if (const InternalData *data = dynamic_cast(&mapping_data)) - if (data->use_mapping_q1_on_current_cell) - return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); - - // otherwise just stick with what we already had - MappingQGeneric::transform(input, mapping_type, mapping_data, output); + // check whether we should in fact work on the Q1 portion of it + if (data->use_mapping_q1_on_current_cell) + return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); + else + // otherwise use the full mapping + MappingQGeneric::transform(input, mapping_type, mapping_data, output); } @@ -359,18 +357,17 @@ transform (const VectorSlice > > input, VectorSlice > > output) const { AssertDimension (input.size(), output.size()); - Assert ((dynamic_cast::InternalData *> (&mapping_data) + Assert ((dynamic_cast::InternalData *> (&mapping_data) != 0), ExcInternalError()); + const InternalData *data = dynamic_cast(&mapping_data); - // If it is a genuine MappingQ::InternalData, we have to test further - // whether we should in fact work on the Q1 portion of it - if (const InternalData *data = dynamic_cast(&mapping_data)) - if (data->use_mapping_q1_on_current_cell) - return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); - - // otherwise just stick with what we already had - MappingQGeneric::transform(input, mapping_type, mapping_data, output); + // check whether we should in fact work on the Q1 portion of it + if (data->use_mapping_q1_on_current_cell) + return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); + else + // otherwise use the full mapping + MappingQGeneric::transform(input, mapping_type, mapping_data, output); } @@ -384,18 +381,17 @@ transform (const VectorSlice VectorSlice > > output) const { AssertDimension (input.size(), output.size()); - Assert ((dynamic_cast::InternalData *> (&mapping_data) + Assert ((dynamic_cast::InternalData *> (&mapping_data) != 0), ExcInternalError()); + const InternalData *data = dynamic_cast(&mapping_data); - // If it is a genuine MappingQ::InternalData, we have to test further - // whether we should in fact work on the Q1 portion of it - if (const InternalData *data = dynamic_cast(&mapping_data)) - if (data->use_mapping_q1_on_current_cell) - return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); - - // otherwise just stick with what we already had - MappingQGeneric::transform(input, mapping_type, mapping_data, output); + // check whether we should in fact work on the Q1 portion of it + if (data->use_mapping_q1_on_current_cell) + return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); + else + // otherwise use the full mapping + MappingQGeneric::transform(input, mapping_type, mapping_data, output); } @@ -407,18 +403,17 @@ transform (const VectorSlice > > input, VectorSlice > > output) const { AssertDimension (input.size(), output.size()); - Assert ((dynamic_cast::InternalData *> (&mapping_data) + Assert ((dynamic_cast::InternalData *> (&mapping_data) != 0), ExcInternalError()); + const InternalData *data = dynamic_cast(&mapping_data); - // If it is a genuine MappingQ::InternalData, we have to test further - // whether we should in fact work on the Q1 portion of it - if (const InternalData *data = dynamic_cast(&mapping_data)) - if (data->use_mapping_q1_on_current_cell) - return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); - - // otherwise just stick with what we already had - MappingQGeneric::transform(input, mapping_type, mapping_data, output); + // check whether we should in fact work on the Q1 portion of it + if (data->use_mapping_q1_on_current_cell) + return q1_mapping->transform (input, mapping_type, *data->mapping_q1_data, output); + else + // otherwise use the full mapping + MappingQGeneric::transform(input, mapping_type, mapping_data, output); } -- 2.39.5