25 #ifndef TPSA_MODEL_HPP 26 #define TPSA_MODEL_HPP 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> 49 template <
class TypeTag>
64 enum { dimWorld = GridView::dimensionworld };
65 enum { historySize = getPropValue<TypeTag, Properties::SolutionHistorySizeTPSA>() };
66 enum { numEq = getPropValue<TypeTag, Properties::NumEqTPSA>() };
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:105
Simplifies multi-threaded capabilities.
Definition: threadmanager.hpp:35
static void registerParameters()
Register all run-time parameters for the Newton method.
Definition: newtonmethod.hh:135
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
std::size_t numGridDof() const
Return number of degrees of freedom in the grid from the Flow model.
Definition: tpsamodel.hpp:322
const SolutionVector & solution(unsigned timeIdx) const
Get reference to history solution vector.
Definition: tpsamodel.hpp:302
Scalar mechPotentialTempForce(unsigned) const
Output potential temparature forces.
Definition: tpsamodel.hpp:526
const NewtonMethod & newtonMethod() const
Return the Newton method.
Definition: tpsamodel.hpp:281
void resizeMaterialState_()
Resize material state vector.
Definition: tpsamodel.hpp:540
Definition: fvbaseprimaryvariables.hh:161
Scalar eqWeight(unsigned, unsigned eqIdx) const
Return equation weights.
Definition: tpsamodel.hpp:354
Scalar mechPotentialForce(unsigned) const
Output potential forces.
Definition: tpsamodel.hpp:500
std::size_t numAuxiliaryModules() const
Return number of auxillary modules.
Definition: tpsamodel.hpp:374
bool operator==(const TpsaBlockVectorWrapper &wrapper) const
Check if incoming block vector is the same as current.
Definition: tpsamodel.hpp:136
Small block vector wrapper class for model solutions.
Definition: tpsamodel.hpp:81
void setEqWeight(unsigned eqIdx, Scalar value)
Set weights for equation.
Definition: tpsamodel.hpp:365
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
SymTensor stress(const unsigned, const bool) const
Output stress tensor.
Definition: tpsamodel.hpp:471
SolutionVector & blockVector()
Get reference of block vector.
Definition: tpsamodel.hpp:119
static TpsaBlockVectorWrapper serializationTestObject()
Test function for serialization.
Definition: tpsamodel.hpp:104
const SolutionVector & blockVector() const
Get const reference of block vector.
Definition: tpsamodel.hpp:127
TpsaModel(Simulator &simulator)
Constructor.
Definition: tpsamodel.hpp:162
std::size_t numAuxiliaryDof() const
Return number of auxillary degrees of freedom.
Definition: tpsamodel.hpp:383
TpsaBlockVectorWrapper()=default
Default constructor.
void updateMaterialState(const unsigned)
Update material state for all cells.
Definition: tpsamodel.hpp:237
const Linearizer & linearizer() const
Return the linearizer.
Definition: tpsamodel.hpp:261
SymTensor delstress(const unsigned) const
Output (del?)stress tensor.
Definition: tpsamodel.hpp:428
SolutionVector & solution(unsigned timeIdx)
Get reference to history solution vector.
Definition: tpsamodel.hpp:313
SymTensor strain(const unsigned, const bool) const
Output strain tensor.
Definition: tpsamodel.hpp:486
NewtonMethod & newtonMethod()
Return the Newton method.
Definition: tpsamodel.hpp:291
void syncOverlap()
Sync primary variables in overlapping cells.
Definition: tpsamodel.hpp:214
void finishInit()
Initialize TPSA model.
Definition: tpsamodel.hpp:182
SymTensor fractureStress(const unsigned) const
Output fracture stress tensor.
Definition: tpsamodel.hpp:442
The Opm property system, traits with inheritance.
std::size_t numTotalDof() const
Return the total number of degrees of freedom.
Definition: tpsamodel.hpp:331
Simplifies multi-threaded capabilities.
DimVector disp(const unsigned globalIdx, const bool) const
Output displacement vector.
Definition: tpsamodel.hpp:411
void prepareTPSA()
Prepare TPSA model for coupled Flow-TPSA scheme.
Definition: tpsamodel.hpp:203
Scalar mechPotentialPressForce(unsigned) const
Output potential pressure forces.
Definition: tpsamodel.hpp:513
SymTensor linstress(const unsigned) const
Output linear stress tensor.
Definition: tpsamodel.hpp:456
TpsaBlockVectorWrapper(const std::string &, const std::size_t size)
Constructor.
Definition: tpsamodel.hpp:92
const MaterialState & materialState(const unsigned globalIdx, unsigned) const
Return current material state.
Definition: tpsamodel.hpp:397
void serializeOp(Serializer &serializer)
Serializing operation.
Definition: tpsamodel.hpp:148
Linearizer & linearizer()
Return the linearizer.
Definition: tpsamodel.hpp:271
TPSA geomechanics model.
Definition: tpsamodel.hpp:50
static void registerParameters()
Register runtime parameters.
Definition: tpsamodel.hpp:194
Scalar dofTotalVolume(unsigned globalIdx) const
Return the total grid volume from the Flow model.
Definition: tpsamodel.hpp:342