// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see .
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#include
#include
#include
#include
#include
#include
#include
#include
namespace Opm {
template
void MechContainer::
allocate(const std::size_t bufferSize,
std::map& rstKeywords)
{
this->potentialForce_.resize(bufferSize, 0.0);
rstKeywords["MECHPOTF"] = 0;
this->potentialTempForce_.resize(bufferSize, 0.0);
rstKeywords["TEMPPOTF"] = 0;
this->potentialPressForce_.resize(bufferSize, 0.0);
rstKeywords["PRESPOTF"] = 0;
std::for_each(disp_.begin(), disp_.end(),
[suffix = "XYZ", is = 0, bufferSize, &rstKeywords](auto& v) mutable
{
v.resize(bufferSize, 0.0);
rstKeywords[std::string{"DISP"} + suffix[is++]] = 0;
});
auto resizeAndRegister =
[&rstKeywords,bufferSize](auto& tensor,
const std::string& name)
{
static constexpr auto fields = std::array{
"XX", "YY", "ZZ", "YZ", "XZ", "XY",
};
tensor.resize(bufferSize);
for (const auto& f : fields) {
rstKeywords[name + f] = 0;
}
};
resizeAndRegister(delstress_, "DELSTR");
resizeAndRegister(linstress_, "LINSTR");
resizeAndRegister(strain_, "STRAIN");
resizeAndRegister(stress_, "STRESS");
this->fracstressXX_.resize(bufferSize,0.0);
rstKeywords["FRCSTRXX"] = 0;
this->fracstressYY_.resize(bufferSize,0.0);
rstKeywords["FRCSTRYY"] = 0;
this->fracstressZZ_.resize(bufferSize,0.0);
rstKeywords["FRCSTRZZ"] = 0;
this->fracstressXY_.resize(bufferSize,0.0);
rstKeywords["FRCSTRXY"] = 0;
this->fracstressXZ_.resize(bufferSize,0.0);
rstKeywords["FRCSTRXZ"] = 0;
this->fracstressYZ_.resize(bufferSize,0.0);
rstKeywords["FRCSTRYZ"] = 0;
allocated_ = true;
}
template
void MechContainer::
assignDelStress(const unsigned globalDofIdx,
const Dune::FieldVector& delStress)
{
this->delstress_.assign(globalDofIdx, VoigtContainer(delStress));
}
template
void MechContainer::
assignDisplacement(const unsigned globalDofIdx,
const Dune::FieldVector& disp)
{
this->disp_[0][globalDofIdx] = disp[0];
this->disp_[1][globalDofIdx] = disp[1];
this->disp_[2][globalDofIdx] = disp[2];
}
template
void MechContainer::
assignLinStress(const unsigned globalDofIdx,
const Dune::FieldVector& linStress)
{
this->linstress_.assign(globalDofIdx, VoigtContainer(linStress));
}
template
void MechContainer::
assignPotentialForces(const unsigned globalDofIdx,
const Scalar force,
const Scalar pressForce,
const Scalar tempForce)
{
potentialForce_[globalDofIdx] = force;
potentialPressForce_[globalDofIdx] = pressForce;
potentialTempForce_[globalDofIdx] = tempForce;
}
template
void MechContainer::
assignStrain(const unsigned globalDofIdx,
const Dune::FieldVector& strain)
{
this->strain_.assign(globalDofIdx, VoigtContainer(strain));
}
template
void MechContainer::
assignStress(const unsigned globalDofIdx,
const Dune::FieldVector& stress)
{
this->stress_.assign(globalDofIdx, VoigtContainer(stress));
}
template
void MechContainer::
outputRestart(data::Solution& sol) const
{
if (!allocated_) {
return;
}
using DataEntry = std::tuple*,
const std::array,3>*,
const VoigtArray*>>;
auto doInsert = [&sol](const std::string& name,
const UnitSystem::measure& measure,
const std::vector& entry)
{
if (!entry.empty()) {
sol.insert(name, measure, entry, data::TargetType::RESTART_OPM_EXTENDED);
}
};
const auto solutionVectors = std::array{
DataEntry{"DELSTR", UnitSystem::measure::pressure, &delstress_},
DataEntry{"DISP", UnitSystem::measure::length, &disp_},
DataEntry{"FRCSTRXX", UnitSystem::measure::pressure, &fracstressXX_},
DataEntry{"FRCSTRYY", UnitSystem::measure::pressure, &fracstressYY_},
DataEntry{"FRCSTRZZ", UnitSystem::measure::pressure, &fracstressZZ_},
DataEntry{"FRCSTRXY", UnitSystem::measure::pressure, &fracstressXY_},
DataEntry{"FRCSTRXZ", UnitSystem::measure::pressure, &fracstressXZ_},
DataEntry{"FRCSTRYZ", UnitSystem::measure::pressure, &fracstressYZ_},
DataEntry{"LINSTR", UnitSystem::measure::pressure, &linstress_},
DataEntry{"MECHPOTF", UnitSystem::measure::pressure, &potentialForce_},
DataEntry{"PRESPOTF", UnitSystem::measure::pressure, &potentialPressForce_},
DataEntry{"STRAIN", UnitSystem::measure::identity, &strain_},
DataEntry{"STRESS", UnitSystem::measure::length, &stress_},
DataEntry{"TEMPPOTF", UnitSystem::measure::pressure, &potentialTempForce_},
};
std::for_each(solutionVectors.begin(), solutionVectors.end(),
[&doInsert](const auto& array)
{
std::visit(VisitorOverloadSet{
[&array, &doInsert](const std::vector* v)
{
doInsert(std::get<0>(array), std::get<1>(array), *v);
},
[&array, &doInsert](const std::array,3>* V)
{
const auto& v = *V;
const auto& name = std::get<0>(array);
const auto& measure = std::get<1>(array);
doInsert(name + "X", measure, v[0]);
doInsert(name + "Y", measure, v[1]);
doInsert(name + "Z", measure, v[2]);
},
[&array, &doInsert](const VoigtArray* V)
{
const auto& v = *V;
const auto& name = std::get<0>(array);
const auto& measure = std::get<1>(array);
doInsert(name + "XX", measure, v[VoigtIndex::XX]);
doInsert(name + "YY", measure, v[VoigtIndex::YY]);
doInsert(name + "ZZ", measure, v[VoigtIndex::ZZ]);
doInsert(name + "YZ", measure, v[VoigtIndex::YZ]);
doInsert(name + "XZ", measure, v[VoigtIndex::XZ]);
doInsert(name + "XY", measure, v[VoigtIndex::XY]);
}
}, std::get<2>(array));
}
);
}
template class MechContainer;
#if FLOW_INSTANTIATE_FLOAT
template class MechContainer;
#endif
} // namespace Opm