From 19531d8934bfb169f5858d4f888441cc67bd3efb Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 23 Dec 2020 00:31:02 +0100 Subject: [PATCH 1/6] fix problems after merge --- amdis/BiLinearForm.inc.hpp | 2 +- amdis/ContextGeometry.hpp | 4 ++-- amdis/linearalgebra/mtl/VectorBackend.hpp | 6 +++--- amdis/linearalgebra/petsc/VectorBackend.hpp | 21 +++++++++++---------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/amdis/BiLinearForm.inc.hpp b/amdis/BiLinearForm.inc.hpp index 95d08a03..89384741 100644 --- a/amdis/BiLinearForm.inc.hpp +++ b/amdis/BiLinearForm.inc.hpp @@ -42,7 +42,7 @@ assemble(RowLocalView const& rowLocalView, ColLocalView const& colLocalView, elementMatrix_ = 0; auto const& gv = this->rowBasis().gridView(); - GlobalContext context{gv, rowLocalView.element(), rowLocalView.element().geometry()}; + GlobalContext context{gv, rowLocalView.element(), rowLocalView.element().geometry()}; Traversal::forEachNode(rowLocalView.treeCache(), [&](auto const& rowNode, auto rowTp) { Traversal::forEachNode(colLocalView.treeCache(), [&](auto const& colNode, auto colTp) { diff --git a/amdis/ContextGeometry.hpp b/amdis/ContextGeometry.hpp index 10b3b168..02c0e0a5 100644 --- a/amdis/ContextGeometry.hpp +++ b/amdis/ContextGeometry.hpp @@ -58,7 +58,7 @@ namespace AMDiS }; /// Constructor. Stores pointer to localContext, element, and geometry. - ContextGeometry(LocalContext const& localContext, Element const& element, Geometry const& geometry) + ContextGeometry(LC const& localContext, Element const& element, Geometry const& geometry) : localContext_(&localContext) , element_(&element) , geometry_(&geometry) @@ -175,7 +175,7 @@ namespace AMDiS }; /// Constructor. Stores a copy of gridView and a pointer to element and geometry. - GlobalContext(GridView const& gridView, Element const& element, + GlobalContext(GV const& gridView, Element const& element, Geometry const& geometry) : gridView_(gridView) , element_(&element) diff --git a/amdis/linearalgebra/mtl/VectorBackend.hpp b/amdis/linearalgebra/mtl/VectorBackend.hpp index e9f59a69..87b50178 100644 --- a/amdis/linearalgebra/mtl/VectorBackend.hpp +++ b/amdis/linearalgebra/mtl/VectorBackend.hpp @@ -93,13 +93,13 @@ namespace AMDiS namespace Recursive { template - struct ForEach> : ForEach>> {}; + struct ForEach> : ForEach>> {}; template - struct Transform> : Transform>> {}; + struct Transform> : Transform>> {}; template - struct InnerProduct> : InnerProduct>> {}; + struct InnerProduct> : InnerProduct>> {}; } // end namespace Recursive } // end namespace AMDiS diff --git a/amdis/linearalgebra/petsc/VectorBackend.hpp b/amdis/linearalgebra/petsc/VectorBackend.hpp index 9df7133b..77acf5c9 100644 --- a/amdis/linearalgebra/petsc/VectorBackend.hpp +++ b/amdis/linearalgebra/petsc/VectorBackend.hpp @@ -224,8 +224,8 @@ namespace AMDiS assert(localGhostedVec != nullptr); // A pointer to a contiguous array that contains this processor's portion of the vector data. - PetscScalar *ptr; - VecGetArray(localGhostedVec, &ptr); + PetscScalar const* ptr; + VecGetArrayRead(localGhostedVec, &ptr); for (auto const& dof : localInd) { @@ -240,7 +240,7 @@ namespace AMDiS } } - VecRestoreArray(localGhostedVec, &ptr); + VecRestoreArrayRead(localGhostedVec, &ptr); VecGhostRestoreLocalForm(vector_, &localGhostedVec); } @@ -250,7 +250,7 @@ namespace AMDiS void forEachLocal(Func&& f) const { // A pointer to a contiguous array that contains this processor's portion of the vector data. - PetscScalar *ptr; + PetscScalar const* ptr; VecGetArrayRead(vector_, &ptr); for (size_type i = 0; i < localSize(); ++i) @@ -281,7 +281,7 @@ namespace AMDiS static void transformLocal(PetscVector& vecOut, Operation op, VecIns const&... vecIn) { PetscScalar *ptrOut; - std::array ptrsIn{}; + std::array ptrsIn{}; // Obtain ptrs to internal local arrays VecGetArray(vecOut.vector_, &ptrOut); @@ -289,7 +289,7 @@ namespace AMDiS VecGetArrayRead(std::get(std::tie(vecIn...)).vector_, &ptrsIn[ii]); }); - for (size_type i = 0; i < localSize(); ++i) { + for (size_type i = 0; i < vecOut.localSize(); ++i) { auto idx = vecOut.dofMap_.dofToLocal(i); Ranges::applyIndices([&](auto... ii) { ptrOut[idx] = op(ptrsIn[ii][idx]...); @@ -306,15 +306,16 @@ namespace AMDiS /// Perform the `op1(init, op2(value1, value2))` on the local elements of [in1] and [in2] // [[not collective]] template - static T innerProductLocal (PetscVector const& in1, PetscVector const& in2, T init, BinOp1 op1, BinOp2 op2) + static T innerProductLocal(PetscVector const& in1, PetscVector const& in2, T init, BinOp1 op1, BinOp2 op2) { - PetscScalar *ptr1, *ptr2; + PetscScalar const* ptr1 + PetscScalar const* ptr2; // Obtain ptrs to internal local arrays VecGetArrayRead(in1.vector_, &ptr1); VecGetArrayRead(in2.vector_, &ptr2); - for (size_type i = 0; i < localSize(); ++i) { + for (size_type i = 0; i < in1.localSize(); ++i) { auto idx = in1.dofMap_.dofToLocal(i); init = op1(std::move(init), op2(ptr1[idx], ptr2[idx])); } @@ -419,7 +420,7 @@ namespace AMDiS struct InnerProduct> { template - static T impl (PetscVector const& in1, PetscVector const& in2, T init, BinOp1 op1, BinOp2 op2) + static T impl(PetscVector const& in1, PetscVector const& in2, T init, BinOp1 op1, BinOp2 op2) { return PetscVector::innerProductLocal(in1, in2, std::move(init), op1, op2); } -- GitLab From f5d8c11b45e8ec4e202029563cc893003d9d566f Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 23 Dec 2020 00:46:09 +0100 Subject: [PATCH 2/6] fix some more minor issues --- amdis/LinearForm.inc.hpp | 2 +- amdis/linearalgebra/petsc/VectorBackend.hpp | 2 +- test/OperatorsTest.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/amdis/LinearForm.inc.hpp b/amdis/LinearForm.inc.hpp index e95e9ee9..8690fad3 100644 --- a/amdis/LinearForm.inc.hpp +++ b/amdis/LinearForm.inc.hpp @@ -36,7 +36,7 @@ assemble(LocalView const& localView, LocalOperators& localOperators) elementVector_ = 0; auto const& gv = this->basis().gridView(); - GlobalContext context{gv, localView.element(), localView.element().geometry()}; + GlobalContext context{gv, localView.element(), localView.element().geometry()}; Traversal::forEachNode(localView.treeCache(), [&](auto const& node, auto tp) { auto& rhsOp = localOperators[tp]; diff --git a/amdis/linearalgebra/petsc/VectorBackend.hpp b/amdis/linearalgebra/petsc/VectorBackend.hpp index 77acf5c9..4a7f731d 100644 --- a/amdis/linearalgebra/petsc/VectorBackend.hpp +++ b/amdis/linearalgebra/petsc/VectorBackend.hpp @@ -308,7 +308,7 @@ namespace AMDiS template static T innerProductLocal(PetscVector const& in1, PetscVector const& in2, T init, BinOp1 op1, BinOp2 op2) { - PetscScalar const* ptr1 + PetscScalar const* ptr1; PetscScalar const* ptr2; // Obtain ptrs to internal local arrays diff --git a/test/OperatorsTest.cpp b/test/OperatorsTest.cpp index 2276ae61..99e4a3c3 100644 --- a/test/OperatorsTest.cpp +++ b/test/OperatorsTest.cpp @@ -24,9 +24,9 @@ void test_local_operator(LOp&& lop, LocalView const& localView, MatVec& matVec, [[maybe_unused]] auto context = [&]{ if constexpr(Dune::Std::is_detected_v) - return GlobalContext{gridView, element, geometry}; + return GlobalContext{gridView, element, geometry}; else - return ContextGeometry{element, element, geometry}; + return ContextGeometry{element, element, geometry}; }(); lop.bind(element); -- GitLab From bccb92f8327654173d825acd18a0d45df416bffa Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 23 Dec 2020 11:18:00 +0100 Subject: [PATCH 3/6] Fix merge errors and add ChangeLog --- CHANGELOG.md | 11 +++++++++++ amdis/linearalgebra/petsc/VectorBackend.hpp | 6 +++--- test/CMakeLists.txt | 10 +++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..ad36ea37 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +## Master (will become release v0.4) + +- Restructuring of local operators. Introduce (global) `Operator` class and use type-erasure + for the storage of `LocalOperator`s in the operator list. In the `GridFunctionLocalOperator` + the local-function is passed to the `assemble()` method directly. +- Move recursive algorithms to subdirectoy `amdis/algorithm/` +- Rename `Recursive::Apply` into `Recursive::Map` + +## Release v0.3 + +See release notes on https://gitlab.mn.tu-dresden.de/amdis/amdis-core/-/releases/v0.3 \ No newline at end of file diff --git a/amdis/linearalgebra/petsc/VectorBackend.hpp b/amdis/linearalgebra/petsc/VectorBackend.hpp index 4a7f731d..08550841 100644 --- a/amdis/linearalgebra/petsc/VectorBackend.hpp +++ b/amdis/linearalgebra/petsc/VectorBackend.hpp @@ -224,8 +224,8 @@ namespace AMDiS assert(localGhostedVec != nullptr); // A pointer to a contiguous array that contains this processor's portion of the vector data. - PetscScalar const* ptr; - VecGetArrayRead(localGhostedVec, &ptr); + PetscScalar* ptr; + VecGetArray(localGhostedVec, &ptr); for (auto const& dof : localInd) { @@ -240,7 +240,7 @@ namespace AMDiS } } - VecRestoreArrayRead(localGhostedVec, &ptr); + VecRestoreArray(localGhostedVec, &ptr); VecGhostRestoreLocalForm(vector_, &localGhostedVec); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6cfe6b23..5a869ea3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,8 @@ # set(DUNE_MAX_TEST_CORES 4) +# additional compiler option for CMAKE_BUILD_TYPE=RelWithDebInfo only for gcc +set(NoVarTrackingAssignments $<$,$>:-fno-var-tracking-assignments>) + dune_add_test(SOURCES AdaptInfoTest.cpp LINK_LIBRARIES amdis) @@ -10,10 +13,10 @@ foreach(_GRID RANGE 7) dune_add_test(NAME "BackupRestoreTest_${_GRID}" SOURCES BackupRestoreTest.cpp COMPILE_DEFINITIONS "GRID_ID=${_GRID}" - COMPILE_FLAGS "-fno-var-tracking-assignments" LABELS "BackupRestore" LINK_LIBRARIES amdis) - add_dune_alberta_flags(GRIDDIM 2 WORLDDIM 2 "BackupRestoreTest_${_GRID}") + add_dune_alberta_flags(GRIDDIM 2 WORLDDIM 2 "BackupRestoreTest_${_GRID}") target_compile_options(BackupRestoreTest_${_GRID} PRIVATE + ${NoVarTrackingAssignments}) endforeach() unset(_GRID) @@ -105,12 +108,13 @@ foreach(_GRID RANGE 6) dune_add_test(NAME "ParallelIndexSetTest_${_GRID}" SOURCES ParallelIndexSetTest.cpp COMPILE_DEFINITIONS "GRID_ID=${_GRID}" - COMPILE_FLAGS "-fno-var-tracking-assignments" LABELS "ParallelIndexSetTest" LINK_LIBRARIES amdis MPI_RANKS 2 3 4 TIMEOUT 300 CMAKE_GUARD MPI_FOUND) + target_compile_options(ParallelIndexSetTest_${_GRID} PRIVATE + ${NoVarTrackingAssignments}) endforeach() unset(_GRID) endif() -- GitLab From 2cf21892c73637766ba93162a005cd60b534198d Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 23 Dec 2020 11:21:23 +0100 Subject: [PATCH 4/6] fix CMakeLists --- test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5a869ea3..dd254e75 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,7 +15,8 @@ foreach(_GRID RANGE 7) COMPILE_DEFINITIONS "GRID_ID=${_GRID}" LABELS "BackupRestore" LINK_LIBRARIES amdis) - add_dune_alberta_flags(GRIDDIM 2 WORLDDIM 2 "BackupRestoreTest_${_GRID}") target_compile_options(BackupRestoreTest_${_GRID} PRIVATE + add_dune_alberta_flags(GRIDDIM 2 WORLDDIM 2 "BackupRestoreTest_${_GRID}") + target_compile_options(BackupRestoreTest_${_GRID} PRIVATE ${NoVarTrackingAssignments}) endforeach() unset(_GRID) -- GitLab From 68e21d84090b977cf06328c98754af48ff392890 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 23 Dec 2020 15:28:38 +0100 Subject: [PATCH 5/6] increase clang version to 7 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 929dc0d1..4488bbfe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ dune-2.7: - dunecontrol --current make -j2 examples dune-git-clang: - image: registry.dune-project.org/docker/ci/dune:git-ubuntu-18.04-clang-6-17 + image: registry.dune-project.org/docker/ci/dune:git-debian-10-clang-7-libcpp-17 script: - duneci-standard-test - dunecontrol --current make -j2 examples -- GitLab From b4956cf2cf7bb1ebef594fa822f0587b590f8707 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 26 Dec 2020 17:11:18 +0100 Subject: [PATCH 6/6] Fix missing return bug --- amdis/linearalgebra/petsc/VectorBackend.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/amdis/linearalgebra/petsc/VectorBackend.hpp b/amdis/linearalgebra/petsc/VectorBackend.hpp index 08550841..72ca88d5 100644 --- a/amdis/linearalgebra/petsc/VectorBackend.hpp +++ b/amdis/linearalgebra/petsc/VectorBackend.hpp @@ -323,6 +323,8 @@ namespace AMDiS // Restore array obtained with VecGetArrayRead() VecRestoreArrayRead(in1.vector_, &ptr1); VecRestoreArrayRead(in2.vector_, &ptr2); + + return init; } /// Set all entries to \p value, including the ghost entries -- GitLab