]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement interpolation.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 18 May 1998 08:40:34 +0000 (08:40 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 18 May 1998 08:40:34 +0000 (08:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@304 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/numerics/vectors.cc

index 040410d3c70d74ff8ea882278559c15719a67184..061aa87c067481d97869f6618f41861c58c9163d 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <basic/function.h>
 #include <grid/dof.h>
+#include <grid/dof_accessor.h>
+#include <grid/tria_iterator.h>
 #include <grid/dof_constraints.h>
 #include <fe/fe.h>
 #include <numerics/vectors.h>
 template <int dim>
 void VectorCreator<dim>::interpolate (const DoFHandler<dim>    &dof,
                                      const FiniteElement<dim> &fe,
+                                     const Boundary<dim>      &boundary,
                                      const Function<dim>      &function,
                                      dVector                  &vec) {
-  ;
+  DoFHandler<dim>::active_cell_iterator cell = dof.begin_active(),
+                                       endc = dof.end();
+  vector<int>         dofs_on_cell (fe.total_dofs);
+  vector<double>      dof_values_on_cell (fe.total_dofs);
+  vector<Point<dim> > ansatz_points (fe.total_dofs);
+  for (; cell!=endc; ++cell) 
+    {
+                                      // for each cell:
+                                      // get location of finite element
+                                      // off-points
+      fe.get_ansatz_points (cell, boundary, ansatz_points);
+                                      // get function values at these points
+      function.value_list (ansatz_points, dof_values_on_cell);
+                                      // get indices of the dofs on this cell
+      cell->get_dof_indices (dofs_on_cell);
+                                      // distribute function values to the
+                                      // whole vector
+      for (unsigned int i=0; i<fe.total_dofs; ++i)
+       vec(dofs_on_cell[i]) = dof_values_on_cell[i];
+    };
 };
 
 
@@ -40,11 +62,15 @@ void VectorCreator<dim>::project (const DoFHandler<dim>    &dof,
                          dof.n_dofs(),
                          dof.max_couplings_between_dofs());
   dof.make_sparsity_pattern (sparsity);
-
+  constraints.condense (sparsity);
+  
   dSMatrix mass_matrix (sparsity);
   dVector tmp (mass_matrix.n());
   MatrixCreator<dim>::create_mass_matrix (dof, fe, q, boundary,
-                                         mass_matrix, function, vec);
+                                         mass_matrix, function, tmp);
+
+  constraints.condense (mass_matrix);
+  constraints.condense (tmp);
 
   int    max_iter  = 4000;
   double tolerance = 1.e-16;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.