From: Wolfgang Bangerth Date: Mon, 20 Jul 2015 18:22:51 +0000 (-0500) Subject: Update the code in a way that makes it clearer. X-Git-Tag: v8.4.0-rc2~740^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc0dfd0096ed4770e4933a51c3a7c22112669c3b;p=dealii.git Update the code in a way that makes it clearer. Specifically, don't modify an input argument of the function but instead use the old value and just modify the conditions in which it is used. This makes it clearer when certain actions have to be performed. --- diff --git a/source/fe/fe_poly_tensor.cc b/source/fe/fe_poly_tensor.cc index 05503ad986..d150565226 100644 --- a/source/fe/fe_poly_tensor.cc +++ b/source/fe/fe_poly_tensor.cc @@ -423,24 +423,26 @@ FE_PolyTensor::fill_fe_values ( if (mapping_type == mapping_raviart_thomas) get_face_sign_change_rt (cell, this->dofs_per_face, sign_change); - else if (mapping_type == mapping_nedelec) get_face_sign_change_nedelec (cell, this->dofs_per_face, sign_change); - // for Piola mapping, the similarity - // concept cannot be used because of - // possible sign changes from one cell to - // the next. - if ( (mapping_type == mapping_piola) || (mapping_type == mapping_raviart_thomas) - || (mapping_type == mapping_nedelec)) - if (cell_similarity == CellSimilarity::translation) - cell_similarity = CellSimilarity::none; + for (unsigned int i=0; idofs_per_cell; ++i) { const unsigned int first = data.shape_function_to_row_table[i * this->n_components() + this->get_nonzero_components(i).first_selected_component()]; - if (flags & update_values && cell_similarity != CellSimilarity::translation) + // update the shape function values as necessary + // + // we only need to do this if the current cell is not a translation of + // the previous one; or, even if it is a translation, if we use mappings + // other than the standard mappings that require us to recompute values + // and derivatives because of possible sign changes + if (flags & update_values && + ((cell_similarity != CellSimilarity::translation) + || + ((mapping_type == mapping_piola) || (mapping_type == mapping_raviart_thomas) + || (mapping_type == mapping_nedelec)))) switch (mapping_type) { case mapping_none: @@ -495,7 +497,14 @@ FE_PolyTensor::fill_fe_values ( Assert(false, ExcNotImplemented()); } - if (flags & update_gradients && cell_similarity != CellSimilarity::translation) + // update gradients. apply the same logic as above + if (flags & update_gradients + && + ((cell_similarity != CellSimilarity::translation) + || + ((mapping_type == mapping_piola) || (mapping_type == mapping_raviart_thomas) + || (mapping_type == mapping_nedelec)))) + { std::vector > shape_grads1 (n_q_points); //std::vector > shape_grads2 (n_q_points); @@ -583,7 +592,14 @@ FE_PolyTensor::fill_fe_values ( } } - if (flags & update_hessians && cell_similarity != CellSimilarity::translation) + // finally update second derivatives. again apply the same logic + // as above regarding when this has to happen + if (flags & update_hessians + && + ((cell_similarity != CellSimilarity::translation) + || + ((mapping_type == mapping_piola) || (mapping_type == mapping_raviart_thomas) + || (mapping_type == mapping_nedelec)))) this->compute_2nd (mapping, cell, typename QProjector::DataSetDescriptor().cell(), mapping_data, fe_data, data);