mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-26 03:00:17 -06:00
Merge pull request #780 from akva2/fvbasediscretization_serialize
FvBaseDiscretization: add serialization support
This commit is contained in:
commit
1a0a9cd25e
@ -71,6 +71,7 @@
|
||||
#include <dune/fem/misc/capabilities.hh>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <stdexcept>
|
||||
@ -379,6 +380,7 @@ class FvBaseDiscretization
|
||||
|
||||
using LocalEvalBlockVector = typename LocalResidual::LocalEvalBlockVector;
|
||||
|
||||
public:
|
||||
class BlockVectorWrapper
|
||||
{
|
||||
protected:
|
||||
@ -388,12 +390,37 @@ class FvBaseDiscretization
|
||||
: blockVector_(size)
|
||||
{}
|
||||
|
||||
BlockVectorWrapper() = default;
|
||||
|
||||
static BlockVectorWrapper serializationTestObject()
|
||||
{
|
||||
BlockVectorWrapper result("dummy", 3);
|
||||
result.blockVector_[0] = 1.0;
|
||||
result.blockVector_[1] = 2.0;
|
||||
result.blockVector_[2] = 3.0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SolutionVector& blockVector()
|
||||
{ return blockVector_; }
|
||||
const SolutionVector& blockVector() const
|
||||
{ return blockVector_; }
|
||||
|
||||
bool operator==(const BlockVectorWrapper& wrapper) const
|
||||
{
|
||||
return std::equal(this->blockVector_.begin(), this->blockVector_.end(),
|
||||
wrapper.blockVector_.begin(), wrapper.blockVector_.end());
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(blockVector_);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
#if HAVE_DUNE_FEM
|
||||
using DiscreteFunctionSpace = GetPropType<TypeTag, Properties::DiscreteFunctionSpace> ;
|
||||
|
||||
@ -1869,6 +1896,23 @@ public:
|
||||
const Timer& updateTimer() const
|
||||
{ return updateTimer_; }
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
for (auto& sol : solution_)
|
||||
serializer(*sol);
|
||||
}
|
||||
|
||||
bool operator==(const FvBaseDiscretization& rhs) const
|
||||
{
|
||||
return std::equal(this->solution_.begin(), this->solution_.end(),
|
||||
rhs.solution_.begin(), rhs.solution_.end(),
|
||||
[](const auto& x, const auto& y)
|
||||
{
|
||||
return *x == *y;
|
||||
});
|
||||
}
|
||||
|
||||
protected:
|
||||
void resizeAndResetIntensiveQuantitiesCache_()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user