Commit a2274d74 authored by David Moxey's avatar David Moxey

Fix rest of solvers, utilities and libraries, and add HashUtils to fix some...

Fix rest of solvers, utilities and libraries, and add HashUtils to fix some issues with C++11 unordered data structures
parent 5978e85b
......@@ -38,6 +38,7 @@
#include <vector>
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <StdRegions/StdExpansion.h>
#include <SpatialDomains/Geometry.h>
#include <Collections/CollectionsDeclspec.h>
......@@ -49,15 +50,6 @@
namespace Nektar {
namespace Collections {
struct EnumHash
{
template <typename T>
std::size_t operator()(T t) const
{
return static_cast<std::size_t>(t);
}
};
/**
* @brief Collection
*/
......
......@@ -39,6 +39,7 @@ using namespace std;
#include "ProcessDisplacement.h"
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LocalRegions/SegExp.h>
......@@ -72,7 +73,7 @@ struct TriFaceHash : std::unary_function<TriFaceIDs, std::size_t>
ids[2] = p.c;
std::sort(ids.begin(), ids.end());
return boost::hash_range(ids.begin(), ids.end());
return hash_combine(ids[0], ids[1], ids[2]);
}
};
......
///////////////////////////////////////////////////////////////////////////////
//
// File SessionReader.cpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Session reader
//
///////////////////////////////////////////////////////////////////////////////
#ifndef LIBUTILITIES_BASICUTILS_HASHUTILS
#define LIBUTILITIES_BASICUTILS_HASHUTILS
#include <functional>
namespace Nektar
{
inline void hash_combine(std::size_t& seed)
{
}
template <typename T, typename... Args>
inline void hash_combine(std::size_t& seed, const T& v, Args... args)
{
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
hash_combine(seed, args...);
}
template <typename T, typename... Args>
inline std::size_t hash_combine(const T& v, Args... args)
{
std::size_t seed;
hash_combine(seed, args...);
return seed;
}
template<typename Iter>
std::size_t hash_range(Iter first, Iter last)
{
std::size_t seed = 0;
for(; first != last; ++first)
{
hash_combine(seed, *first);
}
return seed;
}
template<typename Iter>
void hash_range(std::size_t &seed, Iter first, Iter last)
{
hash_combine(seed, hash_range(first, last));
}
struct EnumHash
{
template <typename T>
std::size_t operator()(T t) const
{
return static_cast<std::size_t>(t);
}
};
struct PairHash {
template <class T1, class T2>
std::size_t operator()(const std::pair<T1, T2> &p) const
{
std::size_t seed = 0;
auto h1 = std::hash<T1>{}(p.first);
auto h2 = std::hash<T2>{}(p.second);
hash_combine(seed, h1, h2);
return seed;
}
};
}
#endif
......@@ -16,6 +16,7 @@ SET(BasicUtilsHeaders
./BasicUtils/FieldIOXml.h
./BasicUtils/FileSystem.h
./BasicUtils/ErrorUtil.hpp
./BasicUtils/HashUtils.hpp
./BasicUtils/MeshEntities.hpp
./BasicUtils/MeshPartition.h
./BasicUtils/MeshPartitionMetis.h
......
......@@ -183,36 +183,41 @@ namespace Nektar
template<typename FuncPointerT, typename ObjectPointerT>
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
{
using namespace std::placeholders;
m_functors1[0] = std::bind(func, obj, _1, _2, _3);
m_functors1[0] = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3);
}
template<typename FuncPointerT, typename ObjectPointerT>
void DefineOdeExplicitRhs(FuncPointerT func, ObjectPointerT obj)
{
using namespace std::placeholders;
m_functors1[1] = std::bind(func, obj, _1, _2, _3);
m_functors1[1] = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3);
}
template<typename FuncPointerT, typename ObjectPointerT>
void DefineOdeImplicitRhs(FuncPointerT func, ObjectPointerT obj)
{
using namespace std::placeholders;
m_functors1[2] = std::bind(func, obj, _1, _2, _3);
m_functors1[2] = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3);
}
template<typename FuncPointerT, typename ObjectPointerT>
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
{
using namespace std::placeholders;
m_functors1[3] = std::bind(func, obj, _1, _2, _3);
m_functors1[3] = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3);
}
template<typename FuncPointerT, typename ObjectPointerT>
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
{
using namespace std::placeholders;
m_functors2[0] = std::bind(func, obj, _1, _2, _3, _4);
m_functors2[0] = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, std::placeholders::_4);
}
......
......@@ -39,7 +39,7 @@
#include <LocalRegions/Expansion2D.h>
#include <LocalRegions/Expansion3D.h>
#include <LibUtilities/BasicUtils/ShapeType.hpp>
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
......@@ -2033,8 +2033,8 @@ namespace Nektar
}
}
m_hash = boost::hash_range(m_localToGlobalMap.begin(),
m_localToGlobalMap.end());
m_hash = hash_range(m_localToGlobalMap.begin(),
m_localToGlobalMap.end());
// Add up hash values if parallel
int hash = m_hash;
......
......@@ -33,6 +33,7 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <MultiRegions/AssemblyMap/AssemblyMapDG.h>
#include <MultiRegions/ExpList.h>
#include <LocalRegions/SegExp.h>
......@@ -518,8 +519,8 @@ namespace Nektar
SetUpUniversalDGMap (locExp);
SetUpUniversalTraceMap(locExp, tr, periodicTrace);
m_hash = boost::hash_range(m_localToGlobalBndMap.begin(),
m_localToGlobalBndMap.end());
m_hash = hash_range(m_localToGlobalBndMap.begin(),
m_localToGlobalBndMap.end());
}
/**
......
......@@ -36,6 +36,7 @@
#ifndef NEKMESHUTILS_MESHELEMENTS_EDGE
#define NEKMESHUTILS_MESHELEMENTS_EDGE
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <SpatialDomains/SegGeom.h>
#include <NekMeshUtils/NekMeshUtilsDeclspec.h>
......@@ -151,12 +152,9 @@ struct EdgeHash : std::unary_function<EdgeSharedPtr, std::size_t>
{
std::size_t operator()(EdgeSharedPtr const &p) const
{
std::size_t seed = 0;
unsigned int id1 = p->m_n1->m_id;
unsigned int id2 = p->m_n2->m_id;
boost::hash_combine(seed, id1 < id2 ? id1 : id2);
boost::hash_combine(seed, id2 < id1 ? id1 : id2);
return seed;
const unsigned int id1 = p->m_n1->m_id;
const unsigned int id2 = p->m_n2->m_id;
return id1 < id2 ? hash_combine(id1, id2) : hash_combine(id2, id1);
}
};
typedef std::unordered_set<EdgeSharedPtr, EdgeHash> EdgeSet;
......
......@@ -36,6 +36,7 @@
#ifndef NEKMESHUTILS_MESHELEMENTS_FACE
#define NEKMESHUTILS_MESHELEMENTS_FACE
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <SpatialDomains/TriGeom.h>
#include <SpatialDomains/QuadGeom.h>
......@@ -171,7 +172,7 @@ struct FaceHash : std::unary_function<FaceSharedPtr, std::size_t>
}
std::sort(ids.begin(), ids.end());
boost::hash_range(seed, ids.begin(), ids.end());
hash_range(seed, ids.begin(), ids.end());
return seed;
}
......
......@@ -191,15 +191,9 @@ struct HOSurfHash : std::unary_function<HOSurfSharedPtr, std::size_t>
*/
std::size_t operator()(HOSurfSharedPtr const &p) const
{
std::size_t seed = 0;
std::vector<int> ids = p->vertId;
std::sort(ids.begin(), ids.end());
for (int i = 0; i < ids.size(); ++i)
{
boost::hash_combine(seed, ids[i]);
}
return seed;
return hash_range(ids.begin(), ids.end());
}
};
......
......@@ -36,6 +36,7 @@
#ifndef NEKMESHUTILS_MESHELEMENTS_NODE
#define NEKMESHUTILS_MESHELEMENTS_NODE
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <NekMeshUtils/NekMeshUtilsDeclspec.h>
#include <iomanip>
......@@ -431,11 +432,7 @@ struct NodeHash : std::unary_function<NodeSharedPtr, std::size_t>
{
std::size_t operator()(NodeSharedPtr const &p) const
{
std::size_t seed = 0;
boost::hash_combine(seed, p->m_x);
boost::hash_combine(seed, p->m_y);
boost::hash_combine(seed, p->m_z);
return seed;
return hash_combine(p->m_x, p->m_y, p->m_z);
}
};
typedef std::unordered_set<NodeSharedPtr, NodeHash> NodeSet;
......
......@@ -40,6 +40,7 @@
#include <NekMeshUtils/MeshElements/Tetrahedron.h>
#include <NekMeshUtils/MeshElements/Triangle.h>
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <LibUtilities/Foundations/ManagerAccess.h>
using namespace std;
......@@ -365,7 +366,7 @@ struct TetOrientHash : std::unary_function<struct TetOrient, std::size_t>
{
std::size_t operator()(struct TetOrient const &p) const
{
return boost::hash_range(p.nid.begin(), p.nid.end());
return hash_range(p.nid.begin(), p.nid.end());
}
};
typedef std::unordered_set<struct TetOrient, TetOrientHash> TetOrientSet;
......
......@@ -37,7 +37,7 @@
#define NEKTAR_SOLVERUTILS_ADVECTION
#include <string>
#include <boost/function.hpp>
#include <functional>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
......@@ -53,7 +53,7 @@ namespace SolverUtils
/// Defines a callback function which evaluates the flux vector \f$ F(u)
/// \f$ in a conservative advection of the form \f$ \nabla\cdot F(u)
/// \f$.
typedef boost::function<void (
typedef std::function<void (
const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
AdvectionFluxVecCB;
......@@ -89,13 +89,14 @@ public:
* @brief Set the flux vector callback function.
*
* This routine is a utility function to avoid the explicit use of
* boost::bind. A function and object can be passed to this function
* std::bind. A function and object can be passed to this function
* instead.
*/
template<typename FuncPointerT, typename ObjectPointerT>
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
{
m_fluxVector = boost::bind(func, obj, _1, _2);
m_fluxVector = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2);
}
/**
......@@ -162,7 +163,7 @@ protected:
};
/// A shared pointer to an Advection object.
typedef boost::shared_ptr<Advection> AdvectionSharedPtr;
typedef std::shared_ptr<Advection> AdvectionSharedPtr;
/// Datatype of the NekFactory used to instantiate classes derived
/// from the Advection class.
......
......@@ -120,14 +120,14 @@ namespace Nektar
for (it1 = scalars.begin(); it1 != scalars.end(); ++it1)
{
boost::shared_ptr<HomoRSScalar> tmp = MemoryManager<HomoRSScalar>
std::shared_ptr<HomoRSScalar> tmp = MemoryManager<HomoRSScalar>
::AllocateSharedPtr(it1->second, m_numPlanes);
m_riemann->SetScalar(it1->first, &HomoRSScalar::Exec, tmp);
}
for (it2 = vectors.begin(); it2 != vectors.end(); ++it2)
{
boost::shared_ptr<HomoRSVector> tmp = MemoryManager<HomoRSVector>
std::shared_ptr<HomoRSVector> tmp = MemoryManager<HomoRSVector>
::AllocateSharedPtr(it2->second, m_numPlanes, it2->first);
m_riemann->SetVector(it2->first, &HomoRSVector::Exec, tmp);
}
......
......@@ -1027,7 +1027,9 @@ namespace Nektar
int nSolutionPts = fields[0]->GetTotPoints();
vector<bool> negatedFluxNormal = (boost::static_pointer_cast<MultiRegions::DisContField1D>(fields[0]))->GetNegatedFluxNormal();
vector<bool> negatedFluxNormal =
std::static_pointer_cast<MultiRegions::DisContField1D>(
fields[0])->GetNegatedFluxNormal();
// Arrays to store the derivatives of the correction flux
Array<OneD, NekDouble> DCL(nSolutionPts/nElements, 0.0);
......
......@@ -65,7 +65,7 @@ protected:
};
/// Shared pointer to an AdvectionSystem class
typedef boost::shared_ptr<AdvectionSystem> AdvectionSystemSharedPtr;
typedef std::shared_ptr<AdvectionSystem> AdvectionSystemSharedPtr;
}
}
......
......@@ -37,7 +37,7 @@
#define NEKTAR_SOLVERUTILS_DIFFUSION
#include <string>
#include <boost/function.hpp>
#include <functional>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
......@@ -50,20 +50,20 @@ namespace Nektar
{
namespace SolverUtils
{
typedef boost::function<void (
typedef std::function<void (
const int,
const int,
const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, Array<OneD, NekDouble> >&)> DiffusionFluxVecCB;
typedef boost::function<void (
typedef std::function<void (
const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
DiffusionFluxVecCBNS;
typedef boost::function<void (
typedef std::function<void (
const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, NekDouble >&)>
DiffusionArtificialDiffusion;
......@@ -90,7 +90,10 @@ namespace Nektar
template<typename FuncPointerT, typename ObjectPointerT>
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
{
m_fluxVector = boost::bind(func, obj, _1, _2, _3, _4, _5);
m_fluxVector = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, std::placeholders::_4,
std::placeholders::_5);
}
void SetFluxVectorVec(DiffusionFluxVecCB fluxVector)
......@@ -101,13 +104,16 @@ namespace Nektar
template<typename FuncPointerT, typename ObjectPointerT>
void SetFluxVectorNS(FuncPointerT func, ObjectPointerT obj)
{
m_fluxVectorNS = boost::bind(func, obj, _1, _2, _3);
m_fluxVectorNS = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3);
}
template<typename FuncPointerT, typename ObjectPointerT>
void SetArtificialDiffusionVector(FuncPointerT func, ObjectPointerT obj)
{
m_ArtificialDiffusionVector = boost::bind(func, obj, _1, _2);
m_ArtificialDiffusionVector = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2);
}
void SetFluxVectorNS(DiffusionFluxVecCBNS fluxVector)
......@@ -159,7 +165,7 @@ namespace Nektar
};
/// A shared pointer to an EquationSystem object
typedef boost::shared_ptr<Diffusion> DiffusionSharedPtr;
typedef std::shared_ptr<Diffusion> DiffusionSharedPtr;
/// Datatype of the NekFactory used to instantiate classes derived
/// from the Diffusion class.
......
......@@ -126,7 +126,7 @@ namespace Nektar
}
};
typedef boost::shared_ptr<DiffusionLDGNS> DiffusionLDGNSSharedPtr;
typedef std::shared_ptr<DiffusionLDGNS> DiffusionLDGNSSharedPtr;
}
}
......
......@@ -1482,7 +1482,9 @@ namespace Nektar
int nElements = fields[0]->GetExpSize();
int nSolutionPts = fields[0]->GetTotPoints();
vector<bool> negatedFluxNormal = (boost::static_pointer_cast<MultiRegions::DisContField1D>(fields[0]))->GetNegatedFluxNormal();
vector<bool> negatedFluxNormal =
std::static_pointer_cast<MultiRegions::DisContField1D>(
fields[0])->GetNegatedFluxNormal();
// Arrays to store the derivatives of the correction flux
Array<OneD, NekDouble> DCL(nSolutionPts/nElements, 0.0);
......
......@@ -200,7 +200,7 @@ namespace Nektar
}
};
typedef boost::shared_ptr<DiffusionLFRNS> DiffusionLFRNSSharedPtr;
typedef std::shared_ptr<DiffusionLFRNS> DiffusionLFRNSSharedPtr;
}
}
......
......@@ -52,7 +52,7 @@ namespace SolverUtils
class Driver;
/// A shared pointer to a Driver object
typedef boost::shared_ptr<Driver> DriverSharedPtr;
typedef std::shared_ptr<Driver> DriverSharedPtr;
/// Datatype of the NekFactory used to instantiate classes derived from
/// the Driver class.
......
......@@ -55,7 +55,6 @@
#include <GlobalMapping/Mapping.h>
#include <boost/format.hpp>
# include <boost/function.hpp>
#include <iostream>
#include <string>
......
......@@ -59,7 +59,7 @@ class Interpolator;
class EquationSystem;
/// A shared pointer to an EquationSystem object