Forked from
agnumpde / dune-tectonic
28 commits ahead of the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
boundarycondition.hh 1.95 KiB
#ifndef SRC_BOUNDARYCONDITION_HH
#define SRC_BOUNDARYCONDITION_HH
#include <dune/common/bitsetvector.hh>
#include <dune/common/function.hh>
#include <dune/fufem/boundarypatch.hh>
template <class GridView, int dims>
class BoundaryCondition {
public:
using BoundaryPatch = BoundaryPatch<GridView>;
private:
using Function = Dune::VirtualFunction<double, double>;
const std::string tag_; // store type of boundary condition, e.g. dirichlet, neumann, friction, etc
std::shared_ptr<BoundaryPatch> boundaryPatch_;
std::shared_ptr<Dune::BitSetVector<dims>> boundaryNodes_;
std::shared_ptr<Function> boundaryFunction_;
public:
BoundaryCondition(const std::string& tag = "") :
tag_(tag)
{}
BoundaryCondition(std::shared_ptr<BoundaryPatch> patch, std::shared_ptr<Function> function, const std::string& tag = "") :
tag_(tag),
boundaryPatch_(patch),
boundaryFunction_(function)
{}
void setBoundaryPatch(const GridView& gridView, std::shared_ptr<Dune::BitSetVector<dims>> nodes) {
boundaryNodes_ = nodes;
boundaryPatch_ = std::make_shared<BoundaryPatch>(gridView, *nodes);
}
void setBoundaryPatch(std::shared_ptr<BoundaryPatch> patch) {
boundaryPatch_ = patch;
}
void setBoundaryPatch(const BoundaryPatch& patch) {
boundaryPatch_ = std::make_shared<BoundaryPatch>(patch);
}
void setBoundaryFunction(std::shared_ptr<Function> function) {
boundaryFunction_ = function;
}
void set(std::shared_ptr<BoundaryPatch> patch, std::shared_ptr<Function> function) {
boundaryPatch_ = patch;
boundaryFunction_ = function;
}
const std::string& tag() const {
return tag_;
}
const std::shared_ptr<BoundaryPatch>& boundaryPatch() const {
return boundaryPatch_;
}
const std::shared_ptr<Dune::BitSetVector<dims>>& boundaryNodes() const {
return boundaryNodes_;
}
const std::shared_ptr<Function>& boundaryFunction() const {
return boundaryFunction_;
}
};
#endif