OGS
ProcessLib::SolutionDependentDirichletBoundaryCondition Class Referencefinal

Detailed Description

The SolutionDependentDirichletBoundaryCondition belongs to the Dirichlet-type boundary condition.

This class is a special category of Dirichlet boundary condition, applied in the situation where the value assigned for the boundary condition is dependent on the process solution of the last time step. This particular boundary condition is widely used in the reactive transport problems and has the potential to be used in other processes.

Definition at line 26 of file SolutionDependentDirichletBoundaryCondition.h.

#include <SolutionDependentDirichletBoundaryCondition.h>

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

Public Member Functions

 SolutionDependentDirichletBoundaryCondition (std::string property_name, ParameterLib::Parameter< double > const &parameter, MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id)
 
void getEssentialBCValues (double const t, GlobalVector const &x, NumLib::IndexValueVector< GlobalIndexType > &bc_values) const override
 Writes the values of essential BCs to bc_values.
 
void postTimestep (double const, std::vector< GlobalVector * > const &x, int const process_id) override
 
- 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 ~BoundaryCondition ()=default
 

Private Attributes

MeshLib::Mesh const & _bc_mesh
 
int const _variable_id
 
int const _component_id
 
std::unique_ptr< NumLib::LocalToGlobalIndexMap const > _dof_table_boundary
 
std::unique_ptr< ParameterLib::MeshNodeParameter< double > > _parameter
 
MeshLib::PropertyVector< double > * _solution_dependent_bc
 

Constructor & Destructor Documentation

◆ SolutionDependentDirichletBoundaryCondition()

ProcessLib::SolutionDependentDirichletBoundaryCondition::SolutionDependentDirichletBoundaryCondition ( std::string property_name,
ParameterLib::Parameter< double > const & parameter,
MeshLib::Mesh const & bc_mesh,
NumLib::LocalToGlobalIndexMap const & dof_table_bulk,
int const variable_id,
int const component_id )

Definition at line 26 of file SolutionDependentDirichletBoundaryCondition.cpp.

33 : _bc_mesh(bc_mesh), _variable_id(variable_id), _component_id(component_id)
34{
37
38 std::vector<MeshLib::Node*> const& bc_nodes = bc_mesh.getNodes();
39 MeshLib::MeshSubset bc_mesh_subset(_bc_mesh, bc_nodes);
40
41 // Create local DOF table from the BC mesh subset for the given variable
42 // and component id.
43 _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap(
44 variable_id, {component_id}, std::move(bc_mesh_subset));
45
46 if (bc_mesh.getProperties().existsPropertyVector<double>(property_name))
47 {
49 "Found mesh property '{:s}' in the mesh '{:s}' which is for "
50 "boundary assignment. This mesh property is the built-in property "
51 "of the class SolutionDependentDirichletBoundaryCondition.",
52 property_name, bc_mesh.getName());
53 }
54
55 _solution_dependent_bc = MeshLib::getOrCreateMeshProperty<double>(
56 const_cast<MeshLib::Mesh&>(bc_mesh), property_name,
58 _solution_dependent_bc->resize(bc_mesh.getNumberOfNodes());
59
61
62 auto const& nodes = bc_mesh.getNodes();
63 for (std::size_t i = 0; i < _solution_dependent_bc->size(); ++i)
64 {
65 auto const id = nodes[i]->getID();
66 pos.setNodeID(id);
67 (*_solution_dependent_bc)[i] = parameter(0, pos)[0];
68 }
69
70 _parameter = std::make_unique<ParameterLib::MeshNodeParameter<double>>(
71 property_name, bc_mesh, *_solution_dependent_bc);
72}
#define OGS_FATAL(...)
Definition Error.h:26
A subset of nodes on a single mesh.
Definition MeshSubset.h:26
std::size_t size() const
void setNodeID(std::size_t node_id)
std::unique_ptr< NumLib::LocalToGlobalIndexMap const > _dof_table_boundary
std::unique_ptr< ParameterLib::MeshNodeParameter< double > > _parameter
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, _parameter, _solution_dependent_bc, _variable_id, ProcessLib::checkParametersOfDirichletBoundaryCondition(), NumLib::LocalToGlobalIndexMap::deriveBoundaryConstrainedMap(), MeshLib::Properties::existsPropertyVector(), MeshLib::Mesh::getName(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getNumberOfNodes(), MeshLib::Mesh::getProperties(), MeshLib::Node, OGS_FATAL, ParameterLib::SpatialPosition::setNodeID(), and MeshLib::PropertyVector< PROP_VAL_TYPE >::size().

Member Function Documentation

◆ getEssentialBCValues()

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

Writes the values of essential BCs to bc_values.

Reimplemented from ProcessLib::BoundaryCondition.

Definition at line 74 of file SolutionDependentDirichletBoundaryCondition.cpp.

77{
79 _variable_id, _component_id, t, x, bc_values);
80}
void getEssentialBCValuesLocal(ParameterLib::Parameter< double > const &parameter, MeshLib::Mesh const &bc_mesh, std::vector< std::size_t > const &nodes_in_bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, int const variable_id, int const component_id, const double t, GlobalVector const &, NumLib::IndexValueVector< GlobalIndexType > &bc_values)

References _bc_mesh, _component_id, _dof_table_boundary, _parameter, _variable_id, and ProcessLib::getEssentialBCValuesLocal().

◆ postTimestep()

void ProcessLib::SolutionDependentDirichletBoundaryCondition::postTimestep ( double const ,
std::vector< GlobalVector * > const & x,
int const process_id )
overridevirtual

Renchao: The original idea to place the update of the boundary condition value at the preTimestep stage. The update could be achieved within the class function "Process::preTimestep". Whereas, I find it not doable to implement in this way. The class function "Process::preTimestep" is called in a row by the functions "preTimestepForAllProcesses" and "TimeLoop::outputSolutions". These two functions are called when initializing and subsequently looping over the "TimeLoop". Actually, it is not intended to make the boundary condition value updated in the first loop. Instead, the update is intended to start from the second loop. For these two reasons, I think it more proper to do the implementation at the postTimestep stage.

Reimplemented from ProcessLib::BoundaryCondition.

Definition at line 82 of file SolutionDependentDirichletBoundaryCondition.cpp.

85{
86 auto const& nodes = _bc_mesh.getNodes();
87 for (std::size_t i = 0; i < _solution_dependent_bc->size(); ++i)
88 {
89 auto const id = nodes[i]->getID();
90 auto const global_index = _dof_table_boundary->getGlobalIndex(
93
94 assert(global_index >= 0);
95 (*_solution_dependent_bc)[i] = x[process_id]->get(global_index);
96 }
97}
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

References _bc_mesh, _component_id, _dof_table_boundary, _solution_dependent_bc, _variable_id, MeshLib::Mesh::getID(), MeshLib::Mesh::getNodes(), MeshLib::Node, and MeshLib::PropertyVector< PROP_VAL_TYPE >::size().

Member Data Documentation

◆ _bc_mesh

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

◆ _component_id

int const ProcessLib::SolutionDependentDirichletBoundaryCondition::_component_id
private

◆ _dof_table_boundary

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

◆ _parameter

std::unique_ptr<ParameterLib::MeshNodeParameter<double> > ProcessLib::SolutionDependentDirichletBoundaryCondition::_parameter
private

◆ _solution_dependent_bc

MeshLib::PropertyVector<double>* ProcessLib::SolutionDependentDirichletBoundaryCondition::_solution_dependent_bc
private

◆ _variable_id

int const ProcessLib::SolutionDependentDirichletBoundaryCondition::_variable_id
private

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