14#include <range/v3/range/conversion.hpp>
15#include <range/v3/view/transform.hpp>
33template <
int GlobalDim>
42 Eigen::Vector3d
const normal = e.cross(n).normalized();
58 normal.tail<3 - GlobalDim>().setZero();
59 return normal.normalized();
62template <
int GlobalDim,
template <
typename ,
int >
63 class LocalAssemblerImplementation>
66 unsigned const integration_order, unsigned const shapefunction_order,
67 MeshLib::Mesh const& bulk_mesh,
68 NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
69 int const variable_id, MeshLib::Mesh const& bc_mesh,
70 ParameterLib::Parameter<double> const& pressure)
76 auto const& number_of_components =
77 dof_table_bulk.getNumberOfVariableComponents(variable_id);
78 std::vector<int> component_ids(number_of_components);
79 std::iota(std::begin(component_ids), std::end(component_ids), 0);
82 std::vector<MeshLib::Node*>
const bc_nodes =
_bc_mesh.getNodes();
83 DBUG(
"Found {:d} nodes for Natural BCs for the variable {:d}",
84 bc_nodes.size(), variable_id);
90 assert(bulk_element_ids !=
nullptr);
91 auto const& elements =
_bc_mesh.getElements();
94 ranges::views::transform(
98 auto const* bulk_element =
99 bulk_mesh.getElement((*bulk_element_ids)[e_ptr->
getID()]);
100 assert(bulk_element !=
nullptr);
104 ranges::to<std::vector<Eigen::Vector3d>>();
109 variable_id, component_ids, std::move(bc_mesh_subset));
112 GlobalDim, LocalAssemblerImplementation>(
118template <
int GlobalDim,
template <
typename ,
int >
119 class LocalAssemblerImplementation>
121 applyNaturalBC(const double t, std::vector<GlobalVector*> const& x,
122 int const , GlobalMatrix* K, GlobalVector& b,
130template <
int GlobalDim>
137 unsigned const integration_order,
unsigned const shapefunction_order,
138 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters)
140 DBUG(
"Constructing NormalTractionBoundaryCondition from config.");
144 auto const parameter_name =
147 DBUG(
"Using parameter {:s}", parameter_name);
150 parameter_name, parameters, 1, &bc_mesh);
153 integration_order, shapefunction_order, bulk_mesh, dof_table,
154 variable_id, bc_mesh, pressure);
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
T getConfigParameter(std::string const ¶m) const
void checkConfigParameter(std::string const ¶m, std::string_view const value) const
Eigen::Vector3d const & asEigenVector3d() const
virtual MeshElemType getGeomType() const =0
virtual const Node * getNode(unsigned idx) const =0
std::size_t getID() const
Returns the ID of the element.
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
A subset of nodes on a single mesh.
virtual void assemble(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &, GlobalMatrix *, GlobalVector &b, GlobalMatrix *)=0
void applyNaturalBC(const double t, std::vector< GlobalVector * > const &x, int const process_id, GlobalMatrix *K, GlobalVector &b, GlobalMatrix *Jac) override
MeshLib::Mesh const & _bc_mesh
ParameterLib::Parameter< double > const & _pressure
std::vector< Eigen::Vector3d > _element_normals
Normal vectors for each element in the boundary condition mesh.
unsigned const _integration_order
Integration order for integration over the lower-dimensional elements.
NormalTractionBoundaryCondition(unsigned const integration_order, unsigned const shapefunction_order, MeshLib::Mesh const &bulk_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, MeshLib::Mesh const &bc_mesh, ParameterLib::Parameter< double > const &pressure)
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _dof_table_boundary
std::vector< std::unique_ptr< NormalTractionBoundaryConditionLocalAssemblerInterface > > _local_assemblers
Local assemblers for each element of number of _elements.
PropertyVector< std::size_t > const * bulkElementIDs(Mesh const &mesh)
MathLib::Point3d getCenterOfGravity(Element const &element)
Calculates the center of gravity for the mesh element.
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const ¶meter_name, std::vector< std::unique_ptr< ParameterBase > > const ¶meters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
void createLocalAssemblers(NumLib::LocalToGlobalIndexMap const &dof_table, const unsigned shapefunction_order, std::vector< MeshLib::Element * > const &mesh_elements, std::vector< std::unique_ptr< LocalAssemblerInterface > > &local_assemblers, NumLib::IntegrationOrder const integration_order, ExtraCtorArgs &&... extra_ctor_args)
Eigen::Vector3d computeElementNormal(const MeshLib::Element &element, const MeshLib::Element &bulk_element)
std::unique_ptr< NormalTractionBoundaryCondition< GlobalDim, NormalTractionBoundaryConditionLocalAssembler > > createNormalTractionBoundaryCondition(BaseLib::ConfigTree const &config, MeshLib::Mesh const &bc_mesh, MeshLib::Mesh const &bulk_mesh, NumLib::LocalToGlobalIndexMap const &dof_table, int const variable_id, unsigned const integration_order, unsigned const shapefunction_order, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const ¶meters)
static void executeMemberOnDereferenced(Method method, Container const &container, Args &&... args)