From: Johannes Heinz <43043310+jh66637@users.noreply.github.com> Date: Thu, 11 Jan 2024 08:54:47 +0000 (+0100) Subject: Make FERemoteEvaluation work for FCL X-Git-Tag: relicensing~128^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16435%2Fhead;p=dealii.git Make FERemoteEvaluation work for FCL --- diff --git a/include/deal.II/matrix_free/fe_remote_evaluation.h b/include/deal.II/matrix_free/fe_remote_evaluation.h index 94ef418901..5e1a4b2fcf 100644 --- a/include/deal.II/matrix_free/fe_remote_evaluation.h +++ b/include/deal.II/matrix_free/fe_remote_evaluation.h @@ -218,11 +218,11 @@ struct FERemoteCommunicationObjectEntityBatches /** * Similar as @c FERemoteCommunicationObjectEntityBatches. * To relate the points from @c RemotePointEvaluation to - * quadrature points on corresponding cells, cell iterators + * quadrature points on corresponding entities, entity indices * have to be stored. */ template -struct FERemoteCommunicationObjectCells +struct FERemoteCommunicationObject { /** * Object that is reinitialized with the remote points we want to access. @@ -230,27 +230,27 @@ struct FERemoteCommunicationObjectCells std::shared_ptr> rpe; /** - * A vector that stores the cell iterators related to the the remote points. + * A vector that stores the entity indices related to the the remote points. */ - std::vector::cell_iterator> cells; + std::vector indices; /** - * Function that gives access to @c cells. The function is only used + * Function that gives access to @c indices. The function is only used * for a unified access to the vector that stores additional information on * the points that are processed via @c rpe. */ - std::vector::cell_iterator> + std::vector get_communication_object_pntrs() const; }; /** - * Similar as @c FERemoteCommunicationObjectCells. + * Similar as @c FERemoteCommunicationObject. * To relate the points from @c RemotePointEvaluation to * quadrature points on corresponding faces, cell iterators * and face numbers have to be stored. */ template -struct FERemoteCommunicationObjectFaces +struct FERemoteCommunicationObjectTwoLevel { /** * Object that is reinitialized with the remote points we want to access. @@ -293,6 +293,17 @@ public: const std::pair &face_batch_range, const std::vector> &quadrature_vector); + /** + * This function stores given communication objects + * and constructs a @c PrecomputedEvaluationDataView + * object if remote points are related to faces. + */ + void + reinit_faces( + const std::vector> &comm_objects, + const std::pair &face_range, + const std::vector> &quadrature_vector); + /** * This function stores given communication objects * and constructs a @c PrecomputedEvaluationDataView @@ -302,10 +313,12 @@ public: template void reinit_faces( - const std::vector> &comm_objects, + const std::vector> &comm_objects, const IteratorRange &cell_iterator_range, const std::vector>> &quadrature_vector); + + /** * Fill the fields stored in PrecomputedEvaluationData. */ @@ -339,8 +352,8 @@ private: * A variant for all possible communication objects. */ std::vector, - FERemoteCommunicationObjectCells, - FERemoteCommunicationObjectFaces>> + FERemoteCommunicationObject, + FERemoteCommunicationObjectTwoLevel>> communication_objects; /** @@ -352,19 +365,18 @@ private: public: /** * Copy data from @c src to @c dst. Overload for @c - * FERemoteCommunicationObjectCells. + * FERemoteCommunicationObject. */ template static void - copy_data( - const internal::PrecomputedEvaluationDataView &view, - AlignedVector &dst, - const std::vector &src, - const std::vector::cell_iterator> &cells); + copy_data(const internal::PrecomputedEvaluationDataView &view, + AlignedVector &dst, + const std::vector &src, + const std::vector &indices); /** * Copy data from @c src to @c dst. Overload for @c - * FERemoteCommunicationObjectFaces. + * FERemoteCommunicationObjectTwoLevel. */ template static void @@ -651,15 +663,15 @@ FERemoteCommunicationObjectEntityBatches::get_communication_object_pntrs() } template -std::vector::cell_iterator> -FERemoteCommunicationObjectCells::get_communication_object_pntrs() const +std::vector +FERemoteCommunicationObject::get_communication_object_pntrs() const { - return cells; + return indices; } template std::vector::cell_iterator, unsigned int>> -FERemoteCommunicationObjectFaces::get_communication_object_pntrs() const +FERemoteCommunicationObjectTwoLevel::get_communication_object_pntrs() const { return cell_face_nos; } @@ -695,13 +707,38 @@ FERemoteEvaluationCommunicator::reinit_faces( } } +template +void +FERemoteEvaluationCommunicator::reinit_faces( + const std::vector> &comm_objects, + const std::pair &face_range, + const std::vector> &quadrature_vector) +{ + // erase type + communication_objects.clear(); + for (const auto &co : comm_objects) + communication_objects.push_back(co); + + const unsigned int n_faces = quadrature_vector.size(); + AssertDimension(n_faces, face_range.second - face_range.first); + + // construct view: + view.start = face_range.first; + + view.ptrs.resize(n_faces + 1); + + view.ptrs[0] = 0; + for (unsigned int face = 0; face < n_faces; ++face) + view.ptrs[face + 1] = view.ptrs[face] + quadrature_vector[face].size(); +} + template template void FERemoteEvaluationCommunicator::reinit_faces( - const std::vector> &comm_objects, - const IteratorRange &cell_iterator_range, - const std::vector>> &quadrature_vector) + const std::vector> &comm_objects, + const IteratorRange &cell_iterator_range, + const std::vector>> &quadrature_vector) { // erase type communication_objects.clear(); @@ -810,18 +847,17 @@ template template void FERemoteEvaluationCommunicator::CopyInstructions::copy_data( - const internal::PrecomputedEvaluationDataView &view, - AlignedVector &dst, - const std::vector &src, - const std::vector::cell_iterator> &cells) + const internal::PrecomputedEvaluationDataView &view, + AlignedVector &dst, + const std::vector &src, + const std::vector &indices) { dst.resize(view.size()); unsigned int c = 0; - for (const auto &cell : cells) + for (const auto idx : indices) { - for (unsigned int j = view.get_shift(cell->active_cell_index()); - j < view.get_shift(cell->active_cell_index() + 1); + for (unsigned int j = view.get_shift(idx); j < view.get_shift(idx + 1); ++j, ++c) { AssertIndexRange(j, dst.size()); diff --git a/tests/matrix_free/fe_remote_evaluation_01.cc b/tests/matrix_free/fe_remote_evaluation_01.cc index 278d1a6a02..f2e1ce4d6d 100644 --- a/tests/matrix_free/fe_remote_evaluation_01.cc +++ b/tests/matrix_free/fe_remote_evaluation_01.cc @@ -206,7 +206,7 @@ FERemoteEvaluationCommunicator construct_comm_for_cell_face_nos(const MatrixFree &matrix_free) { // Setup Communication objects for all boundary faces - FERemoteCommunicationObjectFaces co; + FERemoteCommunicationObjectTwoLevel co; // Get range of boundary face indices const auto face_batch_range = diff --git a/tests/matrix_free/fe_remote_evaluation_02.cc b/tests/matrix_free/fe_remote_evaluation_02.cc index d4b5fdb14a..50a61634e0 100644 --- a/tests/matrix_free/fe_remote_evaluation_02.cc +++ b/tests/matrix_free/fe_remote_evaluation_02.cc @@ -208,7 +208,7 @@ FERemoteEvaluationCommunicator construct_comm_for_cell_face_nos(const MatrixFree &matrix_free) { // Setup Communication objects for all boundary faces - FERemoteCommunicationObjectFaces co; + FERemoteCommunicationObjectTwoLevel co; // Get range of boundary face indices const auto face_batch_range =