OGS
NodalSourceTerm.cpp
Go to the documentation of this file.
1
11#include "NodalSourceTerm.h"
12
13#include <cassert>
14
15namespace ProcessLib
16{
18 std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
19 std::size_t const source_term_mesh_id,
20 MeshLib::Mesh const& st_mesh,
21 const int variable_id,
22 const int component_id,
23 ParameterLib::Parameter<double> const& parameter)
24 : SourceTerm(std::move(source_term_dof_table)),
25 _source_term_mesh_id(source_term_mesh_id),
26 _st_mesh(st_mesh),
27 _variable_id(variable_id),
28 _component_id(component_id),
29 _parameter(parameter)
30{
31 DBUG("Create NodalSourceTerm.");
32}
33
34void NodalSourceTerm::integrate(const double t, GlobalVector const& /*x*/,
35 GlobalVector& b, GlobalMatrix* /*jac*/) const
36{
37 DBUG("Assemble NodalSourceTerm.");
38
39 for (MeshLib::Node const* const node : _st_mesh.getNodes())
40 {
41 auto const node_id = node->getID();
44 auto const global_index = _source_term_dof_table->getGlobalIndex(
46
47 if (global_index == NumLib::MeshComponentMap::nop)
48 {
49 continue;
50 }
51 // For the DDC approach (e.g. with PETSc option), the negative
52 // index of global_index means that the entry by that index is a ghost
53 // one, which should be dropped. Especially for PETSc routines
54 // MatZeroRows and MatZeroRowsColumns, which are called to apply the
55 // Dirichlet BC, the negative index is not accepted like other matrix or
56 // vector PETSc routines. Therefore, the following if-condition is
57 // applied.
58 if (global_index >= 0)
59 {
61 pos.setNodeID(node_id);
62 pos.setCoordinates(*node);
63
64 b.add(global_index, _parameter(t, pos).front());
65 }
66 }
67}
68
69} // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Global vector based on Eigen vector.
Definition EigenVector.h:25
void add(IndexType rowId, double v)
add entry
Definition EigenVector.h:76
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
static constexpr NUMLIB_EXPORT GlobalIndexType const nop
void setNodeID(std::size_t node_id)
void setCoordinates(MathLib::Point3d const &coordinates)
std::size_t const _source_term_mesh_id
ParameterLib::Parameter< double > const & _parameter
NodalSourceTerm(std::unique_ptr< NumLib::LocalToGlobalIndexMap > source_term_dof_table, std::size_t const source_term_mesh_id, MeshLib::Mesh const &st_mesh, const int variable_id, const int component_id, ParameterLib::Parameter< double > const &parameter)
void integrate(const double t, GlobalVector const &x, GlobalVector &b, GlobalMatrix *jac) const override
MeshLib::Mesh const & _st_mesh
std::unique_ptr< NumLib::LocalToGlobalIndexMap > const _source_term_dof_table
Definition SourceTerm.h:35