The TS-GitLab will have to shut down towards the end of the year — please think about migrating your projects to GitLab.com or GitHub.
(This is still a very early message, meant to keep you informed. There will be more urgent ones in the future.)

Commit 73b6e41d authored by Lukas Riedel's avatar Lukas Riedel

Use vector as storage and update constructor in FlowParameters

* Use vector for direct random access.
* Update copy-constructor. Also copy cache.
parent ebbc64b0
......@@ -71,7 +71,7 @@ private:
using ScaleAdapter = Dorie::ScalingAdapter<Traits>;
/// Storage for parameters and skaling factors
using ParameterStorage = std::unordered_map<Index,
using ParameterStorage = std::vector<
std::tuple<std::shared_ptr<Parameterization>, Scaling>
>;
......@@ -109,29 +109,28 @@ private:
public:
/// Copy constructor for flow parameters.
/** Create a level grid view of level 0, create a mapper on it, and store
* the config tree.
/** Create a deep copy of the associated parameterizations.
* \param other Object to copy from
*/
FlowParameters (
const FlowParameters& flow_param
const FlowParameters& other
):
_config(flow_param._config),
_gv(flow_param._gv),
_log(flow_param._log),
_mapper(flow_param._mapper),
_gravity(flow_param._gravity)
_config(other._config),
_gv(other._gv),
_log(other._log),
_mapper(other._mapper),
_cache(other._cache),
_gravity(other._gravity)
{
// copy parameterization map
this->_param.clear();
for(const auto& [index, tuple] : flow_param._param) {
const auto& [p, sk] = tuple;
// make a hard copy of parameterization
std::shared_ptr<RichardsParameterization<Traits>> _p = p->clone();
this->_param.emplace(index,std::make_tuple(_p,sk));
_param.reserve(other._param.size());
for (auto&& tuple : other._param) {
const auto& [p, sc] = tuple;
_param.emplace_back(std::make_tuple(p->clone(), sc));
}
}
/// Copy constructor
/// Construct a new object
/** Create a level grid view of level 0, create a mapper on it, and store
* the config tree.
* \param config Configuration file tree
......@@ -185,7 +184,7 @@ public:
entity = entity.father();
}
const auto index = _mapper.index(entity);
_cache = _param.find(index)->second;
_cache = _param[index];
}
/// Return a scaled version of the Conductivity function
......@@ -270,6 +269,7 @@ private:
_gv.grid().leafGridView());
// insert parameterization and global scaling for each element
_param.resize(element_index_map.size());
for (auto&& elem : elements(_gv))
{
// evaluate element index and position
......@@ -279,7 +279,7 @@ private:
// read values and insert
const auto p = parameterization_map.at(element_index_map.at(index));
const auto scale = scaling_adapter->evaluate(pos);
_param.emplace(index,std::make_tuple(p, scale));
_param.at(index) = std::make_tuple(p, scale);
}
// check that mapper can map to parameterization
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment