OGS
NodalSourceTerm.cpp
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#include "NodalSourceTerm.h"
5
6#include <cassert>
7
8namespace ProcessLib
9{
11 std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
12 std::size_t const source_term_mesh_id,
13 MeshLib::Mesh const& st_mesh,
14 const int variable_id,
15 const int component_id,
16 ParameterLib::Parameter<double> const& parameter)
17 : SourceTerm(std::move(source_term_dof_table)),
18 _source_term_mesh_id(source_term_mesh_id),
19 _st_mesh(st_mesh),
20 _variable_id(variable_id),
21 _component_id(component_id),
22 _parameter(parameter)
23{
24 DBUG("Create NodalSourceTerm.");
25}
26
27void NodalSourceTerm::integrate(const double t, GlobalVector const& /*x*/,
28 GlobalVector& b, GlobalMatrix* /*jac*/) const
29{
30 DBUG("Assemble NodalSourceTerm.");
31
32 for (MeshLib::Node const* const node : _st_mesh.getNodes())
33 {
34 auto const node_id = node->getID();
37 auto const global_index = _source_term_dof_table->getGlobalIndex(
39
40 if (global_index == NumLib::MeshComponentMap::nop)
41 {
42 continue;
43 }
44 // For the DDC approach (e.g. with PETSc option), the negative
45 // index of global_index means that the entry by that index is a ghost
46 // one, which should be dropped. Especially for PETSc routines
47 // MatZeroRows and MatZeroRowsColumns, which are called to apply the
48 // Dirichlet BC, the negative index is not accepted like other matrix or
49 // vector PETSc routines. Therefore, the following if-condition is
50 // applied.
51 if (global_index >= 0)
52 {
54 pos.setNodeID(node_id);
55 pos.setCoordinates(*node);
56
57 b.add(global_index, _parameter(t, pos).front());
58 }
59 }
60}
61
62} // namespace ProcessLib
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
void add(IndexType rowId, double v)
add entry
Definition EigenVector.h:70
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
SourceTerm(std::unique_ptr< NumLib::LocalToGlobalIndexMap > source_term_dof_table)
std::unique_ptr< NumLib::LocalToGlobalIndexMap > const _source_term_dof_table