Skip to content
Snippets Groups Projects
Commit ce83e0b9 authored by Bernd Flemisch's avatar Bernd Flemisch Committed by Kilian Weishaupt
Browse files

[io] use static std::arrays instead of std::vectors

parent 19571ab9
No related branches found
No related tags found
1 merge request!1212Feature/iofields
......@@ -77,6 +77,8 @@ public:
static std::string primaryVariableName(int pvIdx, int state)
{
using Indices = typename ModelTraits::Indices;
static constexpr auto numStates = 3;
using StringVec = std::array<std::string, numStates>;
int idxSecComps;
if (state == Indices::firstPhaseOnly
......@@ -89,14 +91,14 @@ public:
return ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(idxSecComps, pvIdx)
: IOName::massFraction<FluidSystem>(idxSecComps, pvIdx);
const std::vector<std::string> p0s1SwitchedPvNames = {
static const StringVec p0s1SwitchedPvNames = {
ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx)
: IOName::massFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx),
ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx)
: IOName::massFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx),
IOName::saturation<FluidSystem>(FluidSystem::phase1Idx)};
const std::vector<std::string> p1s0SwitchedPvNames = {
static const StringVec p1s0SwitchedPvNames = {
ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx)
: IOName::massFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx),
ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx)
......
......@@ -75,49 +75,51 @@ public:
static std::string primaryVariableName(int pvIdx, int state)
{
using Indices = typename ModelTraits::Indices;
static constexpr auto numEq = ModelTraits::numEq();
using StringVec = std::array<std::string, numEq>;
switch (state)
{
case Indices::threePhases:
{
const std::vector<std::string> s1 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
static const StringVec s1 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
return s1[pvIdx];
}
case Indices::wPhaseOnly:
{
const std::vector<std::string> s2 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::wPhaseIdx, FluidSystem::gCompIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::wPhaseIdx, FluidSystem::nCompIdx)};
static const StringVec s2 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::wPhaseIdx, FluidSystem::gCompIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::wPhaseIdx, FluidSystem::nCompIdx)};
return s2[pvIdx];
}
case Indices::gnPhaseOnly:
{
const std::vector<std::string> s3 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::wCompIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
static const StringVec s3 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::wCompIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
return s3[pvIdx];
}
case Indices::wnPhaseOnly:
{
const std::vector<std::string> s4 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::wPhaseIdx, FluidSystem::gCompIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
static const StringVec s4 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::wPhaseIdx, FluidSystem::gCompIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
return s4[pvIdx];
}
case Indices::gPhaseOnly:
{
const std::vector<std::string> s5 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::wCompIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::nCompIdx)};
static const StringVec s5 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::wCompIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::nCompIdx)};
return s5[pvIdx];
}
case Indices::wgPhaseOnly:
{
const std::vector<std::string> s6 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::nCompIdx)};
static const StringVec s6 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::nCompIdx)};
return s6[pvIdx];
}
}
......
......@@ -81,49 +81,51 @@ public:
static std::string primaryVariableName(int pvIdx, int state)
{
using Indices = typename ModelTraits::Indices;
static constexpr auto numEq = ModelTraits::numEq();
using StringVec = std::array<std::string, numEq>;
switch (state)
{
case Indices::threePhases:
{
const std::vector<std::string> s1 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
static const StringVec s1 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
return s1[pvIdx];
}
case Indices::wPhaseOnly:
{
const std::vector<std::string> s2 = {IOName::pressure<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::temperature(),
IOName::moleFraction<FluidSystem>(FluidSystem::wPhaseIdx, FluidSystem::nCompIdx)};
static const StringVec s2 = {IOName::pressure<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::temperature(),
IOName::moleFraction<FluidSystem>(FluidSystem::wPhaseIdx, FluidSystem::nCompIdx)};
return s2[pvIdx];
}
case Indices::gnPhaseOnly:
{
const std::vector<std::string> s3 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::nPhaseIdx, FluidSystem::wCompIdx)};
static const StringVec s3 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::nPhaseIdx, FluidSystem::wCompIdx)};
return s3[pvIdx];
}
case Indices::wnPhaseOnly:
{
const std::vector<std::string> s4 = {IOName::pressure<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::temperature(),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
static const StringVec s4 = {IOName::pressure<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::temperature(),
IOName::saturation<FluidSystem>(FluidSystem::nPhaseIdx)};
return s4[pvIdx];
}
case Indices::gPhaseOnly:
{
const std::vector<std::string> s5 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::temperature(),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::nCompIdx)};
static const StringVec s5 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::temperature(),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::nCompIdx)};
return s5[pvIdx];
}
case Indices::wgPhaseOnly:
{
const std::vector<std::string> s6 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::nCompIdx)};
static const StringVec s6 = {IOName::pressure<FluidSystem>(FluidSystem::gPhaseIdx),
IOName::saturation<FluidSystem>(FluidSystem::wPhaseIdx),
IOName::moleFraction<FluidSystem>(FluidSystem::gPhaseIdx, FluidSystem::nCompIdx)};
return s6[pvIdx];
}
}
......
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