Point<spacedim>
StraightBoundary<dim, spacedim>::project_to_manifold(const std::vector<Point<spacedim> > &v,
const Point<spacedim> &trial_point) const {
- if(spacedim <= 1)
- return trial_point;
- else
- switch(v.size()) {
- case 2:
+ // the following number uniquely identifies all possible situations:
+ // 22: project to a line, i.e., on a boundary, in 2d
+ // 32: project to a line, i.e., on a boundary, in 3d
+ // 24: project to a quad in 2d, i.e., in the interior of the domain
+ // 34: project to a quad in 3d, i.e., on a boundary
+ const unsigned int magic = spacedim+10*v.size();
+
+ // The default behavior is "do nothing", but there are cases when we
+ // are on a "flat boundary", and we want to project to it. This is a
+ // hack to maintain backward compatibility with the old boundary
+ // classes.
+ switch(magic) {
+ case 22:
+ case 32:
{
// find the point that lies on the line p1--p2. the formulas
// pan out to something rather simple because the mapping to
return v[0] + s*(v[1]-v[0]);
}
break;
- case 4:
- {
+ case 34:
+ {
// let's look at this for simplicity for a quad (dim==2) in a
// space with spacedim>2:
break;
}
while (true);
-
return x_k;
- }
- break;
- default:
- Assert(false, ExcNotImplemented());
- return trial_point;
}
+ break;
+ default:
+ return trial_point;
+ }
}
:
PolarManifold<dim>(center)
{}
+
template <int dim>
Point<dim>
HyperShellBoundary<dim>::project_to_manifold(const std::vector<Point<dim> > &vertices,
const Point<dim> &p) const {
double radius = vertices[0].norm();
Point<dim> newp = p-this->center;
- return (this->center + radius*p/p.norm());
+ return (this->center + radius*newp/newp.norm());
}