Skip to content
Snippets Groups Projects
Commit adff9671 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'fix/bugs-when-using-growing-grids' into 'next'

[next] Clear local data before updating objects when grid changed

See merge request !389
parents eb0f7d18 49b85a46
No related branches found
No related tags found
Loading
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
// the contructor in the cc case // the contructor in the cc case
CCSubControlVolume(Geometry&& geometry, CCSubControlVolume(Geometry&& geometry,
IndexType elementIndex) IndexType elementIndex)
: ParentType(), geometry_(std::move(geometry)), elementIndex_(elementIndex) {} : ParentType(), geometry_(std::forward<Geometry>(geometry)), elementIndex_(elementIndex) {}
//! The copy constrcutor //! The copy constrcutor
CCSubControlVolume(const CCSubControlVolume& other) = default; CCSubControlVolume(const CCSubControlVolume& other) = default;
...@@ -95,6 +95,7 @@ public: ...@@ -95,6 +95,7 @@ public:
// e.g. for integration // e.g. for integration
const Geometry& geometry() const const Geometry& geometry() const
{ {
assert((geometry_));
return geometry_.value(); return geometry_.value();
} }
......
...@@ -117,6 +117,8 @@ public: ...@@ -117,6 +117,8 @@ public:
const FVElementGeometry& fvGeometry, const FVElementGeometry& fvGeometry,
const SolutionVector& sol) const SolutionVector& sol)
{ {
clear();
const auto& problem = globalVolVars().problem_(); const auto& problem = globalVolVars().problem_();
const auto globalI = problem.elementMapper().index(element); const auto globalI = problem.elementMapper().index(element);
const auto& assemblyMapI = problem.model().localJacobian().assemblyMap()[globalI]; const auto& assemblyMapI = problem.model().localJacobian().assemblyMap()[globalI];
...@@ -201,6 +203,8 @@ public: ...@@ -201,6 +203,8 @@ public:
const FVElementGeometry& fvGeometry, const FVElementGeometry& fvGeometry,
const SolutionVector& sol) const SolutionVector& sol)
{ {
clear();
auto eIdx = globalVolVars().problem_().elementMapper().index(element); auto eIdx = globalVolVars().problem_().elementMapper().index(element);
volumeVariables_.resize(1); volumeVariables_.resize(1);
volVarIndices_.resize(1); volVarIndices_.resize(1);
...@@ -230,6 +234,12 @@ public: ...@@ -230,6 +234,12 @@ public:
const GlobalVolumeVariables& globalVolVars() const const GlobalVolumeVariables& globalVolVars() const
{ return *globalVolVarsPtr_; } { return *globalVolVarsPtr_; }
//! Clear all local storage
void clear()
{
volVarIndices_.clear();
volumeVariables_.clear();
}
private: private:
const GlobalVolumeVariables* globalVolVarsPtr_; const GlobalVolumeVariables* globalVolVarsPtr_;
......
...@@ -499,17 +499,20 @@ private: ...@@ -499,17 +499,20 @@ private:
} }
//! Clear all local data
void clear() void clear()
{ {
scvIndices_.clear(); scvIndices_.clear();
scvfIndices_.clear(); scvfIndices_.clear();
scvs_.clear(); scvs_.clear();
scvfs_.clear(); scvfs_.clear();
flippedScvfIndices_.clear();
neighborScvIndices_.clear(); neighborScvIndices_.clear();
neighborScvfIndices_.clear(); neighborScvfIndices_.clear();
neighborScvs_.clear(); neighborScvs_.clear();
neighborScvfs_.clear(); neighborScvfs_.clear();
flippedNeighborScvfIndices_.clear();
} }
// the bound element // the bound element
......
...@@ -107,6 +107,7 @@ public: ...@@ -107,6 +107,7 @@ public:
scvs_.clear(); scvs_.clear();
scvfs_.clear(); scvfs_.clear();
scvfIndicesOfScv_.clear(); scvfIndicesOfScv_.clear();
flipScvfIndices_.clear();
elementMap_.clear(); elementMap_.clear();
// determine size of containers // determine size of containers
...@@ -351,7 +352,11 @@ public: ...@@ -351,7 +352,11 @@ public:
void update(const Problem& problem) void update(const Problem& problem)
{ {
problemPtr_ = &problem; problemPtr_ = &problem;
// clear local data
elementMap_.clear(); elementMap_.clear();
scvfIndicesOfScv_.clear();
neighborVolVarIndices_.clear();
// reserve memory or resize the containers // reserve memory or resize the containers
numScvs_ = gridView_.size(0); numScvs_ = gridView_.size(0);
......
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
*/ */
void init(const Problem& problem) void init(const Problem& problem)
{ {
map_.clear();
map_.resize(problem.gridView().size(0)); map_.resize(problem.gridView().size(0));
for (const auto& element : elements(problem.gridView())) for (const auto& element : elements(problem.gridView()))
{ {
...@@ -102,7 +103,9 @@ public: ...@@ -102,7 +103,9 @@ public:
if (it != dataJForI.end()) if (it != dataJForI.end())
it->second.scvfsJ.push_back(scvf.index()); it->second.scvfsJ.push_back(scvf.index());
else else
dataJForI.emplace_back(std::make_pair(globalI, DataJ({globalJ, std::vector<IndexType>({scvf.index()})}))); dataJForI.emplace_back(std::make_pair(globalI, DataJ({globalJ,
std::vector<IndexType>({scvf.index()}),
std::vector<IndexType>()})));
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment