28#include <dune/grid/common/gridenums.hh>
30#include <opm/grid/utility/ElementChunks.hpp>
32#include <opm/material/common/MathToolbox.hpp>
35#include <opm/models/tpsa/tpsabaseproperties.hpp>
49template <
class TypeTag>
64 enum { dimWorld = GridView::dimensionworld };
68 enum { disp0Idx = Indices::disp0Idx };
69 enum { rot0Idx = Indices::rot0Idx };
70 enum { solidPres0Idx = Indices::solidPres0Idx };
72 using MaterialState = MaterialStateTPSA<Evaluation>;
74 using DimVector = Dune::FieldVector<Scalar, dimWorld>;
75 using SymTensor = Dune::FieldVector<Scalar, 6>;
84 SolutionVector blockVector_;
107 result.blockVector_[0] = 1.0;
108 result.blockVector_[1] = 2.0;
109 result.blockVector_[2] = 3.0;
120 {
return blockVector_; }
128 {
return blockVector_; }
138 return std::equal(this->blockVector_.begin(), this->blockVector_.end(),
139 wrapper.blockVector_.begin(), wrapper.blockVector_.end());
147 template<
class Serializer>
150 serializer(blockVector_);
163 : linearizer_(std::make_unique<Linearizer>())
164 , newtonMethod_(simulator)
165 , simulator_(simulator)
166 , element_chunks_(simulator.gridView(), Dune::Partitions::all,
ThreadManager::maxThreads())
169 eqWeights_.resize(numEq, 1.0);
173 const std::size_t numDof = simulator_.model().
numGridDof();
174 for (
unsigned timeIdx = 0; timeIdx < historySize; ++timeIdx) {
175 solution_[timeIdx] = std::make_unique<TpsaBlockVectorWrapper>(
"solution", numDof);
185 linearizer_->init(simulator_);
222 auto ghostSync = GhostSyncHandle(
solution(0),
223 simulator_.model().dofMapper());
225 simulator_.gridView().communicate(ghostSync,
226 Dune::InteriorBorder_All_Interface,
227 Dune::ForwardCommunication);
240 const auto& elementMapper = simulator_.model().elementMapper();
242#pragma omp parallel for
244 for (
const auto& chunk : element_chunks_) {
245 for (
const auto& elem : chunk) {
246 const unsigned globalIdx = elementMapper.index(elem);
247 auto& currSol =
solution(0)[globalIdx];
248 setMaterialState_(globalIdx, 0, currSol);
283 return newtonMethod_;
293 return newtonMethod_;
302 const SolutionVector&
solution(
unsigned timeIdx)
const
304 return solution_[timeIdx]->blockVector();
315 return solution_[timeIdx]->blockVector();
324 return simulator_.model().numGridDof();
344 return simulator_.model().dofTotalVolume(globalIdx);
356 return eqWeights_[eqIdx];
367 eqWeights_[eqIdx] = value;
397 const MaterialState&
materialState(
const unsigned globalIdx,
unsigned )
const
399 return materialState_[globalIdx];
411 DimVector
disp(
const unsigned globalIdx,
const bool )
const
414 for (std::size_t i = 0; i < 3; ++i) {
415 d[i] = decay<Scalar>(materialState_[globalIdx].displacement(i));
471 SymTensor
stress(
const unsigned ,
const bool )
const
486 SymTensor
strain(
const unsigned ,
const bool )
const
542 const std::size_t numDof = simulator_.model().numGridDof();
543 materialState_.resize(numDof);
559 void setMaterialState_(
const unsigned globalIdx,
const unsigned , PrimaryVariables& values)
561 auto& dofMaterialState = materialState_[globalIdx];
562 for (
unsigned dirIdx = 0; dirIdx < 3; ++dirIdx) {
563 dofMaterialState.setDisplacement(dirIdx, values.makeEvaluation(disp0Idx + dirIdx, 0));
564 dofMaterialState.setRotation(dirIdx, values.makeEvaluation(rot0Idx + dirIdx, 0));
566 dofMaterialState.setSolidPressure(values.makeEvaluation(solidPres0Idx, 0));
569 std::unique_ptr<Linearizer> linearizer_;
570 NewtonMethod newtonMethod_;
571 Simulator& simulator_;
572 ElementChunks<GridView, Dune::Partitions::All> element_chunks_;
574 std::array<std::unique_ptr<TpsaBlockVectorWrapper>, historySize> solution_;
575 std::vector<Scalar> eqWeights_;
576 std::vector<MaterialState> materialState_;
Data handle for parallel communication which can be used to set the values values of ghost and overla...
Definition gridcommhandles.hh:109
static void registerParameters()
Register all run-time parameters for the Newton method.
Definition newtonmethod.hh:135
Simplifies multi-threaded capabilities.
Definition threadmanager.hpp:36
bool operator==(const TpsaBlockVectorWrapper &wrapper) const
Check if incoming block vector is the same as current.
Definition tpsamodel.hpp:136
static TpsaBlockVectorWrapper serializationTestObject()
Test function for serialization.
Definition tpsamodel.hpp:104
TpsaBlockVectorWrapper()=default
Default constructor.
TpsaBlockVectorWrapper(const std::string &, const std::size_t size)
Constructor.
Definition tpsamodel.hpp:92
void serializeOp(Serializer &serializer)
Serializing operation.
Definition tpsamodel.hpp:148
const SolutionVector & blockVector() const
Get const reference of block vector.
Definition tpsamodel.hpp:127
SolutionVector & blockVector()
Get reference of block vector.
Definition tpsamodel.hpp:119
NewtonMethod & newtonMethod()
Return the Newton method.
Definition tpsamodel.hpp:291
std::size_t numAuxiliaryDof() const
Return number of auxillary degrees of freedom.
Definition tpsamodel.hpp:383
Scalar mechPotentialPressForce(unsigned) const
Output potential pressure forces.
Definition tpsamodel.hpp:513
Scalar mechPotentialForce(unsigned) const
Output potential forces.
Definition tpsamodel.hpp:500
DimVector disp(const unsigned globalIdx, const bool) const
Output displacement vector.
Definition tpsamodel.hpp:411
void finishInit()
Initialize TPSA model.
Definition tpsamodel.hpp:182
void setEqWeight(unsigned eqIdx, Scalar value)
Set weights for equation.
Definition tpsamodel.hpp:365
SymTensor linstress(const unsigned) const
Output linear stress tensor.
Definition tpsamodel.hpp:456
std::size_t numGridDof() const
Return number of degrees of freedom in the grid from the Flow model.
Definition tpsamodel.hpp:322
const Linearizer & linearizer() const
Return the linearizer.
Definition tpsamodel.hpp:261
const NewtonMethod & newtonMethod() const
Return the Newton method.
Definition tpsamodel.hpp:281
std::size_t numAuxiliaryModules() const
Return number of auxillary modules.
Definition tpsamodel.hpp:374
void updateMaterialState(const unsigned)
Update material state for all cells.
Definition tpsamodel.hpp:237
Scalar mechPotentialTempForce(unsigned) const
Output potential temparature forces.
Definition tpsamodel.hpp:526
const SolutionVector & solution(unsigned timeIdx) const
Get reference to history solution vector.
Definition tpsamodel.hpp:302
const MaterialState & materialState(const unsigned globalIdx, unsigned) const
Return current material state.
Definition tpsamodel.hpp:397
Scalar dofTotalVolume(unsigned globalIdx) const
Return the total grid volume from the Flow model.
Definition tpsamodel.hpp:342
void resizeMaterialState_()
Resize material state vector.
Definition tpsamodel.hpp:540
static void registerParameters()
Register runtime parameters.
Definition tpsamodel.hpp:194
SymTensor delstress(const unsigned) const
Output (del?)stress tensor.
Definition tpsamodel.hpp:428
Scalar eqWeight(unsigned, unsigned eqIdx) const
Return equation weights.
Definition tpsamodel.hpp:354
TpsaModel(Simulator &simulator)
Constructor.
Definition tpsamodel.hpp:162
SymTensor strain(const unsigned, const bool) const
Output strain tensor.
Definition tpsamodel.hpp:486
SolutionVector & solution(unsigned timeIdx)
Get reference to history solution vector.
Definition tpsamodel.hpp:313
void prepareTPSA()
Prepare TPSA model for coupled Flow-TPSA scheme.
Definition tpsamodel.hpp:203
SymTensor fractureStress(const unsigned) const
Output fracture stress tensor.
Definition tpsamodel.hpp:442
std::size_t numTotalDof() const
Return the total number of degrees of freedom.
Definition tpsamodel.hpp:331
SymTensor stress(const unsigned, const bool) const
Output stress tensor.
Definition tpsamodel.hpp:471
Linearizer & linearizer()
Return the linearizer.
Definition tpsamodel.hpp:271
void syncOverlap()
Sync primary variables in overlapping cells.
Definition tpsamodel.hpp:214
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:45
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
The Opm property system, traits with inheritance.
Simplifies multi-threaded capabilities.