]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
additional weight function argument in #integrate_difference# for systems
authorhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 Jul 1999 15:09:54 +0000 (15:09 +0000)
committerhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 Jul 1999 15:09:54 +0000 (15:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@1531 0785d39b-7218-0410-832d-ea1e28bc413d

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

index ed21e2dafe42f720f9219bfd856b4609635a8212..95fda10a0ec70bf999a7288fcdc38df70d884dcd 100644 (file)
@@ -447,13 +447,27 @@ class VectorTools //<dim>
                                     /**
                                      * Compute the error for the solution of a system.
                                      * See the other #integrate_difference#.
+                                     *
+                                     * The additional argument #weight# allows
+                                     * to evaluate weighted norms. This is useful
+                                     * for weighting the error of different parts
+                                     * differently. A special use is
+                                     * to have #weight=0# in some parts of the 
+                                     * domain, e.g. at
+                                     * the location of a shock and #weight=1#
+                                     * elsewhere. This allows convergence tests
+                                     * in smooth parts of in general discontinuous
+                                     * solutions.
+                                     * By default, no weighting function is given,
+                                     * i.e. weight=1 in the whole domain.
                                      */
     static void integrate_difference (const DoFHandler<dim>   &dof,
                                      const Vector<double>     &fe_function,
                                      const VectorFunction<dim>&exact_solution,
                                      Vector<float>            &difference,
                                      const Quadrature<dim>    &q,
-                                     const NormType           &norm);
+                                     const NormType           &norm,
+                                     const Function<dim>      *weight=0);
     
 
                                     /**
index 9ed65f0b1b881976d7791cce4b19d900a3305931..1c20446e0f694abbfe27156b4370d527a8a3f13e 100644 (file)
@@ -878,7 +878,8 @@ VectorTools<dim>::integrate_difference (const DoFHandler<dim>    &dof,
                                        const VectorFunction<dim>&exact_solution,
                                        Vector<float>            &difference,
                                        const Quadrature<dim>    &q,
-                                       const NormType           &norm)
+                                       const NormType           &norm,
+                                       const Function<dim>      *weight)
 {
   Assert(norm != mean , ExcNotUseful());
 
@@ -958,10 +959,21 @@ VectorTools<dim>::integrate_difference (const DoFHandler<dim>    &dof,
                      Assert (false, ExcNotImplemented());
              };
 
+                                            // now weight the values
+                                            // at the quadrature points due
+                                            // to the weighting function
+           if (weight)
+             {
+               vector<double> w(n_q_points);
+               weight->value_list(fe_values.get_quadrature_points(),w);
+               for (unsigned int q=0; q<n_q_points; ++q)
+                 psi_scalar[q]*=w[q];
+             }
+
                                             // ok, now we have the integrand,
                                             // let's compute the integral,
                                             // which is
-                                            // sum_j psi_j JxW_j
+                                            // sum_j psi_j weight_j JxW_j
                                             // (or |psi_j| or |psi_j|^2
            switch (norm)
              {
@@ -1030,6 +1042,17 @@ VectorTools<dim>::integrate_difference (const DoFHandler<dim>    &dof,
              for (unsigned int k=0; k<fe.n_components; ++k)
                psi_square[q] += sqr_point(psi[q][k]);
 
+                                            // now weight the values
+                                            // at the quadrature points due
+                                            // to the weighting function
+           if (weight)
+             {
+               vector<double> w(n_q_points);
+               weight->value_list(fe_values.get_quadrature_points(),w);
+               for (unsigned int q=0; q<n_q_points; ++q)
+                 psi_square[q]*=w[q];
+             }
+
                                             // add seminorm to L_2 norm or
                                             // to zero
            diff += inner_product (psi_square.begin(), psi_square.end(),

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.