From 06b44fdf03912eedd32c0642b8f92f320d7a1953 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Fri, 7 Sep 2018 11:32:51 +0200 Subject: [PATCH] Improve style for alias definitions 'typedef ConcreteType AliasType;' -> 'using AliasType = ConcreteType;' This is much cleaner --- src/main.cpp | 26 +++++++++++------------ src/mesh/Connectivity.cpp | 4 ++-- src/mesh/ConnectivityMatrix.hpp | 4 ++-- src/mesh/GmshReader.cpp | 12 +++++------ src/mesh/GmshReader.hpp | 23 ++++++++++++-------- src/mesh/ItemValue.hpp | 2 +- src/mesh/Mesh.hpp | 5 +++-- src/mesh/MeshData.hpp | 4 ++-- src/mesh/MeshNodeBoundary.hpp | 19 ++++++++++------- src/scheme/AcousticSolver.hpp | 8 +++---- src/scheme/BoundaryCondition.hpp | 2 +- src/scheme/FiniteVolumesEulerUnknowns.hpp | 6 +++--- 12 files changed, 62 insertions(+), 53 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 06aec1142..4ffdd9b0a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -147,10 +147,10 @@ int main(int argc, char *argv[]) bc_descriptor_list.push_back(std::shared_ptr<BoundaryConditionDescriptor>(sym_bc_descriptor)); } - typedef Connectivity1D ConnectivityType; - typedef Mesh<ConnectivityType> MeshType; - typedef MeshData<MeshType> MeshDataType; - typedef FiniteVolumesEulerUnknowns<MeshDataType> UnknownsType; + using ConnectivityType = Connectivity1D; + using MeshType = Mesh<ConnectivityType>; + using MeshDataType = MeshData<MeshType>; + using UnknownsType = FiniteVolumesEulerUnknowns<MeshDataType>; const MeshType& mesh = dynamic_cast<const MeshType&>(*gmsh_reader.mesh()); @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) AcousticSolver<MeshDataType> acoustic_solver(mesh_data, unknowns, bc_list); - typedef TinyVector<MeshType::dimension> Rd; + using Rd = TinyVector<MeshType::dimension>; const CellValue<const double>& Vj = mesh_data.Vj(); @@ -256,10 +256,10 @@ int main(int argc, char *argv[]) bc_descriptor_list.push_back(std::shared_ptr<BoundaryConditionDescriptor>(sym_bc_descriptor)); } - typedef Connectivity2D ConnectivityType; - typedef Mesh<ConnectivityType> MeshType; - typedef MeshData<MeshType> MeshDataType; - typedef FiniteVolumesEulerUnknowns<MeshDataType> UnknownsType; + using ConnectivityType = Connectivity2D; + using MeshType = Mesh<ConnectivityType>; + using MeshDataType = MeshData<MeshType>; + using UnknownsType = FiniteVolumesEulerUnknowns<MeshDataType>; const MeshType& mesh = dynamic_cast<const MeshType&>(*gmsh_reader.mesh()); @@ -352,10 +352,10 @@ int main(int argc, char *argv[]) bc_descriptor_list.push_back(std::shared_ptr<BoundaryConditionDescriptor>(sym_bc_descriptor)); } - typedef Connectivity3D ConnectivityType; - typedef Mesh<ConnectivityType> MeshType; - typedef MeshData<MeshType> MeshDataType; - typedef FiniteVolumesEulerUnknowns<MeshDataType> UnknownsType; + using ConnectivityType = Connectivity3D; + using MeshType = Mesh<ConnectivityType>; + using MeshDataType = MeshData<MeshType>; + using UnknownsType = FiniteVolumesEulerUnknowns<MeshDataType>; const MeshType& mesh = dynamic_cast<const MeshType&>(*gmsh_reader.mesh()); diff --git a/src/mesh/Connectivity.cpp b/src/mesh/Connectivity.cpp index c3a2c01a9..94733f347 100644 --- a/src/mesh/Connectivity.cpp +++ b/src/mesh/Connectivity.cpp @@ -4,7 +4,7 @@ template<> void Connectivity<3>::_computeCellFaceAndFaceNodeConnectivities() { - typedef std::tuple<unsigned int, unsigned short, bool> CellFaceInfo; + using CellFaceInfo = std::tuple<unsigned int, unsigned short, bool>; const auto& cell_to_node_matrix = this->getMatrix(ItemType::cell, ItemType::node); @@ -160,7 +160,7 @@ void Connectivity<2>::_computeCellFaceAndFaceNodeConnectivities() = this->getMatrix(ItemType::cell, ItemType::node); // In 2D faces are simply define - typedef std::pair<unsigned int, unsigned short> CellFaceId; + using CellFaceId = std::pair<unsigned int, unsigned short>; std::map<Face, std::vector<CellFaceId>> face_cells_map; for (unsigned int j=0; j<this->numberOfCells(); ++j) { const auto& cell_nodes = cell_to_node_matrix.rowConst(j); diff --git a/src/mesh/ConnectivityMatrix.hpp b/src/mesh/ConnectivityMatrix.hpp index 356ee6da5..4387070d0 100644 --- a/src/mesh/ConnectivityMatrix.hpp +++ b/src/mesh/ConnectivityMatrix.hpp @@ -7,13 +7,13 @@ class ConnectivityMatrix { private: - typedef Kokkos::StaticCrsGraph<unsigned int, Kokkos::HostSpace> HostMatrix; + using HostMatrix = Kokkos::StaticCrsGraph<unsigned int, Kokkos::HostSpace>; HostMatrix m_host_matrix; bool m_is_built{false}; public: - typedef HostMatrix::row_map_type HostRowType; + using HostRowType = HostMatrix::row_map_type; const bool& isBuilt() const { diff --git a/src/mesh/GmshReader.cpp b/src/mesh/GmshReader.cpp index 736bc9470..b14e9c493 100644 --- a/src/mesh/GmshReader.cpp +++ b/src/mesh/GmshReader.cpp @@ -837,8 +837,8 @@ GmshReader::__proceedData() connectivity.addRefFaceList(RefFaceList(physical_ref_id.refId(), face_list)); } - typedef Mesh<Connectivity3D> MeshType; - typedef TinyVector<3, double> Rd; + using MeshType = Mesh<Connectivity3D>; + using Rd = TinyVector<3, double>; NodeValue<Rd> xr(connectivity); for (size_t i=0; i<__vertices.size(); ++i) { @@ -909,8 +909,8 @@ GmshReader::__proceedData() connectivity.addRefNodeList(RefNodeList(physical_ref_id.refId(), point_list)); } - typedef Mesh<Connectivity2D> MeshType; - typedef TinyVector<2, double> Rd; + using MeshType = Mesh<Connectivity2D>; + using Rd = TinyVector<2, double>; NodeValue<Rd> xr(connectivity); for (size_t i=0; i<__vertices.size(); ++i) { @@ -953,8 +953,8 @@ GmshReader::__proceedData() connectivity.addRefNodeList(RefNodeList(physical_ref_id.refId(), point_list)); } - typedef Mesh<Connectivity1D> MeshType; - typedef TinyVector<1, double> Rd; + using MeshType = Mesh<Connectivity1D>; + using Rd = TinyVector<1, double>; NodeValue<Rd> xr(connectivity); for (size_t i=0; i<__vertices.size(); ++i) { diff --git a/src/mesh/GmshReader.hpp b/src/mesh/GmshReader.hpp index 5a43e3f61..ba9ffe250 100644 --- a/src/mesh/GmshReader.hpp +++ b/src/mesh/GmshReader.hpp @@ -17,7 +17,7 @@ class GmshReader { public: - typedef TinyVector<3, double> R3; + using R3 = TinyVector<3, double>; class PhysicalRefId { @@ -80,22 +80,27 @@ private: Array<R3> __vertices; - typedef unsigned int Point; + using Point = unsigned int; Array<Point> __points; std::vector<int> __points_ref; - typedef TinyVector<2,unsigned int> Edge; + + using Edge = TinyVector<2,unsigned int>; Array<Edge> __edges; std::vector<int> __edges_ref; - typedef TinyVector<3,unsigned int> Triangle; + + using Triangle = TinyVector<3,unsigned int>; Array<Triangle> __triangles; std::vector<int> __triangles_ref; - typedef TinyVector<4,unsigned int> Quadrangle; + + using Quadrangle = TinyVector<4,unsigned int>; Array<Quadrangle> __quadrangles; std::vector<int> __quadrangles_ref; - typedef TinyVector<4,unsigned int> Tetrahedron; + + using Tetrahedron = TinyVector<4,unsigned int>; Array<Tetrahedron> __tetrahedra; std::vector<int> __tetrahedra_ref; - typedef TinyVector<8,unsigned int> Hexahedron; + + using Hexahedron = TinyVector<8,unsigned int>; Array<Hexahedron> __hexahedra; std::vector<int> __hexahedra_ref; @@ -194,7 +199,7 @@ private: * List of known keywords * */ - typedef std::map<std::string, int> KeywordList; + using KeywordList = std::map<std::string, int>; KeywordList __keywordList; /**< The keyword list */ @@ -202,7 +207,7 @@ private: * Type for keyword * */ - typedef std::pair<std::string, int> Keyword; + using Keyword = std::pair<std::string, int>; /** * Skips next comments if exists diff --git a/src/mesh/ItemValue.hpp b/src/mesh/ItemValue.hpp index 9b4bf5cfc..6f9516543 100644 --- a/src/mesh/ItemValue.hpp +++ b/src/mesh/ItemValue.hpp @@ -15,7 +15,7 @@ class ItemValue { public: static const ItemType item_t{item_type}; - typedef DataType data_type; + using data_type = DataType; private: bool m_is_built{false}; diff --git a/src/mesh/Mesh.hpp b/src/mesh/Mesh.hpp index 383e92294..0188d507c 100644 --- a/src/mesh/Mesh.hpp +++ b/src/mesh/Mesh.hpp @@ -16,9 +16,10 @@ template <typename ConnectivityType> class Mesh final : public IMesh { public: - typedef ConnectivityType Connectivity; + using Connectivity = ConnectivityType; + static constexpr size_t dimension = ConnectivityType::dimension; - typedef TinyVector<dimension> Rd; + using Rd = TinyVector<dimension>; private: const std::shared_ptr<Connectivity> m_connectivity; diff --git a/src/mesh/MeshData.hpp b/src/mesh/MeshData.hpp index b30c3d42f..70c73a004 100644 --- a/src/mesh/MeshData.hpp +++ b/src/mesh/MeshData.hpp @@ -13,12 +13,12 @@ template <typename M> class MeshData { public: - typedef M MeshType; + using MeshType = M; static constexpr size_t dimension = MeshType::dimension; static_assert(dimension>0, "dimension must be strictly positive"); - typedef TinyVector<dimension> Rd; + using Rd = TinyVector<dimension>; static constexpr double inv_dimension = 1./dimension; diff --git a/src/mesh/MeshNodeBoundary.hpp b/src/mesh/MeshNodeBoundary.hpp index e8e3403f5..16c016166 100644 --- a/src/mesh/MeshNodeBoundary.hpp +++ b/src/mesh/MeshNodeBoundary.hpp @@ -90,7 +90,9 @@ template <size_t dimension> class MeshFlatNodeBoundary : public MeshNodeBoundary<dimension> { - typedef TinyVector<dimension, double> Rd; + public: + using Rd = TinyVector<dimension, double>; + private: const Rd m_outgoing_normal; @@ -147,7 +149,8 @@ _checkBoundaryIsFlat(const TinyVector<2,double>& normal, const MeshType& mesh) const { static_assert(MeshType::dimension == 2); - typedef TinyVector<2,double> R2; + using R2 = TinyVector<2,double>; + const R2 origin = 0.5*(xmin+xmax); const double length = l2Norm(xmax-xmin); @@ -169,7 +172,7 @@ MeshFlatNodeBoundary<1>:: _getNormal(const MeshType& mesh) { static_assert(MeshType::dimension == 1); - typedef TinyVector<1,double> R; + using R = TinyVector<1,double>; if (m_node_list.size() != 1) { std::cerr << "Node boundaries in 1D require to have exactly 1 node\n"; @@ -186,7 +189,7 @@ MeshFlatNodeBoundary<2>:: _getNormal(const MeshType& mesh) { static_assert(MeshType::dimension == 2); - typedef TinyVector<2,double> R2; + using R2 = TinyVector<2,double>; const NodeValue<const R2>& xr = mesh.xr(); @@ -228,7 +231,7 @@ MeshFlatNodeBoundary<3>:: _getNormal(const MeshType& mesh) { static_assert(MeshType::dimension == 3); - typedef TinyVector<3,double> R3; + using R3 = TinyVector<3,double>; R3 xmin(std::numeric_limits<double>::max(), @@ -312,7 +315,7 @@ MeshFlatNodeBoundary<1>:: _getOutgoingNormal(const MeshType& mesh) { static_assert(MeshType::dimension == 1); - typedef TinyVector<1,double> R; + using R = TinyVector<1,double>; const R normal = this->_getNormal(mesh); @@ -349,7 +352,7 @@ MeshFlatNodeBoundary<2>:: _getOutgoingNormal(const MeshType& mesh) { static_assert(MeshType::dimension == 2); - typedef TinyVector<2,double> R2; + using R2 = TinyVector<2,double>; const R2 normal = this->_getNormal(mesh); @@ -386,7 +389,7 @@ MeshFlatNodeBoundary<3>:: _getOutgoingNormal(const MeshType& mesh) { static_assert(MeshType::dimension == 3); - typedef TinyVector<3,double> R3; + using R3 = TinyVector<3,double>; const R3 normal = this->_getNormal(mesh); diff --git a/src/scheme/AcousticSolver.hpp b/src/scheme/AcousticSolver.hpp index a23f13d7e..fe9801155 100644 --- a/src/scheme/AcousticSolver.hpp +++ b/src/scheme/AcousticSolver.hpp @@ -20,8 +20,8 @@ template<typename MeshData> class AcousticSolver { - typedef typename MeshData::MeshType MeshType; - typedef FiniteVolumesEulerUnknowns<MeshData> UnknownsType; + using MeshType = typename MeshData::MeshType; + using UnknownsType = FiniteVolumesEulerUnknowns<MeshData>; MeshData& m_mesh_data; const MeshType& m_mesh; @@ -30,8 +30,8 @@ class AcousticSolver constexpr static size_t dimension = MeshType::dimension; - typedef TinyVector<dimension> Rd; - typedef TinyMatrix<dimension> Rdd; + using Rd = TinyVector<dimension>; + using Rdd = TinyMatrix<dimension>; private: KOKKOS_INLINE_FUNCTION diff --git a/src/scheme/BoundaryCondition.hpp b/src/scheme/BoundaryCondition.hpp index b1fe0d34e..fc62f8e9e 100644 --- a/src/scheme/BoundaryCondition.hpp +++ b/src/scheme/BoundaryCondition.hpp @@ -83,7 +83,7 @@ class SymmetryBoundaryCondition : public BoundaryCondition { public: - typedef TinyVector<dimension, double> Rd; + using Rd = TinyVector<dimension, double>; private: diff --git a/src/scheme/FiniteVolumesEulerUnknowns.hpp b/src/scheme/FiniteVolumesEulerUnknowns.hpp index ba0684ad2..e20317d19 100644 --- a/src/scheme/FiniteVolumesEulerUnknowns.hpp +++ b/src/scheme/FiniteVolumesEulerUnknowns.hpp @@ -8,11 +8,11 @@ template <typename TMeshData> class FiniteVolumesEulerUnknowns { public: - typedef TMeshData MeshDataType; - typedef typename MeshDataType::MeshType MeshType; + using MeshDataType = TMeshData; + using MeshType = typename MeshDataType::MeshType; static constexpr size_t dimension = MeshType::dimension; - typedef TinyVector<dimension> Rd; + using Rd = TinyVector<dimension>; private: const MeshDataType& m_mesh_data; -- GitLab