From 449c29be980729603a75065d8d8f4ce61586b19e Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Wed, 6 Apr 2016 12:15:22 +0200 Subject: [PATCH] Moved weights inside data --- include/deal.II/fe/mapping_manifold.h | 8 ++++++ source/fe/mapping_manifold.cc | 40 ++++++++++++++++++--------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/include/deal.II/fe/mapping_manifold.h b/include/deal.II/fe/mapping_manifold.h index 9b81a82951..c9446c1ea7 100644 --- a/include/deal.II/fe/mapping_manifold.h +++ b/include/deal.II/fe/mapping_manifold.h @@ -257,6 +257,14 @@ public: */ std::vector > cell_manifold_quadrature_weights; + + /** + * Weights for vertices to use in Manifold::get_new_point(). + * + * Computed each. + */ + mutable std::vector vertex_weights; + /** * Unit tangential vectors. Used for the computation of boundary forms and * normal vectors. diff --git a/source/fe/mapping_manifold.cc b/source/fe/mapping_manifold.cc index eedf1fa43e..082879cd22 100644 --- a/source/fe/mapping_manifold.cc +++ b/source/fe/mapping_manifold.cc @@ -51,11 +51,17 @@ std::size_t MappingManifold::InternalData::memory_consumption () const { return (Mapping::InternalDataBase::memory_consumption() + + MemoryConsumption::memory_consumption (vertices) + + MemoryConsumption::memory_consumption (cell) + + MemoryConsumption::memory_consumption (quad) + + MemoryConsumption::memory_consumption (cell_manifold_quadrature_weights) + + MemoryConsumption::memory_consumption (vertex_weights) + + MemoryConsumption::memory_consumption (unit_tangentials) + MemoryConsumption::memory_consumption (covariant) + MemoryConsumption::memory_consumption (contravariant) + - MemoryConsumption::memory_consumption (unit_tangentials) + MemoryConsumption::memory_consumption (aux) + - MemoryConsumption::memory_consumption (volume_elements)); + MemoryConsumption::memory_consumption (volume_elements) + + MemoryConsumption::memory_consumption (manifold) ); } @@ -74,6 +80,8 @@ initialize (const UpdateFlags update_flags, this->quad = q; const unsigned int n_q_points = q.size(); + // Resize the weights + this->vertex_weights.resize(GeometryInfo::vertices_per_cell); // see if we need the (transformation) shape function values // and/or gradients and resize the necessary arrays @@ -111,7 +119,8 @@ initialize_face (const UpdateFlags update_flags, const unsigned int nfaces = GeometryInfo::faces_per_cell; unit_tangentials.resize (nfaces*(dim-1), std::vector > (n_original_q_points)); - if (dim==2) + switch(dim) { + case 2: { // ensure a counterclockwise // orientation of tangentials @@ -123,8 +132,9 @@ initialize_face (const UpdateFlags update_flags, std::fill (unit_tangentials[i].begin(), unit_tangentials[i].end(), tang); } + break; } - else if (dim==3) + case 3: { for (unsigned int i=0; i::MappingManifold (const MappingManifold Mapping * MappingManifold::clone () const @@ -179,6 +192,7 @@ MappingManifold::clone () const } + template Point MappingManifold:: @@ -189,6 +203,8 @@ transform_real_to_unit_cell (const typename Triangulation::cell_it return Point(); } + + template Point MappingManifold:: @@ -406,9 +422,6 @@ namespace internal std::fill(data.contravariant.begin(), data.contravariant.end(), DerivativeForm<1,dim,spacedim>()); - // Cache of weights used to compute points on the reference cell - std::vector weights(GeometryInfo::vertices_per_cell); - AssertDimension(GeometryInfo::vertices_per_cell, data.vertices.size()); for (unsigned int point=0; point ei = Point::unit_vector(i); - double ai = ei*p; + const Point ei = Point::unit_vector(i); + const double ai = ei*p; Assert(ai >=0, ExcInternalError("Was expecting a quadrature point " "inside the unit reference element.")); - Point np(ai > .5 ? p-ai *ei : p+(1-ai)*ei); + const Point np(ai > .5 ? p-ai *ei : p+(1-ai)*ei); // In the lenghts, we store also the direction sign, // which is positive, if the coordinate is < .5, @@ -439,10 +452,11 @@ namespace internal // Get the weights to compute the np point in real space for (unsigned int j=0; j::vertices_per_cell; ++j) - weights[j] = GeometryInfo::d_linear_shape_function(np, j); + data.vertex_weights[j] = GeometryInfo::d_linear_shape_function(np, j); Point NP=data.manifold-> - get_new_point(Quadrature(data.vertices, weights)); + get_new_point(Quadrature(data.vertices, + data.vertex_weights)); Tensor<1,spacedim> T = data.manifold->get_tangent_vector(P, NP); -- 2.39.5