From 4dfbb9c113fe96ea445886c35fbe58a0b6d7c0e0 Mon Sep 17 00:00:00 2001 From: guido Date: Fri, 12 Oct 2001 09:45:54 +0000 Subject: [PATCH] BlockVector in DataOut git-svn-id: https://svn.dealii.org/trunk@5145 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/multigrid/multigrid.templates.h | 84 +++++------ deal.II/deal.II/include/numerics/data_out.h | 31 ++++- deal.II/deal.II/include/numerics/vectors.h | 12 +- deal.II/deal.II/source/dofs/dof_accessor.cc | 20 +++ deal.II/deal.II/source/fe/fe_values.cc | 30 +++- deal.II/deal.II/source/numerics/data_out.cc | 131 ++++++++++++++++-- .../deal.II/source/numerics/data_out_faces.cc | 35 +++-- .../source/numerics/data_out_rotation.cc | 23 ++- .../deal.II/source/numerics/data_out_stack.cc | 1 + deal.II/deal.II/source/numerics/vectors.cc | 131 +++++++++++++++++- deal.II/doc/news/2001/c-3-2.html | 21 +++ 11 files changed, 428 insertions(+), 91 deletions(-) diff --git a/deal.II/deal.II/include/multigrid/multigrid.templates.h b/deal.II/deal.II/include/multigrid/multigrid.templates.h index 8874e31296..2519312541 100644 --- a/deal.II/deal.II/include/multigrid/multigrid.templates.h +++ b/deal.II/deal.II/include/multigrid/multigrid.templates.h @@ -15,7 +15,7 @@ #include -#include +//#include #include #include #include @@ -185,52 +185,52 @@ Multigrid::copy_from_mg(Vector &dst) const template void -Multigrid::print_vector (const unsigned int level, - const Vector& v, - const char* name) const +Multigrid::print_vector (const unsigned int /*level*/, + const Vector& /*v*/, + const char* /*name*/) const { - if (level!=maxlevel) - return; +// if (level!=maxlevel) +// return; - const DoFHandler* dof = mg_dof_handler; +// const DoFHandler* dof = mg_dof_handler; - Vector out_vector(dof->n_dofs()); +// Vector out_vector(dof->n_dofs()); - out_vector = -10000; +// out_vector = -10000; - const unsigned int dofs_per_cell = mg_dof_handler->get_fe().dofs_per_cell; - - std::vector global_dof_indices (dofs_per_cell); - std::vector level_dof_indices (dofs_per_cell); - - typename DoFHandler::active_cell_iterator - global_cell = dof->begin_active(level); - typename MGDoFHandler::active_cell_iterator - level_cell = mg_dof_handler->begin_active(level); - const typename MGDoFHandler::cell_iterator - endc = mg_dof_handler->end(level); - - // traverse all cells and copy the - // data appropriately to the output - // vector - for (; level_cell != endc; ++level_cell, ++global_cell) - { - global_cell->get_dof_indices (global_dof_indices); - level_cell->get_mg_dof_indices(level_dof_indices); - - // copy level-wise data to - // global vector - for (unsigned int i=0; i out; - out.attach_dof_handler(*dof); - out.add_data_vector(out_vector, "v"); - out.build_patches(5); - out.write_gnuplot(out_file); +// const unsigned int dofs_per_cell = mg_dof_handler->get_fe().dofs_per_cell; + +// std::vector global_dof_indices (dofs_per_cell); +// std::vector level_dof_indices (dofs_per_cell); + +// typename DoFHandler::active_cell_iterator +// global_cell = dof->begin_active(level); +// typename MGDoFHandler::active_cell_iterator +// level_cell = mg_dof_handler->begin_active(level); +// const typename MGDoFHandler::cell_iterator +// endc = mg_dof_handler->end(level); + +// // traverse all cells and copy the +// // data appropriately to the output +// // vector +// for (; level_cell != endc; ++level_cell, ++global_cell) +// { +// global_cell->get_dof_indices (global_dof_indices); +// level_cell->get_mg_dof_indices(level_dof_indices); + +// // copy level-wise data to +// // global vector +// for (unsigned int i=0; i out; +// out.attach_dof_handler(*dof); +// out.add_data_vector(out_vector, "v"); +// out.build_patches(5); +// out.write_gnuplot(out_file); } #endif diff --git a/deal.II/deal.II/include/numerics/data_out.h b/deal.II/deal.II/include/numerics/data_out.h index 128e126a51..47a8b04f46 100644 --- a/deal.II/deal.II/include/numerics/data_out.h +++ b/deal.II/deal.II/include/numerics/data_out.h @@ -16,6 +16,7 @@ #include #include +template class BlockVector; /** @@ -266,7 +267,8 @@ class DataOut_DoFData : public DataOutInterface * class to see which characters * are valid and which are not. */ - void add_data_vector (const Vector &data, + template + void add_data_vector (const VECTOR &data, const std::vector &names, const DataVectorType type = type_automatic); @@ -294,7 +296,8 @@ class DataOut_DoFData : public DataOutInterface * underscore and the number of * each component to @p{name} */ - void add_data_vector (const Vector &data, + template + void add_data_vector (const VECTOR &data, const std::string &name, const DataVectorType type = type_automatic); @@ -405,6 +408,12 @@ class DataOut_DoFData : public DataOutInterface * STL classes). */ DataEntry (const Vector *data = 0, + const std::vector &names = std::vector()); + + /** + * Constructor for block vector data. + */ + DataEntry (const BlockVector *data, const std::vector &names = std::vector()); /** @@ -421,8 +430,22 @@ class DataOut_DoFData : public DataOutInterface * pointed to remains with * the caller of this class. */ - const Vector *data; - + const Vector *single_data; + + /** + * Pointer to a block vector of + * data. Either this pointer + * or the previous is used, + * depending on the stored + * vector type. + */ + const BlockVector* block_data; + + /** + * True if stored vector is a block vector. + */ + bool has_block; + /** * Names of the components of this * data vector. diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h index b3c9476462..4fcf3abe4f 100644 --- a/deal.II/deal.II/include/numerics/vectors.h +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -746,12 +746,12 @@ class VectorTools * See the general documentation of this * class for more information. */ - template + template static void integrate_difference (const Mapping &mapping, const DoFHandler &dof, - const Vector &fe_function, + const InVector &fe_function, const Function &exact_solution, - Vector &difference, + OutVector &difference, const Quadrature &q, const NormType &norm, const Function *weight=0); @@ -761,11 +761,11 @@ class VectorTools * function, see above, with * @p{mapping=MappingQ1()}. */ - template + template static void integrate_difference (const DoFHandler &dof, - const Vector &fe_function, + const InVector &fe_function, const Function &exact_solution, - Vector &difference, + OutVector &difference, const Quadrature &q, const NormType &norm, const Function *weight=0); diff --git a/deal.II/deal.II/source/dofs/dof_accessor.cc b/deal.II/deal.II/source/dofs/dof_accessor.cc index d7aa8ea17e..9b5495a782 100644 --- a/deal.II/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/dof_accessor.cc @@ -847,6 +847,14 @@ template void DoFObjectAccessor<3,deal_II_dimension>::set_dof_values (const Vector &, BlockVector &) const; +template +void +DoFObjectAccessor<3,deal_II_dimension>::get_dof_values (const BlockVector &, + Vector &) const; +template +void +DoFObjectAccessor<3,deal_II_dimension>::set_dof_values (const Vector &, + BlockVector &) const; #endif @@ -891,6 +899,18 @@ DoFCellAccessor:: set_dof_values_by_interpolation(const Vector &, BlockVector &) const; +template +void +DoFCellAccessor:: +get_interpolated_dof_values (const BlockVector &, + Vector &) const; + +template +void +DoFCellAccessor:: +set_dof_values_by_interpolation(const Vector &, + BlockVector &) const; + template class DoFAccessor; diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index 408d6b3bdd..ab4e935364 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -835,14 +835,23 @@ template class FESubfaceValues; //----------------------------------------------------------------------------- template -void FEValuesBase::get_function_values (const Vector &, - std::vector &) const; +void FEValuesBase::get_function_values (const Vector&, + std::vector&) const; template -void FEValuesBase::get_function_values (const Vector &, - std::vector &) const; +void FEValuesBase::get_function_values (const Vector&, + std::vector&) const; template -void FEValuesBase::get_function_values (const BlockVector &, - std::vector &) const; +void FEValuesBase::get_function_values (const Vector&, + std::vector&) const; +template +void FEValuesBase::get_function_values (const BlockVector&, + std::vector&) const; +template +void FEValuesBase::get_function_values (const BlockVector&, + std::vector&) const; +template +void FEValuesBase::get_function_values (const BlockVector&, + std::vector&) const; //----------------------------------------------------------------------------- @@ -850,11 +859,17 @@ template void FEValuesBase::get_function_values (const Vector &, std::vector > &) const; template +void FEValuesBase::get_function_values (const Vector &, + std::vector > &) const; +template void FEValuesBase::get_function_values (const Vector &, std::vector > &) const; template void FEValuesBase::get_function_values (const BlockVector &, std::vector > &) const; +template +void FEValuesBase::get_function_values (const BlockVector &, + std::vector > &) const; //----------------------------------------------------------------------------- @@ -879,6 +894,9 @@ void FEValuesBase::get_function_grads (const Vector &, template void FEValuesBase::get_function_grads (const BlockVector &, std::vector > > &) const; +template +void FEValuesBase::get_function_grads (const BlockVector &, + std::vector > > &) const; //----------------------------------------------------------------------------- diff --git a/deal.II/deal.II/source/numerics/data_out.cc b/deal.II/deal.II/source/numerics/data_out.cc index 9bf1555c51..d08c5e76dd 100644 --- a/deal.II/deal.II/source/numerics/data_out.cc +++ b/deal.II/deal.II/source/numerics/data_out.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,19 @@ template DataOut_DoFData::DataEntry:: DataEntry (const Vector *data, const std::vector &names) : - data(data), + single_data(data), + has_block(false), + names(names) +{}; + + + +template +DataOut_DoFData::DataEntry:: +DataEntry (const BlockVector *data, + const std::vector &names) : + block_data(data), + has_block(true), names(names) {}; @@ -53,7 +66,7 @@ unsigned int DataOut_DoFData:: DataEntry::memory_consumption () const { - return (sizeof (data) + + return (sizeof (single_data) + sizeof (block_data) + MemoryConsumption::memory_consumption (names)); }; @@ -95,9 +108,10 @@ attach_dof_handler (const DoFHandler &d) template +template void DataOut_DoFData:: -add_data_vector (const Vector &vec, +add_data_vector (const VECTOR &vec, const std::vector &names, const DataVectorType type) { @@ -162,9 +176,10 @@ add_data_vector (const Vector &vec, template +template void DataOut_DoFData:: -add_data_vector (const Vector &vec, +add_data_vector (const VECTOR &vec, const std::string &name, const DataVectorType type) { @@ -215,10 +230,16 @@ void DataOut_DoFData::clear_input_data_references () { for (unsigned int i=0; i::build_some_patches (Data data) { if (data.n_components == 1) { - fe_patch_values.get_function_values (*dof_data[dataset].data, - data.patch_values); + if (dof_data[dataset].has_block) + fe_patch_values.get_function_values (*dof_data[dataset].block_data, + data.patch_values); + else + fe_patch_values.get_function_values (*dof_data[dataset].single_data, + data.patch_values); + for (unsigned int q=0; qdata(dataset,q) = data.patch_values[q]; } else // system of components { - fe_patch_values.get_function_values (*dof_data[dataset].data, - data.patch_values_system); + if (dof_data[dataset].has_block) + fe_patch_values.get_function_values (*dof_data[dataset].block_data, + data.patch_values_system); + else + fe_patch_values.get_function_values (*dof_data[dataset].single_data, + data.patch_values_system); + for (unsigned int component=0; component::build_some_patches (Data data) // then do the cell data for (unsigned int dataset=0; datasetdata(dataset+dof_data.size()*data.n_components,q) = - value; + if (cell_data[dataset].has_block) + { + const double value = (*cell_data[dataset].block_data)(cell_number); + for (unsigned int q=0; qdata(dataset+dof_data.size()*data.n_components,q) = + value; + } else { + const double value = (*cell_data[dataset].single_data)(cell_number); + for (unsigned int q=0; qdata(dataset+dof_data.size()*data.n_components,q) = + value; + } }; }; // next cell (patch) in this thread @@ -501,11 +540,75 @@ DataOut::next_cell (const typename DoFHandler::cell_iterator &cell) // explicit instantiations template class DataOut_DoFData; +template void +DataOut_DoFData::add_data_vector ( + const Vector &vec, + const std::vector &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const BlockVector &vec, + const std::vector &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const Vector &vec, + const std::string &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const BlockVector &vec, + const std::string &name, + const DataVectorType type); + template class DataOut_DoFData; +template void +DataOut_DoFData::add_data_vector ( + const Vector &vec, + const std::vector &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const BlockVector &vec, + const std::vector &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const Vector &vec, + const std::string &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const BlockVector &vec, + const std::string &name, + const DataVectorType type); + template class DataOut; + // for 3d, also generate an extra class #if deal_II_dimension >= 2 template class DataOut_DoFData; +template void +DataOut_DoFData::add_data_vector ( + const Vector &vec, + const std::vector &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const BlockVector &vec, + const std::vector &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const Vector &vec, + const std::string &name, + const DataVectorType type); +template void +DataOut_DoFData::add_data_vector ( + const BlockVector &vec, + const std::string &name, + const DataVectorType type); + #endif diff --git a/deal.II/deal.II/source/numerics/data_out_faces.cc b/deal.II/deal.II/source/numerics/data_out_faces.cc index 2cedfbe327..0467ac8487 100644 --- a/deal.II/deal.II/source/numerics/data_out_faces.cc +++ b/deal.II/deal.II/source/numerics/data_out_faces.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -78,16 +79,26 @@ void DataOutFaces::build_some_patches (Data data) { if (data.n_components == 1) { - fe_patch_values.get_function_values (*dof_data[dataset].data, - data.patch_values); + if (dof_data[dataset].has_block) + fe_patch_values.get_function_values (*dof_data[dataset].block_data, + data.patch_values); + else + fe_patch_values.get_function_values (*dof_data[dataset].single_data, + data.patch_values); + for (unsigned int q=0; qdata(dataset,q) = data.patch_values[q]; } else // system of components { - fe_patch_values.get_function_values (*dof_data[dataset].data, - data.patch_values_system); + if (dof_data[dataset].has_block) + fe_patch_values.get_function_values (*dof_data[dataset].block_data, + data.patch_values_system); + else + fe_patch_values.get_function_values (*dof_data[dataset].single_data, + data.patch_values_system); + for (unsigned int component=0; component::build_some_patches (Data data) // then do the cell data for (unsigned int dataset=0; datasetdata(dataset+dof_data.size()*data.n_components,q) = - value; + if (cell_data[dataset].has_block) + { + const double value = (*cell_data[dataset].block_data)(face_number); + for (unsigned int q=0; qdata(dataset+dof_data.size()*data.n_components,q) = + value; + } else { + const double value = (*cell_data[dataset].single_data)(face_number); + for (unsigned int q=0; qdata(dataset+dof_data.size()*data.n_components,q) = + value; + } }; }; // next cell (patch) in this thread diff --git a/deal.II/deal.II/source/numerics/data_out_rotation.cc b/deal.II/deal.II/source/numerics/data_out_rotation.cc index 877d544619..b1230087a3 100644 --- a/deal.II/deal.II/source/numerics/data_out_rotation.cc +++ b/deal.II/deal.II/source/numerics/data_out_rotation.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -165,8 +166,13 @@ void DataOutRotation::build_some_patches (Data data) { if (data.n_components == 1) { - fe_patch_values.get_function_values (*dof_data[dataset].data, - data.patch_values); + if (dof_data[dataset].has_block) + fe_patch_values.get_function_values (*dof_data[dataset].block_data, + data.patch_values); + else + fe_patch_values.get_function_values (*dof_data[dataset].single_data, + data.patch_values); + switch (dim) { case 1: @@ -195,8 +201,13 @@ void DataOutRotation::build_some_patches (Data data) else // system of components { - fe_patch_values.get_function_values (*dof_data[dataset].data, - data.patch_values_system); + if (dof_data[dataset].has_block) + fe_patch_values.get_function_values (*dof_data[dataset].block_data, + data.patch_values_system); + else + fe_patch_values.get_function_values (*dof_data[dataset].single_data, + data.patch_values_system); + for (unsigned int component=0; component::build_some_patches (Data data) // then do the cell data for (unsigned int dataset=0; dataset #include #include +#include #include #include #include diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index 3e9d1dd42f..b859fea894 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -1057,13 +1057,13 @@ VectorTools::project_boundary_values (const DoFHandler &dof, -template +template void VectorTools::integrate_difference (const Mapping &mapping, const DoFHandler &dof, - const Vector &fe_function, + const InVector &fe_function, const Function &exact_solution, - Vector &difference, + OutVector &difference, const Quadrature &q, const NormType &norm, const Function *weight) @@ -1389,12 +1389,12 @@ VectorTools::integrate_difference (const Mapping &mapping, }; -template +template void VectorTools::integrate_difference (const DoFHandler &dof, - const Vector &fe_function, + const InVector &fe_function, const Function &exact_solution, - Vector &difference, + OutVector &difference, const Quadrature &q, const NormType &norm, const Function *weight) @@ -1536,6 +1536,125 @@ void VectorTools::integrate_difference (const DoFHandler &, const Quadrature &, const NormType &, const Function *); +template +void VectorTools::integrate_difference (const Mapping &, + const DoFHandler &, + const Vector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const DoFHandler &, + const Vector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const Mapping &, + const DoFHandler &, + const Vector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const DoFHandler &, + const Vector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const Mapping &, + const DoFHandler &, + const Vector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const DoFHandler &, + const Vector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const Mapping &, + const DoFHandler &, + const BlockVector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const DoFHandler &, + const BlockVector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const Mapping &, + const DoFHandler &, + const BlockVector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const DoFHandler &, + const BlockVector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const Mapping &, + const DoFHandler &, + const BlockVector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const DoFHandler &, + const BlockVector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const Mapping &, + const DoFHandler &, + const BlockVector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template +void VectorTools::integrate_difference (const DoFHandler &, + const BlockVector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); #if deal_II_dimension != 1 template void VectorTools::project_boundary_values (const Mapping &, diff --git a/deal.II/doc/news/2001/c-3-2.html b/deal.II/doc/news/2001/c-3-2.html index a887b90a24..214920348b 100644 --- a/deal.II/doc/news/2001/c-3-2.html +++ b/deal.II/doc/news/2001/c-3-2.html @@ -84,6 +84,27 @@ documentation, etc.

deal.II

    +
  1. + Improved: Both functions DataOut_DoFData::add_data_vector accepts BlockVector as argument. +
    + (GK 2001/10/12) +

    + +
  2. + Improved: Both functions VectorTools::integrate_difference take ingoing and + outgoing vector types as template arguments. This allows + applying them to BlockVector and of + outputting a vector of doubles suitable for DataOut. +
    + (GK 2001/10/12) +

    +
  3. Fixed: Functions creating sparsity patterns for DG elements in DoFTools get the pattern type as -- 2.39.5