Skip to content

Commit

Permalink
Merge pull request #14936 from masterleinad/fix_namespace_std_tests
Browse files Browse the repository at this point in the history
Don't use namespace std in tests
  • Loading branch information
kronbichler committed Mar 22, 2023
2 parents 0d60e74 + 158f5f8 commit f1b6f24
Show file tree
Hide file tree
Showing 82 changed files with 223 additions and 280 deletions.
2 changes: 0 additions & 2 deletions tests/base/polynomials_bdm_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#include "../tests.h"

using namespace std;

template <int dim>
void
plot(const PolynomialsBDM<dim> &poly)
Expand Down
2 changes: 0 additions & 2 deletions tests/base/polynomials_bdm_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#include "../tests.h"

using namespace std;

template <int dim>
void
plot(const PolynomialsBDM<dim> &poly)
Expand Down
2 changes: 0 additions & 2 deletions tests/base/polynomials_rt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

#include "../tests.h"

using namespace std;

template <int dim>
void
plot(const PolynomialsRaviartThomas<dim> &poly)
Expand Down
2 changes: 0 additions & 2 deletions tests/base/polynomials_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

#include "../tests.h"

using namespace std;

template <int dim, class PolynomialType>
void
check_point(const Point<dim> &x, const PolynomialType &p)
Expand Down
2 changes: 0 additions & 2 deletions tests/bits/count_dofs_per_component_hp_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
// for the hp-case


using namespace std;

template <int dim>
void
test()
Expand Down
2 changes: 0 additions & 2 deletions tests/bits/count_dofs_per_component_hp_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
// collection has more than one element


using namespace std;

template <int dim>
void
test()
Expand Down
2 changes: 0 additions & 2 deletions tests/bits/map_dofs_to_support_points_hp_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
// for the hp-case


using namespace std;

template <int dim>
void
test()
Expand Down
2 changes: 0 additions & 2 deletions tests/bits/map_dofs_to_support_points_hp_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
// on different cells.


using namespace std;

template <int dim>
void
test()
Expand Down
32 changes: 15 additions & 17 deletions tests/codim_one/bem_integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@
#include <iostream>
#include <string>

using namespace std;

ofstream logfile("output");
std::ofstream logfile("output");


template <int dim>
Expand All @@ -74,7 +72,7 @@ class LaplaceKernelIntegration

void
compute_SD_integral_on_cell(
vector<double> & dst,
std::vector<double> & dst,
typename DoFHandler<dim, dim + 1>::active_cell_iterator &cell,
const Point<dim + 1> & point);

Expand All @@ -95,14 +93,14 @@ class LaplaceKernelIntegration
template <>
LaplaceKernelIntegration<2>::LaplaceKernelIntegration()
{
static FE_DGP<2, 3> fe(0);
vector<Point<2>> qps(5);
static FE_DGP<2, 3> fe(0);
std::vector<Point<2>> qps(5);
qps[0] = Point<2>(0, 0);
qps[1] = Point<2>(0, 1);
qps[2] = Point<2>(1, 0);
qps[3] = Point<2>(1, 1);
qps[4] = Point<2>(.5, .5);
vector<double> ws(5, 1.);
std::vector<double> ws(5, 1.);
static Quadrature<2> quadrature(qps, ws);
fe_values = new FEValues<2, 3>(
fe, quadrature, update_values | update_jacobians | update_normal_vectors);
Expand All @@ -120,22 +118,22 @@ LaplaceKernelIntegration<dim>::~LaplaceKernelIntegration()
template <>
void
LaplaceKernelIntegration<2>::compute_SD_integral_on_cell(
vector<double> & dst,
std::vector<double> & dst,
DoFHandler<2, 3>::active_cell_iterator &cell,
const Point<3> & point)
{
Assert(dst.size() == 2, ExcDimensionMismatch(dst.size(), 2));
fe_values->reinit(cell);
vector<DerivativeForm<1, 2, 3>> jacobians = fe_values->get_jacobians();
vector<Tensor<1, 3>> normals = fe_values->get_normal_vectors();
std::vector<DerivativeForm<1, 2, 3>> jacobians = fe_values->get_jacobians();
std::vector<Tensor<1, 3>> normals = fe_values->get_normal_vectors();

Tensor<1, 3> n, n_c;
Tensor<1, 3> r_c = point - cell->center();
n_c = normals[4];

double rn_c = r_c * n_c;
vector<double> i_S(4);
vector<double> i_D(4);
double rn_c = r_c * n_c;
std::vector<double> i_S(4);
std::vector<double> i_D(4);
for (unsigned int q_point = 0; q_point < 4; ++q_point)
{
const Tensor<1, 3> r = point - cell->vertex(q_point);
Expand Down Expand Up @@ -198,7 +196,7 @@ integration(Point<3> point)
DoFHandler<2, 3>::active_cell_iterator cell = dof_handler.begin_active();

LaplaceKernelIntegration<2> laplace;
vector<double> integrals(2);
std::vector<double> integrals(2);
laplace.compute_SD_integral_on_cell(integrals, cell, point);
return integrals[0];
}
Expand All @@ -215,17 +213,17 @@ main()
Point<3> point(.5, .5, 0);
double true_result = -3.163145629 / numbers::PI;
deallog << "Error on " << point << " : " << integration(point) - true_result
<< endl;
<< std::endl;

point = Point<3>(3, 3, 0);
true_result = -.2306783616;
deallog << "Error on " << point << " : " << integration(point) - true_result
<< endl;
<< std::endl;

point = Point<3>(1.5, .5, 0);
true_result = -1.006860525;
deallog << "Error on " << point << " : " << integration(point) - true_result
<< endl;
<< std::endl;

return 0;
}
4 changes: 1 addition & 3 deletions tests/codim_one/boundary_indicator_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

#include "../tests.h"

using namespace std;



template <int dim, int spacedim>
Expand All @@ -56,7 +54,7 @@ main()
// Extract the boundary of 3/4 of a sphere
{
const int dim = 3;
deallog << "Testing hyper_cube in dim: " << dim << "..." << endl;
deallog << "Testing hyper_cube in dim: " << dim << "..." << std::endl;

const SphericalManifold<dim> boundary_description;
Triangulation<dim> volume_mesh;
Expand Down
2 changes: 0 additions & 2 deletions tests/codim_one/direction_flag_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

#include "../tests.h"

using namespace std;


void
test()
Expand Down
2 changes: 0 additions & 2 deletions tests/codim_one/direction_flag_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

#include "../tests.h"

using namespace std;


void
test()
Expand Down
2 changes: 0 additions & 2 deletions tests/codim_one/direction_flag_03.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#include "../tests.h"

using namespace std;


template <int dim>
void
Expand Down
24 changes: 11 additions & 13 deletions tests/codim_one/extract_boundary_mesh_00.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

#include "../tests.h"

using namespace std;


template <int dim, int spacedim>
void
Expand All @@ -53,9 +51,9 @@ main()
// Extract the whole boundary of a hyper-cube
const int dim = 2;

deallog << "Testing hyper_cube in dim: " << dim << "..." << endl;
map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
deallog << "Testing hyper_cube in dim: " << dim << "..." << std::endl;
std::map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
surface_to_volume_mapping;

Triangulation<dim> volume_mesh;
Expand All @@ -77,9 +75,9 @@ main()
// Extract the whole boundary of a hyper-cube
const int dim = 3;

deallog << "Testing hyper_cube in dim: " << dim << "..." << endl;
map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
deallog << "Testing hyper_cube in dim: " << dim << "..." << std::endl;
std::map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
surface_to_volume_mapping;

Triangulation<dim> volume_mesh;
Expand All @@ -102,10 +100,10 @@ main()
// Extract a piece of the boundary of a hyper-cube

const int dim = 3;
deallog << "Testing hyper_cube in dim: " << dim << "..." << endl;
deallog << "Testing hyper_cube in dim: " << dim << "..." << std::endl;

map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
std::map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
surface_to_volume_mapping;

Triangulation<dim> volume_mesh;
Expand All @@ -115,8 +113,8 @@ main()

save_mesh(volume_mesh);

Triangulation<dim - 1, dim> boundary_mesh;
const set<types::boundary_id> boundary_ids = {0};
Triangulation<dim - 1, dim> boundary_mesh;
const std::set<types::boundary_id> boundary_ids = {0};

surface_to_volume_mapping =
GridGenerator::extract_boundary_mesh(volume_mesh,
Expand Down
22 changes: 10 additions & 12 deletions tests/codim_one/extract_boundary_mesh_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@

#include "../tests.h"

using namespace std;


template <int s_dim, int spacedim>
bool
test_vertices_orientation(
const Triangulation<s_dim, spacedim> &boundary_mesh,
map<typename Triangulation<s_dim, spacedim>::cell_iterator,
typename Triangulation<s_dim + 1, spacedim>::face_iterator>
std::map<typename Triangulation<s_dim, spacedim>::cell_iterator,
typename Triangulation<s_dim + 1, spacedim>::face_iterator>
& surface_to_volume_mapping,
const int verbosity = 1)
{
Expand All @@ -55,13 +53,13 @@ test_vertices_orientation(

if (verbosity > 1)
{
deallog << "The last column should be 0" << endl;
deallog << "The last column should be 0" << std::endl;
deallog << "Vol faces"
<< "\t\t"
<< "Surf cell"
<< "\t\t"
<< "Distance" << endl
<< endl;
<< "Distance" << std::endl
<< std::endl;
}

for (; cell != endc; ++cell)
Expand All @@ -73,15 +71,15 @@ test_vertices_orientation(
if (verbosity > 1)
{
deallog << face->center() << "\t\t";
deallog << cell->center() << "\t\t\t" << diff.square() << endl;
deallog << cell->center() << "\t\t\t" << diff.square() << std::endl;
}
if (diff.square() > 0)
{
success = false;
break;
}
if (verbosity > 1)
deallog << endl;
deallog << std::endl;
}
return success;
}
Expand All @@ -105,10 +103,10 @@ main()
// Extract the boundary of a hyper-sphere

const int dim = 3;
deallog << "Testing hyper_ball in dim: " << dim << "..." << endl;
deallog << "Testing hyper_ball in dim: " << dim << "..." << std::endl;

map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
std::map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
surface_to_volume_mapping;
Triangulation<dim> volume_mesh;
GridGenerator::hyper_ball(volume_mesh);
Expand Down
12 changes: 5 additions & 7 deletions tests/codim_one/extract_boundary_mesh_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@

#include "../tests.h"

using namespace std;


template <int s_dim, int spacedim>
void
test_vertices_orientation(
const Triangulation<s_dim, spacedim> &boundary_mesh,
map<typename Triangulation<s_dim, spacedim>::cell_iterator,
typename Triangulation<s_dim + 1, spacedim>::face_iterator>
std::map<typename Triangulation<s_dim, spacedim>::cell_iterator,
typename Triangulation<s_dim + 1, spacedim>::face_iterator>
&surface_to_volume_mapping)
{
typename Triangulation<s_dim, spacedim>::active_cell_iterator
Expand Down Expand Up @@ -88,10 +86,10 @@ main()
// Extract the boundary of a hyper-sphere

const int dim = 3;
deallog << "Testing hyper_cube in dim: " << dim << "..." << endl;
deallog << "Testing hyper_cube in dim: " << dim << "..." << std::endl;

map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
std::map<Triangulation<dim - 1, dim>::cell_iterator,
Triangulation<dim, dim>::face_iterator>
surface_to_volume_mapping;
const SphericalManifold<dim> boundary_description;
Triangulation<dim> volume_mesh;
Expand Down

0 comments on commit f1b6f24

Please sign in to comment.