Initialize tracers based on optional values in TracerConfig

This commit is contained in:
Joakim Hove 2021-11-23 09:11:59 +01:00
parent 6d8223f233
commit 8f31d3150e

View File

@ -47,6 +47,7 @@
#include <ebos/femcpgridcompat.hh> #include <ebos/femcpgridcompat.hh>
#endif #endif
#include <fmt/format.h>
#include <iostream> #include <iostream>
#include <set> #include <set>
#include <stdexcept> #include <stdexcept>
@ -168,24 +169,28 @@ doInit(bool enabled, size_t numGridDof,
//TBLK keyword //TBLK keyword
if (!tracer.free_concentration.empty()){ if (tracer.free_concentration.has_value()){
int tblkDatasize = tracer.free_concentration.size(); const auto& free_concentration = tracer.free_concentration.value();
int tblkDatasize = free_concentration.size();
if (tblkDatasize < cartMapper_.cartesianSize()){ if (tblkDatasize < cartMapper_.cartesianSize()){
throw std::runtime_error("Wrong size of TBLK for" + tracer.name); throw std::runtime_error("Wrong size of TBLK for" + tracer.name);
} }
for (size_t globalDofIdx = 0; globalDofIdx < numGridDof; ++globalDofIdx){ for (size_t globalDofIdx = 0; globalDofIdx < numGridDof; ++globalDofIdx){
int cartDofIdx = cartMapper_.cartesianIndex(globalDofIdx); int cartDofIdx = cartMapper_.cartesianIndex(globalDofIdx);
tracerConcentration_[tracerIdx][globalDofIdx] = tracer.free_concentration[cartDofIdx]; tracerConcentration_[tracerIdx][globalDofIdx] = free_concentration[cartDofIdx];
} }
} }
//TVDPF keyword //TVDPF keyword
else { else if (tracer.free_tvdp.has_value()) {
const auto& free_tvdp = tracer.free_tvdp.value();
for (size_t globalDofIdx = 0; globalDofIdx < numGridDof; ++globalDofIdx){ for (size_t globalDofIdx = 0; globalDofIdx < numGridDof; ++globalDofIdx){
tracerConcentration_[tracerIdx][globalDofIdx] = tracerConcentration_[tracerIdx][globalDofIdx] =
tracer.free_tvdp.evaluate("TRACER_CONCENTRATION", free_tvdp.evaluate("TRACER_CONCENTRATION",
centroids_(globalDofIdx)[2]); centroids_(globalDofIdx)[2]);
} }
} } else
throw std::logic_error(fmt::format("Can not initialize tracer: {}", tracer.name));
++tracerIdx; ++tracerIdx;
} }