From: Jean-Paul Pelteret Date: Mon, 11 Jan 2021 20:43:44 +0000 (+0100) Subject: Add get_laplacians to MeshWorker::ScratchData X-Git-Tag: v9.3.0-rc1~331^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11898%2Fhead;p=dealii.git Add get_laplacians to MeshWorker::ScratchData --- diff --git a/doc/news/changes/minor/20211012Jean-PaulPelteret-2 b/doc/news/changes/minor/20211012Jean-PaulPelteret-2 new file mode 100644 index 0000000000..444796d5c8 --- /dev/null +++ b/doc/news/changes/minor/20211012Jean-PaulPelteret-2 @@ -0,0 +1,5 @@ +New: The MeshWorker::ScratchData class is now able to compute the Laplacians +of the scalar-valued and vector-valued components of the solution vector. +
+(Jean-Paul Pelteret, 2021/03/13) + diff --git a/include/deal.II/meshworker/scratch_data.h b/include/deal.II/meshworker/scratch_data.h index 2d7b3b5255..13af08e5f8 100644 --- a/include/deal.II/meshworker/scratch_data.h +++ b/include/deal.II/meshworker/scratch_data.h @@ -751,6 +751,35 @@ namespace MeshWorker const Extractor & variable, const Number dummy = Number(0)); + /** + * For the solution vector identified by @p global_vector_name, compute + * the Laplacians of the function at the quadrature points, and return a + * vector with the correct type deduced by the Extractor you passed as the + * @p variable argument. + * + * Before you can call this method, you need to call the + * extract_local_dof_values() method at least once, passing the same + * @p global_vector_name string, and the same type for the variable @p dummy. + * + * If you have not previously called the extract_local_dof_values() method, + * this function will throw an exception. + * + * For this function to work properly, the underlying FEValues, + * FEFaceValues, or FESubfaceValues object for which you called one of the + * reinit() functions, must have computed the information you are + * requesting. To do so, the update_hessians flag must be an element of the + * list of UpdateFlags that you passed to the constructor of this object. + * See "The interplay of UpdateFlags, Mapping, and FiniteElement" in + * the documentation of the FEValues class for more information. + */ + template + const std::vector< + typename internal::OutputType:: + laplacian_type> & + get_laplacians(const std::string &global_vector_name, + const Extractor & variable, + const Number dummy = Number(0)); + /** * For the solution vector identified by @p global_vector_name, compute * the third_derivatives of the function at the quadrature points, and @@ -1130,6 +1159,45 @@ namespace MeshWorker + template + template + const std::vector< + typename internal::OutputType:: + laplacian_type> & + ScratchData::get_laplacians( + const std::string &global_vector_name, + const Extractor & variable, + const Number dummy) + { + const std::vector &independent_local_dofs = + get_local_dof_values(global_vector_name, dummy); + + const FEValuesBase &fev = get_current_fe_values(); + + const unsigned int n_q_points = fev.n_quadrature_points; + + const std::string name = get_unique_name( + global_vector_name, variable, "_laplacians_q", n_q_points, dummy); + + // Now build the return type + using RetType = std::vector< + typename internal::OutputType:: + laplacian_type>; + + RetType &ret = + internal_data_storage.template get_or_add_object_with_name( + name, n_q_points); + + + AssertDimension(ret.size(), n_q_points); + + fev[variable].get_function_laplacians_from_local_dof_values( + independent_local_dofs, ret); + return ret; + } + + + template template const std::vector<