From: wolf Date: Thu, 3 Jul 2003 19:10:22 +0000 (+0000) Subject: Generalize merge_patches so that it can handle other DataOut_DoFData objects as well. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e82c83c8e011859dd7b357030ea86a6efb893c45;p=dealii-svn.git Generalize merge_patches so that it can handle other DataOut_DoFData objects as well. git-svn-id: https://svn.dealii.org/trunk@7842 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 3afd01051a..33d0444a50 100644 --- a/deal.II/deal.II/include/numerics/data_out.h +++ b/deal.II/deal.II/include/numerics/data_out.h @@ -400,7 +400,8 @@ class DataOut_DoFData : public DataOutInterface * object did not yet set up any * patches. */ - void merge_patches (const DataOut_DoFData &source, + template + void merge_patches (const DataOut_DoFData &source, const Point &shift = Point()); /** @@ -585,6 +586,13 @@ class DataOut_DoFData : public DataOutInterface * of the base class. */ virtual std::vector get_dataset_names () const; + + /** + * Make all template siblings + * friends. Needed for the + * @p{merge_patches} function. + */ + template friend class DataOut_DoFData; }; @@ -758,4 +766,56 @@ class DataOut : public DataOut_DoFData }; + +// -------------------- template and inline functions ------------------------ + +template +template +void +DataOut_DoFData:: +merge_patches (const DataOut_DoFData &source, + const Point &shift) +{ + 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()); + + // perform shift, if so desired + if (shift != Point()) + for (unsigned int i=old_n_patches; i::vertices_per_cell; ++v) + patches[i].vertices[v] += shift; + + // 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; +} + + #endif diff --git a/deal.II/deal.II/source/numerics/data_out.cc b/deal.II/deal.II/source/numerics/data_out.cc index 0fb47ba80c..26f2529438 100644 --- a/deal.II/deal.II/source/numerics/data_out.cc +++ b/deal.II/deal.II/source/numerics/data_out.cc @@ -37,7 +37,8 @@ template DataOut_DoFData::DataEntry:: DataEntry (const Vector *data, - const std::vector &names) : + const std::vector &names) + : single_data(data), has_block(false), names(names) @@ -48,7 +49,8 @@ DataEntry (const Vector *data, template DataOut_DoFData::DataEntry:: DataEntry (const BlockVector *data, - const std::vector &names) : + const std::vector &names) + : block_data(data), has_block(true), names(names) @@ -70,7 +72,8 @@ DataEntry::memory_consumption () const template -DataOut_DoFData::DataOut_DoFData () : +DataOut_DoFData::DataOut_DoFData () + : dofs(0) {} @@ -257,55 +260,6 @@ clear_input_data_references () -template -void -DataOut_DoFData:: -merge_patches (const DataOut_DoFData &source, - const Point &shift) -{ - 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()); - - // perform shift, if so desired - if (shift != Point()) - for (unsigned int i=old_n_patches; i::vertices_per_cell; ++v) - patches[i].vertices[v] += shift; - - // 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 () @@ -583,13 +537,13 @@ void DataOut::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 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 > ( const std::string &name, const DataVectorType type); + template class DataOut_DoFData; template void DataOut_DoFData:: @@ -791,4 +746,5 @@ add_data_vector > ( const std::string &name, const DataVectorType type); + #endif