diff --git a/dune/gfe/sumenergy.hh b/dune/gfe/sumenergy.hh new file mode 100644 index 0000000000000000000000000000000000000000..d5074c6fccabf601400974ffe6b4c6e5b533aa64 --- /dev/null +++ b/dune/gfe/sumenergy.hh @@ -0,0 +1,60 @@ +#ifndef DUNE_GFE_SUMENERGY_HH +#define DUNE_GFE_SUMENERGY_HH + +#include <vector> + +#include <dune/gfe/localenergy.hh> +#include <dune/gfe/mixedlocalgeodesicfestiffness.hh> + +namespace Dune::GFE { + + /** + \brief Assembles the a sum of energies for a single element by summing up the energies of each GFE::LocalEnergy. + + This class works similarly to the class Dune::Elasticity::SumEnergy, where Dune::Elasticity::SumEnergy extends + Dune::Elasticity::LocalEnergy and Dune::GFE::SumEnergy extends Dune::GFE::LocalEnergy. + */ + +template<class Basis, class... TargetSpaces> +class SumEnergy + : public Dune::GFE::LocalEnergy<Basis, TargetSpaces...>, + public MixedLocalGeodesicFEStiffness<Basis, TargetSpaces...> + //Inheriting from MixedLocalGeodesicFEStiffness is hack, and will be replaced eventually; once MixedLocalGFEADOLCStiffness + //will be removed and its functionality will be included in LocalGeodesicFEADOLCStiffness this is not needed anymore! + +{ + + using LocalView = typename Basis::LocalView; + using GridView = typename LocalView::GridView; + using DT = typename GridView::Grid::ctype; + using RT = typename Dune::GFE::LocalEnergy<Basis,TargetSpaces...>::RT; + +public: + + /** \brief Default Constructor*/ + SumEnergy() + {} + + void addLocalEnergy(std::shared_ptr<GFE::LocalEnergy<Basis,TargetSpaces...>> localEnergy) + { + localEnergies_.push_back(localEnergy); + } + + RT energy(const typename Basis::LocalView& localView, + const std::vector<TargetSpaces>&... localSolution) const + { + RT sum = 0.; + for ( const auto& localEnergy : localEnergies_ ) + sum += localEnergy->energy( localView, localSolution... ); + + return sum; + } + +private: + // vector containing pointers to the local energies + std::vector<std::shared_ptr<GFE::LocalEnergy<Basis, TargetSpaces...>>> localEnergies_; +}; + +} // namespace Dune::GFE + +#endif //#ifndef DUNE_GFE_SUMENERGY_HH diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 75a0de76eda797c620c95777ab14db4b5a76739f..f03e9b5f9f8a9afe159d914399f4412568fccaa7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ set(programs compute-disc-error rod3d) # rodobstacle) -if (dune-parmg_FOUND) +if (dune-parmg_FOUND AND ${DUNE_ELASTICITY_VERSION} VERSION_GREATER_EQUAL 2.8) set(programs film-on-substrate ${programs}) endif() foreach(_program ${programs}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7f452954c2ce12749383586c23e009bd6a144542..e1952d1af6c8993a4dcc161acec079f6a3436980 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,11 +26,12 @@ dune_add_test(SOURCES harmonicmaptest.cc TIMEOUT 600 CMAKE_GUARD MPI_FOUND) -# Run distributed tests +if (${DUNE_ELASTICITY_VERSION} VERSION_GREATER_EQUAL 2.7) dune_add_test(SOURCES geodesicfeassemblerwrappertest.cc MPI_RANKS 1 4 TIMEOUT 600 CMAKE_GUARD MPI_FOUND) +endif() # Copy the example grid used for testing into the build dir file(COPY grids/irregular-square.msh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/grids)