OGS
CreateAnchorTerm.cpp
Go to the documentation of this file.
1
11#include "CreateAnchorTerm.h"
12
13#include "AnchorTerm.h"
14#include "BaseLib/ConfigTree.h"
15#include "BaseLib/Logging.h"
16#include "ParameterLib/Utils.h"
17
18namespace ProcessLib
19{
20template <int GlobalDim>
21std::unique_ptr<SourceTerm> createAnchorTerm(
22 BaseLib::ConfigTree const& config, MeshLib::Mesh const& st_mesh,
23 std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
24 std::size_t const source_term_mesh_id, const int variable_id,
25 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
26{
27 DBUG("Constructing AnchorTerm from config.");
29 config.checkConfigParameter("type", "Anchor");
30
31 auto const param_name =
33 config.getConfigParameter<std::string>("anchor_force_constant");
34 DBUG("Using parameter {:s} as anchor stiffness constant.", param_name);
35
36 auto& param = ParameterLib::findParameter<double>(param_name, parameters, 1,
37 &st_mesh);
38
39 for (MeshLib::Element const* const element : st_mesh.getElements())
40 {
41 if (element->getNumberOfNodes() != 2)
42 {
44 "Every anchor element needs to have precisely two nodes.");
45 }
46 }
47
48 return std::make_unique<AnchorTerm<GlobalDim>>(
49 std::move(dof_table), source_term_mesh_id, st_mesh, variable_id, param);
50}
51
52template std::unique_ptr<SourceTerm> createAnchorTerm<2>(
53 BaseLib::ConfigTree const& config, MeshLib::Mesh const& st_mesh,
54 std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
55 std::size_t const source_term_mesh_id, const int variable_id,
56 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
57 parameters);
58
59template std::unique_ptr<SourceTerm> createAnchorTerm<3>(
60 BaseLib::ConfigTree const& config, MeshLib::Mesh const& st_mesh,
61 std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
62 std::size_t const source_term_mesh_id, const int variable_id,
63 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
64 parameters);
65} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
std::unique_ptr< SourceTerm > createAnchorTerm(BaseLib::ConfigTree const &config, MeshLib::Mesh const &st_mesh, std::unique_ptr< NumLib::LocalToGlobalIndexMap > dof_table, std::size_t const source_term_mesh_id, const int variable_id, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
template std::unique_ptr< SourceTerm > createAnchorTerm< 3 >(BaseLib::ConfigTree const &config, MeshLib::Mesh const &st_mesh, std::unique_ptr< NumLib::LocalToGlobalIndexMap > dof_table, std::size_t const source_term_mesh_id, const int variable_id, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
template std::unique_ptr< SourceTerm > createAnchorTerm< 2 >(BaseLib::ConfigTree const &config, MeshLib::Mesh const &st_mesh, std::unique_ptr< NumLib::LocalToGlobalIndexMap > dof_table, std::size_t const source_term_mesh_id, const int variable_id, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)