OGS 6.1.0-1699-ge946d4c5f
HydroMechanicsLocalAssemblerInterface.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <utility>
13 #include <vector>
14 
15 #include "BaseLib/Error.h"
16 
18 
21 
22 namespace ProcessLib
23 {
24 namespace LIE
25 {
26 namespace HydroMechanics
27 {
31 {
32 public:
34  bool const is_axially_symmetric,
35  std::size_t n_local_size,
36  std::vector<unsigned>
37  dofIndex_to_localIndex)
38  : _element(element),
39  _is_axially_symmetric(is_axially_symmetric),
40  _dofIndex_to_localIndex(std::move(dofIndex_to_localIndex))
41  {
42  _local_u.resize(n_local_size);
43  _local_udot.resize(n_local_size);
44  _local_b.resize(_local_u.size());
45  _local_J.resize(_local_u.size(), _local_u.size());
46  }
47 
48  void assemble(double const /*t*/, std::vector<double> const& /*local_x*/,
49  std::vector<double>& /*local_M_data*/,
50  std::vector<double>& /*local_K_data*/,
51  std::vector<double>& /*local_rhs_data*/) override
52  {
53  OGS_FATAL(
54  "HydroMechanicsLocalAssembler: assembly without jacobian is not "
55  "implemented.");
56  }
57 
58  void assembleWithJacobian(double const t,
59  std::vector<double> const& local_x_,
60  std::vector<double> const& local_xdot_,
61  const double /*dxdot_dx*/, const double /*dx_dx*/,
62  std::vector<double>& /*local_M_data*/,
63  std::vector<double>& /*local_K_data*/,
64  std::vector<double>& local_b_data,
65  std::vector<double>& local_Jac_data) override
66  {
67  auto const local_dof_size = local_x_.size();
68 
69  _local_u.setZero();
70  for (unsigned i = 0; i < local_dof_size; i++)
71  {
72  _local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
73  }
74  _local_udot.setZero();
75  for (unsigned i = 0; i < local_dof_size; i++)
76  {
77  _local_udot[_dofIndex_to_localIndex[i]] = local_xdot_[i];
78  }
79  _local_b.setZero();
80  _local_J.setZero();
81 
83  _local_J);
84 
85  local_b_data.resize(local_dof_size);
86  for (unsigned i = 0; i < local_dof_size; i++)
87  {
88  local_b_data[i] = _local_b[_dofIndex_to_localIndex[i]];
89  }
90 
91  local_Jac_data.resize(local_dof_size * local_dof_size);
92  for (unsigned i = 0; i < local_dof_size; i++)
93  {
94  for (unsigned j = 0; j < local_dof_size; j++)
95  {
96  local_Jac_data[i * local_dof_size + j] = _local_J(
98  }
99  }
100  }
101 
103  const double t, std::vector<double> const& local_x_) override
104  {
105  auto const local_dof_size = local_x_.size();
106 
107  _local_u.setZero();
108  for (unsigned i = 0; i < local_dof_size; i++)
109  {
110  _local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
111  }
112 
114  }
115 
116 protected:
117  virtual void assembleWithJacobianConcrete(double const t,
118  Eigen::VectorXd const& local_u,
119  Eigen::VectorXd const& local_udot,
120  Eigen::VectorXd& local_b,
121  Eigen::MatrixXd& local_J) = 0;
122 
124  double const t, Eigen::VectorXd const& local_u) = 0;
125 
128 
129 private:
130  Eigen::VectorXd _local_u;
131  Eigen::VectorXd _local_udot;
132  Eigen::VectorXd _local_b;
133  Eigen::MatrixXd _local_J;
134  // a vector for mapping the index in the local DoF vector to the index in
135  // the complete local solution vector which also include nodes where DoF are
136  // not assigned.
137  std::vector<unsigned> const _dofIndex_to_localIndex;
138 };
139 
140 } // namespace HydroMechanics
141 } // namespace LIE
142 } // namespace ProcessLib
HydroMechanicsLocalAssemblerInterface(MeshLib::Element const &element, bool const is_axially_symmetric, std::size_t n_local_size, std::vector< unsigned > dofIndex_to_localIndex)
void assembleWithJacobian(double const t, std::vector< double > const &local_x_, std::vector< double > const &local_xdot_, const double, const double, std::vector< double > &, std::vector< double > &, std::vector< double > &local_b_data, std::vector< double > &local_Jac_data) override
void assemble(double const, std::vector< double > const &, std::vector< double > &, std::vector< double > &, std::vector< double > &) override
virtual void computeSecondaryVariableConcreteWithVector(double const t, Eigen::VectorXd const &local_u)=0
void computeSecondaryVariableConcrete(const double t, std::vector< double > const &local_x_) override
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
Definition of the Element class.
virtual void assembleWithJacobianConcrete(double const t, Eigen::VectorXd const &local_u, Eigen::VectorXd const &local_udot, Eigen::VectorXd &local_b, Eigen::MatrixXd &local_J)=0