From: kronbichler Date: Tue, 24 Nov 2009 00:03:32 +0000 (+0000) Subject: Add a check for translation of vertices by mapping. Use this to improve DataOut. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19e566fed2e2db2154871502157555a1420cdf4b;p=dealii-svn.git Add a check for translation of vertices by mapping. Use this to improve DataOut. git-svn-id: https://svn.dealii.org/trunk@20158 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/fe/mapping.h b/deal.II/deal.II/include/fe/mapping.h index ad7c193492..3e57fe9a1d 100644 --- a/deal.II/deal.II/include/fe/mapping.h +++ b/deal.II/deal.II/include/fe/mapping.h @@ -443,6 +443,16 @@ class Mapping : public Subscriptor virtual Mapping * clone () const = 0; + /** + * Returns whether the mapping preserves + * vertex locations. Returns @p true for + * MappingQ, MappingQ1, MappingCartesian, + * but @p false for MappingQEulerian, + * MappingQ1Eulerian. + */ + virtual + bool preserves_vertex_locations () const = 0; + /** * Exception */ diff --git a/deal.II/deal.II/include/fe/mapping_cartesian.h b/deal.II/deal.II/include/fe/mapping_cartesian.h index 8fa505d91a..737a0b06a5 100644 --- a/deal.II/deal.II/include/fe/mapping_cartesian.h +++ b/deal.II/deal.II/include/fe/mapping_cartesian.h @@ -32,7 +32,7 @@ DEAL_II_NAMESPACE_OPEN * along the coordinate directions. It is specifically developed for * cartesian meshes. Apply this mapping to a general mesh to get * strange results. - * + * * For more information about the spacedim template parameter * check the documentation of FiniteElement or the one of * Triangulation. @@ -101,8 +101,8 @@ class MappingCartesian : public Mapping transform (const VectorSlice > > input, VectorSlice > > output, const typename Mapping::InternalDataBase &internal, - const MappingType type) const; - + const MappingType type) const; + virtual Point transform_unit_to_real_cell ( const typename Triangulation::cell_iterator &cell, @@ -122,7 +122,7 @@ class MappingCartesian : public Mapping transform_real_to_unit_cell ( const typename Triangulation::cell_iterator &cell, const Point &p) const; - + /** * Return a pointer to a copy of the @@ -131,9 +131,16 @@ class MappingCartesian : public Mapping */ virtual Mapping * clone () const; - + + /** + * Always returns @p true because + * MappingCartesian preserves vertex + * locations. + */ + bool preserves_vertex_locations () const; + protected: - /** + /** * Storage for internal data of * the scaling. */ @@ -165,7 +172,7 @@ class MappingCartesian : public Mapping * The volume element */ double volume_element; - + /** * Vector of all quadrature * points. Especially, all @@ -173,7 +180,7 @@ class MappingCartesian : public Mapping */ std::vector > quadrature_points; }; - + /** * Do the computation for the * fill_* functions. @@ -187,21 +194,33 @@ class MappingCartesian : public Mapping std::vector >& normal_vectors) const; private: - virtual UpdateFlags update_once (const UpdateFlags) const; + virtual UpdateFlags update_once (const UpdateFlags) const; virtual UpdateFlags update_each (const UpdateFlags) const; - + /** * Value to indicate that a given * face or subface number is * invalid. */ - static const unsigned int invalid_face_number = numbers::invalid_unsigned_int; + static const unsigned int invalid_face_number = numbers::invalid_unsigned_int; }; /*@}*/ /* -------------- declaration of explicit specializations ------------- */ +#ifndef DOXYGEN + +template +inline +bool +MappingCartesian::preserves_vertex_locations () const +{ + return true; +} + +#endif // DOXYGEN + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/deal.II/deal.II/include/fe/mapping_q.h b/deal.II/deal.II/include/fe/mapping_q.h index deb56a34f1..4dfe95605e 100644 --- a/deal.II/deal.II/include/fe/mapping_q.h +++ b/deal.II/deal.II/include/fe/mapping_q.h @@ -35,7 +35,7 @@ template class TensorProductPolynomials; * For more details about Qp-mappings, see the `mapping' report at * deal.II/doc/reports/mapping_q/index.html in the `Reports' * section of `Documentation'. - * + * * For more information about the spacedim template parameter * check the documentation of FiniteElement or the one of * Triangulation. @@ -89,7 +89,7 @@ class MappingQ : public MappingQ1 * Destructor. */ virtual ~MappingQ (); - + /** * Transforms the point @p p on * the unit cell to the point @@ -100,7 +100,7 @@ class MappingQ : public MappingQ1 transform_unit_to_real_cell ( const typename Triangulation::cell_iterator &cell, const Point &p) const; - + /** * Transforms the point @p p on * the real cell to the point @@ -127,7 +127,7 @@ class MappingQ : public MappingQ1 VectorSlice > > output, const typename Mapping::InternalDataBase &internal, const MappingType type) const; - + /** * Return the degree of the * mapping, i.e. the value which @@ -142,8 +142,8 @@ class MappingQ : public MappingQ1 */ virtual Mapping * clone () const; - - /** + + /** * Storage for internal data of * Q_degree transformation. */ @@ -154,7 +154,7 @@ class MappingQ : public MappingQ1 * Constructor. */ InternalData (const unsigned int n_shape_functions); - + /** * Return an estimate (in @@ -189,7 +189,7 @@ class MappingQ : public MappingQ1 * used. */ bool use_mapping_q1_on_current_cell; - + /** * On interior cells * @p MappingQ1 is used. @@ -297,9 +297,9 @@ class MappingQ : public MappingQ1 virtual void add_quad_support_points(const typename Triangulation::cell_iterator &cell, std::vector > &a) const; - + private: - + virtual typename Mapping::InternalDataBase * get_data (const UpdateFlags, @@ -314,7 +314,7 @@ class MappingQ : public MappingQ1 typename Mapping::InternalDataBase * get_subface_data (const UpdateFlags flags, const Quadrature& quadrature) const; - + /** * Compute shape values and/or * derivatives. @@ -342,7 +342,7 @@ class MappingQ : public MappingQ1 */ void set_laplace_on_quad_vector(Table<2,double> &loqvs) const; - + /** * This function is needed by the * constructor of MappingQ<3>. @@ -360,7 +360,7 @@ class MappingQ : public MappingQ1 * of the `mapping' report. */ void set_laplace_on_hex_vector(Table<2,double> &lohvs) const; - + /** * Computes the * laplace_on_quad(hex)_vector. @@ -397,7 +397,7 @@ class MappingQ : public MappingQ1 */ void apply_laplace_vector(const Table<2,double> &lvs, std::vector > &a) const; - + /** * Computes the support points of * the mapping. @@ -423,7 +423,7 @@ class MappingQ : public MappingQ1 void compute_support_points_laplace( const typename Triangulation::cell_iterator &cell, std::vector > &a) const; - + /** * Needed by the * @p laplace_on_quad function @@ -445,7 +445,7 @@ class MappingQ : public MappingQ1 * `mapping' report. */ Table<2,double> laplace_on_quad_vector; - + /** * Needed by the * @p laplace_on_hex function @@ -464,13 +464,13 @@ class MappingQ : public MappingQ1 DeclException1 (ExcLaplaceVectorNotSet, int, << "laplace_vector not set for degree=" << arg1 << "."); - + /** * Degree @p p of the * polynomials used as shape * functions for the Qp mapping * of cells at the boundary. - */ + */ const unsigned int degree; /** @@ -484,7 +484,7 @@ class MappingQ : public MappingQ1 * functions on the boundary. */ const unsigned int n_outer; - + /** * Pointer to the * @p dim-dimensional tensor @@ -494,7 +494,7 @@ class MappingQ : public MappingQ1 * boundary. */ const TensorProductPolynomials *tensor_pols; - + /** * Number of the Qp tensor * product shape functions. diff --git a/deal.II/deal.II/include/fe/mapping_q1.h b/deal.II/deal.II/include/fe/mapping_q1.h index 8df810df35..f3ef1992fc 100644 --- a/deal.II/deal.II/include/fe/mapping_q1.h +++ b/deal.II/deal.II/include/fe/mapping_q1.h @@ -41,7 +41,7 @@ DEAL_II_NAMESPACE_OPEN * Shape function for this mapping are the same as for the finite * element FE_Q of order 1. Therefore, coupling these two yields * an isoparametric element. - * + * * For more information about the spacedim template parameter * check the documentation of FiniteElement or the one of * Triangulation. @@ -56,12 +56,12 @@ class MappingQ1 : public Mapping * Default constructor. */ MappingQ1 (); - + virtual Point transform_unit_to_real_cell ( const typename Triangulation::cell_iterator &cell, const Point &p) const; - + /** * Transforms the point @p p on * the real cell to the point @@ -76,7 +76,7 @@ class MappingQ1 : public Mapping transform_real_to_unit_cell ( const typename Triangulation::cell_iterator &cell, const Point &p) const; - + virtual void transform (const VectorSlice > > input, VectorSlice > > output, @@ -88,7 +88,7 @@ class MappingQ1 : public Mapping VectorSlice > > output, const typename Mapping::InternalDataBase &internal, const MappingType type) const; - + /** * Return a pointer to a copy of the * present object. The caller of this @@ -97,7 +97,7 @@ class MappingQ1 : public Mapping virtual Mapping * clone () const; - /** + /** * Storage for internal data of * d-linear transformation. */ @@ -119,14 +119,14 @@ class MappingQ1 : public Mapping */ double shape (const unsigned int qpoint, const unsigned int shape_nr) const; - + /** * Shape function at quadrature * point. See above. */ double &shape (const unsigned int qpoint, const unsigned int shape_nr); - + /** * Gradient of shape function * in quadrature point. See @@ -166,7 +166,7 @@ class MappingQ1 : public Mapping * object. */ virtual unsigned int memory_consumption () const; - + /** * Values of shape * functions. Access by @@ -175,7 +175,7 @@ class MappingQ1 : public Mapping * Computed once. */ std::vector shape_values; - + /** * Values of shape function * derivatives. Access by @@ -184,7 +184,7 @@ class MappingQ1 : public Mapping * Computed once. */ std::vector > shape_derivatives; - + /** * Values of shape function * second derivatives. Access @@ -194,7 +194,7 @@ class MappingQ1 : public Mapping * Computed once. */ std::vector > shape_second_derivatives; - + /** * Tensors of covariant * transformation at each of @@ -209,7 +209,7 @@ class MappingQ1 : public Mapping * Computed on each cell. */ std::vector > covariant; - + /** * Tensors of contravariant * transformation at each of @@ -222,7 +222,7 @@ class MappingQ1 : public Mapping * Computed on each cell. */ std::vector > contravariant; - + /** * Unit tangential vectors. Used * for the computation of @@ -232,7 +232,7 @@ class MappingQ1 : public Mapping * Filled once. */ std::vector > > unit_tangentials; - + /** * Auxiliary vectors for internal use. */ @@ -244,14 +244,14 @@ class MappingQ1 : public Mapping * the @p cell_of_current_support_points. */ std::vector > mapping_support_points; - + /** * Stores the cell of which the * @p mapping_support_points are * stored. */ typename Triangulation::cell_iterator cell_of_current_support_points; - + /** * Default value of this flag * is @p true. If *this @@ -287,7 +287,7 @@ class MappingQ1 : public Mapping typedef typename QProjector::DataSetDescriptor DataSetDescriptor; - + /** * Implementation of the interface in * Mapping. @@ -332,7 +332,7 @@ class MappingQ1 : public Mapping std::vector &JxW_values, typename std::vector > &boundary_form, typename std::vector > &normal_vectors) const ; - + /** * Compute shape values and/or * derivatives. @@ -377,7 +377,7 @@ class MappingQ1 : public Mapping const Quadrature &quadrature, const unsigned int n_orig_q_points, InternalData &data) const; - + /** * Do the computation for the * fill_* functions. @@ -388,7 +388,7 @@ class MappingQ1 : public Mapping const CellSimilarity::Similarity cell_similarity, InternalData &data, std::vector > &quadrature_points) const; - + /** * Do the computation for the * fill_* functions. @@ -404,7 +404,7 @@ class MappingQ1 : public Mapping std::vector &JxW_values, std::vector > &boundary_form, std::vector > &normal_vectors) const; - + /** * Compute shape values and/or * derivatives. @@ -439,7 +439,7 @@ class MappingQ1 : public Mapping * support points. */ Point transform_unit_to_real_cell_internal (const InternalData &mdata) const; - + /** * Transforms the point @p p on * the real cell to the point @@ -479,6 +479,13 @@ class MappingQ1 : public Mapping InternalData &mdata, Point &p_unit) const; + /** + * Always returns @p true because + * MappingQ1 preserves vertex locations. + */ + virtual + bool preserves_vertex_locations () const; + private: /** * Implementation of the interface in @@ -509,7 +516,7 @@ class MappingQ1 : public Mapping * */ virtual UpdateFlags update_once (const UpdateFlags flags) const; - + /** * Implementation of the interface in * Mapping. @@ -700,6 +707,15 @@ MappingQ1::InternalData::second_derivative (const unsigned int qpo } + +template +inline +bool +MappingQ1::preserves_vertex_locations () const +{ + return true; +} + #endif // DOXYGEN /* -------------- declaration of explicit specializations ------------- */ diff --git a/deal.II/deal.II/include/fe/mapping_q1_eulerian.h b/deal.II/deal.II/include/fe/mapping_q1_eulerian.h index 6cb5a0fcd9..0077db0097 100644 --- a/deal.II/deal.II/include/fe/mapping_q1_eulerian.h +++ b/deal.II/deal.II/include/fe/mapping_q1_eulerian.h @@ -15,7 +15,7 @@ #include #include -#include +#include DEAL_II_NAMESPACE_OPEN @@ -27,19 +27,19 @@ DEAL_II_NAMESPACE_OPEN * functions. Each cell is thus shifted in space by values given to * the mapping through a finite element field. * - *

Usage

+ *

Usage

* * The constructor of this class takes two arguments: a reference to * the vector that defines the mapping from the reference * configuration to the current configuration and a reference to the * DoFHandler. The vector should then represent a (flattened out - * version of a) vector valued field defined at nodes defined by the + * version of a) vector valued field defined at nodes defined by the * the DoFHandler, where the number of components of the vector - * field equals the number of space dimensions. Thus, the - * DoFHandler shall operate on a finite element that has as many - * components as space dimensions. As an additional requirement, we + * field equals the number of space dimensions. Thus, the + * DoFHandler shall operate on a finite element that has as many + * components as space dimensions. As an additional requirement, we * impose that it have as many degree of freedom per vertex as there - * are space dimensions; since this object only evaluates the finite + * are space dimensions; since this object only evaluates the finite * element field at the vertices, the values * of all other degrees of freedom (not associated to vertices) are * ignored. These requirements are met if the finite element which the @@ -77,7 +77,7 @@ DEAL_II_NAMESPACE_OPEN * Not specifying this template argument in applications using the PETSc * vector classes leads to the construction of a copy of the vector * which is not acccessible afterwards! - * + * * For more information about the spacedim template parameter * check the documentation of FiniteElement or the one of * Triangulation. @@ -112,7 +112,7 @@ class MappingQ1Eulerian : public MappingQ1 */ MappingQ1Eulerian (const VECTOR &euler_transform_vectors, const DoFHandler &shiftmap_dof_handler); - + /** * Return a pointer to a copy of the * present object. The caller of this @@ -121,12 +121,19 @@ class MappingQ1Eulerian : public MappingQ1 virtual Mapping * clone () const; - + /** + * Always returns @p false because + * MappingQ1Eulerian does not preserve + * vertex locations. + */ + bool preserves_vertex_locations () const; + + /** * Exception */ DeclException0 (ExcWrongNoOfComponents); - + /** * Exception. */ @@ -166,16 +173,16 @@ class MappingQ1Eulerian : public MappingQ1 * shifts. */ const VECTOR &euler_transform_vectors; - + /** * Pointer to the DoFHandler to * which the mapping vector is * associated. */ const SmartPointer,MappingQ1Eulerian > shiftmap_dof_handler; - - private: + + private: /** * Computes the support points of * the mapping. For @@ -185,11 +192,25 @@ class MappingQ1Eulerian : public MappingQ1 virtual void compute_mapping_support_points( const typename Triangulation::cell_iterator &cell, std::vector > &a) const; - + }; /*@}*/ +/*----------------------------------------------------------------------*/ + +#ifndef DOXYGEN + +template +inline +bool +MappingQ1Eulerian::preserves_vertex_locations () const +{ + return false; +} + +#endif // DOXYGEN + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index ab4b268342..118e272d2c 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -887,7 +887,7 @@ namespace DoFRenumbering // Actually, we compute the // inverse of the reordering // vector, called reverse here. - // Later, irs inverse is computed + // Later, its inverse is computed // into new_indices, which is the // return argument. diff --git a/deal.II/deal.II/source/numerics/data_out.cc b/deal.II/deal.II/source/numerics/data_out.cc index 68e0793ed0..f23595084e 100644 --- a/deal.II/deal.II/source/numerics/data_out.cc +++ b/deal.II/deal.II/source/numerics/data_out.cc @@ -679,13 +679,20 @@ build_one_patch (const std::pair *cell_and_index, DataOutBase::Patch &patch, const CurvedCellRegion curved_cell_region) { - // use ucd_to_deal map as patch - // vertices are in the old, - // unnatural ordering + // use ucd_to_deal map as patch vertices + // are in the old, unnatural ordering. if + // the mapping does not preserve locations + // (e.g. MappingQEulerian), we need to + // compute the offset of the vertex for the + // graphical output. Otherwise, we can just + // use the vertex info. for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) - patch.vertices[vertex] = data.mapping_collection[0].transform_unit_to_real_cell - (cell_and_index->first, - GeometryInfo::unit_cell_vertex (vertex)); + if (data.mapping_collection[0].preserves_vertex_locations()) + patch.vertices[vertex] = cell_and_index->first->vertex(vertex); + else + patch.vertices[vertex] = data.mapping_collection[0].transform_unit_to_real_cell + (cell_and_index->first, + GeometryInfo::unit_cell_vertex (vertex)); if (data.n_datasets > 0) {