- Deprecated variants of MeshWorker::loop and MeshWorker::integration_loop.
- ThreadManagement::spawn.
- Threads::ThreadCondition and Threads::ThreadMutex.
+ - GridGenerator::laplace_transformation.
</ol>
<li> Removed: The config.h file no longer exports HAVE_* definitions.
* allowing them to be distinguished for the purpose of attaching geometry
* objects and evaluating different boundary conditions.
*
- * This namespace also provides a function
- * GridGenerator::laplace_transformation that smoothly transforms a domain
- * into another one. This can be used to transform basic geometries to more
- * complicated ones, like a shell to a grid of an airfoil, for example.
- *
* @ingroup grid
*/
namespace GridGenerator
* @}
*/
- /**
- * @name Deprecated functions
- * @{
- */
-
- /**
- * This function transforms the @p Triangulation @p tria smoothly to a
- * domain that is described by the boundary points in the map @p new_points.
- * This map maps the point indices to the boundary points in the transformed
- * domain.
- *
- * Note, that the @p Triangulation is changed in-place, therefore you don't
- * need to keep two triangulations, but the given triangulation is changed
- * (overwritten).
- *
- * In 1d, this function is not currently implemented.
- *
- * An optional @p coefficient for the Laplace problem an be used to control
- * the amount of mesh deformation in different parts of the domain. Larger
- * values make cells less prone to deformation (effectively increasing their
- * stiffness). The coefficient is evaluated in the coordinate system of the
- * old, undeformed configuration of the triangulation as input, i.e., before
- * the transformation is applied. Should this function be provided, sensible
- * results can only be expected if all coefficients are positive.
- *
- * @deprecated This function has been moved to GridTools::laplace_transform
- */
- template <int dim>
- void laplace_transformation (Triangulation<dim> &tria,
- const std::map<unsigned int,Point<dim> > &new_points,
- const Function<dim> *coefficient = 0) DEAL_II_DEPRECATED;
-
- /*
- * @}
- */
-
/**
* @name Exceptions
* @{
//
// ---------------------------------------------------------------------
-#include <deal.II/base/quadrature_lib.h>
-#include <deal.II/base/thread_management.h>
-#include <deal.II/lac/vector.h>
-#include <deal.II/lac/vector_memory.h>
-#include <deal.II/lac/filtered_matrix.h>
-#include <deal.II/lac/precondition.h>
-#include <deal.II/lac/solver_cg.h>
-#include <deal.II/lac/sparse_matrix.h>
-#include <deal.II/lac/compressed_sparsity_pattern.h>
-#include <deal.II/lac/constraint_matrix.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_reordering.h>
#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/grid/intergrid_map.h>
-#include <deal.II/dofs/dof_handler.h>
-#include <deal.II/dofs/dof_accessor.h>
-#include <deal.II/dofs/dof_tools.h>
-#include <deal.II/fe/mapping_q1.h>
-#include <deal.II/fe/fe_q.h>
-#include <deal.II/numerics/matrix_tools.h>
#include <deal.II/distributed/tria.h>
}
- /**
- * Solve the Laplace equation for @p laplace_transformation function for one
- * of the @p dim space dimensions. Factorized into a function of its own
- * in order to allow parallel execution.
- */
- void laplace_solve (const SparseMatrix<double> &S,
- const std::map<unsigned int,double> &m,
- Vector<double> &u)
- {
- const unsigned int n_dofs=S.n();
- FilteredMatrix<Vector<double> > SF (S);
- PreconditionJacobi<SparseMatrix<double> > prec;
- prec.initialize(S, 1.2);
- FilteredMatrix<Vector<double> > PF (prec);
-
- SolverControl control (n_dofs, 1.e-10, false, false);
- GrowingVectorMemory<Vector<double> > mem;
- SolverCG<Vector<double> > solver (control, mem);
-
- Vector<double> f(n_dofs);
-
- SF.add_constraints(m);
- SF.apply_constraints (f, true);
- solver.solve(SF, u, f, PF);
- }
-
-
-// Implementation for 1D only
- template <>
- void laplace_transformation (Triangulation<1> &,
- const std::map<unsigned int,Point<1> > &,
- const Function<1> *)
- {
- Assert(false, ExcNotImplemented());
- }
-
-
-// Implementation for dimensions except 1
- template <int dim>
- void laplace_transformation (Triangulation<dim> &tria,
- const std::map<unsigned int,Point<dim> > &new_points,
- const Function<dim> *coefficient)
- {
- // first provide everything that is
- // needed for solving a Laplace
- // equation.
- MappingQ1<dim> mapping_q1;
- FE_Q<dim> q1(1);
-
- DoFHandler<dim> dof_handler(tria);
- dof_handler.distribute_dofs(q1);
-
- CompressedSparsityPattern c_sparsity_pattern (dof_handler.n_dofs (),
- dof_handler.n_dofs ());
- DoFTools::make_sparsity_pattern (dof_handler, c_sparsity_pattern);
- c_sparsity_pattern.compress ();
-
- SparsityPattern sparsity_pattern;
- sparsity_pattern.copy_from (c_sparsity_pattern);
- sparsity_pattern.compress ();
-
- SparseMatrix<double> S(sparsity_pattern);
-
- QGauss<dim> quadrature(4);
-
- MatrixCreator::create_laplace_matrix(mapping_q1, dof_handler, quadrature, S,coefficient);
-
- // set up the boundary values for
- // the laplace problem
- std::vector<std::map<unsigned int,double> > m(dim);
- typename std::map<unsigned int,Point<dim> >::const_iterator map_end=new_points.end();
-
- // fill these maps using the data
- // given by new_points
- typename DoFHandler<dim>::cell_iterator cell=dof_handler.begin_active(),
- endc=dof_handler.end();
- for (; cell!=endc; ++cell)
- {
- for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
- {
- const typename DoFHandler<dim>::face_iterator face=cell->face(face_no);
-
- // loop over all vertices of the cell and see if it is listed in the map
- // given as first argument of the function
- for (unsigned int vertex_no=0;
- vertex_no<GeometryInfo<dim>::vertices_per_face; ++vertex_no)
- {
- const unsigned int vertex_index=face->vertex_index(vertex_no);
-
- const typename std::map<unsigned int,Point<dim> >::const_iterator map_iter
- = new_points.find(vertex_index);
-
- if (map_iter!=map_end)
- for (unsigned int i=0; i<dim; ++i)
- m[i].insert(std::pair<unsigned int,double> (
- face->vertex_dof_index(vertex_no, 0), map_iter->second(i)));
- }
- }
- }
-
- // solve the dim problems with
- // different right hand sides.
- Vector<double> us[dim];
- for (unsigned int i=0; i<dim; ++i)
- us[i].reinit (dof_handler.n_dofs());
-
- // solve linear systems in parallel
- Threads::TaskGroup<> tasks;
- for (unsigned int i=0; i<dim; ++i)
- tasks += Threads::new_task (&laplace_solve,
- S, m[i], us[i]);
- tasks.join_all ();
-
- // change the coordinates of the
- // points of the triangulation
- // according to the computed values
- for (cell=dof_handler.begin_active(); cell!=endc; ++cell)
- for (unsigned int vertex_no=0;
- vertex_no<GeometryInfo<dim>::vertices_per_cell; ++vertex_no)
- {
- Point<dim> &v=cell->vertex(vertex_no);
- const unsigned int dof_index=cell->vertex_dof_index(vertex_no, 0);
- for (unsigned int i=0; i<dim; ++i)
- v(i)=us[i](dof_index);
- }
- }
-
-
-
template <>
void hyper_cube_with_cylindrical_hole (Triangulation<1> &,
const double,
const bool);
#endif
-#if deal_II_dimension > 1
- template void
- laplace_transformation<deal_II_dimension> (Triangulation<deal_II_dimension> &,
- const std::map<unsigned int,Point<deal_II_dimension> > &,
- const Function<deal_II_dimension> *);
-#endif
-
\}
}
#include <deal.II/base/std_cxx11/array.h>
#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/thread_management.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector_memory.h>
+#include <deal.II/lac/filtered_matrix.h>
+#include <deal.II/lac/precondition.h>
+#include <deal.II/lac/solver_cg.h>
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/lac/sparsity_tools.h>
+#include <deal.II/lac/compressed_sparsity_pattern.h>
#include <deal.II/grid/tria.h>
#include <deal.II/distributed/tria.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_boundary.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_tools.h>
-#include <deal.II/lac/sparsity_pattern.h>
-#include <deal.II/lac/sparsity_tools.h>
-#include <deal.II/lac/compressed_sparsity_pattern.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_tools.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/hp/mapping_collection.h>
#include <deal.II/multigrid/mg_dof_handler.h>
+#include <deal.II/numerics/matrix_tools.h>
#include <boost/random/uniform_real_distribution.hpp>
#include <boost/random/mersenne_twister.hpp>
}
+ namespace
+ {
+ /**
+ * Solve the Laplace equation for the @p laplace_transform function for one
+ * of the @p dim space dimensions. Factorized into a function of its own
+ * in order to allow parallel execution.
+ */
+ void laplace_solve (const SparseMatrix<double> &S,
+ const std::map<unsigned int,double> &m,
+ Vector<double> &u)
+ {
+ const unsigned int n_dofs=S.n();
+ FilteredMatrix<Vector<double> > SF (S);
+ PreconditionJacobi<SparseMatrix<double> > prec;
+ prec.initialize(S, 1.2);
+ FilteredMatrix<Vector<double> > PF (prec);
+
+ SolverControl control (n_dofs, 1.e-10, false, false);
+ GrowingVectorMemory<Vector<double> > mem;
+ SolverCG<Vector<double> > solver (control, mem);
+
+ Vector<double> f(n_dofs);
+
+ SF.add_constraints(m);
+ SF.apply_constraints (f, true);
+ solver.solve(SF, u, f, PF);
+ }
+ }
+
+
+
+ // Implementation for 1D only
+ template <>
+ void laplace_transform (const std::map<unsigned int,Point<1> > &,
+ Triangulation<1> &,
+ const Function<1> *)
+ {
+ Assert(false, ExcNotImplemented());
+ }
+
+
+ // Implementation for dimensions except 1
template <int dim>
void
laplace_transform (const std::map<unsigned int,Point<dim> > &new_points,
Triangulation<dim> &triangulation,
const Function<dim> *coefficient)
{
- //TODO: Move implementation of this function into the current
- // namespace
- GridGenerator::laplace_transformation(triangulation, new_points, coefficient);
+ // first provide everything that is
+ // needed for solving a Laplace
+ // equation.
+ MappingQ1<dim> mapping_q1;
+ FE_Q<dim> q1(1);
+
+ DoFHandler<dim> dof_handler(triangulation);
+ dof_handler.distribute_dofs(q1);
+
+ CompressedSparsityPattern c_sparsity_pattern (dof_handler.n_dofs (),
+ dof_handler.n_dofs ());
+ DoFTools::make_sparsity_pattern (dof_handler, c_sparsity_pattern);
+ c_sparsity_pattern.compress ();
+
+ SparsityPattern sparsity_pattern;
+ sparsity_pattern.copy_from (c_sparsity_pattern);
+ sparsity_pattern.compress ();
+
+ SparseMatrix<double> S(sparsity_pattern);
+
+ QGauss<dim> quadrature(4);
+
+ MatrixCreator::create_laplace_matrix(mapping_q1, dof_handler, quadrature, S,coefficient);
+
+ // set up the boundary values for
+ // the laplace problem
+ std::vector<std::map<unsigned int,double> > m(dim);
+ typename std::map<unsigned int,Point<dim> >::const_iterator map_end=new_points.end();
+
+ // fill these maps using the data
+ // given by new_points
+ typename DoFHandler<dim>::cell_iterator cell=dof_handler.begin_active(),
+ endc=dof_handler.end();
+ for (; cell!=endc; ++cell)
+ {
+ for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
+ {
+ const typename DoFHandler<dim>::face_iterator face=cell->face(face_no);
+
+ // loop over all vertices of the cell and see if it is listed in the map
+ // given as first argument of the function
+ for (unsigned int vertex_no=0;
+ vertex_no<GeometryInfo<dim>::vertices_per_face; ++vertex_no)
+ {
+ const unsigned int vertex_index=face->vertex_index(vertex_no);
+
+ const typename std::map<unsigned int,Point<dim> >::const_iterator map_iter
+ = new_points.find(vertex_index);
+
+ if (map_iter!=map_end)
+ for (unsigned int i=0; i<dim; ++i)
+ m[i].insert(std::pair<unsigned int,double> (
+ face->vertex_dof_index(vertex_no, 0), map_iter->second(i)));
+ }
+ }
+ }
+
+ // solve the dim problems with
+ // different right hand sides.
+ Vector<double> us[dim];
+ for (unsigned int i=0; i<dim; ++i)
+ us[i].reinit (dof_handler.n_dofs());
+
+ // solve linear systems in parallel
+ Threads::TaskGroup<> tasks;
+ for (unsigned int i=0; i<dim; ++i)
+ tasks += Threads::new_task (&laplace_solve,
+ S, m[i], us[i]);
+ tasks.join_all ();
+
+ // change the coordinates of the
+ // points of the triangulation
+ // according to the computed values
+ for (cell=dof_handler.begin_active(); cell!=endc; ++cell)
+ for (unsigned int vertex_no=0;
+ vertex_no<GeometryInfo<dim>::vertices_per_cell; ++vertex_no)
+ {
+ Point<dim> &v=cell->vertex(vertex_no);
+ const unsigned int dof_index=cell->vertex_dof_index(vertex_no, 0);
+ for (unsigned int i=0; i<dim; ++i)
+ v(i)=us[i](dof_index);
+ }
}
Triangulation<deal_II_dimension, deal_II_space_dimension> &result);
#if deal_II_dimension == deal_II_space_dimension
+# if deal_II_dimension > 1
template
void
laplace_transform (const std::map<unsigned int,Point<deal_II_dimension> > &new_points,
Triangulation<deal_II_dimension> &triangulation,
const Function<deal_II_dimension> *coefficient);
+# endif
template
Triangulation<deal_II_dimension,deal_II_space_dimension>::DistortedCellList
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/fe/mapping_q.h>
}
}
- GridGenerator::laplace_transformation (tria, new_points);
+ GridTools::laplace_transform (new_points, tria);
HyperBallBoundary<dim> inner_ball(n_center, n_radius);
tria.set_boundary(1, inner_ball);
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/grid_out.h>
#include <fstream>
}
}
- GridGenerator::laplace_transformation (tria, new_points);
+ GridTools::laplace_transform (new_points, tria);
GridOut grid_out;
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/fe/mapping_q.h>
}
Coefficient<dim> c;
- GridGenerator::laplace_transformation (tria, new_points, &c);
+ GridTools::laplace_transform (new_points, tria, &c);
HyperBallBoundary<dim> inner_ball(n_center, n_radius);
tria.set_boundary(1, inner_ball);