]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
merge_patches
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 7 Apr 2003 15:39:02 +0000 (15:39 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 7 Apr 2003 15:39:02 +0000 (15:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@7362 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 34f7896b88c3d286e554477d2724c9ac54de7533..96df493f599e744a82951333cba9d725526e3acf 100644 (file)
@@ -272,7 +272,7 @@ class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
                                      * class to see which characters
                                      * are valid and which are not.
                                      */
-  template <class VECTOR>
+    template <class VECTOR>
     void add_data_vector (const VECTOR                   &data,
                          const std::vector<std::string> &names,
                          const DataVectorType            type = type_automatic);
@@ -301,7 +301,7 @@ class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
                                      * underscore and the number of
                                      * each component to @p{name}
                                      */
-  template <class VECTOR>
+    template <class VECTOR>
     void add_data_vector (const VECTOR         &data,
                          const std::string    &name,
                          const DataVectorType  type = type_automatic);
@@ -342,6 +342,47 @@ class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
                                      */
     void clear_input_data_references ();
 
+                                     /**
+                                      * This function can be used to
+                                      * merge the patches that were
+                                      * created using the
+                                      * @p{build_patches} function of
+                                      * the object given as argument
+                                      * into the list of patches
+                                      * created by this object. This
+                                      * is sometimes handy if one has,
+                                      * for example, a domain
+                                      * decomposition algorithm where
+                                      * each block is represented by a
+                                      * @ref{DoFHandler} of its own,
+                                      * but one wants to output the
+                                      * solution on all the blocks at
+                                      * the same time.
+                                      *
+                                      * For this to work, the given
+                                      * argument and this object need
+                                      * to have the same number of
+                                      * output vectors, and they need
+                                      * to use the same number of
+                                      * subdivisions per patch. The
+                                      * output will probably look
+                                      * rather funny if patches in
+                                      * both objects overlap in space.
+                                      *
+                                      * If you call
+                                      * @ref{build_patches} for this
+                                      * object after merging in
+                                      * patches, the previous state is
+                                      * overwritten, and the merged-in
+                                      * patches are lost.
+                                      *
+                                      * This function will fail if
+                                      * either this or the other
+                                      * object did not yet set up any
+                                      * patches.
+                                      */
+    void merge_patches (const DataOut_DoFData &source);
+    
                                     /**
                                      * Release the pointers to the
                                      * data vectors and the DoF
@@ -400,7 +441,19 @@ class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
                    << "You have to give one name per component in your "
                    << "data vector. The number you gave was " << arg1
                    << ", but the number of components is " << arg2);
-
+                                     /**
+                                      * Exception
+                                      */
+    DeclException0 (ExcNoPatches);
+                                     /**
+                                      * Exception
+                                      */
+    DeclException0 (ExcIncompatibleDatasetNames);
+                                     /**
+                                      * Exception
+                                      */
+    DeclException0 (ExcIncompatiblePatchLists);
+    
   protected:
                                     /**
                                      * Declare an entry in the list of
index 0571e0f9d41dd7a033e28712657eaeb9295c7a10..b1f19c8cc6e820c56d76da2297642b3955ab238b 100644 (file)
@@ -233,7 +233,8 @@ void DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::clear_data_vect
 
 template <int dof_handler_dim, int patch_dim, int patch_space_dim>
 void
-DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::clear_input_data_references ()
+DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::
+clear_input_data_references ()
 {
   for (unsigned int i=0; i<dof_data.size(); ++i)
     {
@@ -256,6 +257,46 @@ DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::clear_input_data_ref
 
 
 
+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 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());
+                                   // 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 ()

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.