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:
Collaboration diagram for ProcessLib::SolutionDependentDirichletBoundaryCondition:

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. More...
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 25 of file SolutionDependentDirichletBoundaryCondition.cpp.

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

Writes the values of essential BCs to bc_values.

Reimplemented from ProcessLib::BoundaryCondition.

Definition at line 73 of file SolutionDependentDirichletBoundaryCondition.cpp.

76 {
79  t, x, bc_values);
80 }
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:95
void getEssentialBCValuesLocal(ParameterLib::Parameter< double > const &parameter, MeshLib::Mesh const &bc_mesh, std::vector< MeshLib::Node * > 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, ProcessLib::getEssentialBCValuesLocal(), and MeshLib::Mesh::getNodes().

◆ postTimestep()

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

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(
94  assert(global_index >= 0);
95  (*_solution_dependent_bc)[i] = x[process_id]->get(global_index);
96  }
97 }
std::size_t getID() const
Get id of the mesh.
Definition: Mesh.h:110

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

◆ _component_id

int const ProcessLib::SolutionDependentDirichletBoundaryCondition::_component_id

◆ _dof_table_boundary

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

◆ _parameter

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

◆ _solution_dependent_bc

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

◆ _variable_id

int const ProcessLib::SolutionDependentDirichletBoundaryCondition::_variable_id

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