]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Generalize merge_patches so that it can handle other DataOut_DoFData objects as well.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 3 Jul 2003 19:10:22 +0000 (19:10 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 3 Jul 2003 19:10:22 +0000 (19:10 +0000)
git-svn-id: https://svn.dealii.org/trunk@7842 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 3afd01051adc374964cb40556ae2eb0d7cefc752..33d0444a50392b0eda97a535c1fbd3ac9057174d 100644 (file)
@@ -400,7 +400,8 @@ class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
                                       * object did not yet set up any
                                       * patches.
                                       */
-    void merge_patches (const DataOut_DoFData        &source,
+    template <int dof_handler_dim2>
+    void merge_patches (const DataOut_DoFData<dof_handler_dim2,patch_dim,patch_space_dim> &source,
                        const Point<patch_space_dim> &shift = Point<patch_space_dim>());
     
                                     /**
@@ -585,6 +586,13 @@ class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
                                      * of the base class.
                                      */
     virtual std::vector<std::string> get_dataset_names () const;
+
+                                    /**
+                                     * Make all template siblings
+                                     * friends. Needed for the
+                                     * @p{merge_patches} function.
+                                     */
+    template <int,int,int> friend class DataOut_DoFData;
 };
 
 
@@ -758,4 +766,56 @@ class DataOut : public DataOut_DoFData<dim,dim>
 };
 
 
+
+// -------------------- template and inline functions ------------------------
+
+template <int dof_handler_dim, int patch_dim, int patch_space_dim>
+template <int dof_handler_dim2>
+void
+DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::
+merge_patches (const DataOut_DoFData<dof_handler_dim2,patch_dim,patch_space_dim> &source,
+              const Point<patch_space_dim> &shift)
+{
+  const std::vector<Patch> source_patches = source.get_patches ();
+  Assert (patches.size () != 0,        ExcNoPatches ());
+  Assert (source_patches.size () != 0, ExcNoPatches ());
+                                   // check equality of component
+                                   // names
+  Assert (get_dataset_names() == source.get_dataset_names(),
+          ExcIncompatibleDatasetNames());
+                                   // make sure patches are compatible
+  Assert (patches[0].n_subdivisions == source_patches[0].n_subdivisions,
+          ExcIncompatiblePatchLists());
+  Assert (patches[0].data.n_rows() == source_patches[0].data.n_rows(),
+          ExcIncompatiblePatchLists());
+  Assert (patches[0].data.n_cols() == source_patches[0].data.n_cols(),
+          ExcIncompatiblePatchLists());
+
+                                   // merge patches. store old number
+                                   // of elements, since we need to
+                                   // adjust patch numbers, etc
+                                   // afterwards
+  const unsigned int old_n_patches = patches.size();
+  patches.insert (patches.end(),
+                  source_patches.begin(),
+                  source_patches.end());
+
+                                  // perform shift, if so desired
+  if (shift != Point<patch_space_dim>())
+    for (unsigned int i=old_n_patches; i<patches.size(); ++i)
+      for (unsigned int v=0; v<GeometryInfo<patch_dim>::vertices_per_cell; ++v)
+       patches[i].vertices[v] += shift;
+  
+                                   // adjust patch numbers
+  for (unsigned int i=old_n_patches; i<patches.size(); ++i)
+    patches[i].patch_index += old_n_patches;
+  
+                                   // adjust patch neighbors
+  for (unsigned int i=old_n_patches; i<patches.size(); ++i)
+    for (unsigned int n=0; n<GeometryInfo<patch_dim>::faces_per_cell; ++n)
+      if (patches[i].neighbors[n] != Patch::no_neighbor)
+        patches[i].neighbors[n] += old_n_patches;
+}
+
+
 #endif
index 0fb47ba80c663715a13cef5ab1ad9fe3fb68cc63..26f2529438392d3f8912e4641089676cf1251823 100644 (file)
@@ -37,7 +37,8 @@
 template <int dof_handler_dim, int patch_dim, int patch_space_dim>
 DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::DataEntry::
 DataEntry (const Vector<double> *data,
-          const std::vector<std::string> &names) :
+          const std::vector<std::string> &names)
+               :
                single_data(data),
                has_block(false),
                names(names)
@@ -48,7 +49,8 @@ DataEntry (const Vector<double> *data,
 template <int dof_handler_dim, int patch_dim, int patch_space_dim>
 DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::DataEntry::
 DataEntry (const BlockVector<double> *data,
-          const std::vector<std::string> &names) :
+          const std::vector<std::string> &names)
+               :
                block_data(data),
                has_block(true),
                names(names)
@@ -70,7 +72,8 @@ DataEntry::memory_consumption () const
 
 
 template <int dof_handler_dim, int patch_dim, int patch_space_dim>
-DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::DataOut_DoFData () :
+DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::DataOut_DoFData ()
+               :
                dofs(0)
 {}
 
@@ -257,55 +260,6 @@ clear_input_data_references ()
 
 
 
-template <int dof_handler_dim, int patch_dim, int patch_space_dim>
-void
-DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::
-merge_patches (const DataOut_DoFData        &source,
-              const Point<patch_space_dim> &shift)
-{
-  const std::vector<Patch> source_patches = source.get_patches ();
-  Assert (patches.size () != 0,        ExcNoPatches ());
-  Assert (source_patches.size () != 0, ExcNoPatches ());
-                                   // check equality of component
-                                   // names
-  Assert (get_dataset_names() == source.get_dataset_names(),
-          ExcIncompatibleDatasetNames());
-                                   // make sure patches are compatible
-  Assert (patches[0].n_subdivisions == source_patches[0].n_subdivisions,
-          ExcIncompatiblePatchLists());
-  Assert (patches[0].data.n_rows() == source_patches[0].data.n_rows(),
-          ExcIncompatiblePatchLists());
-  Assert (patches[0].data.n_cols() == source_patches[0].data.n_cols(),
-          ExcIncompatiblePatchLists());
-
-                                   // merge patches. store old number
-                                   // of elements, since we need to
-                                   // adjust patch numbers, etc
-                                   // afterwards
-  const unsigned int old_n_patches = patches.size();
-  patches.insert (patches.end(),
-                  source_patches.begin(),
-                  source_patches.end());
-
-                                  // perform shift, if so desired
-  if (shift != Point<patch_space_dim>())
-    for (unsigned int i=old_n_patches; i<patches.size(); ++i)
-      for (unsigned int v=0; v<GeometryInfo<patch_dim>::vertices_per_cell; ++v)
-       patches[i].vertices[v] += shift;
-  
-                                   // adjust patch numbers
-  for (unsigned int i=old_n_patches; i<patches.size(); ++i)
-    patches[i].patch_index += old_n_patches;
-  
-                                   // adjust patch neighbors
-  for (unsigned int i=old_n_patches; i<patches.size(); ++i)
-    for (unsigned int n=0; n<GeometryInfo<patch_dim>::faces_per_cell; ++n)
-      if (patches[i].neighbors[n] != Patch::no_neighbor)
-        patches[i].neighbors[n] += old_n_patches;
-}
-
-
-
 template <int dof_handler_dim, int patch_dim, int patch_space_dim>
 void
 DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::clear ()
@@ -583,13 +537,13 @@ void DataOut<dim>::build_patches (const unsigned int n_subdivisions,
 
   const unsigned int n_threads = (DEAL_II_USE_MT ? n_threads_ : 1);
 
-                                  // before we start the loop:
-                                  // create a quadrature rule that
-                                  // actually has the points on this
-                                  // patch
+                                  // before we start the loop:
+                                  // create a quadrature rule that
+                                  // actually has the points on this
+                                  // patch
   QTrapez<1>     q_trapez;
   QIterated<dim> patch_points (q_trapez, n_subdivisions);
-
+  
   const unsigned int n_q_points     = patch_points.n_quadrature_points;
   const unsigned int n_components   = this->dofs->get_fe().n_components();
   const unsigned int n_datasets     = this->dof_data.size() * n_components +
@@ -733,6 +687,7 @@ add_data_vector<BlockVector<double> > (
   const std::string    &name,
   const DataVectorType  type);
 
+
 template class DataOut_DoFData<deal_II_dimension,deal_II_dimension+1>;
 template void
 DataOut_DoFData<deal_II_dimension,deal_II_dimension+1>::
@@ -791,4 +746,5 @@ add_data_vector<BlockVector<double> > (
   const std::string    &name,
   const DataVectorType  type);
 
+
 #endif

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.