// a function (here a ball).
// z_max_domain is the z value of the surface of the work piece
template <int dim>
- class Obstacle : public Function<dim>
+ class SphereObstacle : public Function<dim>
{
public:
- Obstacle (const std_cxx1x::shared_ptr<Input<dim> > &input,
- const bool use_read_obstacle,
+ SphereObstacle (const double z_max_domain)
+ :
+ Function<dim>(dim),
+ z_max_domain(z_max_domain)
+ {}
+
+ virtual
+ double value (const Point<dim> &p,
+ const unsigned int component = 0) const;
+
+ virtual
+ void vector_value (const Point<dim> &p,
+ Vector<double> &values) const;
+
+ private:
+ double z_max_domain;
+ };
+
+
+ template <int dim>
+ double
+ SphereObstacle<dim>::value (const Point<dim> &p,
+ const unsigned int component) const
+ {
+ if (component == 0)
+ return p(0);
+ if (component == 1)
+ return p(1);
+
+ //component==2:
+ return -std::sqrt(0.36 - (p(0) - 0.5) * (p(0) - 0.5)
+ - (p(1) - 0.5) * (p(1) - 0.5)) + z_max_domain + 0.59;
+ }
+
+ template <int dim>
+ void
+ SphereObstacle<dim>::vector_value (const Point<dim> &p,
+ Vector<double> &values) const
+ {
+ for (unsigned int c = 0; c < this->n_components; ++c)
+ values(c) = SphereObstacle<dim>::value(p, c);
+ }
+
+ template <int dim>
+ class ChineseObstacle : public Function<dim>
+ {
+ public:
+ ChineseObstacle (const std_cxx1x::shared_ptr<Input<dim> > &input,
const double z_max_domain)
:
Function<dim>(dim),
input_obstacle(input),
- use_read_obstacle(use_read_obstacle),
z_max_domain(z_max_domain)
{}
private:
const std_cxx1x::shared_ptr<Input<dim> > &input_obstacle;
- bool use_read_obstacle;
double z_max_domain;
};
template <int dim>
double
- Obstacle<dim>::value (const Point<dim> &p,
+ ChineseObstacle<dim>::value (const Point<dim> &p,
const unsigned int component) const
{
if (component == 0)
return p(1);
//component==2:
- if (use_read_obstacle)
- {
- if (p(0) >= 0.0 && p(0) <= 1.0 && p(1) >= 0.0 && p(1) <= 1.0)
- return z_max_domain + 0.999
- - input_obstacle->get_value(p(0), p(1));
- else
- return 10000.0;
- }
- else
- {
- //sphere:
- return -std::sqrt(0.36 - (p(0) - 0.5) * (p(0) - 0.5)
- - (p(1) - 0.5) * (p(1) - 0.5)) + z_max_domain + 0.59;
- }
+ if (p(0) >= 0.0 && p(0) <= 1.0 && p(1) >= 0.0 && p(1) <= 1.0)
+ return z_max_domain + 0.999 - input_obstacle->get_value(p(0), p(1));
+ else
+ return 10000.0;
+
}
template <int dim>
void
- Obstacle<dim>::vector_value (const Point<dim> &p,
+ ChineseObstacle<dim>::vector_value (const Point<dim> &p,
Vector<double> &values) const
{
for (unsigned int c = 0; c < this->n_components; ++c)
- values(c) = Obstacle<dim>::value(p, c);
+ values(c) = ChineseObstacle<dim>::value(p, c);
}
}
void
PlasticityContactProblem<dim>::update_solution_and_constraints ()
{
- const EquationData::Obstacle<dim> obstacle(input_obstacle,
- (obstacle_filename != ""), (base_mesh == "box" ? 1.0 : 0.5));
+ const EquationData::SphereObstacle<dim> obstacle((base_mesh == "box" ? 1.0 : 0.5));
+
+// const EquationData::ChineseObstacle<dim> obstacle(input_obstacle, (base_mesh == "box" ? 1.0 : 0.5));
+
std::vector<bool> vertex_touched(dof_handler.n_dofs(), false);
typename DoFHandler<dim>::active_cell_iterator cell =