OGS
SteadyStateDiffusionFEM.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <vector>
14
30
31namespace ProcessLib
32{
33namespace SteadyStateDiffusion
34{
35const unsigned NUM_NODAL_DOF = 1;
36
40{
41public:
42 virtual std::vector<double> const& getIntPtDarcyVelocity(
43 const double t,
44 std::vector<GlobalVector*> const& x,
45 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
46 std::vector<double>& cache) const = 0;
47};
48
49template <typename ShapeFunction, int GlobalDim>
51{
54
56 ShapeMatricesType, ShapeFunction::NPOINTS, NUM_NODAL_DOF, GlobalDim>;
57
61
62public:
66 MeshLib::Element const& element,
67 std::size_t const /*local_matrix_size*/,
68 NumLib::GenericIntegrationMethod const& integration_method,
69 bool const is_axially_symmetric,
70 SteadyStateDiffusionData const& process_data)
71 : _element(element),
72 _process_data(process_data),
73 _integration_method(integration_method),
75 NumLib::initShapeMatrices<ShapeFunction, ShapeMatricesType,
76 GlobalDim>(
77 element, is_axially_symmetric, _integration_method))
78 {
79 }
80
81 void assemble(double const t, double const dt,
82 std::vector<double> const& local_x,
83 std::vector<double> const& /*local_x_prev*/,
84 std::vector<double>& /*local_M_data*/,
85 std::vector<double>& local_K_data,
86 std::vector<double>& /*local_b_data*/) override
87 {
88 auto const local_matrix_size = local_x.size();
89 // This assertion is valid only if all nodal d.o.f. use the same shape
90 // matrices.
91 assert(local_matrix_size == ShapeFunction::NPOINTS * NUM_NODAL_DOF);
92
94 local_K_data, local_matrix_size, local_matrix_size);
95
96 unsigned const n_integration_points =
98
101
102 auto const& medium =
105 vars.temperature =
106 medium
107 .property(
109 .template value<double>(vars, pos, t, dt);
110
111 for (unsigned ip = 0; ip < n_integration_points; ip++)
112 {
113 auto const& sm = _shape_matrices[ip];
114 auto const& wp = _integration_method.getWeightedPoint(ip);
115
116 double p_int_pt = 0.0;
117 NumLib::shapeFunctionInterpolate(local_x, sm.N, p_int_pt);
118 vars.liquid_phase_pressure = p_int_pt;
121 .value(vars, pos, t, dt));
122
123 local_K.noalias() += sm.dNdx.transpose() * k * sm.dNdx * sm.detJ *
124 sm.integralMeasure * wp.getWeight();
125 }
126 }
127
130 Eigen::Vector3d getFlux(MathLib::Point3d const& p_local_coords,
131 double const t,
132 std::vector<double> const& local_x) const override
133 {
134 // TODO (tf) Temporary value not used by current material models. Need
135 // extension of getFlux interface
136 double const dt = std::numeric_limits<double>::quiet_NaN();
137
138 // Eval shape matrices at given point
139 // Note: Axial symmetry is set to false here, because we only need dNdx
140 // here, which is not affected by axial symmetry.
141 auto const shape_matrices =
143 GlobalDim>(
144 _element, false /*is_axially_symmetric*/,
145 std::array{p_local_coords})[0];
146
147 // fetch hydraulic conductivity
150 auto const& medium =
152
154 vars.temperature =
155 medium
156 .property(
158 .template value<double>(vars, pos, t, dt);
159 double pressure = 0.0;
160 NumLib::shapeFunctionInterpolate(local_x, shape_matrices.N, pressure);
161 vars.liquid_phase_pressure = pressure;
162
165 .value(vars, pos, t, dt));
166
167 Eigen::Vector3d flux(0.0, 0.0, 0.0);
168 flux.head<GlobalDim>() =
169 -k * shape_matrices.dNdx *
170 Eigen::Map<const NodalVectorType>(local_x.data(), local_x.size());
171
172 return flux;
173 }
174
175 Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
176 const unsigned integration_point) const override
177 {
178 auto const& N = _shape_matrices[integration_point].N;
179
180 // assumes N is stored contiguously in memory
181 return Eigen::Map<const Eigen::RowVectorXd>(N.data(), N.size());
182 }
183
184 std::vector<double> const& getIntPtDarcyVelocity(
185 const double t,
186 std::vector<GlobalVector*> const& x,
187 std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
188 std::vector<double>& cache) const override
189 {
190 // TODO (tf) Temporary value not used by current material models. Need
191 // extension of secondary variable interface.
192 double const dt = std::numeric_limits<double>::quiet_NaN();
193
194 auto const n_integration_points =
196
197 int const process_id = 0; // monolithic scheme
198 auto const indices =
199 NumLib::getIndices(_element.getID(), *dof_table[process_id]);
200 assert(!indices.empty());
201 auto const local_x = x[process_id]->get(indices);
202 auto const local_x_vec =
204 local_x, ShapeFunction::NPOINTS);
205
206 cache.clear();
207 auto cache_mat = MathLib::createZeroedMatrix<
208 Eigen::Matrix<double, GlobalDim, Eigen::Dynamic, Eigen::RowMajor>>(
209 cache, GlobalDim, n_integration_points);
210
213
214 auto const& medium =
216
218 vars.temperature =
219 medium
220 .property(
222 .template value<double>(vars, pos, t, dt);
223 double pressure = 0.0;
224 for (unsigned i = 0; i < n_integration_points; ++i)
225 {
227 pressure);
228 vars.liquid_phase_pressure = pressure;
229
232 .value(vars, pos, t, dt));
233 // dimensions: (d x 1) = (d x n) * (n x 1)
234 cache_mat.col(i).noalias() =
235 -k * _shape_matrices[i].dNdx * local_x_vec;
236 }
237
238 return cache;
239 }
240
241private:
244
246 std::vector<ShapeMatrices, Eigen::aligned_allocator<ShapeMatrices>>
248};
249
250} // namespace SteadyStateDiffusion
251} // namespace ProcessLib
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:89
MathLib::WeightedPoint const & getWeightedPoint(unsigned const igp) const
void setElementID(std::size_t element_id)
void assemble(double const t, double const dt, std::vector< double > const &local_x, std::vector< double > const &, std::vector< double > &, std::vector< double > &local_K_data, std::vector< double > &) override
LocalAssemblerData(MeshLib::Element const &element, std::size_t const, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, SteadyStateDiffusionData const &process_data)
typename LocalAssemblerTraits::LocalMatrix NodalMatrixType
ShapeMatrixPolicyType< ShapeFunction, GlobalDim > ShapeMatricesType
Eigen::Map< const Eigen::RowVectorXd > getShapeMatrix(const unsigned integration_point) const override
Provides the shape matrix at the given integration point.
std::vector< ShapeMatrices, Eigen::aligned_allocator< ShapeMatrices > > _shape_matrices
typename ShapeMatricesType::ShapeMatrices ShapeMatrices
Eigen::Vector3d getFlux(MathLib::Point3d const &p_local_coords, double const t, std::vector< double > const &local_x) const override
typename ShapeMatricesType::GlobalDimVectorType GlobalDimVectorType
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 override
typename LocalAssemblerTraits::LocalVector NodalVectorType
NumLib::GenericIntegrationMethod const & _integration_method
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
Eigen::Matrix< double, GlobalDim, GlobalDim > formEigenTensor(MaterialPropertyLib::PropertyDataType const &values)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
Eigen::Map< Matrix > createZeroedMatrix(std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
void shapeFunctionInterpolate(const NodalValues &, const ShapeMatrix &)
std::vector< GlobalIndexType > getIndices(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
std::vector< typename ShapeMatricesType::ShapeMatrices, Eigen::aligned_allocator< typename ShapeMatricesType::ShapeMatrices > > computeShapeMatrices(MeshLib::Element const &e, bool const is_axially_symmetric, PointContainer const &points)
NumLib::ShapeMatrices< NodalRowVectorType, DimNodalMatrixType, DimMatrixType, GlobalDimNodalMatrixType > ShapeMatrices
VectorType< GlobalDim > GlobalDimVectorType
MaterialPropertyLib::MaterialSpatialDistributionMap media_map
Matrix< NNodes *NodalDOF, NNodes *NodalDOF > LocalMatrix