Skip to content
Snippets Groups Projects
Commit d4a32a6a authored by Jacques Xing's avatar Jacques Xing
Browse files

Merge branch 'fix/using-namespace-std' into 'master'

Fix `using namespace std` in headers

See merge request !1810
parents 93aeec3c fc178cee
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
using namespace std;
using namespace Nektar; using namespace Nektar;
using namespace Nektar::LibUtilities; using namespace Nektar::LibUtilities;
using namespace Nektar::StdRegions; using namespace Nektar::StdRegions;
...@@ -69,23 +68,23 @@ public: ...@@ -69,23 +68,23 @@ public:
("help,h", ("help,h",
"Produce this help message and list basis and shape types.") "Produce this help message and list basis and shape types.")
("nodal,n", ("nodal,n",
po::value<string>(&m_ntype), po::value<std::string>(&m_ntype),
"Optional nodal type, autofills shape and basis choices.") "Optional nodal type, autofills shape and basis choices.")
("shape,s", ("shape,s",
po::value<string>(&m_shape), po::value<std::string>(&m_shape),
"Region shape to project function on.") "Region shape to project function on.")
("basis,b", ("basis,b",
po::value<vector<string>>(&m_basis)->multitoken(), po::value<std::vector<std::string>>(&m_basis)->multitoken(),
"Basis type, separate by spaces for higher dimensions.") "Basis type, separate by spaces for higher dimensions.")
("order,o", ("order,o",
po::value<vector<int>>(&m_order)->multitoken()->required(), po::value<std::vector<int>>(&m_order)->multitoken()->required(),
"Order of basis sets, separate by spaces for higher dimensions.") "Order of basis sets, separate by spaces for higher dimensions.")
("points,p", ("points,p",
po::value<vector<int>>(&m_points)->multitoken()->required(), po::value<std::vector<int>>(&m_points)->multitoken()->required(),
"Number of quadrature points, separate by spaces for " "Number of quadrature points, separate by spaces for "
"higher dimensions.") "higher dimensions.")
("pointstype,P", ("pointstype,P",
po::value<vector<string>>(&m_pointstype)->multitoken(), po::value<std::vector<std::string>>(&m_pointstype)->multitoken(),
"Optional points type, separate by spaces for higher dimensions."); "Optional points type, separate by spaces for higher dimensions.");
// clang-format on // clang-format on
} }
...@@ -97,42 +96,49 @@ public: ...@@ -97,42 +96,49 @@ public:
po::store(po::parse_command_line(argc, argv, m_desc), m_vm); po::store(po::parse_command_line(argc, argv, m_desc), m_vm);
if (m_vm.count("help")) if (m_vm.count("help"))
{ {
cout << m_desc; std::cout << m_desc;
cout << endl << "All nodal types, -n [ --nodal ], are:" << endl; std::cout << std::endl
<< "All nodal types, -n [ --nodal ], are:"
<< std::endl;
for (int i = 22; i < SIZE_PointsType; ++i) for (int i = 22; i < SIZE_PointsType; ++i)
{ {
cout << kPointsTypeStr[i] << endl; std::cout << kPointsTypeStr[i] << std::endl;
}; };
cout << endl << "All shape types, -s [ --shape ], are:" << endl; std::cout << std::endl
<< "All shape types, -s [ --shape ], are:"
<< std::endl;
for (int i = 1; i < SIZE_ShapeType; ++i) for (int i = 1; i < SIZE_ShapeType; ++i)
{ {
cout << ShapeTypeMap[i] << endl; std::cout << ShapeTypeMap[i] << std::endl;
}; };
cout << endl << "All basis types, -b [ --basis ], are:" << endl; std::cout << std::endl
<< "All basis types, -b [ --basis ], are:"
<< std::endl;
for (int i = 1; i < SIZE_BasisType; ++i) for (int i = 1; i < SIZE_BasisType; ++i)
{ {
cout << BasisTypeMap[i] << endl; std::cout << BasisTypeMap[i] << std::endl;
}; };
cout << endl std::cout << std::endl
<< "All points types, -P [ --pointstype ], are:" << endl; << "All points types, -P [ --pointstype ], are:"
<< std::endl;
for (int i = 1; i < SIZE_PointsType; ++i) for (int i = 1; i < SIZE_PointsType; ++i)
{ {
cout << kPointsTypeStr[i] << endl; std::cout << kPointsTypeStr[i] << std::endl;
}; };
exit(0); exit(0);
} }
po::notify(m_vm); po::notify(m_vm);
} }
catch (const exception &e) catch (const std::exception &e)
{ {
cerr << "Error: " << e.what() << endl << m_desc; std::cerr << "Error: " << e.what() << std::endl << m_desc;
exit(1); exit(1);
} }
} }
StdExpansion *CreateStdExpansion() StdExpansion *CreateStdExpansion()
{ {
vector<PointsType> ptype; std::vector<PointsType> ptype;
if (m_vm.count("pointstype")) if (m_vm.count("pointstype"))
{ {
for (auto &p : m_pointstype) for (auto &p : m_pointstype)
...@@ -158,7 +164,7 @@ public: ...@@ -158,7 +164,7 @@ public:
// Convert string input argument to nodal type // Convert string input argument to nodal type
PointsType nodaltype = eNoPointsType; PointsType nodaltype = eNoPointsType;
ShapeType stype = eNoShapeType; ShapeType stype = eNoShapeType;
vector<BasisType> btype(3, eNoBasisType); std::vector<BasisType> btype(3, eNoBasisType);
if (m_vm.count("nodal")) if (m_vm.count("nodal"))
{ {
for (int i = 22; i < SIZE_PointsType; ++i) // starts at nodal points for (int i = 22; i < SIZE_PointsType; ++i) // starts at nodal points
...@@ -262,7 +268,7 @@ public: ...@@ -262,7 +268,7 @@ public:
} }
// check basis selection is permitted for chosen shape // check basis selection is permitted for chosen shape
map<ShapeType, vector<vector<BasisType>>> allowableBasis; std::map<ShapeType, std::vector<std::vector<BasisType>>> allowableBasis;
allowableBasis[ePoint] = {{eOrtho_A, eModified_A, eFourier, allowableBasis[ePoint] = {{eOrtho_A, eModified_A, eFourier,
eGLL_Lagrange, eGauss_Lagrange, eLegendre, eGLL_Lagrange, eGauss_Lagrange, eLegendre,
eChebyshev, eMonomial, eFourierSingleMode, eChebyshev, eMonomial, eFourierSingleMode,
...@@ -305,9 +311,9 @@ public: ...@@ -305,9 +311,9 @@ public:
} }
ASSERTL0(j != basisListLength - 1, ASSERTL0(j != basisListLength - 1,
("The basis type '" + ("The basis type '" +
static_cast<string>(BasisTypeMap[btype[i]]) + static_cast<std::string>(BasisTypeMap[btype[i]]) +
"' is invalid for basis argument " + "' is invalid for basis argument " +
to_string(i + 1) + " for shape '" + std::to_string(i + 1) + " for shape '" +
ShapeTypeMap[stype] + "'.")) ShapeTypeMap[stype] + "'."))
} }
} }
...@@ -355,8 +361,8 @@ public: ...@@ -355,8 +361,8 @@ public:
} }
} }
vector<PointsKey> pkey; std::vector<PointsKey> pkey;
vector<BasisKey> bkey; std::vector<BasisKey> bkey;
for (int i = 0; i < dimension; ++i) for (int i = 0; i < dimension; ++i)
{ {
pkey.emplace_back(PointsKey(m_points[i], ptype[i])); pkey.emplace_back(PointsKey(m_points[i], ptype[i]));
...@@ -430,12 +436,12 @@ public: ...@@ -430,12 +436,12 @@ public:
return m_vm; return m_vm;
} }
std::vector<string> &GetPointsType() std::vector<std::string> &GetPointsType()
{ {
return m_pointstype; return m_pointstype;
} }
std::vector<string> &GetBasisType() std::vector<std::string> &GetBasisType()
{ {
return m_basis; return m_basis;
} }
...@@ -491,10 +497,10 @@ protected: ...@@ -491,10 +497,10 @@ protected:
std::string m_shape; std::string m_shape;
std::string m_ntype; std::string m_ntype;
vector<string> m_basis{3, "NoBasisType"}; std::vector<std::string> m_basis{3, "NoBasisType"};
vector<string> m_pointstype{3, "NoPointsType"}; std::vector<std::string> m_pointstype{3, "NoPointsType"};
vector<int> m_order; std::vector<int> m_order;
vector<int> m_points; std::vector<int> m_points;
}; };
#endif #endif
...@@ -67,7 +67,7 @@ int main(int argc, char *argv[]) ...@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
// Create a new element but with the evenly-spaced points type, so that we // Create a new element but with the evenly-spaced points type, so that we
// perform a PhysEvaluate at a different set of nodal points // perform a PhysEvaluate at a different set of nodal points
// (i.e. non-collocated interpolation). // (i.e. non-collocated interpolation).
vector<string> &ptypes = demo.GetPointsType(); std::vector<std::string> &ptypes = demo.GetPointsType();
for (int i = 0; i < dimension; ++i) for (int i = 0; i < dimension; ++i)
{ {
ptypes[i] = "PolyEvenlySpaced"; ptypes[i] = "PolyEvenlySpaced";
...@@ -94,9 +94,10 @@ int main(int argc, char *argv[]) ...@@ -94,9 +94,10 @@ int main(int argc, char *argv[])
sol = EvalPoly(coordsF); sol = EvalPoly(coordsF);
cout << "L infinity error : " << scientific << E->Linf(physOut, sol) std::cout << "L infinity error : " << std::scientific
<< endl; << E->Linf(physOut, sol) << std::endl;
cout << "L 2 error : " << scientific << E->L2(physOut, sol) << endl; std::cout << "L 2 error : " << std::scientific << E->L2(physOut, sol)
<< std::endl;
return 0; return 0;
} }
...@@ -79,8 +79,10 @@ int main(int argc, char *argv[]) ...@@ -79,8 +79,10 @@ int main(int argc, char *argv[])
E->FillMode(k, tmp); E->FillMode(k, tmp);
} }
cout << "L infinity error : " << scientific << E->Linf(phys, sol) << endl; std::cout << "L infinity error : " << std::scientific << E->Linf(phys, sol)
cout << "L 2 error : " << scientific << E->L2(phys, sol) << endl; << std::endl;
std::cout << "L 2 error : " << std::scientific << E->L2(phys, sol)
<< std::endl;
return 0; return 0;
} }
...@@ -114,7 +114,7 @@ int main(int argc, char *argv[]) ...@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
// perform a PhysEvaluateDeriv at a different set of nodal points // perform a PhysEvaluateDeriv at a different set of nodal points
// (i.e. non-collocated interpolation), all tests use default types // (i.e. non-collocated interpolation), all tests use default types
// initially // initially
vector<string> &ptypes = demo.GetPointsType(); std::vector<std::string> &ptypes = demo.GetPointsType();
for (int i = 0; i < dimension; ++i) for (int i = 0; i < dimension; ++i)
{ {
ptypes[i] = "PolyEvenlySpaced"; ptypes[i] = "PolyEvenlySpaced";
...@@ -167,14 +167,14 @@ int main(int argc, char *argv[]) ...@@ -167,14 +167,14 @@ int main(int argc, char *argv[])
break; break;
} }
cout << "\nL infinity error: " << scientific std::cout << "\nL infinity error: " << std::scientific
<< E->Linf(physOut, sol) + E->Linf(physOut0, sol0) + << E->Linf(physOut, sol) + E->Linf(physOut0, sol0) +
E->Linf(physOut1, sol1) + E->Linf(physOut2, sol2) E->Linf(physOut1, sol1) + E->Linf(physOut2, sol2)
<< endl; << std::endl;
cout << "L 2 error : " << scientific std::cout << "L 2 error : " << std::scientific
<< E->L2(physOut, sol) + E->L2(physOut0, sol0) + << E->L2(physOut, sol) + E->L2(physOut0, sol0) +
E->L2(physOut1, sol1) + E->L2(physOut2, sol2) E->L2(physOut1, sol1) + E->L2(physOut2, sol2)
<< endl; << std::endl;
return 0; return 0;
} }
...@@ -38,8 +38,9 @@ ...@@ -38,8 +38,9 @@
namespace po = boost::program_options; namespace po = boost::program_options;
NekDouble Shape_sol(NekDouble x, NekDouble y, NekDouble z, vector<int> order, NekDouble Shape_sol(NekDouble x, NekDouble y, NekDouble z,
vector<BasisType> btype, ShapeType stype, bool diff); std::vector<int> order, std::vector<BasisType> btype,
ShapeType stype, bool diff);
// Modification to deal with exact solution for diff. Return 1 if integer < 0. // Modification to deal with exact solution for diff. Return 1 if integer < 0.
static double pow_loc(const double val, const int i) static double pow_loc(const double val, const int i)
...@@ -161,10 +162,10 @@ int main(int argc, char *argv[]) ...@@ -161,10 +162,10 @@ int main(int argc, char *argv[])
} }
// Calculate L_inf & L_2 error // Calculate L_inf & L_2 error
cout << "L infinity error: \t" << E->Linf(phys, sol) << endl; std::cout << "L infinity error: \t" << E->Linf(phys, sol) << std::endl;
if (stype != ePoint) if (stype != ePoint)
{ {
cout << "L 2 error: \t \t \t" << E->L2(phys, sol) << endl; std::cout << "L 2 error: \t \t \t" << E->L2(phys, sol) << std::endl;
} }
if (!vm.count("diff") && stype != ePoint) if (!vm.count("diff") && stype != ePoint)
...@@ -178,12 +179,12 @@ int main(int argc, char *argv[]) ...@@ -178,12 +179,12 @@ int main(int argc, char *argv[])
NekDouble nsol = E->PhysEvaluate(t, phys); NekDouble nsol = E->PhysEvaluate(t, phys);
cout << "Error at x = ("; std::cout << "Error at x = (";
for (int i = 0; i < dimension; ++i) for (int i = 0; i < dimension; ++i)
{ {
cout << t[i] << ", "; std::cout << t[i] << ", ";
} }
cout << "\b\b): " << nsol - sol[0] << endl; std::cout << "\b\b): " << nsol - sol[0] << std::endl;
} }
// Calculate integral of known function to test different quadrature // Calculate integral of known function to test different quadrature
...@@ -231,54 +232,63 @@ int main(int argc, char *argv[]) ...@@ -231,54 +232,63 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
NekDouble Shape_sol(NekDouble x, NekDouble y, NekDouble z, vector<int> order, NekDouble Shape_sol(NekDouble x, NekDouble y, NekDouble z,
vector<BasisType> btype, ShapeType stype, bool diff) std::vector<int> order, std::vector<BasisType> btype,
ShapeType stype, bool diff)
{ {
map<ShapeType, function<int(int, const vector<int> &)>> shapeConstraint2; std::map<ShapeType, std::function<int(int, const std::vector<int> &)>>
shapeConstraint2[ePoint] = [](int, const vector<int> &) { return 1; }; shapeConstraint2;
shapeConstraint2[eSegment] = [](int, const vector<int> &) { return 1; }; shapeConstraint2[ePoint] = [](int, const std::vector<int> &) { return 1; };
shapeConstraint2[eTriangle] = [](int k, const vector<int> &order) { shapeConstraint2[eSegment] = [](int, const std::vector<int> &) {
return 1;
};
shapeConstraint2[eTriangle] = [](int k, const std::vector<int> &order) {
return order[1] - k; return order[1] - k;
}; };
shapeConstraint2[eQuadrilateral] = [](int, const vector<int> &order) { shapeConstraint2[eQuadrilateral] = [](int, const std::vector<int> &order) {
return order[1]; return order[1];
}; };
shapeConstraint2[eTetrahedron] = [](int k, const vector<int> &order) { shapeConstraint2[eTetrahedron] = [](int k, const std::vector<int> &order) {
return order[1] - k; return order[1] - k;
}; };
shapeConstraint2[ePyramid] = [](int k, const vector<int> &order) { shapeConstraint2[ePyramid] = [](int k, const std::vector<int> &order) {
return order[1] - k; return order[1] - k;
}; };
shapeConstraint2[ePrism] = [](int, const vector<int> &order) { shapeConstraint2[ePrism] = [](int, const std::vector<int> &order) {
return order[1]; return order[1];
}; };
shapeConstraint2[eHexahedron] = [](int, const vector<int> &order) { shapeConstraint2[eHexahedron] = [](int, const std::vector<int> &order) {
return order[1]; return order[1];
}; };
map<ShapeType, function<int(int, int, const vector<int> &order)>> std::map<ShapeType,
std::function<int(int, int, const std::vector<int> &order)>>
shapeConstraint3; shapeConstraint3;
shapeConstraint3[ePoint] = [](int, int, const vector<int> &) { return 1; }; shapeConstraint3[ePoint] = [](int, int, const std::vector<int> &) {
shapeConstraint3[eSegment] = [](int, int, const vector<int> &) { return 1;
};
shapeConstraint3[eSegment] = [](int, int, const std::vector<int> &) {
return 1; return 1;
}; };
shapeConstraint3[eTriangle] = [](int, int, const vector<int> &) { shapeConstraint3[eTriangle] = [](int, int, const std::vector<int> &) {
return 1; return 1;
}; };
shapeConstraint3[eQuadrilateral] = [](int, int, const vector<int> &) { shapeConstraint3[eQuadrilateral] = [](int, int, const std::vector<int> &) {
return 1; return 1;
}; };
shapeConstraint3[eTetrahedron] = shapeConstraint3[eTetrahedron] = [](int k, int l,
[](int k, int l, const vector<int> &order) { return order[2] - k - l; }; const std::vector<int> &order) {
shapeConstraint3[ePyramid] = [](int k, int l, const vector<int> &order) {
return order[2] - k - l; return order[2] - k - l;
}; };
shapeConstraint3[ePrism] = [](int k, int, const vector<int> &order) { shapeConstraint3[ePyramid] = [](int k, int l,
return order[2] - k; const std::vector<int> &order) {
return order[2] - k - l;
}; };
shapeConstraint3[eHexahedron] = [](int, int, const vector<int> &order) { shapeConstraint3[ePrism] = [](int k, int, const std::vector<int> &order) {
return order[2]; return order[2] - k;
}; };
shapeConstraint3[eHexahedron] =
[](int, int, const std::vector<int> &order) { return order[2]; };
NekDouble sol = 0.0; NekDouble sol = 0.0;
if (!diff) if (!diff)
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <algorithm> #include <algorithm>
#include <cstdlib> #include <cstdlib>
#include <math.h> #include <math.h>
using namespace std;
using namespace Nektar; using namespace Nektar;
namespace Smath namespace Smath
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_DIRK_TIME_INTEGRATION_SCHEME #define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_DIRK_TIME_INTEGRATION_SCHEME
#define LUE LIB_UTILITIES_EXPORT #define LUE LIB_UTILITIES_EXPORT
using namespace std;
#include <LibUtilities/TimeIntegration/TimeIntegrationSchemeGLM.h> #include <LibUtilities/TimeIntegration/TimeIntegrationSchemeGLM.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment