*
* This function is called by
* @p transform_unit_to_real_cell
- * and multiply (through the
+ * and multiple times (through the
* Newton iteration) by
* @p transform_real_to_unit_cell_internal.
*
* computations of the mapping
* support points.
*/
- Point<spacedim> transform_unit_to_real_cell_internal (const InternalData &mdata) const;
+ Point<spacedim>
+ transform_unit_to_real_cell_internal (const InternalData &mdata) const;
/**
* Transforms the point @p p on
- * the real cell to the point
- * @p p_unit on the unit cell
+ * the real cell to the corresponding
+ * point on the unit cell
* @p cell by a Newton
* iteration.
*
* and
* @p update_transformation_gradients
* and a one point Quadrature
- * including the given point
- * @p p_unit. Hence this
+ * that includes the given
+ * initial guess for the
+ * transformation
+ * @p initial_p_unit. Hence this
* function assumes that
* @p mdata already includes the
* transformation shape values
* and gradients computed at
- * @p p_unit.
+ * @p initial_p_unit.
*
- * These assumptions should be
- * fulfilled by the calling
- * function. That is up to now
- * only the function
- * @p transform_real_to_unit_cell
- * and its overloaded versions.
* @p mdata will be changed by
* this function.
*/
- void transform_real_to_unit_cell_internal (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
- const Point<spacedim> &p,
- InternalData &mdata,
- Point<dim> &p_unit) const;
-
-
-
-
-
-
-
+ Point<dim>
+ transform_real_to_unit_cell_internal (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
+ const Point<spacedim> &p,
+ const Point<dim> &initial_p_unit,
+ InternalData &mdata) const;
/**
* Always returns @p true because
protected:
/* Trick to templatize transform_real_to_unit_cell<dim, dim+1> */
template<int dim_>
- void transform_real_to_unit_cell_internal_codim1
+ Point<dim_>
+ transform_real_to_unit_cell_internal_codim1
(const typename Triangulation<dim_,dim_+1>::cell_iterator &cell,
const Point<dim_+1> &p,
- InternalData &mdata,
- Point<dim_> &p_unit) const;
+ const Point<dim_> &initial_p_unit,
+ InternalData &mdata) const;
/**
Compute an initial guess to pass to the Newton method in
};
+// explicit specializations
+
template<>
-void
+Point<2>
MappingQ1<2,3>::
transform_real_to_unit_cell_internal
(const Triangulation<2,3>::cell_iterator &cell,
- const Point<3> &p,
- InternalData &mdata,
- Point<2> &p_unit) const;
+ const Point<3> &p,
+ const Point<2> &initial_p_unit,
+ InternalData &mdata) const;
-/* Only used in mapping Q if degree > 1 */
template<>
-void
+Point<1>
MappingQ1<1,2>::
-transform_real_to_unit_cell_internal (const Triangulation<1,2>::cell_iterator &cell,
- const Point<2> &p,
- InternalData &mdata,
- Point<1> &p_unit) const;
+transform_real_to_unit_cell_internal
+(const Triangulation<1,2>::cell_iterator &cell,
+ const Point<2> &p,
+ const Point<1> &initial_p_unit,
+ InternalData &mdata) const;
-/* Only used in mapping Q if degree > 1 */
template<>
-void
+Point<1>
MappingQ1<1,3>::
-transform_real_to_unit_cell_internal (const Triangulation<1,3>::cell_iterator &cell,
- const Point<3> &p,
- InternalData &mdata,
- Point<1> &p_unit) const;
+transform_real_to_unit_cell_internal
+(const Triangulation<1,3>::cell_iterator &cell,
+ const Point<3> &p,
+ const Point<1> &initial_p_unit,
+ InternalData &mdata) const;
/**
transform_real_to_unit_cell_initial_guess (const std::vector<Point<spacedim> > &vertex,
const Point<spacedim> &p) const
{
-
Point<dim> p_unit;
FullMatrix<double> KA(GeometryInfo<dim>::vertices_per_cell, dim);
A_1.vmult(dest,b); //A^{-1}*b
-
for (unsigned int i=0;i<dim;++i)
p_unit[i]=dest(i);
-
return p_unit;
-
}
+
+
template<int dim, int spacedim>
Point<dim>
MappingQ1<dim,spacedim>::
transform_real_to_unit_cell (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
const Point<spacedim> &p) const
{
-
-
// Find the initial value for the
// Newton iteration by a normal projection
// to the least square plane determined by
// the vertices of the cell
std::vector<Point<spacedim> > a;
compute_mapping_support_points (cell,a);
- Point<dim> p_unit =
+ const Point<dim> initial_p_unit =
transform_real_to_unit_cell_initial_guess(a,p);
// if dim==1 there is nothing
- // else to do the initial value is the answer.
- if (dim>1)
+ // else to do to the initial
+ // value, and it is the answer
+ if (dim == 1)
+ return initial_p_unit;
+ else
{
-
// Use the get_data function to
// create an InternalData with data
// vectors of the right size and
// transformation shape values and
// derivatives already computed at
- // point p_unit.
- const Quadrature<dim> point_quadrature(p_unit);
+ // point initial_p_unit.
+ const Quadrature<dim> point_quadrature(initial_p_unit);
UpdateFlags update_flags = update_transformation_values| update_transformation_gradients;
if (spacedim>dim)
// Ignore non vertex support points.
mdata->mapping_support_points.resize(GeometryInfo<dim>::vertices_per_cell);
- // perform the newton iteration.
- transform_real_to_unit_cell_internal(cell, p, *mdata, p_unit);
+ // perform the Newton iteration and
+ // return the result
+ return transform_real_to_unit_cell_internal(cell, p, initial_p_unit,
+ *mdata);
}
-
- return p_unit;
}
template<int dim, int spacedim>
-void
+Point<dim>
MappingQ1<dim,spacedim>::
transform_real_to_unit_cell_internal
(const typename Triangulation<dim,spacedim>::cell_iterator &cell,
const Point<spacedim> &p,
- InternalData &mdata,
- Point<dim> &p_unit) const
+ const Point<dim> &initial_p_unit,
+ InternalData &mdata) const
{
const unsigned int n_shapes=mdata.shape_values.size();
Assert(n_shapes!=0, ExcInternalError());
// f(x)
+ Point<dim> p_unit = initial_p_unit;
+
compute_shapes(std::vector<Point<dim> > (1, p_unit), mdata);
Point<spacedim> p_real(transform_unit_to_real_cell_internal(mdata));
Point<spacedim> f = p_real-p;
// f(x)
p_real = transform_unit_to_real_cell_internal(mdata);
f = p_real-p;
-
}
// Here we check that in the last
// increased and tested, and thus
// havereached the limit.
AssertThrow(loop<loop_limit, ExcTransformationFailed());
+
+ return p_unit;
}
*/
template<>
-void MappingQ1<2,3>::
+Point<2>
+MappingQ1<2,3>::
transform_real_to_unit_cell_internal (const Triangulation<2,3>::cell_iterator &cell,
const Point<3> &p,
- InternalData &mdata,
- Point<2> &p_unit) const
+ const Point<2> &initial_p_unit,
+ InternalData &mdata) const
{
- transform_real_to_unit_cell_internal_codim1(cell,p, mdata, p_unit);
+ return
+ transform_real_to_unit_cell_internal_codim1(cell, p, initial_p_unit,
+ mdata);
}
template<>
-void MappingQ1<1,2>::
+Point<1>
+MappingQ1<1,2>::
transform_real_to_unit_cell_internal (const Triangulation<1,2>::cell_iterator &cell,
const Point<2> &p,
- InternalData &mdata,
- Point<1> &p_unit) const
+ const Point<1> &initial_p_unit,
+ InternalData &mdata) const
{
- transform_real_to_unit_cell_internal_codim1(cell,p, mdata, p_unit);
+ return
+ transform_real_to_unit_cell_internal_codim1(cell, p, initial_p_unit,
+ mdata);
}
+
template<>
-void MappingQ1<1,3>::
+Point<1>
+MappingQ1<1,3>::
transform_real_to_unit_cell_internal (const Triangulation<1,3>::cell_iterator &/*cell*/,
const Point<3> &/*p*/,
- InternalData &/*mdata*/,
- Point<1> &/*p_unit*/) const
+ const Point<1> &/*initial_p_unit*/,
+ InternalData &/*mdata*/) const
{
Assert(false, ExcNotImplemented());
+ return Point<1>();
}
template<int dim, int spacedim>
template<int dim_>
-void MappingQ1<dim,spacedim>::
+Point<dim_>
+MappingQ1<dim,spacedim>::
transform_real_to_unit_cell_internal_codim1
(const typename Triangulation<dim_,dim_ + 1>::cell_iterator &cell,
const Point<dim_ + 1> &p,
- MappingQ1<dim,spacedim>::InternalData &mdata,
- Point<dim_ > &p_unit) const
+ const Point<dim_ > &initial_p_unit,
+ MappingQ1<dim,spacedim>::InternalData &mdata) const
{
-
const unsigned int spacedim1 = dim_+1;
const unsigned int dim1 = dim_;
Point<spacedim1> DF[dim1];
Point<spacedim1> D2F[dim1][dim1];
+ Point<dim1> p_unit = initial_p_unit;
Point<dim1> f;
Tensor<2,dim1> df;
// increased and tested, and thus
// have reached the limit.
AssertThrow (loop<loop_limit, ExcTransformationFailed());
+
+ return p_unit;
}