]> https://gitweb.dealii.org/ - dealii.git/commitdiff
DoFTools::make_flux_sparsity_pattern for 1d.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 3 Sep 2001 16:51:57 +0000 (16:51 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 3 Sep 2001 16:51:57 +0000 (16:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@4944 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/dof_tools.h
deal.II/deal.II/source/dofs/dof_tools.cc
deal.II/doc/news/2001/c-3-1.html

index 8a315a0aa9071d35fbb7eb7cf7be5639ab671688..af78450873379b9775a2e12626c1fc240ae6b09b 100644 (file)
@@ -430,6 +430,13 @@ class DoFTools
     make_flux_sparsity_pattern (const DoFHandler<dim> &dof_handler,
                                SparsityPattern       &sparsity_pattern);
 
+                                    /**
+                                     * Same function, but for 1d.
+                                     */
+    static void
+    make_flux_sparsity_pattern (const DoFHandler<1> &dof_handler,
+                               SparsityPattern     &sparsity_pattern);
+    
                                     /**
                                      * This function does the same as
                                      * the other with the same name,
index a9c93175e6e48e93072946b95a496c96a60db721..b6850748c338bce3b3c6ad58da9ba680c51b9df6 100644 (file)
@@ -289,6 +289,7 @@ void DoFTools::make_boundary_sparsity_pattern (const DoFHandler<dim>& dof,
 };
 
 
+
 template<int dim>
 void
 DoFTools::make_flux_sparsity_pattern (const DoFHandler<dim> &dof,
@@ -382,6 +383,54 @@ DoFTools::make_flux_sparsity_pattern (const DoFHandler<dim> &dof,
 }
 
 
+#if deal_II_dimension == 1
+
+void
+DoFTools::make_flux_sparsity_pattern (const DoFHandler<1> &dof,
+                                     SparsityPattern     &sparsity)
+{
+  typedef DoFHandler<1>::cell_iterator        cell_iterator;
+  typedef DoFHandler<1>::active_cell_iterator active_cell_iterator;
+
+  const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
+  std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+  std::vector<unsigned int> neighbor_dof_indices (dofs_per_cell);
+  
+  active_cell_iterator cell = dof.begin_active(),
+                      endc = dof.end();
+  for (; cell!=endc; ++cell)
+    {
+                                      // first do couplings of dofs
+                                      // locally on this cell
+      cell->get_dof_indices (local_dof_indices);
+      for (unsigned int i=0; i<dofs_per_cell; ++i)
+       for (unsigned int j=0; j<dofs_per_cell; ++j)
+         sparsity.add (local_dof_indices[i], local_dof_indices[j]);
+
+                                      // then do the same for the up
+                                      // to 2 neighbors
+      for (unsigned int nb=0; nb<2; ++nb)
+       if (! cell->at_boundary(nb))
+         {
+                                            // find active neighbor
+           cell_iterator neighbor = cell->neighbor(nb);
+           while (neighbor->has_children())
+             neighbor = neighbor->child(nb==0 ? 1 : 0);
+
+                                            // get dofs on it
+           neighbor->get_dof_indices (neighbor_dof_indices);
+
+                                            // compute couplings
+           for (unsigned int i=0; i<dofs_per_cell; ++i)
+             for (unsigned int j=0; j<dofs_per_cell; ++j)
+               sparsity.add (local_dof_indices[i], neighbor_dof_indices[j]);
+         };
+    };
+};
+
+
+#endif
+
 
 template<int dim>
 void
index a5eb46a2bd5fba951fbc233770594d11bb0deb6a..0fecf4391711db14b598704fead98d701da40672 100644 (file)
@@ -581,6 +581,13 @@ documentation, etc</a>.
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p> 
+       New: <code class="member">DoFTools::make_flux_sparsity_pattern</code>
+       now exists also for 1d.
+       <br>
+       (WB 2001/09/03)
+       </p>
+
   <li> <p> 
        New: There are now two functions
        <code

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.