OGS
HydroMechanicsLocalAssemblerInterface.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <utility>
7#include <vector>
8
9#include "BaseLib/Error.h"
14
15namespace ProcessLib
16{
17namespace LIE
18{
19namespace HydroMechanics
20{
21
23template <typename ShapeMatrixType>
25{
26 std::vector<ShapeMatrixType, Eigen::aligned_allocator<ShapeMatrixType>> N;
27};
28
32{
33public:
35 MeshLib::Element const& element,
36 bool const is_axially_symmetric,
37 NumLib::GenericIntegrationMethod const& integration_method,
38 std::size_t n_local_size,
39 std::vector<unsigned>
40 dofIndex_to_localIndex)
41 : _element(element),
42 _is_axially_symmetric(is_axially_symmetric),
43 _integration_method(integration_method),
44 _dofIndex_to_localIndex(std::move(dofIndex_to_localIndex))
45 {
46 _local_u.resize(n_local_size);
47 _local_u_prev.resize(n_local_size);
48 _local_b.resize(_local_u.size());
49 _local_J.resize(_local_u.size(), _local_u.size());
50 }
51
52 void assemble(double const /*t*/, double const /*dt*/,
53 std::vector<double> const& /*local_x*/,
54 std::vector<double> const& /*local_x_prev*/,
55 std::vector<double>& /*local_M_data*/,
56 std::vector<double>& /*local_K_data*/,
57 std::vector<double>& /*local_rhs_data*/) override
58 {
60 "HydroMechanicsLocalAssembler: assembly without jacobian is not "
61 "implemented.");
62 }
63
64 void assembleWithJacobian(double const t, double const dt,
65 std::vector<double> const& local_x_,
66 std::vector<double> const& local_x_prev_,
67 std::vector<double>& local_b_data,
68 std::vector<double>& local_Jac_data) override
69 {
70 auto const local_dof_size = local_x_.size();
71
72 _local_u.setZero();
73 for (unsigned i = 0; i < local_dof_size; i++)
74 {
75 _local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
76 }
77 _local_u_prev.setZero();
78 for (unsigned i = 0; i < local_dof_size; i++)
79 {
80 _local_u_prev[_dofIndex_to_localIndex[i]] = local_x_prev_[i];
81 }
82 _local_b.setZero();
83 _local_J.setZero();
84
86 _local_J);
87
88 local_b_data.resize(local_dof_size);
89 for (unsigned i = 0; i < local_dof_size; i++)
90 {
91 local_b_data[i] = _local_b[_dofIndex_to_localIndex[i]];
92 }
93
94 local_Jac_data.resize(local_dof_size * local_dof_size);
95 for (unsigned i = 0; i < local_dof_size; i++)
96 {
97 for (unsigned j = 0; j < local_dof_size; j++)
98 {
99 local_Jac_data[i * local_dof_size + j] = _local_J(
101 }
102 }
103 }
104
105 void postTimestepConcrete(Eigen::VectorXd const& local_x_,
106 Eigen::VectorXd const& /*local_x_prev*/,
107 const double t, double const dt,
108 int const /*process_id*/) override
109 {
110 _local_u.setZero();
111 for (Eigen::Index i = 0; i < local_x_.rows(); i++)
112 {
113 _local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
114 }
115
117 }
118
119 virtual std::vector<double> const& getIntPtSigma(
120 const double t,
121 std::vector<GlobalVector*> const& x,
122 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
123 std::vector<double>& cache) const = 0;
124
125 virtual std::vector<double> const& getIntPtEpsilon(
126 const double t,
127 std::vector<GlobalVector*> const& x,
128 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
129 std::vector<double>& cache) const = 0;
130
131 virtual std::vector<double> const& getIntPtDarcyVelocity(
132 const double t,
133 std::vector<GlobalVector*> const& x,
134 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
135 std::vector<double>& cache) const = 0;
136
137 virtual std::vector<double> const& getIntPtFractureVelocity(
138 const double t,
139 std::vector<GlobalVector*> const& x,
140 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
141 std::vector<double>& cache) const = 0;
142
143 virtual std::vector<double> const& getIntPtFractureStress(
144 const double t,
145 std::vector<GlobalVector*> const& x,
146 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
147 std::vector<double>& cache) const = 0;
148
149 virtual std::vector<double> const& getIntPtFractureAperture(
150 const double t,
151 std::vector<GlobalVector*> const& x,
152 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
153 std::vector<double>& cache) const = 0;
154
155 virtual std::vector<double> const& getIntPtFracturePermeability(
156 const double t,
157 std::vector<GlobalVector*> const& x,
158 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
159 std::vector<double>& cache) const = 0;
160
161protected:
163 double const t, double const dt, Eigen::VectorXd const& local_u,
164 Eigen::VectorXd const& local_u_prev, Eigen::VectorXd& local_b,
165 Eigen::MatrixXd& local_J) = 0;
166
168 double const t, double const dt, Eigen::VectorXd const& local_u) = 0;
169
173
174private:
175 Eigen::VectorXd _local_u;
176 Eigen::VectorXd _local_u_prev;
177 Eigen::VectorXd _local_b;
178 Eigen::MatrixXd _local_J;
179 // a vector for mapping the index in the local DoF vector to the index in
180 // the complete local solution vector which also include nodes where DoF are
181 // not assigned.
182 std::vector<unsigned> const _dofIndex_to_localIndex;
183};
184
185} // namespace HydroMechanics
186} // namespace LIE
187} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
virtual void postTimestepConcreteWithVector(double const t, double const dt, Eigen::VectorXd const &local_u)=0
virtual std::vector< double > const & getIntPtFracturePermeability(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
HydroMechanicsLocalAssemblerInterface(MeshLib::Element const &element, bool const is_axially_symmetric, NumLib::GenericIntegrationMethod const &integration_method, std::size_t n_local_size, std::vector< unsigned > dofIndex_to_localIndex)
virtual void assembleWithJacobianConcrete(double const t, double const dt, Eigen::VectorXd const &local_u, Eigen::VectorXd const &local_u_prev, Eigen::VectorXd &local_b, Eigen::MatrixXd &local_J)=0
virtual std::vector< double > const & getIntPtDarcyVelocity(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
virtual std::vector< double > const & getIntPtFractureAperture(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
void assembleWithJacobian(double const t, double const dt, std::vector< double > const &local_x_, std::vector< double > const &local_x_prev_, std::vector< double > &local_b_data, std::vector< double > &local_Jac_data) override
virtual std::vector< double > const & getIntPtFractureStress(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
void assemble(double const, double const, std::vector< double > const &, std::vector< double > const &, std::vector< double > &, std::vector< double > &, std::vector< double > &) override
virtual std::vector< double > const & getIntPtEpsilon(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
void postTimestepConcrete(Eigen::VectorXd const &local_x_, Eigen::VectorXd const &, const double t, double const dt, int const) override
virtual std::vector< double > const & getIntPtFractureVelocity(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
virtual std::vector< double > const & getIntPtSigma(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0
Used for the extrapolation of the integration point values.
std::vector< ShapeMatrixType, Eigen::aligned_allocator< ShapeMatrixType > > N