From 99f1125b605c358129b7d5b297971f3c97d2cb01 Mon Sep 17 00:00:00 2001 From: rschulz Date: Tue, 23 May 2006 13:38:59 +0000 Subject: [PATCH] Added VectorTools::create_point_source_vector git-svn-id: https://svn.dealii.org/trunk@13129 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/Makefile | 3 ++ deal.II/deal.II/include/numerics/vectors.h | 30 ++++++++++++++ .../include/numerics/vectors.templates.h | 40 ++++++++++++++++++- deal.II/deal.II/source/numerics/vectors.cc | 11 +++++ deal.II/doc/news/changes.html | 6 +++ 5 files changed, 88 insertions(+), 2 deletions(-) diff --git a/deal.II/deal.II/Makefile b/deal.II/deal.II/Makefile index 21a5fb8d11..7edf880552 100644 --- a/deal.II/deal.II/Makefile +++ b/deal.II/deal.II/Makefile @@ -125,6 +125,7 @@ $(LIBDIR)/libdeal_II_3d$(static-lib-suffix): $(o-files-3d) $(LIBDIR)/libdeal_II_1d.g$(shared-lib-suffix): $(go-files-1d) @echo "=====deal.II====1d====debug======$(MT)== Linking library: $(@F)" + @echo $(SHLIBLD) $(LDFLAGS) $(SHLIBFLAGS) -o $@ $(go-files-1d) $(deplibs.g) @$(SHLIBLD) $(LDFLAGS) $(SHLIBFLAGS) -o $@ $(go-files-1d) $(deplibs.g) $(LIBDIR)/libdeal_II_1d$(shared-lib-suffix): $(o-files-1d) @@ -143,10 +144,12 @@ $(LIBDIR)/libdeal_II_2d$(shared-lib-suffix): $(o-files-2d) $(LIBDIR)/libdeal_II_3d.g$(shared-lib-suffix): $(go-files-3d) @echo "=====deal.II====3d====debug======$(MT)== Linking library: $(@F)" + @echo $(SHLIBLD) $(LDFLAGS) $(SHLIBFLAGS) -o $@ $(go-files-3d) $(deplibs.g) @$(SHLIBLD) $(LDFLAGS) $(SHLIBFLAGS) -o $@ $(go-files-3d) $(deplibs.g) $(LIBDIR)/libdeal_II_3d$(shared-lib-suffix): $(o-files-3d) @echo "=====deal.II====3d====optimized==$(MT)== Linking library: $(@F)" + @echo $(SHLIBLD) $(LDFLAGS) $(SHLIBFLAGS) -o $@ $(o-files-3d) $(deplibs.o) @$(SHLIBLD) $(LDFLAGS) $(SHLIBFLAGS) -o $@ $(o-files-3d) $(deplibs.o) diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h index 35dd13ae76..3bdfccb08a 100644 --- a/deal.II/deal.II/include/numerics/vectors.h +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -165,6 +165,10 @@ class ConstraintMatrix; * MatrixCreator::create_* functions which take a right hand side do, * but without assembling a matrix. * + *
  • Creation of right hand side vectors for point sources: + * The @p create_point_source_vector function computes the vector + * $f_i = \int_\Omega \delta_0(x-x_0) \phi_i(x) dx$. + * *
  • Creation of boundary right hand side vectors: The * @p create_boundary_right_hand_side function computes the vector * $f_i = \int_{\partial\Omega} g(x) \phi_i(x) dx$. This is the @@ -568,6 +572,32 @@ class VectorTools Vector &rhs_vector); /** + * Create a right hand side + * vector for a point source at point @p p. + * Prior content of the + * given @p rhs_vector vector is + * deleted. + * + * See the general documentation of this + * class for further information. + */ + template + static void create_point_source_vector(const Mapping &mapping, + const DoFHandler &dof, + const Point &p, + Vector &rhs_vector); + + /** + * Calls the @p create_point_source_vector + * function, see above, with + * mapping=MappingQ1@(). + */ + template + static void create_point_source_vector(const DoFHandler &dof, + const Point &p, + Vector &rhs_vector); + + /** * Create a right hand side * vector from boundary * forces. Prior content of the diff --git a/deal.II/deal.II/include/numerics/vectors.templates.h b/deal.II/deal.II/include/numerics/vectors.templates.h index 7c665cc40a..67068eb5b8 100644 --- a/deal.II/deal.II/include/numerics/vectors.templates.h +++ b/deal.II/deal.II/include/numerics/vectors.templates.h @@ -572,12 +572,48 @@ void VectorTools::create_right_hand_side (const DoFHandler &dof_handler, Vector &rhs_vector) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); - static const MappingQ1 mapping; - create_right_hand_side(mapping, dof_handler, quadrature, + create_right_hand_side(StaticMappingQ1::mapping, dof_handler, quadrature, rhs_function, rhs_vector); } +template +void VectorTools::create_point_source_vector (const Mapping &mapping, + const DoFHandler &dof_handler, + const Point &p, + Vector &rhs_vector) +{ + Assert (rhs_vector.size() == dof_handler.n_dofs(), + ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); + rhs_vector = 0; + + std::pair::active_cell_iterator, Point > + cell_point = + GridTools::find_active_cell_around_point (mapping, dof_handler, p); + + Quadrature q(GeometryInfo::project_to_unit_cell(cell_point.second)); + + FEValues fe_values(dof_handler.get_fe(), q, UpdateFlags(update_values)); + fe_values.reinit(cell_point.first); + + const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell; + + std::vector local_dof_indices (dofs_per_cell); + cell_point.first->get_dof_indices (local_dof_indices); + + for(unsigned int i=0; i +void VectorTools::create_point_source_vector (const DoFHandler &dof_handler, + const Point &p, + Vector &rhs_vector) +{ + Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); + create_point_source_vector(StaticMappingQ1::mapping, dof_handler, + p, rhs_vector); +} #if deal_II_dimension != 1 diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index 380eeefb46..d5d5e6f3a3 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -102,6 +102,17 @@ void VectorTools::create_right_hand_side const Quadrature &, const Function &, Vector &); +template +void VectorTools::create_point_source_vector +(const Mapping &, + const DoFHandler &, + const Point &, + Vector &); +template +void VectorTools::create_point_source_vector +(const DoFHandler &, + const Point &, + Vector &); #if deal_II_dimension != 1 template diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index d9fc3b0109..eb946c6362 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -646,6 +646,12 @@ inconvenience this causes.

    deal.II

      +
    1. + New: Function VectorTools::create_point_source_vector to calculate the projection + of a Dirac pulse on the base functions. This models a point source as + used in the calculations of Green's functions and can also be used to + extract the value of a finite element solution in a single point.

    2. Changed: Functions VectorTools::point_value and VectorTools::