From: Wolfgang Bangerth Date: Tue, 27 Aug 2019 00:42:07 +0000 (-0600) Subject: Rule out the use of postprocessors when using complex-valued solutions. X-Git-Tag: v9.2.0-rc1~1120^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1194f81c93406cf89b275e958b09a1f1d2082f70;p=dealii.git Rule out the use of postprocessors when using complex-valued solutions. --- diff --git a/source/numerics/data_out.cc b/source/numerics/data_out.cc index ac12a40afd..7dd2dbe345 100644 --- a/source/numerics/data_out.cc +++ b/source/numerics/data_out.cc @@ -161,26 +161,34 @@ DataOut::build_one_patch( if (postprocessor != nullptr) { - // we have to postprocess the data, so determine, which fields + // We have to postprocess the data, so determine, which fields // have to be updated const UpdateFlags update_flags = postprocessor->get_needed_update_flags(); - if (n_components == 1) + + if ((n_components == 1) && + (this->dof_data[dataset]->is_complex_valued() == false)) { - // at each point there is only one component of value, - // gradient etc. + // At each point there is only one component of value, + // gradient etc. Based on the 'if' statement above, we + // know that the solution is scalar and real-valued, so + // we do not need to worry about getting any imaginary + // components to the postprocessor, and we can safely + // call the function that evaluates a scalar field if (update_flags & update_values) this->dof_data[dataset]->get_function_values( this_fe_patch_values, internal::DataOutImplementation::ComponentExtractor:: real_part, scratch_data.patch_values_scalar.solution_values); + if (update_flags & update_gradients) this->dof_data[dataset]->get_function_gradients( this_fe_patch_values, internal::DataOutImplementation::ComponentExtractor:: real_part, scratch_data.patch_values_scalar.solution_gradients); + if (update_flags & update_hessians) this->dof_data[dataset]->get_function_hessians( this_fe_patch_values, @@ -188,6 +196,8 @@ DataOut::build_one_patch( real_part, scratch_data.patch_values_scalar.solution_hessians); + // Also fill some of the other fields postprocessors may + // want to access. if (update_flags & update_quadrature_points) scratch_data.patch_values_scalar.evaluation_points = this_fe_patch_values.get_quadrature_points(); @@ -200,6 +210,8 @@ DataOut::build_one_patch( scratch_data.patch_values_scalar .template set_cell(dh_cell); + // Finally call the postprocessor's function that + // deals with scalar inputs. postprocessor->evaluate_scalar_field( scratch_data.patch_values_scalar, scratch_data.postprocessed_values[dataset]); @@ -208,27 +220,46 @@ DataOut::build_one_patch( { scratch_data.resize_system_vectors(n_components); - // at each point there is a vector valued function and its - // derivative... - if (update_flags & update_values) - this->dof_data[dataset]->get_function_values( - this_fe_patch_values, - internal::DataOutImplementation::ComponentExtractor:: - real_part, - scratch_data.patch_values_system.solution_values); - if (update_flags & update_gradients) - this->dof_data[dataset]->get_function_gradients( - this_fe_patch_values, - internal::DataOutImplementation::ComponentExtractor:: - real_part, - scratch_data.patch_values_system.solution_gradients); - if (update_flags & update_hessians) - this->dof_data[dataset]->get_function_hessians( - this_fe_patch_values, - internal::DataOutImplementation::ComponentExtractor:: - real_part, - scratch_data.patch_values_system.solution_hessians); + // At each point we now have to evaluate a vector valued + // function and its derivatives. It may be that the solution + // is scalar and complex-valued, but we treat this as a vector + // field with two components. + + // At this point, we need to ask how we fill the fields that + // we want to pass on to the postprocessor. If the field in + // question is real-valued, we'll just extract the (only) + // real component from the solution fields + if (this->dof_data[dataset]->is_complex_valued() == false) + { + if (update_flags & update_values) + this->dof_data[dataset]->get_function_values( + this_fe_patch_values, + internal::DataOutImplementation::ComponentExtractor:: + real_part, + scratch_data.patch_values_system.solution_values); + + if (update_flags & update_gradients) + this->dof_data[dataset]->get_function_gradients( + this_fe_patch_values, + internal::DataOutImplementation::ComponentExtractor:: + real_part, + scratch_data.patch_values_system.solution_gradients); + + if (update_flags & update_hessians) + this->dof_data[dataset]->get_function_hessians( + this_fe_patch_values, + internal::DataOutImplementation::ComponentExtractor:: + real_part, + scratch_data.patch_values_system.solution_hessians); + } + else + { + // The solution is complex-valued. We don't currently + // know how to handle this. + Assert(false, ExcNotImplemented()); + } + // Now set other fields we may need if (update_flags & update_quadrature_points) scratch_data.patch_values_system.evaluation_points = this_fe_patch_values.get_quadrature_points();