diff --git a/src/mesh/ItemValueSynchronizer.hpp b/src/mesh/ItemValueSynchronizer.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e4189014fdf1ce26b21d493bebe28dcd847ecffc --- /dev/null +++ b/src/mesh/ItemValueSynchronizer.hpp @@ -0,0 +1,32 @@ +#ifndef ITEM_VALUE_SYNCHRONIZER_HPP +#define ITEM_VALUE_SYNCHRONIZER_HPP + +#include <ItemValue.hpp> +#include <Connectivity.hpp> + +class ItemValueSynchronizer +{ + public: + template <typename DataType, + ItemType item_type, + typename ConnectivityPtr> + PASTIS_INLINE + void synchronize(ItemValue<DataType, item_type, ConnectivityPtr>& item_value) + { + pout() << "Calling synchronize...\n"; + auto connectivity_ptr = item_value.connectivity_ptr(); + Assert(connectivity_ptr.use_count()>0, "No connectivity is associated to this ItemValue"); + parallel::barrier(); + parallel::Messenger::destroy(); + pout() << __FILE__ << ':' << __LINE__ << ": NIY!\n"; + std::exit(0); + } + + PASTIS_INLINE + ItemValueSynchronizer() + { + ; + } +}; + +#endif // ITEM_VALUE_SYNCHRONIZER_HPP diff --git a/src/mesh/ItemValueUtils.hpp b/src/mesh/ItemValueUtils.hpp index 26d05a37bf975eb39544002c89bbaafcac30d0f5..cd1110fe78461856f5f82d31ab12789322776d07 100644 --- a/src/mesh/ItemValueUtils.hpp +++ b/src/mesh/ItemValueUtils.hpp @@ -6,6 +6,8 @@ #include <Connectivity.hpp> +#include <ItemValueSynchronizer.hpp> + template <typename DataType, ItemType item_type> std::remove_const_t<DataType> @@ -282,4 +284,16 @@ sum(const ItemValue<DataType, item_type>& item_value) return parallel::allReduceSum(local_sum); } +template <typename DataType, + ItemType item_type, + typename ConnectivityPtr> +void synchronize(ItemValue<DataType, item_type, ConnectivityPtr>& item_value) +{ + static_assert(not std::is_const_v<DataType>, "cannot synchronize ItemValue of const data"); + if (parallel::size() > 1) { + ItemValueSynchronizer synchronizer; + synchronizer.synchronize(item_value); + } +} + #endif // ITEM_VALUE_UTILS_HPP diff --git a/src/scheme/AcousticSolver.hpp b/src/scheme/AcousticSolver.hpp index 142b6f03b973b96037e50a42fb12c175213c912a..cb83a583bc6fb4ec064dace3a75964816b6d7b20 100644 --- a/src/scheme/AcousticSolver.hpp +++ b/src/scheme/AcousticSolver.hpp @@ -210,13 +210,16 @@ class AcousticSolver computeAjr(rhocj, Cjr, ljr, njr); NodeValuePerCell<const Rdd> Ajr = m_Ajr; - const NodeValue<const Rdd> Ar = computeAr(Ajr); - const NodeValue<const Rd> br = computeBr(m_Ajr, Cjr, uj, pj); + this->computeAr(Ajr); + this->computeBr(m_Ajr, Cjr, uj, pj); this->applyBoundaryConditions(); + synchronize(m_Ar); + synchronize(m_br); + NodeValue<Rd>& ur = m_ur; - ur = computeUr(Ar, br); + ur = computeUr(m_Ar, m_br); computeFjr(m_Ajr, ur, Cjr, uj, pj); }