From 0546553aa322c138df1b4896fabbd5c442a40f06 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 14 Feb 2012 09:52:56 +0000 Subject: [PATCH] Allow IndexSet as a vector type in FEValues::get_function_values and friends; consequently, also allow it as the data type for DataOut::add_data_vector. git-svn-id: https://svn.dealii.org/trunk@25066 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 12 + deal.II/include/deal.II/fe/fe_values.h | 34 +- deal.II/include/deal.II/numerics/data_out.h | 50 +-- deal.II/source/fe/fe_values.cc | 153 +++++++-- deal.II/source/fe/fe_values.inst.in | 335 +++++++++++++++++++- deal.II/source/numerics/data_out.cc | 150 +++++---- deal.II/source/numerics/data_out.inst.in | 191 ++++++++--- 7 files changed, 753 insertions(+), 172 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 920122e574..85588c0e13 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -34,6 +34,18 @@ inconvenience this causes.

General

    +
  1. New: Functions like FEValues::get_function_values have long been +able to extract values from pretty much any vector kind given to it (e.g. +of kind Vector, BlockVector, PETScWrappers::Vector, etc). The list of +allowed "vector" types now also includes IndexSet, which is interpreted +as a vector of elements that are either zero or one, depending on whether +an index is in the IndexSet or not. +
    +As a consequence of this, the DataOut::add_data_vector functions now also +work for such types of vectors, a use demonstrated in step-41. +
    +(Wolfgang Bangerth, 2012/02/14) +
  2. New: It has long been a nuisance that the deal.II vector classes could only be accessed using operator() whereas the C++ std::vector class required operator[]. This diff --git a/deal.II/include/deal.II/fe/fe_values.h b/deal.II/include/deal.II/fe/fe_values.h index a7cac2ec3f..cdb1f571c0 100644 --- a/deal.II/include/deal.II/fe/fe_values.h +++ b/deal.II/include/deal.II/fe/fe_values.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -1992,7 +1992,13 @@ class FEValuesBase : protected FEValuesData, * associated with the DofHandler * object with which this * FEValues object was last - * initialized. + * initialized. Alternatively, + * if the vector argument is of + * type IndexSet, then the function + * is represented as one that + * is either zero or one, depending + * on whether a DoF index is in + * the set or not. */ template void get_function_values (const InputVector& fe_function, @@ -2233,7 +2239,13 @@ class FEValuesBase : protected FEValuesData, * associated with the DofHandler * object with which this * FEValues object was last - * initialized. + * initialized. Alternatively, + * if the vector argument is of + * type IndexSet, then the function + * is represented as one that + * is either zero or one, depending + * on whether a DoF index is in + * the set or not. */ template void get_function_gradients (const InputVector &fe_function, @@ -2399,7 +2411,13 @@ class FEValuesBase : protected FEValuesData, * associated with the DofHandler * object with which this * FEValues object was last - * initialized. + * initialized. Alternatively, + * if the vector argument is of + * type IndexSet, then the function + * is represented as one that + * is either zero or one, depending + * on whether a DoF index is in + * the set or not. */ template void @@ -2558,7 +2576,13 @@ class FEValuesBase : protected FEValuesData, * associated with the DofHandler * object with which this * FEValues object was last - * initialized. + * initialized. Alternatively, + * if the vector argument is of + * type IndexSet, then the function + * is represented as one that + * is either zero or one, depending + * on whether a DoF index is in + * the set or not. */ template void diff --git a/deal.II/include/deal.II/numerics/data_out.h b/deal.II/include/deal.II/numerics/data_out.h index cc9f8d8d5f..f55315369a 100644 --- a/deal.II/include/deal.II/numerics/data_out.h +++ b/deal.II/include/deal.II/numerics/data_out.h @@ -592,16 +592,14 @@ class DataOut_DoFData : public DataOutInterface * * If it is a vector holding DoF * data, the names given shall be - * one for each component, if the - * finite element in use is - * composed of several - * subelements. If it is a - * finite element composed of - * only one subelement, then - * there is another function - * following which takes a single - * name instead of a vector of - * names. + * one for each component of the + * underlying finite element. If + * it is a finite element + * composed of only one + * subelement, then there is + * another function following + * which takes a single name + * instead of a vector of names. * * The data_component_interpretation * argument contains information about @@ -648,11 +646,17 @@ class DataOut_DoFData : public DataOutInterface * class to see which characters * are valid and which are not. * - * The actual type for the template - * argument may be any vector type from - * which FEValues can extract values - * on a cell using the - * FEValuesBase::get_function_values() function. + * @note The actual type for the + * vector argument may be any + * vector type from which + * FEValues can extract values on + * a cell using the + * FEValuesBase::get_function_values() + * function. In particular, this + * includes all of the usual + * vector types, but also + * IndexSet (see step-41 for a + * use of this). */ template void add_data_vector (const VECTOR &data, @@ -715,11 +719,17 @@ class DataOut_DoFData : public DataOutInterface * type is also known implicitly and does * not have to be given. * - * The actual type for the template - * argument may be any vector type from - * which FEValues can extract values - * on a cell using the - * FEValuesBase::get_function_values() function. + * @note The actual type for the + * vector argument may be any + * vector type from which + * FEValues can extract values on + * a cell using the + * FEValuesBase::get_function_values() + * function. In particular, this + * includes all of the usual + * vector types, but also + * IndexSet (see step-41 for a + * use of this). */ template void add_data_vector (const VECTOR &data, diff --git a/deal.II/source/fe/fe_values.cc b/deal.II/source/fe/fe_values.cc index 79182e569b..3c9aa45faf 100644 --- a/deal.II/source/fe/fe_values.cc +++ b/deal.II/source/fe/fe_values.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -35,6 +35,41 @@ DEAL_II_NAMESPACE_OPEN +namespace +{ + template + double + get_vector_element (const VectorType &vector, + const unsigned int cell_number) + { + return vector[cell_number]; + } + + + double + get_vector_element (const IndexSet &is, + const unsigned int cell_number) + { + return (is.is_element(cell_number) ? 1 : 0); + } + + + + template + struct ValueType + { + typedef typename VectorType::value_type type; + }; + + + template <> + struct ValueType + { + typedef double type; + }; +} + + namespace { template @@ -356,7 +391,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (values.begin(), values.end(), value_type()); @@ -398,7 +433,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (gradients.begin(), gradients.end(), gradient_type()); @@ -441,7 +476,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (hessians.begin(), hessians.end(), hessian_type()); @@ -484,7 +519,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (laplacians.begin(), laplacians.end(), value_type()); @@ -526,7 +561,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (values.begin(), values.end(), value_type()); @@ -588,7 +623,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (gradients.begin(), gradients.end(), gradient_type()); @@ -651,7 +686,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (symmetric_gradients.begin(), symmetric_gradients.end(), @@ -716,7 +751,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (divergences.begin(), divergences.end(), divergence_type()); @@ -774,7 +809,7 @@ namespace FEValuesViews Assert (fe_function.size () == fe_values.present_cell->n_dofs_for_dof_handler (), ExcDimensionMismatch (fe_function.size (), fe_values.present_cell->n_dofs_for_dof_handler ())); // get function values of dofs on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values (fe_function, dof_values); std::fill (curls.begin (), curls.end (), curl_type ()); @@ -947,7 +982,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (hessians.begin(), hessians.end(), hessian_type()); @@ -1010,7 +1045,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values (fe_values.dofs_per_cell); + dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (laplacians.begin(), laplacians.end(), value_type()); @@ -1073,7 +1108,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values(fe_values.dofs_per_cell); + dealii::Vector::type > dof_values(fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill(values.begin(), values.end(), value_type()); @@ -1138,7 +1173,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values(fe_values.dofs_per_cell); + dealii::Vector::type > dof_values(fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill(divergences.begin(), divergences.end(), divergence_type()); @@ -1336,6 +1371,15 @@ class FEValuesBase::CellIteratorBase n_dofs_for_dof_handler () const = 0; #include "fe_values.decl.1.inst" + + /// Call + /// @p get_interpolated_dof_values + /// of the iterator with the + /// given arguments. + virtual + void + get_interpolated_dof_values (const IndexSet &in, + Vector &out) const = 0; }; @@ -1397,6 +1441,15 @@ class FEValuesBase::CellIterator : public FEValuesBase &out) const; + private: /** * Copy of the iterator which @@ -1491,6 +1544,15 @@ class FEValuesBase::TriaCellIterator : public FEValuesBase &out) const; + private: /** * Copy of the iterator which @@ -1548,6 +1610,23 @@ FEValuesBase::CellIterator::n_dofs_for_dof_handler () const #include "fe_values.impl.1.inst" +template +template +void +FEValuesBase::CellIterator:: +get_interpolated_dof_values (const IndexSet &in, + Vector &out) const +{ + Assert (cell->has_children() == false, ExcNotImplemented()); + + std::vector dof_indices (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (dof_indices); + + for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) + out[i] = (in.is_element (dof_indices[i]) ? 1 : 0); +} + + /* ---------------- FEValuesBase::TriaCellIterator --------- */ template @@ -1592,6 +1671,16 @@ FEValuesBase::TriaCellIterator::n_dofs_for_dof_handler () const #include "fe_values.impl.2.inst" +template +void +FEValuesBase::TriaCellIterator:: +get_interpolated_dof_values (const IndexSet &, + Vector &) const +{ + Assert (false, ExcMessage (message_string)); +} + + /* --------------------- FEValuesData ----------------- */ @@ -1730,7 +1819,7 @@ void FEValuesBase::get_function_values ( // get function values of dofs // on this cell - Vector dof_values (dofs_per_cell); + Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); // initialize with zero @@ -1818,7 +1907,7 @@ void FEValuesBase::get_function_values ( // innermost loop) for (unsigned int shape_func=0; shape_func::get_function_values ( // get function values of dofs // on this cell - Vector dof_values (dofs_per_cell); + Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); // initialize with zero @@ -1997,7 +2086,7 @@ void FEValuesBase::get_function_values ( for (unsigned int mc = 0; mc < component_multiple; ++mc) for (unsigned int shape_func=0; shape_func::get_function_values ( for (unsigned int mc = 0; mc < component_multiple; ++mc) for (unsigned int shape_func=0; shape_func::get_function_gradients ( // get function values of dofs // on this cell - Vector dof_values (dofs_per_cell); + Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); // initialize with zero @@ -2261,7 +2350,7 @@ void FEValuesBase::get_function_gradients ( // in the innermost loop) for (unsigned int shape_func=0; shape_func::get_function_gradients ( // get function values of dofs // on this cell - Vector dof_values (dofs_per_cell); + Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); // initialize with zero @@ -2417,7 +2506,7 @@ void FEValuesBase::get_function_gradients ( for (unsigned int mc = 0; mc < component_multiple; ++mc) for (unsigned int shape_func=0; shape_func dof_values (dofs_per_cell); + Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); // initialize with zero @@ -2545,7 +2634,7 @@ void FEValuesBase::get_function_hessians ( // functions for (unsigned int shape_func=0; shape_func dof_values (dofs_per_cell); + Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); // initialize with zero @@ -2708,7 +2797,7 @@ void FEValuesBase::get_function_hessians ( for (unsigned int mc = 0; mc < component_multiple; ++mc) for (unsigned int shape_func=0; shape_func::get_function_laplacians ( // get function values of dofs // on this cell - Vector dof_values (dofs_per_cell); + Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); // initialize with zero @@ -2842,7 +2931,7 @@ void FEValuesBase::get_function_laplacians ( // the hessians and get their trace for (unsigned int shape_func=0; shape_func::get_function_laplacians ( // get function values of dofs // on this cell - Vector dof_values (dofs_per_cell); + Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); // initialize with zero @@ -2994,7 +3083,7 @@ void FEValuesBase::get_function_laplacians ( for (unsigned int mc = 0; mc < component_multiple; ++mc) for (unsigned int shape_func=0; shape_func::get_function_laplacians ( for (unsigned int mc = 0; mc < component_multiple; ++mc) for (unsigned int shape_func=0; shape_func::get_function_values + (const dealii::IndexSet&, std::vector&) const; + template + void FEValuesViews::Scalar::get_function_gradients + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Scalar::get_function_hessians + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Scalar::get_function_laplacians + (const dealii::IndexSet&, std::vector&) const; + + template + void FEValuesViews::Vector::get_function_values + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Vector::get_function_gradients + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Vector::get_function_symmetric_gradients + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Vector::get_function_curls + (const dealii::IndexSet&, std::vector&) const; + template + void FEValuesViews::Vector::get_function_divergences + (const dealii::IndexSet&, std::vector&) const; + template + void FEValuesViews::Vector::get_function_hessians + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Vector::get_function_laplacians + (const dealii::IndexSet&, std::vector >&) const; + + template + void FEValuesViews::SymmetricTensor<2,deal_II_dimension>::get_function_values + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::SymmetricTensor<2,deal_II_dimension>::get_function_divergences + (const dealii::IndexSet&, std::vector >&) const; + + +#if deal_II_dimension != 3 + template + void FEValuesViews::Scalar + ::get_function_values + (const dealii::IndexSet&, std::vector&) const; + template + void FEValuesViews::Scalar + ::get_function_gradients + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Scalar + ::get_function_hessians + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Scalar + ::get_function_laplacians + (const dealii::IndexSet&, std::vector&) const; + + template + void FEValuesViews::Vector + ::get_function_values + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Vector + ::get_function_gradients + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Vector + ::get_function_symmetric_gradients + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Vector + ::get_function_divergences + (const dealii::IndexSet&, std::vector&) const; + template + void FEValuesViews::Vector + ::get_function_hessians + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::Vector + ::get_function_laplacians + (const dealii::IndexSet&, std::vector >&) const; + + template + void FEValuesViews::SymmetricTensor<2, deal_II_dimension, deal_II_dimension+1> + ::get_function_values + (const dealii::IndexSet&, std::vector >&) const; + template + void FEValuesViews::SymmetricTensor<2, deal_II_dimension, deal_II_dimension+1> + ::get_function_divergences + (const dealii::IndexSet&, std::vector >&) const; + +#endif + + } + + + +// Instantiations of functions in FEValuesBase and IndexSet=IndexSet + +for (deal_II_dimension : DIMENSIONS) + { + template + void FEValuesBase::get_function_values + (const IndexSet&, std::vector&) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, std::vector&) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, std::vector&) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, std::vector&) const; + + template + void FEValuesBase::get_function_values + (const IndexSet&, std::vector > &) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, std::vector > &) const; + + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, + VectorSlice > >, bool) const; +// template +// void FEValuesBase::get_function_values +// (const IndexSet&, const VectorSlice >&, +// VectorSlice > >, bool) const; + + template + void FEValuesBase::get_function_gradients + (const IndexSet&, std::vector > &) const; + template + void FEValuesBase::get_function_gradients + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + + template + void FEValuesBase::get_function_gradients + (const IndexSet&, std::vector > > &) const; + template + void FEValuesBase::get_function_gradients + (const IndexSet&, const VectorSlice >&, + VectorSlice > > >, bool) const; + + template + void FEValuesBase::get_function_hessians + (const IndexSet&, std::vector > &) const; + template + void FEValuesBase::get_function_hessians + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + + template + void FEValuesBase::get_function_hessians + (const IndexSet&, std::vector > > &, bool) const; + template + void FEValuesBase::get_function_hessians + (const IndexSet&, const VectorSlice >&, + VectorSlice > > >, bool) const; + + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, std::vector&) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, std::vector&) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, std::vector&) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, std::vector&) const; + + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, std::vector > &) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, std::vector > &) const; + + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, + std::vector > &, bool) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, + std::vector > &, bool) const; + + +#if deal_II_dimension != 3 + + template + void FEValuesBase::get_function_values + (const IndexSet&, std::vector&) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, std::vector&) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, std::vector&) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, std::vector&) const; + + template + void FEValuesBase::get_function_values + (const IndexSet&, std::vector > &) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, std::vector > &) const; + + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + + template + void FEValuesBase::get_function_values + (const IndexSet&, const VectorSlice >&, + VectorSlice > >, bool) const; +// template +// void FEValuesBase::get_function_values +// (const IndexSet&, const VectorSlice >&, +// VectorSlice > >, bool) const; + + template + void FEValuesBase::get_function_gradients + (const IndexSet&, std::vector > &) const; + template + void FEValuesBase::get_function_gradients + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + + template + void FEValuesBase::get_function_gradients + (const IndexSet&, std::vector > > &) const; + template + void FEValuesBase::get_function_gradients + (const IndexSet&, const VectorSlice >&, + VectorSlice > > >, bool) const; + + template + void FEValuesBase::get_function_hessians + (const IndexSet&, std::vector > &) const; + template + void FEValuesBase::get_function_hessians + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + + template + void FEValuesBase::get_function_hessians + (const IndexSet&, std::vector > > &, bool) const; + template + void FEValuesBase::get_function_hessians + (const IndexSet&, const VectorSlice >&, + VectorSlice > > >, bool) const; + + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, std::vector&) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, std::vector&) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, std::vector&) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, std::vector&) const; + + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, std::vector > &) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, std::vector > &) const; + + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, + std::vector > &) const; + + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, + std::vector > &, bool) const; + template + void FEValuesBase::get_function_laplacians + (const IndexSet&, const VectorSlice >&, + std::vector > &, bool) const; + + +#endif + + } diff --git a/deal.II/source/numerics/data_out.cc b/deal.II/source/numerics/data_out.cc index 961cc5b83c..04da595d11 100644 --- a/deal.II/source/numerics/data_out.cc +++ b/deal.II/source/numerics/data_out.cc @@ -96,6 +96,70 @@ namespace internal { namespace DataOut { + template + DataEntryBase::DataEntryBase (const std::vector &names_in, + const std::vector &data_component_interpretation) + : + names(names_in), + data_component_interpretation (data_component_interpretation), + postprocessor(0, typeid(*this).name()), + n_output_variables(names.size()) + { + Assert (names.size() == data_component_interpretation.size(), + ExcDimensionMismatch(data_component_interpretation.size(), + names.size())); + + // check that the names use only allowed + // characters + // check names for invalid characters + for (unsigned int i=0; i()") == std::string::npos, + typename dealii::DataOut:: + ExcInvalidCharacter (names[i], + names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_<>()"))); + } + + + + template + DataEntryBase::DataEntryBase (const DataPostprocessor *data_postprocessor) + : + names(data_postprocessor->get_names()), + data_component_interpretation (data_postprocessor->get_data_component_interpretation()), + postprocessor(data_postprocessor, typeid(*this).name()), + n_output_variables(names.size()) + { + Assert (data_postprocessor->get_names().size() + == + data_postprocessor->get_data_component_interpretation().size(), + ExcDimensionMismatch (data_postprocessor->get_names().size(), + data_postprocessor->get_data_component_interpretation().size())); + + // check that the names use only allowed + // characters + for (unsigned int i=0; i()") == std::string::npos, + typename dealii::DataOut:: + ExcInvalidCharacter (names[i], + names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_<>()"))); + } + + + + template + DataEntryBase::~DataEntryBase () + {} + + + /** * Class that stores a pointer to a * vector of type equal to the template @@ -238,70 +302,6 @@ namespace internal - template - DataEntryBase::DataEntryBase (const std::vector &names_in, - const std::vector &data_component_interpretation) - : - names(names_in), - data_component_interpretation (data_component_interpretation), - postprocessor(0, typeid(*this).name()), - n_output_variables(names.size()) - { - Assert (names.size() == data_component_interpretation.size(), - ExcDimensionMismatch(data_component_interpretation.size(), - names.size())); - - // check that the names use only allowed - // characters - // check names for invalid characters - for (unsigned int i=0; i()") == std::string::npos, - typename dealii::DataOut:: - ExcInvalidCharacter (names[i], - names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789_<>()"))); - } - - - - template - DataEntryBase::DataEntryBase (const DataPostprocessor *data_postprocessor) - : - names(data_postprocessor->get_names()), - data_component_interpretation (data_postprocessor->get_data_component_interpretation()), - postprocessor(data_postprocessor, typeid(*this).name()), - n_output_variables(names.size()) - { - Assert (data_postprocessor->get_names().size() - == - data_postprocessor->get_data_component_interpretation().size(), - ExcDimensionMismatch (data_postprocessor->get_names().size(), - data_postprocessor->get_data_component_interpretation().size())); - - // check that the names use only allowed - // characters - for (unsigned int i=0; i()") == std::string::npos, - typename dealii::DataOut:: - ExcInvalidCharacter (names[i], - names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789_<>()"))); - } - - - - template - DataEntryBase::~DataEntryBase () - {} - - - template DataEntry:: DataEntry (const VectorType *data, @@ -324,13 +324,33 @@ namespace internal {} + namespace + { + template + double + get_vector_element (const VectorType &vector, + const unsigned int cell_number) + { + return vector[cell_number]; + } + + + double + get_vector_element (const IndexSet &is, + const unsigned int cell_number) + { + return (is.is_element(cell_number) ? 1 : 0); + } + } + + template double DataEntry:: get_cell_data_value (const unsigned int cell_number) const { - return (*vector)(cell_number); + return get_vector_element(*vector, cell_number); } diff --git a/deal.II/source/numerics/data_out.inst.in b/deal.II/source/numerics/data_out.inst.in index 6a2c8dbcec..4121cc7704 100644 --- a/deal.II/source/numerics/data_out.inst.in +++ b/deal.II/source/numerics/data_out.inst.in @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2010 by the deal.II authors +// Copyright (C) 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -15,93 +15,186 @@ for (VEC : SERIAL_VECTORS; DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENS { // codim=0 - template void + template void DataOut_DoFData,deal_II_dimension,deal_II_dimension>:: - add_data_vector (const VEC &, - const std::string &, - const DataVectorType, - const std::vector &); + add_data_vector (const VEC &, + const std::string &, + const DataVectorType, + const std::vector &); - template void + template void DataOut_DoFData,deal_II_dimension,deal_II_dimension>:: - add_data_vector (const VEC &, - const std::vector &, - const DataVectorType, - const std::vector &); + add_data_vector (const VEC &, + const std::vector &, + const DataVectorType, + const std::vector &); - template void + template void DataOut_DoFData,deal_II_dimension,deal_II_dimension>:: - add_data_vector (const VEC &, + add_data_vector (const VEC &, const DataPostprocessor::space_dimension> &); // stuff needed for face data - template void + template void DataOut_DoFData,deal_II_dimension-1,deal_II_dimension>:: - add_data_vector (const VEC &, - const std::string &, - const DataVectorType, - const std::vector &); + add_data_vector (const VEC &, + const std::string &, + const DataVectorType, + const std::vector &); - template void + template void DataOut_DoFData,deal_II_dimension-1,deal_II_dimension>:: - add_data_vector (const VEC &, - const std::vector &, - const DataVectorType, - const std::vector &); + add_data_vector (const VEC &, + const std::vector &, + const DataVectorType, + const std::vector &); - template void + template void DataOut_DoFData,deal_II_dimension-1,deal_II_dimension>:: - add_data_vector (const VEC &, + add_data_vector (const VEC &, const DataPostprocessor::space_dimension> &); // things for DataOutRotation - template void + template void DataOut_DoFData,deal_II_dimension+1,deal_II_dimension+1>:: - add_data_vector (const VEC &, - const std::string &, - const DataVectorType, - const std::vector &); + add_data_vector (const VEC &, + const std::string &, + const DataVectorType, + const std::vector &); - template void + template void DataOut_DoFData,deal_II_dimension+1,deal_II_dimension+1>:: - add_data_vector (const VEC &, - const std::vector &, - const DataVectorType, - const std::vector &); + add_data_vector (const VEC &, + const std::vector &, + const DataVectorType, + const std::vector &); - template void + template void DataOut_DoFData,deal_II_dimension+1,deal_II_dimension+1>:: - add_data_vector (const VEC &, + add_data_vector (const VEC &, const DataPostprocessor::space_dimension> &); // codim 1 #if deal_II_dimension < 3 - template void + template void DataOut_DoFData,deal_II_dimension,deal_II_dimension+1>:: - add_data_vector (const VEC &, - const std::string &, - const DataVectorType, - const std::vector &); + add_data_vector (const VEC &, + const std::string &, + const DataVectorType, + const std::vector &); - template void + template void DataOut_DoFData,deal_II_dimension,deal_II_dimension+1>:: - add_data_vector (const VEC &, - const std::vector &, - const DataVectorType, - const std::vector &); + add_data_vector (const VEC &, + const std::vector &, + const DataVectorType, + const std::vector &); - template void + template void DataOut_DoFData,deal_II_dimension,deal_II_dimension+1>:: - add_data_vector (const VEC &, + add_data_vector (const VEC &, const DataPostprocessor::space_dimension> &); #endif } + +for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) +{ +// codim=0 + + template void + DataOut_DoFData,deal_II_dimension,deal_II_dimension>:: + add_data_vector (const IndexSet &, + const std::string &, + const DataVectorType, + const std::vector &); + + template void + DataOut_DoFData,deal_II_dimension,deal_II_dimension>:: + add_data_vector (const IndexSet &, + const std::vector &, + const DataVectorType, + const std::vector &); + + template void + DataOut_DoFData,deal_II_dimension,deal_II_dimension>:: + add_data_vector (const IndexSet &, + const DataPostprocessor::space_dimension> &); + +// stuff needed for face data + + template void + DataOut_DoFData,deal_II_dimension-1,deal_II_dimension>:: + add_data_vector (const IndexSet &, + const std::string &, + const DataVectorType, + const std::vector &); + + template void + DataOut_DoFData,deal_II_dimension-1,deal_II_dimension>:: + add_data_vector (const IndexSet &, + const std::vector &, + const DataVectorType, + const std::vector &); + + template void + DataOut_DoFData,deal_II_dimension-1,deal_II_dimension>:: + add_data_vector (const IndexSet &, + const DataPostprocessor::space_dimension> &); + +// things for DataOutRotation + + template void + DataOut_DoFData,deal_II_dimension+1,deal_II_dimension+1>:: + add_data_vector (const IndexSet &, + const std::string &, + const DataVectorType, + const std::vector &); + + template void + DataOut_DoFData,deal_II_dimension+1,deal_II_dimension+1>:: + add_data_vector (const IndexSet &, + const std::vector &, + const DataVectorType, + const std::vector &); + + template void + DataOut_DoFData,deal_II_dimension+1,deal_II_dimension+1>:: + add_data_vector (const IndexSet &, + const DataPostprocessor::space_dimension> &); + +// codim 1 + + #if deal_II_dimension < 3 + template void + DataOut_DoFData,deal_II_dimension,deal_II_dimension+1>:: + add_data_vector (const IndexSet &, + const std::string &, + const DataVectorType, + const std::vector &); + + template void + DataOut_DoFData,deal_II_dimension,deal_II_dimension+1>:: + add_data_vector (const IndexSet &, + const std::vector &, + const DataVectorType, + const std::vector &); + + template void + DataOut_DoFData,deal_II_dimension,deal_II_dimension+1>:: + add_data_vector (const IndexSet &, + const DataPostprocessor::space_dimension> &); + #endif + +} + + + for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) { template class DataOut_DoFData,deal_II_dimension>; -- 2.39.5