From: Wolfgang Bangerth Date: Tue, 8 May 2018 14:41:54 +0000 (+0800) Subject: Obtain the correct size for an output vector from the source, rather than from an... X-Git-Tag: v9.1.0-rc1~1165^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=426782081424ba70d17c1a4f90876cde094bc335;p=dealii.git Obtain the correct size for an output vector from the source, rather than from an output array. --- diff --git a/include/deal.II/numerics/data_out_dof_data.templates.h b/include/deal.II/numerics/data_out_dof_data.templates.h index 11c2b7c3c5..3f259adce5 100644 --- a/include/deal.II/numerics/data_out_dof_data.templates.h +++ b/include/deal.II/numerics/data_out_dof_data.templates.h @@ -651,15 +651,28 @@ namespace internal } else { - std::vector > tmp(patch_values_system.size()); - for (unsigned int i = 0; i < patch_values_system.size(); i++) - tmp[i].reinit(patch_values_system[i].size()); + // OK, so we know that the data type stored by the user-provided + // vector is not simply a double. In that case, we need to + // ask the FEValuesBase object to extract function values for + // us from the evaluation points in the provided data + // type, and then copy them by hand into the output location. + const unsigned int n_components = fe_patch_values.get_fe().n_components(); + const unsigned int n_eval_points = fe_patch_values.n_quadrature_points; + + std::vector > tmp(n_eval_points); + for (unsigned int i = 0; i < n_eval_points; i++) + tmp[i].reinit(n_components); fe_patch_values.get_function_values (*vector, tmp); - for (unsigned int i = 0; i < patch_values_system.size(); i++) - for (unsigned int j=0; j > > - tmp(patch_gradients_system.size()); - for (unsigned int i = 0; i < tmp.size(); i++) - tmp[i].resize(patch_gradients_system[i].size()); + tmp(n_eval_points); + for (unsigned int i = 0; i < n_eval_points; i++) + tmp[i].resize(n_components); fe_patch_values.get_function_gradients (*vector, tmp); - for (unsigned int i = 0; i < tmp.size(); i++) - for (unsigned int j = 0; j < tmp[i].size(); j++) - patch_gradients_system[i][j] = get_component (tmp[i][j], extract_component); + AssertDimension (patch_gradients_system.size(), n_eval_points); + for (unsigned int i = 0; i < n_eval_points; i++) + { + AssertDimension (patch_gradients_system[i].size(), n_components); + + for (unsigned int j = 0; j < n_components; j++) + patch_gradients_system[i][j] = get_component (tmp[i][j], extract_component); + } } } @@ -800,17 +826,30 @@ namespace internal } else { + // OK, so we know that the data type stored by the user-provided + // vector is not simply a double. In that case, we need to + // ask the FEValuesBase object to extract function values for + // us from the evaluation points in the provided data + // type, and then copy them by hand into the output location. + const unsigned int n_components = fe_patch_values.get_fe().n_components(); + const unsigned int n_eval_points = fe_patch_values.n_quadrature_points; + std::vector > > - tmp(patch_hessians_system.size()); - for (unsigned int i = 0; i < tmp.size(); i++) - tmp[i].resize(patch_hessians_system[i].size()); + tmp(n_eval_points); + for (unsigned int i = 0; i < n_eval_points; i++) + tmp[i].resize(n_components); fe_patch_values.get_function_hessians (*vector, tmp); - for (unsigned int i = 0; i < tmp.size(); i++) - for (unsigned int j = 0; j < tmp[i].size(); j++) - patch_hessians_system[i][j] = get_component (tmp[i][j], extract_component); + AssertDimension (patch_hessians_system.size(), n_eval_points); + for (unsigned int i = 0; i < n_eval_points; i++) + { + AssertDimension (patch_hessians_system[i].size(), n_components); + + for (unsigned int j = 0; j < n_components; j++) + patch_hessians_system[i][j] = get_component (tmp[i][j], extract_component); + } } }