// you are probably already used to by now:
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/function.h>
+#include <deal.II/base/numbers.h>
#include <deal.II/base/logstream.h>
#include <deal.II/base/table_handler.h>
#include <deal.II/lac/vector.h>
// Last task -- generate output:
output_table.add_value("cells", triangulation.n_active_cells());
output_table.add_value("|u|_1", norm);
- output_table.add_value("error",
- std::fabs(norm - std::sqrt(3.14159265358 / 2)));
+ output_table.add_value("error", std::fabs(norm - std::sqrt(numbers::PI_2)));
}
// recycle the test to use constants instead of units
#include <deal.II/base/function_parser.h>
+#include <deal.II/base/numbers.h>
#include <deal.II/base/point.h>
#include <deal.II/lac/vector.h>
std::vector<std::string> function(1);
std::map<std::string, double> constants;
- constants["PI"] = 3.141592654;
+ constants["PI"] = numbers::PI;
constants["cm"] = 10;
constants["m"] = 1000;
// for trivially-copyable (small) types, packing is just a memcpy
// operation
+#include <deal.II/base/numbers.h>
#include <deal.II/base/point.h>
#include <deal.II/base/utilities.h>
deallog << "std::array:" << std::endl;
check(std::array<int, 3>{{1, 2, 3}});
deallog << "struct X:" << std::endl;
- check(X{1, 2, 3.1415926});
+ check(X{1, 2, numbers::PI});
deallog << "double:" << std::endl;
check(1.);
}
// a un-hp-ified version of hp/step-11
#include <deal.II/base/function.h>
+#include <deal.II/base/numbers.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/table_handler.h>
output_table.add_value("cells", triangulation.n_active_cells());
output_table.add_value("|u|_1", norm);
- output_table.add_value("error",
- std::fabs(norm - std::sqrt(3.14159265358 / 2)));
+ output_table.add_value("error", std::fabs(norm - std::sqrt(numbers::PI_2)));
}
+#include <deal.II/base/numbers.h>
+
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/dofs/dof_renumbering.h>
if (y < x)
if (y < 1 - x)
- middle(1) = 0.04 * std::sin(6 * 3.141592 * middle(0));
+ middle(1) = 0.04 * std::sin(6 * numbers::PI * middle(0));
else
- middle(0) = 1 + 0.04 * std::sin(6 * 3.141592 * middle(1));
+ middle(0) = 1 + 0.04 * std::sin(6 * numbers::PI * middle(1));
else if (y < 1 - x)
- middle(0) = 0.04 * std::sin(6 * 3.141592 * middle(1));
+ middle(0) = 0.04 * std::sin(6 * numbers::PI * middle(1));
else
- middle(1) = 1 + 0.04 * std::sin(6 * 3.141592 * middle(0));
+ middle(1) = 1 + 0.04 * std::sin(6 * numbers::PI * middle(0));
return middle;
}
if (y < x)
if (y < 1 - x)
- middle(1) = 0.04 * std::sin(6 * 3.141592 * middle(0));
+ middle(1) = 0.04 * std::sin(6 * numbers::PI * middle(0));
else
- middle(0) = 1 + 0.04 * std::sin(6 * 3.141592 * middle(1));
+ middle(0) = 1 + 0.04 * std::sin(6 * numbers::PI * middle(1));
else if (y < 1 - x)
- middle(0) = 0.04 * std::sin(6 * 3.141592 * middle(1));
+ middle(0) = 0.04 * std::sin(6 * numbers::PI * middle(1));
else
- middle(1) = 1 + 0.04 * std::sin(6 * 3.141592 * middle(0));
+ middle(1) = 1 + 0.04 * std::sin(6 * numbers::PI * middle(0));
return middle;
}
// and compare again whether the matrices are the same
+#include <deal.II/base/numbers.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/dofs/dof_accessor.h>
quadrature,
update_values | update_gradients | update_JxW_values);
- const double nu = 3.14159265358e-2;
+ const double nu = 0.01 * numbers::PI;
for (; cell != endc; ++cell)
{
quadrature,
update_values | update_gradients | update_JxW_values);
- const double nu = 3.14159265358e-2;
+ const double nu = 0.01 * numbers::PI;
for (; cell != endc; ++cell)
{
quadrature,
update_values | update_gradients | update_JxW_values);
- const double nu = 3.14159265358e-2;
+ const double nu = 0.01 * numbers::PI;
for (; cell != endc; ++cell)
{
// of course, it makes absolutely no sense to work the Stokes equation
// with a Nedelec element, but this is just to test the library, no?
+#include <deal.II/base/numbers.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/dofs/dof_accessor.h>
quadrature,
update_values | update_gradients | update_JxW_values);
- const double nu = 3.14159265358e-2;
+ const double nu = 0.01 * numbers::PI;
for (; cell != endc; ++cell)
{
quadrature,
update_values | update_gradients | update_JxW_values);
- const double nu = 3.14159265358e-2;
+ const double nu = 0.01 * numbers::PI;
for (; cell != endc; ++cell)
{
+#include <deal.II/base/numbers.h>
+
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/manifold_lib.h>
if (y < x)
if (y < 1 - x)
- middle(1) = 0.04 * std::sin(6 * 3.141592 * middle(0));
+ middle(1) = 0.04 * std::sin(6 * numbers::PI * middle(0));
else
- middle(0) = 1 + 0.04 * std::sin(6 * 3.141592 * middle(1));
+ middle(0) = 1 + 0.04 * std::sin(6 * numbers::PI * middle(1));
else if (y < 1 - x)
- middle(0) = 0.04 * std::sin(6 * 3.141592 * middle(1));
+ middle(0) = 0.04 * std::sin(6 * numbers::PI * middle(1));
else
- middle(1) = 1 + 0.04 * std::sin(6 * 3.141592 * middle(0));
+ middle(1) = 1 + 0.04 * std::sin(6 * numbers::PI * middle(0));
return middle;
}
if (y < x)
if (y < 1 - x)
- middle(1) = 0.04 * std::sin(6 * 3.141592 * middle(0));
+ middle(1) = 0.04 * std::sin(6 * numbers::PI * middle(0));
else
- middle(0) = 1 + 0.04 * std::sin(6 * 3.141592 * middle(1));
+ middle(0) = 1 + 0.04 * std::sin(6 * numbers::PI * middle(1));
else if (y < 1 - x)
- middle(0) = 0.04 * std::sin(6 * 3.141592 * middle(1));
+ middle(0) = 0.04 * std::sin(6 * numbers::PI * middle(1));
else
- middle(1) = 1 + 0.04 * std::sin(6 * 3.141592 * middle(0));
+ middle(1) = 1 + 0.04 * std::sin(6 * numbers::PI * middle(0));
return middle;
}
#include <deal.II/base/function.h>
+#include <deal.II/base/numbers.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/table_handler.h>
output_table.add_value("cells", triangulation.n_active_cells());
output_table.add_value("|u|_1", norm);
- output_table.add_value("error",
- std::fabs(norm - std::sqrt(3.14159265358 / 2)));
+ output_table.add_value("error", std::fabs(norm - std::sqrt(numbers::PI_2)));
}
// check that LinearAlgebra::distributed::Vector::add_and_dot works correctly
// for complex-valued vectors
+#include <deal.II/base/numbers.h>
+
#include <deal.II/lac/la_parallel_vector.h>
#include "../tests.h"
{
v1(i) = std::complex<number>(0.1 + 0.005 * i, 1.234 + 12 * i);
v2(i) = std::complex<number>(-5.2 + 0.18 * i, 42.4242 + 42 * i);
- v3(i) = std::complex<number>(3.14159 + 2.7183 / (1. + i), 13.);
+ v3(i) =
+ std::complex<number>(numbers::PI + numbers::E / (1. + i), 13.);
}
check = v1;
const std::complex<number> factor = std::complex<number>(0.01432);
// check that LinearAlgebra::Vector::add_and_dot works correctly
+#include <deal.II/base/numbers.h>
+
#include <deal.II/lac/la_vector.h>
#include "../tests.h"
{
v1[i] = 0.1 + 0.005 * i;
v2[i] = -5.2 + 0.18 * i;
- v3[i] = 3.14159 + 2.7183 / (1. + i);
+ v3[i] = numbers::PI + numbers::E / (1. + i);
}
check = v1;
const number factor = 0.01432;
// check that LinearAlgebra::Vector::add_and_dot works correctly for
// complex-valued vectors
+#include <deal.II/base/numbers.h>
+
#include <deal.II/lac/la_vector.h>
#include "../tests.h"
{
v1(i) = std::complex<number>(0.1 + 0.005 * i, 1.234 + 12 * i);
v2(i) = std::complex<number>(-5.2 + 0.18 * i, 42.4242 + 42 * i);
- v3(i) = std::complex<number>(3.14159 + 2.7183 / (1. + i), 13.);
+ v3(i) =
+ std::complex<number>(numbers::PI + numbers::E / (1. + i), 13.);
}
check = v1;
const std::complex<number> factor = std::complex<number>(0.01432);
// (check the summation algorithm), including an accuracy test (should not
// lose more than 1 decimal also for 200000 vector entries)
+#include <deal.II/base/numbers.h>
+
#include <deal.II/lac/la_vector.h>
#include "../tests.h"
ExcInternalError());
// test accuracy of summation
- const long double value = 3.14159265358979323846;
+ constexpr long double value = numbers::PI;
for (unsigned int i = 0; i < size; ++i)
vec[i] = (number)value;
const number l1_norma = vec.l1_norm();
AssertThrow(std::abs(l1_norm - sum) < acc * sum, ExcInternalError());
// test accuracy of summation
- const std::complex<long double> value(3.14159265358979323846, 0.1);
+ constexpr std::complex<long double> value(numbers::PI, 0.1);
for (unsigned int i = 0; i < size; ++i)
vec[i] = std::complex<number>(value);
const number l1_norma = vec.l1_norm();
// check that Vector::add_and_dot works correctly
+#include <deal.II/base/numbers.h>
+
#include <deal.II/lac/vector.h>
#include "../tests.h"
{
v1(i) = 0.1 + 0.005 * i;
v2(i) = -5.2 + 0.18 * i;
- v3(i) = 3.14159 + 2.7183 / (1. + i);
+ v3(i) = numbers::PI + numbers::E / (1. + i);
}
check = v1;
const number factor = 0.01432;
// check that Vector::add_and_dot works correctly for complex-valued
// vectors
+#include <deal.II/base/numbers.h>
+
#include <deal.II/lac/vector.h>
#include "../tests.h"
{
v1(i) = std::complex<number>(0.1 + 0.005 * i, 1.234 + 12 * i);
v2(i) = std::complex<number>(-5.2 + 0.18 * i, 42.4242 + 42 * i);
- v3(i) = std::complex<number>(3.14159 + 2.7183 / (1. + i), 13.);
+ v3(i) =
+ std::complex<number>(numbers::PI + numbers::E / (1. + i), 13.);
}
check = v1;
const std::complex<number> factor = std::complex<number>(0.01432);
// (check the summation algorithm), including an accuracy test (should not
// lose more than 1 decimal also for 200000 vector entries)
+#include <deal.II/base/numbers.h>
+
#include <deal.II/lac/vector.h>
#include "../tests.h"
ExcInternalError());
// test accuracy of summation
- const long double value = 3.14159265358979323846;
- vec = (number)value;
- const number l1_norma = vec.l1_norm();
+ constexpr long double value = numbers::PI;
+ vec = (number)value;
+ const number l1_norma = vec.l1_norm();
AssertThrow(std::abs(l1_norma - value * size) < acc * size * value,
ExcInternalError());
const number l2_norma = vec.l2_norm();
AssertThrow(std::abs(l1_norm - sum) < acc * sum, ExcInternalError());
// test accuracy of summation
- const std::complex<long double> value(3.14159265358979323846, 0.1);
+ constexpr std::complex<long double> value(numbers::PI, 0.1);
vec = std::complex<number>(value);
const number l1_norma = vec.l1_norm();
AssertThrow(std::abs(l1_norma - std::abs(value) * size) <
// check that internal::VectorOperations::parallel_for works for start-end
#include <deal.II/base/index_set.h>
+#include <deal.II/base/numbers.h>
#include <deal.II/lac/vector_operations_internal.h>
64,
sizeof(Number) * size);
- const Number s = 3.1415;
+ const Number s = numbers::PI;
internal::VectorOperations::Vector_set<Number> setter(s, val);
// now break the size in chunks
#include <deal.II/base/function.h>
#include <deal.II/base/logstream.h>
+#include <deal.II/base/numbers.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/table_handler.h>
// Last task -- generate output:
output_table.add_value("cells", triangulation.n_active_cells());
output_table.add_value("|u|_1", norm);
- output_table.add_value("error",
- std::fabs(norm - std::sqrt(3.14159265358 / 2)));
+ output_table.add_value("error", std::fabs(norm - std::sqrt(numbers::PI_2)));
}
#include <deal.II/base/function.h>
+#include <deal.II/base/numbers.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/table_handler.h>
output_table.add_value("cells", triangulation.n_active_cells());
output_table.add_value("|u|_1", norm);
- output_table.add_value("error",
- std::fabs(norm - std::sqrt(3.14159265358 / 2)));
+ output_table.add_value("error", std::fabs(norm - std::sqrt(numbers::PI_2)));
- last_error = std::fabs(norm - std::sqrt(3.14159265358 / 2));
+ last_error = std::fabs(norm - std::sqrt(numbers::PI_2));
}