]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
L2-projection between degrees
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Nov 2003 15:49:37 +0000 (15:49 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Nov 2003 15:49:37 +0000 (15:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@8213 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/fe/fe_tools.h
deal.II/deal.II/source/fe/fe_tools.cc
deal.II/doc/news/c-4-0.html

index 5e87a72e21b8611616e652dffddc28623ee68b28..1ab3d595b3edda58f92e31b1ad0723d301c4f587 100644 (file)
@@ -112,6 +112,11 @@ class FETools
                                        const FiniteElement<dim> &fe2,
                                        FullMatrix<number> &difference_matrix);
 
+                                    /**
+                                     * Compute the local
+                                     * $L^2$-projection matrix from
+                                     * fe1 to fe2.
+                                     */
     template <int dim, typename number>
     static void get_projection_matrix(const FiniteElement<dim> &fe1,
                                      const FiniteElement<dim> &fe2,
@@ -334,8 +339,28 @@ class FETools
                                         const InVector&         z1,
                                         const DoFHandler<dim>&  dof2,
                                         const ConstraintMatrix& constraints2,
-                                        OutVector&              z1_difference);    
-
+                                        OutVector&              z1_difference);
+    
+                                    /**
+                                     * $L^2$ projection for
+                                     * discontinuous
+                                     * elements. Operates the same
+                                     * direction as interpolate.
+                                     *
+                                     * The global projection can be
+                                     * computed by local matrices if
+                                     * the finite element spaces are
+                                     * discontinuous. With continuous
+                                     * elements, this is impossible,
+                                     * since a global mass matrix
+                                     * must be inverted.
+                                     */
+    template <int dim, class InVector, class OutVector>
+    static void project_dg (const DoFHandler<dim>& dof1,
+                           const InVector&        u1,
+                           const DoFHandler<dim>& dof2,
+                           OutVector&             u2);
+    
                                     /**
                                      * Gives the patchwise
                                      * extrapolation of a @p{dof1}
index 2ac088be8324235b410454daa7fb430d77a057e2..f491bcb4702018ced24c896ebbeaafbb17c6a72f 100644 (file)
@@ -650,6 +650,48 @@ void FETools::interpolation_difference(const DoFHandler<dim> &dof1,
 }
 
   
+template <int dim, class InVector, class OutVector>
+void FETools::project_dg(const DoFHandler<dim> &dof1,
+                        const InVector &u1,
+                        const DoFHandler<dim> &dof2,
+                        OutVector &u2)
+{
+  Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch());
+  Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(),
+        ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components()));
+  Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));  
+  Assert(u2.size()==dof2.n_dofs(), ExcDimensionMismatch(u2.size(), dof2.n_dofs()));
+
+  typename DoFHandler<dim>::active_cell_iterator cell1 = dof1.begin_active();
+  typename DoFHandler<dim>::active_cell_iterator cell2 = dof2.begin_active();
+  typename DoFHandler<dim>::active_cell_iterator end = dof2.end();
+
+  const unsigned int n1 = dof1.get_fe().dofs_per_cell;
+  const unsigned int n2 = dof2.get_fe().dofs_per_cell;
+  
+  Vector<double> u1_local(n1);
+  Vector<double> u2_local(n2);
+  std::vector<unsigned int> dofs(n2);
+  
+  FullMatrix<double> matrix(n2,n1);
+  get_projection_matrix(dof1.get_fe(), dof2.get_fe(), matrix);
+  
+  while (cell2 != end)
+    {
+      cell1->get_dof_values(u1, u1_local);
+      matrix.vmult(u2_local, u1_local);
+      cell2->get_dof_indices(dofs);
+      for (unsigned int i=0; i<n2; ++i)
+       {
+         u2(dofs[i])+=u2_local(i);
+       }
+     
+      ++cell1;
+      ++cell2;
+    }
+}
+
+  
 template <int dim, class InVector, class OutVector>
 void FETools::extrapolate(const DoFHandler<dim> &dof1,
                          const InVector &u1,
@@ -1564,6 +1606,10 @@ void FETools::interpolation_difference<deal_II_dimension>
  const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
  Vector<double> &);
 template
+void FETools::project_dg<deal_II_dimension>
+(const DoFHandler<deal_II_dimension> &, const Vector<double> &,
+ const DoFHandler<deal_II_dimension> &, Vector<double> &);
+template
 void FETools::extrapolate<deal_II_dimension>
 (const DoFHandler<deal_II_dimension> &, const Vector<double> &,
  const DoFHandler<deal_II_dimension> &, Vector<double> &);
@@ -1604,6 +1650,10 @@ void FETools::interpolation_difference<deal_II_dimension>
  const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
  Vector<float> &);
 template
+void FETools::project_dg<deal_II_dimension>
+(const DoFHandler<deal_II_dimension> &, const Vector<float> &,
+ const DoFHandler<deal_II_dimension> &, Vector<float> &);
+template
 void FETools::extrapolate<deal_II_dimension>
 (const DoFHandler<deal_II_dimension> &, const Vector<float> &,
  const DoFHandler<deal_II_dimension> &, Vector<float> &);
@@ -1644,6 +1694,10 @@ void FETools::interpolation_difference<deal_II_dimension>
  const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
  BlockVector<double> &);
 template
+void FETools::project_dg<deal_II_dimension>
+(const DoFHandler<deal_II_dimension> &, const BlockVector<double> &,
+ const DoFHandler<deal_II_dimension> &, BlockVector<double> &);
+template
 void FETools::extrapolate<deal_II_dimension>
 (const DoFHandler<deal_II_dimension> &, const BlockVector<double> &,
  const DoFHandler<deal_II_dimension> &, BlockVector<double> &);
@@ -1693,6 +1747,10 @@ void FETools::interpolation_difference<deal_II_dimension>
  const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
  BlockVector<float> &);
 template
+void FETools::project_dg<deal_II_dimension>
+(const DoFHandler<deal_II_dimension> &, const BlockVector<float> &,
+ const DoFHandler<deal_II_dimension> &, BlockVector<float> &);
+template
 void FETools::extrapolate<deal_II_dimension>
 (const DoFHandler<deal_II_dimension> &, const BlockVector<float> &,
  const DoFHandler<deal_II_dimension> &, BlockVector<float> &);
index 22a5c5f8b9a5baee1181e43a9fb29034e371cf6b..012c4cb7cc2c580f6c2298620d43d427fa60b429 100644 (file)
@@ -304,6 +304,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 
 <ol>
 
+  <li> <p>
+  New: The function
+  <class="class">FETools</code>::<class="member">project_dg</code> performs
+  <i>L<sup>2</sup></i>-projections between finite element spaces of different
+  degrees on the same mesh.
+  <br>
+  (GK 2003/11/28)
+  </p>
+
   <li> <p>
   Improved: <code class="class">FiniteElementData</code> has a function
   <class="member">tensor_degree()</code>, returning the degree of the

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.