From: wolf Date: Mon, 7 Apr 2003 15:39:02 +0000 (+0000) Subject: merge_patches X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce1dbbfc2d45900a5bb4b1059e1864fe1f32b827;p=dealii-svn.git merge_patches git-svn-id: https://svn.dealii.org/trunk@7362 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/data_out.h b/deal.II/deal.II/include/numerics/data_out.h index 34f7896b88..96df493f59 100644 --- a/deal.II/deal.II/include/numerics/data_out.h +++ b/deal.II/deal.II/include/numerics/data_out.h @@ -272,7 +272,7 @@ class DataOut_DoFData : public DataOutInterface * class to see which characters * are valid and which are not. */ - template + template void add_data_vector (const VECTOR &data, const std::vector &names, const DataVectorType type = type_automatic); @@ -301,7 +301,7 @@ class DataOut_DoFData : public DataOutInterface * underscore and the number of * each component to @p{name} */ - template + template 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 */ 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 << "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 diff --git a/deal.II/deal.II/source/numerics/data_out.cc b/deal.II/deal.II/source/numerics/data_out.cc index 0571e0f9d4..b1f19c8cc6 100644 --- a/deal.II/deal.II/source/numerics/data_out.cc +++ b/deal.II/deal.II/source/numerics/data_out.cc @@ -233,7 +233,8 @@ void DataOut_DoFData::clear_data_vect template void -DataOut_DoFData::clear_input_data_references () +DataOut_DoFData:: +clear_input_data_references () { for (unsigned int i=0; i::clear_input_data_ref +template +void +DataOut_DoFData:: +merge_patches (const DataOut_DoFData &source) +{ + const std::vector 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::faces_per_cell; ++n) + if (patches[i].neighbors[n] != Patch::no_neighbor) + patches[i].neighbors[n] += old_n_patches; +} + + + template void DataOut_DoFData::clear ()