]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add residuals
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 9 Aug 2012 17:44:04 +0000 (17:44 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 9 Aug 2012 17:44:04 +0000 (17:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@25832 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/integrators/divergence.h

index 8734fff170486f0d2c575dbee1dced7f53607fe0..70128a4f92f7338bc88cf1616ff7139332236cb5 100644 (file)
@@ -102,6 +102,40 @@ namespace LocalIntegrators
             }
         }
     }
+
+/**
+ * The residual of the divergence operator in strong form.
+ * \f[
+ * \int_Z v\nabla \cdot \mathbf u \,dx
+ * \f]
+ * This is the strong divergence operator and the trial
+ * space should be at least <b>H</b><sup>div</sup>. The test functions
+ * may be discontinuous.
+ *
+ * The function cell_matrix() is the Frechet derivative of this function with respect
+ * to the test functions.
+ */
+    template <int dim>
+    void cell_residual(
+                       Vector<double>& result,
+                       const FEValuesBase<dim>& fetest,
+                       const VectorSlice<const std::vector<std::vector<Tensor<1,dim> > > >& input,
+                       const double factor = 1.)
+    {
+       AssertDimension(fetest.get_fe().n_components(), 1);
+       AssertVectorVectorDimension(input, dim, fetest.n_quadrature_points);
+       const unsigned int t_dofs = fetest.dofs_per_cell;
+       Assert (result.size() == t_dofs, ExcDimensionMismatch(result.size(), t_dofs));
+
+       for (unsigned k=0;k<fetest.n_quadrature_points;++k)
+           {
+             const double dx = factor * fetest.JxW(k);
+
+             for (unsigned i=0;i<t_dofs;++i)
+               for (unsigned int d=0;d<dim;++d)
+                 result(i) += dx * input[d][k][d] * fetest.shape_value(i,k);
+           }
+    }
 /**
  * Cell matrix for gradient. The derivative is on the trial
  * function.
@@ -144,6 +178,39 @@ namespace LocalIntegrators
         }
     }
 
+    /**
+     * The residual of the gradient operator in strong form.
+     * \f[
+     * \int_Z \mathbf v\cdot\nabla u \,dx
+     * \f]
+     * This is the strong gradient operator and the trial
+     * space should be at least <b>H</b><sup>1</sup>. The test functions
+     * may be discontinuous.
+     *
+     * The function cell_residual() is the Frechet derivative of this function with respect to the test functions.
+     */
+        template <int dim>
+        void gradient_residual(
+                               Vector<double>& result,
+                               const FEValuesBase<dim>& fetest,
+                               const std::vector<Tensor<1,dim> >& input,
+                               const double factor = 1.)
+        {
+               AssertDimension(fetest.get_fe().n_components(), dim);
+               AssertDimension(input.size(), fetest.n_quadrature_points);
+               const unsigned int t_dofs = fetest.dofs_per_cell;
+               Assert (result.size() == t_dofs, ExcDimensionMismatch(result.size(), t_dofs));
+
+               for (unsigned k=0;k<fetest.n_quadrature_points;++k)
+                   {
+                     const double dx = factor * fetest.JxW(k);
+
+                     for (unsigned i=0;i<t_dofs;++i)
+                       for (unsigned int d=0;d<dim;++d)
+                         result(i) += dx * input[k][d] * fetest.shape_value_component(i,k,d);
+                   }
+        }
+
 /**
  * The trace of the divergence
  * operator, namely the product

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.