OGS
ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition Class Referencefinal

Detailed Description

The PrimaryVariableConstraintDirichletBoundaryCondition is a Dirichlet-type boundary condition.

The class implements a constraint Dirichlet-type boundary condition. Using a threshold for the primary variable which is given by a parameter the boundary condition can be switched on/off. The value that is set a Dirichlet-type boundary condition is given by another parameter.

Definition at line 36 of file PrimaryVariableConstraintDirichletBoundaryCondition.h.

#include <PrimaryVariableConstraintDirichletBoundaryCondition.h>

Inheritance diagram for ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition:
[legend]
Collaboration diagram for ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition:
[legend]

Public Member Functions

 PrimaryVariableConstraintDirichletBoundaryCondition (ParameterLib::Parameter< double > const &parameter, MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id, ParameterLib::Parameter< double > const &threshold_parameter, bool const less)
 
void getEssentialBCValues (const double t, GlobalVector const &x, NumLib::IndexValueVector< GlobalIndexType > &bc_values) const override
 Writes the values of essential BCs to bc_values.
 
- Public Member Functions inherited from ProcessLib::BoundaryCondition
virtual void applyNaturalBC (const double, std::vector< GlobalVector * > const &, int const, GlobalMatrix *, GlobalVector &, GlobalMatrix *)
 
virtual void preTimestep (const double, std::vector< GlobalVector * > const &, int const)
 
virtual void postTimestep (const double, std::vector< GlobalVector * > const &, int const)
 
virtual ~BoundaryCondition ()=default
 

Private Attributes

ParameterLib::Parameter< double > const & _parameter
 < parameter that defines the Dirirchlet-type condition values
 
MeshLib::Mesh const & _bc_mesh
 
std::unique_ptr< NumLib::LocalToGlobalIndexMap const > _dof_table_boundary
 
int const _variable_id
 
int const _component_id
 
ParameterLib::Parameter< double > const & _threshold_parameter
 
bool const _less
 

Constructor & Destructor Documentation

◆ PrimaryVariableConstraintDirichletBoundaryCondition()

ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::PrimaryVariableConstraintDirichletBoundaryCondition ( ParameterLib::Parameter< double > const & parameter,
MeshLib::Mesh const & bc_mesh,
NumLib::LocalToGlobalIndexMap const & dof_table_bulk,
int const variable_id,
int const component_id,
ParameterLib::Parameter< double > const & threshold_parameter,
bool const less )

Definition at line 27 of file PrimaryVariableConstraintDirichletBoundaryCondition.cpp.

35 : _parameter(parameter),
36 _bc_mesh(bc_mesh),
37 _variable_id(variable_id),
38 _component_id(component_id),
39 _threshold_parameter(threshold_parameter),
40 _less(less)
41{
44
45 std::vector<MeshLib::Node*> const& bc_nodes = bc_mesh.getNodes();
46 MeshLib::MeshSubset bc_mesh_subset(_bc_mesh, bc_nodes);
47
48 // Create local DOF table from the BC mesh subset for the given variable
49 // and component id.
50 _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap(
51 variable_id, {component_id}, std::move(bc_mesh_subset));
52}
A subset of nodes on a single mesh.
Definition MeshSubset.h:26
ParameterLib::Parameter< double > const & _parameter
< parameter that defines the Dirirchlet-type condition values
void checkParametersOfDirichletBoundaryCondition(MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id)

References _bc_mesh, _component_id, _dof_table_boundary, _variable_id, ProcessLib::checkParametersOfDirichletBoundaryCondition(), NumLib::LocalToGlobalIndexMap::deriveBoundaryConstrainedMap(), and MeshLib::Mesh::getNodes().

Member Function Documentation

◆ getEssentialBCValues()

void ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::getEssentialBCValues ( const double ,
GlobalVector const & ,
NumLib::IndexValueVector< GlobalIndexType > &  ) const
overridevirtual

Writes the values of essential BCs to bc_values.

Reimplemented from ProcessLib::BoundaryCondition.

Definition at line 54 of file PrimaryVariableConstraintDirichletBoundaryCondition.cpp.

57{
59
60 bc_values.ids.clear();
61 bc_values.values.clear();
62
63 auto const& nodes_in_bc_mesh = _bc_mesh.getNodes();
64 // convert mesh node ids to global index for the given component
65 bc_values.ids.reserve(bc_values.ids.size() + nodes_in_bc_mesh.size());
66 bc_values.values.reserve(bc_values.values.size() + nodes_in_bc_mesh.size());
67 for (auto const* const node : nodes_in_bc_mesh)
68 {
69 auto const id = node->getID();
70 // TODO: that might be slow, but only done once
71 auto const global_index = _dof_table_boundary->getGlobalIndex(
74 if (global_index == NumLib::MeshComponentMap::nop)
75 {
76 continue;
77 }
78 // For the DDC approach (e.g. with PETSc option), the negative
79 // index of global_index means that the entry by that index is a ghost
80 // one, which should be dropped. Especially for PETSc routines
81 // MatZeroRows and MatZeroRowsColumns, which are called to apply the
82 // Dirichlet BC, the negative index is not accepted like other matrix or
83 // vector PETSc routines. Therefore, the following if-condition is
84 // applied.
85 if (global_index >= 0)
86 {
87 // fetch the value of the primary variable
88 auto const local_x = x.get(std::vector{global_index});
89 pos.setNodeID(id);
90 pos.setCoordinates(*node);
91 if (_less && local_x[0] < _threshold_parameter(t, pos).front())
92 {
93 bc_values.ids.emplace_back(global_index);
94 bc_values.values.emplace_back(_parameter(t, pos).front());
95 }
96 else if (!_less &&
97 local_x[0] > _threshold_parameter(t, pos).front())
98 {
99 bc_values.ids.emplace_back(global_index);
100 bc_values.values.emplace_back(_parameter(t, pos).front());
101 }
102 }
103 }
104}
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
std::size_t getID() const
Get id of the mesh.
Definition Mesh.h:121
static constexpr NUMLIB_EXPORT GlobalIndexType const nop
void setNodeID(std::size_t node_id)
void setCoordinates(MathLib::Point3d const &coordinates)

References _bc_mesh, _component_id, _dof_table_boundary, _less, _parameter, _threshold_parameter, _variable_id, MathLib::EigenVector::get(), MeshLib::Mesh::getID(), MeshLib::Mesh::getNodes(), NumLib::IndexValueVector< typename >::ids, MeshLib::Node, NumLib::MeshComponentMap::nop, ParameterLib::SpatialPosition::setCoordinates(), ParameterLib::SpatialPosition::setNodeID(), and NumLib::IndexValueVector< typename >::values.

Member Data Documentation

◆ _bc_mesh

MeshLib::Mesh const& ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::_bc_mesh
private

◆ _component_id

int const ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::_component_id
private

◆ _dof_table_boundary

std::unique_ptr<NumLib::LocalToGlobalIndexMap const> ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::_dof_table_boundary
private

◆ _less

bool const ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::_less
private

The value less is used for the calculation of the constraint criterion. If less is set to true (i.e. 'less' is set in the project file) the criterion 'calculated_value < _threshold_parameter' is evaluated to switch on/off the boundary condition. If less will be set to false in case 'greater' is given in the project file and the condition 'calculated_value > _threshold_parameter' is evaluated.

Definition at line 73 of file PrimaryVariableConstraintDirichletBoundaryCondition.h.

Referenced by getEssentialBCValues().

◆ _parameter

ParameterLib::Parameter<double> const& ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::_parameter
private

< parameter that defines the Dirirchlet-type condition values

Definition at line 54 of file PrimaryVariableConstraintDirichletBoundaryCondition.h.

Referenced by getEssentialBCValues().

◆ _threshold_parameter

ParameterLib::Parameter<double> const& ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::_threshold_parameter
private

The threshold parameter used to the switch on/off the Dirichlet-type boundary condition.

Definition at line 63 of file PrimaryVariableConstraintDirichletBoundaryCondition.h.

Referenced by getEssentialBCValues().

◆ _variable_id

int const ProcessLib::PrimaryVariableConstraintDirichletBoundaryCondition::_variable_id
private

The documentation for this class was generated from the following files: