OGS
VolumetricSourceTermFEM.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 <vector>
7
16
17namespace ProcessLib
18{
20{
21public:
22 virtual void integrate(
23 std::size_t const id,
24 NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
25 double const t, GlobalVector& b) = 0;
27};
28
29template <typename ShapeFunction, int GlobalDim>
32{
33 static const unsigned NUM_NODAL_DOF = 1;
34
36
38 ShapeMatricesType, ShapeFunction::NPOINTS, NUM_NODAL_DOF, GlobalDim>;
39
42
43public:
45 MeshLib::Element const& element,
46 std::size_t const local_matrix_size,
47 NumLib::GenericIntegrationMethod const& integration_method,
48 bool const is_axially_symmetric,
49 ParameterLib::Parameter<double> const& volumetric_source_term)
50 : _volumetric_source_term(volumetric_source_term),
51 _integration_method(integration_method),
52 _element(element),
53 _local_rhs(local_matrix_size)
54 {
55 unsigned const n_integration_points =
56 _integration_method.getNumberOfPoints();
57
58 auto const shape_matrices =
60 GlobalDim>(_element, is_axially_symmetric,
62
63 for (unsigned ip = 0; ip < n_integration_points; ip++)
64 {
65 _ip_data.emplace_back(
66 shape_matrices[ip].N,
67 _integration_method.getWeightedPoint(ip).getWeight() *
68 shape_matrices[ip].integralMeasure *
69 shape_matrices[ip].detJ);
70 }
71 }
72
73 void integrate(std::size_t const id,
74 NumLib::LocalToGlobalIndexMap const& source_term_dof_table,
75 double const t, GlobalVector& b) override
76 {
77 _local_rhs.setZero();
78
79 unsigned const n_integration_points =
80 _integration_method.getNumberOfPoints();
81
82 for (unsigned ip = 0; ip < n_integration_points; ip++)
83 {
84 auto const& N = _ip_data[ip].N;
85 auto const& w = _ip_data[ip].integration_weight;
86
88 std::nullopt, _element.getID(),
92 N))};
93 auto const st_val = _volumetric_source_term(t, pos)[0];
94
95 _local_rhs.noalias() += N.transpose() * st_val * w;
96 }
97 auto const indices = NumLib::getIndices(id, source_term_dof_table);
98 b.add(indices, _local_rhs);
99 }
100
101private:
103
105 std::vector<SourceTermIntegrationPointData<NodalRowVectorType>,
106 Eigen::aligned_allocator<
111};
112
113} // namespace ProcessLib
MathLib::EigenVector GlobalVector
EigenFixedShapeMatrixPolicy< ShapeFunction, GlobalDim > ShapeMatrixPolicyType
void add(IndexType rowId, double v)
add entry
Definition EigenVector.h:70
virtual void integrate(std::size_t const id, NumLib::LocalToGlobalIndexMap const &source_term_dof_table, double const t, GlobalVector &b)=0
typename ShapeMatricesType::NodalRowVectorType NodalRowVectorType
typename LocalAssemblerTraits::LocalVector NodalVectorType
void integrate(std::size_t const id, NumLib::LocalToGlobalIndexMap const &source_term_dof_table, double const t, GlobalVector &b) override
ParameterLib::Parameter< double > const & _volumetric_source_term
std::vector< SourceTermIntegrationPointData< NodalRowVectorType >, Eigen::aligned_allocator< SourceTermIntegrationPointData< NodalRowVectorType > > > _ip_data
NumLib::GenericIntegrationMethod const & _integration_method
ProcessLib::LocalAssemblerTraits< ShapeMatricesType, ShapeFunction::NPOINTS, NUM_NODAL_DOF, GlobalDim > LocalAssemblerTraits
ShapeMatrixPolicyType< ShapeFunction, GlobalDim > ShapeMatricesType
VolumetricSourceTermLocalAssembler(MeshLib::Element const &element, std::size_t const local_matrix_size, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, ParameterLib::Parameter< double > const &volumetric_source_term)
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 > > initShapeMatrices(MeshLib::Element const &e, bool const is_axially_symmetric, IntegrationMethod const &integration_method)
std::array< double, 3 > interpolateCoordinates(MeshLib::Element const &e, typename ShapeMatricesType::ShapeMatrices::ShapeType const &N)
detail::LocalAssemblerTraitsFixed< ShpPol, NNodes, NodalDOF, Dim > LocalAssemblerTraits
RowVectorType< ShapeFunction::NPOINTS > NodalRowVectorType