mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Also copy flags, and helper function with test.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <opm/simulators/aquifers/AquiferGridUtils.hpp>
|
||||
|
||||
#include <opm/simulators/flow/partitionCells.hpp>
|
||||
#include <opm/simulators/flow/priVarsPacking.hpp>
|
||||
#include <opm/simulators/flow/SubDomain.hpp>
|
||||
|
||||
#include <opm/simulators/linalg/extractMatrix.hpp>
|
||||
@@ -266,7 +267,22 @@ public:
|
||||
const auto& comm = model_.ebosSimulator().vanguard().grid().comm();
|
||||
if (comm.size() > 1) {
|
||||
const auto& ccomm = model_.ebosSimulator().model().newtonMethod().linearSolver().comm();
|
||||
|
||||
// Copy numerical values from primary vars.
|
||||
ccomm->copyOwnerToAll(solution, solution);
|
||||
|
||||
// Copy flags from primary vars.
|
||||
const std::size_t num = solution.size();
|
||||
Dune::BlockVector<std::size_t> allmeanings(num);
|
||||
for (std::size_t ii = 0; ii < num; ++ii) {
|
||||
allmeanings[ii] = PVUtil::pack(solution[ii]);
|
||||
}
|
||||
ccomm->copyOwnerToAll(allmeanings, allmeanings);
|
||||
for (std::size_t ii = 0; ii < num; ++ii) {
|
||||
PVUtil::unPack(solution[ii], allmeanings[ii]);
|
||||
}
|
||||
|
||||
// Update intensive quantities for our overlap values.
|
||||
model_.ebosSimulator().model().invalidateAndUpdateIntensiveQuantitiesOverlap(/*timeIdx=*/0);
|
||||
}
|
||||
|
||||
|
||||
54
opm/simulators/flow/priVarsPacking.hpp
Normal file
54
opm/simulators/flow/priVarsPacking.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright 2023 Total SE
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_PRIVARSPACKING_HEADER_INCLUDED
|
||||
#define OPM_PRIVARSPACKING_HEADER_INCLUDED
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
namespace PVUtil {
|
||||
constexpr int fbits = 4;
|
||||
|
||||
template <class PV>
|
||||
std::size_t pack(const PV& privar) {
|
||||
std::size_t m1 = static_cast<std::size_t>(privar.primaryVarsMeaningWater());
|
||||
std::size_t m2 = static_cast<std::size_t>(privar.primaryVarsMeaningPressure());
|
||||
std::size_t m3 = static_cast<std::size_t>(privar.primaryVarsMeaningGas());
|
||||
std::size_t m4 = static_cast<std::size_t>(privar.primaryVarsMeaningBrine());
|
||||
return m1 + (m2 << fbits*1) + (m3 << fbits*2) + (m4 << fbits*3);
|
||||
}
|
||||
|
||||
template <class PV>
|
||||
void unPack(PV& privar, const std::size_t meanings) {
|
||||
const std::size_t filter = ((1 << fbits) - 1);
|
||||
std::size_t m1 = (meanings >> fbits*0) & filter;
|
||||
std::size_t m2 = (meanings >> fbits*1) & filter;
|
||||
std::size_t m3 = (meanings >> fbits*2) & filter;
|
||||
std::size_t m4 = (meanings >> fbits*3) & filter;
|
||||
privar.setPrimaryVarsMeaningWater(typename PV::WaterMeaning(m1));
|
||||
privar.setPrimaryVarsMeaningPressure(typename PV::PressureMeaning(m2));
|
||||
privar.setPrimaryVarsMeaningGas(typename PV::GasMeaning(m3));
|
||||
privar.setPrimaryVarsMeaningBrine(typename PV::BrineMeaning(m4));
|
||||
}
|
||||
} // namespace PVMeanings
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_PRIVARSPACKING_HEADER_INCLUDED
|
||||
Reference in New Issue
Block a user