Forked from
agnumpde / dune-tectonic
166 commits ahead of the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
bc.hh 3.02 KiB
#ifndef SRC_ONE_BODY_PROBLEM_DATA_BC_HH
#define SRC_ONE_BODY_PROBLEM_DATA_BC_HH
#include <cassert>
#include <dune/common/function.hh>
class VelocityDirichletCondition
: public Dune::VirtualFunction<double, double> {
public:
VelocityDirichletCondition(const double finalVelocity = 5e-5, const double threshold = 0.1) :
finalVelocity_(finalVelocity),
threshold_(threshold)
{}
void evaluate(double const &relativeTime, double &y) const {
// Assumed to vanish at time zero
//std::cout << "VelocityDirichletCondition::evaluate()" << std::endl;
/*if (relativeTime <= 0.1)
std::cout << "- loading phase" << std::endl;
else
std::cout << "- final velocity reached" << std::endl;*/
y = (relativeTime <= threshold_)
? finalVelocity_ * (1.0 - std::cos(relativeTime * M_PI / threshold_)) / 2.0
: finalVelocity_;
//y = relativeTime * finalVelocity;
}
private:
const double finalVelocity_;
const double threshold_;
};
class VelocityDirichletConditionLinearLoading
: public Dune::VirtualFunction<double, double> {
public:
VelocityDirichletConditionLinearLoading(const double finalVelocity = 5e-5, const double threshold = 0.1) :
finalVelocity_(finalVelocity),
threshold_(threshold)
{}
void evaluate(double const &relativeTime, double &y) const {
// Assumed to vanish at time zero
//std::cout << "VelocityDirichletCondition::evaluate()" << std::endl;
/*if (relativeTime <= 0.1)
std::cout << "- loading phase" << std::endl;
else
std::cout << "- final velocity reached" << std::endl;*/
y = (relativeTime <= threshold_)
? finalVelocity_ * relativeTime / threshold_
: finalVelocity_;
//y = relativeTime * finalVelocity;
}
private:
const double finalVelocity_;
const double threshold_;