From: Wolfgang Bangerth Date: Thu, 5 Feb 2015 12:50:14 +0000 (-0600) Subject: Use the Tensor member function norm_square() instead of the Point function square... X-Git-Tag: v8.3.0-rc1~494^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a26ca05d29485fc0a01f102b1619c5c34a91e53;p=dealii.git Use the Tensor member function norm_square() instead of the Point function square() for objects that are logically points. --- diff --git a/examples/step-8/step-8.cc b/examples/step-8/step-8.cc index 8625efab2c..98e3def95f 100644 --- a/examples/step-8/step-8.cc +++ b/examples/step-8/step-8.cc @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * - * Copyright (C) 2000 - 2014 by the deal.II authors + * Copyright (C) 2000 - 2015 by the deal.II authors * * This file is part of the deal.II library. * @@ -210,15 +210,15 @@ namespace Step8 // If now the point p is in a circle (sphere) of radius 0.2 // around one of these points, then set the force in x-direction to one, // otherwise to zero: - if (((p-point_1).square() < 0.2*0.2) || - ((p-point_2).square() < 0.2*0.2)) + if (((p-point_1).norm_square() < 0.2*0.2) || + ((p-point_2).norm_square() < 0.2*0.2)) values(0) = 1; else values(0) = 0; // Likewise, if p is in the vicinity of the origin, then set // the y-force to 1, otherwise to zero: - if (p.square() < 0.2*0.2) + if (p.norm_square() < 0.2*0.2) values(1) = 1; else values(1) = 0; diff --git a/examples/step-9/step-9.cc b/examples/step-9/step-9.cc index 24939609bb..76dcaad9e9 100644 --- a/examples/step-9/step-9.cc +++ b/examples/step-9/step-9.cc @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * - * Copyright (C) 2000 - 2014 by the deal.II authors + * Copyright (C) 2000 - 2015 by the deal.II authors * * This file is part of the deal.II library. * @@ -329,7 +329,7 @@ namespace Step9 { Assert (component == 0, ExcIndexRange (component, 0, 1)); const double diameter = 0.1; - return ( (p-center_point).square() < diameter*diameter ? + return ( (p-center_point).norm_square() < diameter*diameter ? .1/std::pow(diameter,dim) : 0); } @@ -376,8 +376,8 @@ namespace Step9 { Assert (component == 0, ExcIndexRange (component, 0, 1)); - const double sine_term = std::sin(16*numbers::PI*std::sqrt(p.square())); - const double weight = std::exp(-5*p.square()) / std::exp(-5.); + const double sine_term = std::sin(16*numbers::PI*std::sqrt(p.norm_square())); + const double weight = std::exp(-5*p.norm_square()) / std::exp(-5.); return sine_term * weight; } @@ -1254,8 +1254,8 @@ namespace Step9 // two cells. Note that as opposed to the introduction, we denote // by y the normalized difference vector, as this is // the quantity used everywhere in the computations. - Point y = neighbor_center - this_center; - const double distance = std::sqrt(y.square()); + Tensor<1,dim> y = neighbor_center - this_center; + const double distance = y.norm(); y /= distance; // Then add up the contribution of this cell to the Y matrix... @@ -1300,7 +1300,7 @@ namespace Step9 // using this quantity and the right powers of the mesh width: const Tensor<2,dim> Y_inverse = invert(Y); - Point gradient; + Tensor<1,dim> gradient; contract (gradient, Y_inverse, projected_gradient); // The last part of this function is the one where we @@ -1311,7 +1311,7 @@ namespace Step9 // difficult: *(std_cxx11::get<1>(cell.iterators)) = (std::pow(std_cxx11::get<0>(cell.iterators)->diameter(), 1+1.0*dim/2) * - std::sqrt(gradient.square())); + std::sqrt(gradient.norm_square())); } }