Commit 623a8b06 authored by Dave Moxey's avatar Dave Moxey
Browse files

Merge branch 'feature/boost-std-cleanup' into 'master'

Propagate C++11 throughout Nektar++

See merge request !795
parents 1d1e6195 c907cf33
......@@ -177,10 +177,6 @@ IF (${CMAKE_COMPILER_IS_GNUCXX})
MARK_AS_ADVANCED(NEKTAR_ENABLE_PROFILE)
ENDIF (${CMAKE_COMPILER_IS_GNUCXX})
OPTION(NEKTAR_USE_EXPRESSION_TEMPLATES
"Use Expression templates." OFF)
MARK_AS_ADVANCED(NEKTAR_USE_EXPRESSION_TEMPLATES)
# BLAS Support
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_SYSTEM_BLAS_LAPACK
"Use the system provided blas and lapack libraries" ON
......@@ -282,10 +278,6 @@ IF( NEKTAR_USE_TINYXML_STL )
ADD_DEFINITIONS( -DTIXML_USE_STL)
ENDIF( NEKTAR_USE_TINYXML_STL )
IF( NEKTAR_USE_EXPRESSION_TEMPLATES )
ADD_DEFINITIONS(-DNEKTAR_USE_EXPRESSION_TEMPLATES -DNEKTAR_USING_CMAKE)
ENDIF( NEKTAR_USE_EXPRESSION_TEMPLATES )
IF( NEKTAR_USE_MEMORY_POOLS )
ADD_DEFINITIONS(-DNEKTAR_MEMORY_POOL_ENABLED)
ELSE( NEKTAR_USE_MEMORY_POOLS )
......
......@@ -9,8 +9,7 @@
#If the user has not set BOOST_ROOT, look in a couple common places first.
MESSAGE(STATUS "Searching for Boost:")
SET(MIN_VER "1.56.0")
SET(NEEDED_BOOST_LIBS thread iostreams date_time filesystem system
program_options regex)
SET(NEEDED_BOOST_LIBS thread iostreams filesystem system program_options regex)
SET(Boost_DEBUG 0)
SET(Boost_NO_BOOST_CMAKE ON)
IF( BOOST_ROOT )
......
......@@ -72,7 +72,7 @@ class CoalescedGeomData
std::map<GeomData,Array<TwoD, NekDouble> > m_twoDGeomData;
};
typedef boost::shared_ptr<CoalescedGeomData> CoalescedGeomDataSharedPtr;
typedef std::shared_ptr<CoalescedGeomData> CoalescedGeomDataSharedPtr;
static CoalescedGeomDataSharedPtr GeomDataNull;
......
......@@ -48,8 +48,6 @@ Collection::Collection(
vector<StdRegions::StdExpansionSharedPtr> pCollExp,
OperatorImpMap &impTypes)
{
OperatorImpMap::iterator it;
// Initialise geometry data.
m_geomData = MemoryManager<CoalescedGeomData>::AllocateSharedPtr();
......@@ -59,7 +57,8 @@ Collection::Collection(
OperatorType opType = (OperatorType)i;
ImplementationType impType;
if ((it = impTypes.find(opType)) != impTypes.end())
auto it = impTypes.find(opType);
if (it != impTypes.end())
{
impType = it->second;
OperatorKey opKey(pCollExp[0]->DetShapeType(), opType, impType,
......
......@@ -38,18 +38,16 @@
#include <vector>
#include <LibUtilities/BasicUtils/HashUtils.hpp>
#include <StdRegions/StdExpansion.h>
#include <SpatialDomains/Geometry.h>
#include <Collections/CollectionsDeclspec.h>
#include <Collections/Operator.h>
#include <Collections/CoalescedGeomData.h>
#include <boost/unordered_map.hpp>
namespace Nektar {
namespace Collections {
/**
* @brief Collection
*/
......@@ -88,15 +86,15 @@ class Collection
inline bool HasOperator(const OperatorType &op);
protected:
StdRegions::StdExpansionSharedPtr m_stdExp;
std::vector<SpatialDomains::GeometrySharedPtr> m_geom;
boost::unordered_map<OperatorType, OperatorSharedPtr> m_ops;
CoalescedGeomDataSharedPtr m_geomData;
StdRegions::StdExpansionSharedPtr m_stdExp;
std::vector<SpatialDomains::GeometrySharedPtr> m_geom;
std::unordered_map<OperatorType, OperatorSharedPtr, EnumHash> m_ops;
CoalescedGeomDataSharedPtr m_geomData;
};
typedef std::vector<Collection> CollectionVector;
typedef boost::shared_ptr<CollectionVector> CollectionVectorSharedPtr;
typedef std::shared_ptr<CollectionVector> CollectionVectorSharedPtr;
/**
......
......@@ -51,9 +51,7 @@ CollectionOptimisation::CollectionOptimisation(
ImplementationType defaultType)
{
int i;
map<ElmtOrder, ImplementationType> defaults;
map<ElmtOrder, ImplementationType> defaultsPhysDeriv;
map<ElmtOrder, ImplementationType>::iterator it;
map<ElmtOrder, ImplementationType> defaults, defaultsPhysDeriv;
bool verbose = (pSession.get()) &&
(pSession->DefinesCmdLineArgument("verbose")) &&
(pSession->GetComm()->GetRank() == 0);
......@@ -64,7 +62,6 @@ CollectionOptimisation::CollectionOptimisation(
m_defaultType = defaultType == eNoImpType ? eIterPerExp : defaultType;
map<string, LibUtilities::ShapeType> elTypes;
map<string, LibUtilities::ShapeType>::iterator it2;
elTypes["S"] = LibUtilities::eSegment;
elTypes["T"] = LibUtilities::eTriangle;
elTypes["Q"] = LibUtilities::eQuadrilateral;
......@@ -74,29 +71,29 @@ CollectionOptimisation::CollectionOptimisation(
elTypes["H"] = LibUtilities::eHexahedron;
// Set defaults for all element types.
for (it2 = elTypes.begin(); it2 != elTypes.end(); ++it2)
for (auto &it2 : elTypes)
{
defaults [ElmtOrder(it2->second, -1)] = m_defaultType;
defaultsPhysDeriv [ElmtOrder(it2->second, -1)] = m_defaultType;
defaults [ElmtOrder(it2.second, -1)] = m_defaultType;
defaultsPhysDeriv [ElmtOrder(it2.second, -1)] = m_defaultType;
}
if (defaultType == eNoImpType)
{
for (it2 = elTypes.begin(); it2 != elTypes.end(); ++it2)
for (auto &it2 : elTypes)
{
// For 1<=N<=5 use StdMat otherwise IterPerExp or given default type
for (int i = 1; i < 5; ++i)
{
defaults[ElmtOrder(it2->second, i)] = eStdMat;
defaults[ElmtOrder(it2.second, i)] = eStdMat;
}
// For 1<=N<=3 use SumFac otherwise NoCollection. Note that
// default is not currently overwritten by given default
// type
defaultsPhysDeriv [ElmtOrder(it2->second, -1)] = eNoCollection;
defaultsPhysDeriv [ElmtOrder(it2.second, -1)] = eNoCollection;
for (int i = 1; i < 3; ++i)
{
defaultsPhysDeriv[ElmtOrder(it2->second, i)] = eSumFac;
defaultsPhysDeriv[ElmtOrder(it2.second, i)] = eSumFac;
}
}
}
......@@ -164,9 +161,9 @@ CollectionOptimisation::CollectionOptimisation(
defaults.clear();
// Override default types
for (it2 = elTypes.begin(); it2 != elTypes.end(); ++it2)
for (auto &it2 : elTypes)
{
defaults[ElmtOrder(it2->second, -1)] = m_defaultType;
defaults[ElmtOrder(it2.second, -1)] = m_defaultType;
}
for (i = 0; i < SIZE_OperatorType; ++i)
......@@ -210,7 +207,7 @@ CollectionOptimisation::CollectionOptimisation(
ASSERTL0(attr, "Missing TYPE in ELEMENT tag.");
string elType(attr);
it2 = elTypes.find(elType);
auto it2 = elTypes.find(elType);
ASSERTL0(it2 != elTypes.end(),
"Unknown element type "+elType+" in ELEMENT "
"tag");
......@@ -260,21 +257,17 @@ CollectionOptimisation::CollectionOptimisation(
if (m_setByXml)
{
map<OperatorType, map<ElmtOrder,
ImplementationType> >::iterator mIt;
map<ElmtOrder, ImplementationType>::iterator eIt;
for (mIt = m_global.begin(); mIt != m_global.end(); mIt++)
for (auto &mIt : m_global)
{
cout << "Operator " << OperatorTypeMap[mIt->first]
<< ":" << endl;
cout << "Operator " << OperatorTypeMap[mIt.first]
<< ":" << endl;
for (eIt = mIt->second.begin();
eIt != mIt->second.end(); eIt++)
for (auto &eIt : mIt.second)
{
cout << "- "
<< LibUtilities::ShapeTypeMap[eIt->first.first]
<< " order " << eIt->first.second << " -> "
<< ImplementationTypeMap[eIt->second] << endl;
<< LibUtilities::ShapeTypeMap[eIt.first.first]
<< " order " << eIt.first.second << " -> "
<< ImplementationTypeMap[eIt.second] << endl;
}
}
}
......@@ -286,24 +279,21 @@ CollectionOptimisation::CollectionOptimisation(
OperatorImpMap CollectionOptimisation::GetOperatorImpMap(
StdRegions::StdExpansionSharedPtr pExp)
{
map<OperatorType, map<ElmtOrder, ImplementationType> >::iterator it;
map<ElmtOrder, ImplementationType>::iterator it2;
OperatorImpMap ret;
ElmtOrder searchKey(pExp->DetShapeType(),
pExp->GetBasisNumModes(0));
ElmtOrder defSearch(pExp->DetShapeType(), -1);
for (it = m_global.begin(); it != m_global.end(); ++it)
for (auto &it : m_global)
{
ImplementationType impType;
it2 = it->second.find(searchKey);
auto it2 = it.second.find(searchKey);
if (it2 == it->second.end())
if (it2 == it.second.end())
{
it2 = it->second.find(defSearch);
if (it2 == it->second.end())
it2 = it.second.find(defSearch);
if (it2 == it.second.end())
{
// Shouldn't be able to reach here.
impType = eNoCollection;
......@@ -318,7 +308,7 @@ OperatorImpMap CollectionOptimisation::GetOperatorImpMap(
impType = it2->second;
}
ret[it->first] = impType;
ret[it.first] = impType;
}
return ret;
......
......@@ -44,36 +44,36 @@ namespace Collections {
*/
bool operator< (OperatorKey const &p1, OperatorKey const &p2)
{
if (boost::get<0>(p1) < boost::get<0>(p2))
if (std::get<0>(p1) < std::get<0>(p2))
{
return true;
}
if (boost::get<0>(p1) > boost::get<0>(p2))
if (std::get<0>(p1) > std::get<0>(p2))
{
return false;
}
if (boost::get<1>(p1) < boost::get<1>(p2))
if (std::get<1>(p1) < std::get<1>(p2))
{
return true;
}
if (boost::get<1>(p1) > boost::get<1>(p2))
if (std::get<1>(p1) > std::get<1>(p2))
{
return false;
}
if (boost::get<2>(p1) < boost::get<2>(p2))
if (std::get<2>(p1) < std::get<2>(p2))
{
return true;
}
if (boost::get<2>(p1) > boost::get<2>(p2))
if (std::get<2>(p1) > std::get<2>(p2))
{
return false;
}
if (boost::get<3>(p1) < boost::get<3>(p2))
if (std::get<3>(p1) < std::get<3>(p2))
{
return true;
}
if (boost::get<3>(p1) > boost::get<3>(p2))
if (std::get<3>(p1) > std::get<3>(p2))
{
return false;
}
......@@ -87,10 +87,10 @@ bool operator< (OperatorKey const &p1, OperatorKey const &p2)
*/
std::ostream &operator<<(std::ostream &os, OperatorKey const &p)
{
os << LibUtilities::ShapeTypeMap[boost::get<0>(p)] << ", "
<< OperatorTypeMap [boost::get<1>(p)] << ", "
<< ImplementationTypeMap [boost::get<2>(p)] << ", "
<< (boost::get<3>(p) ? "Nodal" : "Modal");
os << LibUtilities::ShapeTypeMap[std::get<0>(p)] << ", "
<< OperatorTypeMap [std::get<1>(p)] << ", "
<< ImplementationTypeMap [std::get<2>(p)] << ", "
<< (std::get<3>(p) ? "Nodal" : "Modal");
return os;
}
......
......@@ -47,7 +47,7 @@
friend class MemoryManager<cname>; \
static OperatorSharedPtr create( \
std::vector<StdRegions::StdExpansionSharedPtr> pCollExp,\
boost::shared_ptr<CoalescedGeomData> GeomData) \
std::shared_ptr<CoalescedGeomData> GeomData) \
{ \
return MemoryManager<cname> \
::AllocateSharedPtr(pCollExp, GeomData); \
......@@ -59,7 +59,7 @@ namespace Collections
{
class CoalescedGeomData;
typedef boost::shared_ptr<CoalescedGeomData> CoalescedGeomDataSharedPtr;
typedef std::shared_ptr<CoalescedGeomData> CoalescedGeomDataSharedPtr;
enum OperatorType
{
......@@ -111,7 +111,7 @@ class Operator
/// Constructor
Operator(
std::vector<StdRegions::StdExpansionSharedPtr> pCollExp,
boost::shared_ptr<CoalescedGeomData> GeomData)
std::shared_ptr<CoalescedGeomData> GeomData)
: m_stdExp(pCollExp[0]->GetStdExp()),
m_numElmt(pCollExp.size()),
m_wspSize(0)
......@@ -149,10 +149,10 @@ class Operator
};
/// Shared pointer to an Operator object
typedef boost::shared_ptr<Operator> OperatorSharedPtr;
typedef std::shared_ptr<Operator> OperatorSharedPtr;
/// Key for describing an Operator
typedef boost::tuple<
typedef std::tuple<
LibUtilities::ShapeType,
OperatorType,
ImplementationType,
......
......@@ -39,10 +39,10 @@
#include <LibUtilities/Communication/CommMpi.h>
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
#include <boost/unordered_set.hpp>
#include <unordered_set>
#include <string>
typedef boost::unordered_set<int> IntSet;
typedef std::unordered_set<int> IntSet;
using namespace Nektar;
using namespace LibUtilities;
......@@ -218,8 +218,8 @@ Array<OneD, int> ReadIDsForThisRank(Experiment &exp, FieldIOSharedPtr fio)
std::string infoFile = exp.dataSource + "/Info.xml";
boost::shared_ptr<FieldIOXml> fioXml =
boost::dynamic_pointer_cast<FieldIOXml>(fio);
std::shared_ptr<FieldIOXml> fioXml =
std::dynamic_pointer_cast<FieldIOXml>(fio);
fioXml->ImportMultiFldFileIDs(infoFile, fileNames, elementList,
fieldmetadatamap);
......@@ -328,7 +328,6 @@ void FilterDataForThisRank(const DefVec &inFieldDefs,
if (elOut.size())
{
// create the outFieldDefs
// boost::make_shared only works up to 9 arguments it seems.
FieldDefinitionsSharedPtr defOut =
FieldDefinitionsSharedPtr(new FieldDefinitions(
inDef->m_shapeType,
......
......@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
PointsKey key(nPts, pointsType);
PointsSharedPtr points = PointsManager()[key];
//boost::shared_ptr<Points<NekDouble> > points = PointsManager()[key];
//std::shared_ptr<Points<NekDouble> > points = PointsManager()[key];
//const ptr<Points<NekDouble> > points = PointsManager()[key];
......@@ -192,7 +192,7 @@ int main(int argc, char *argv[])
// Generate a list of interpolating nodes
int nNodes = 2*nPts; // Number of interpolating nodes
boost::shared_ptr<Points<NekDouble> > nodes = PointsManager()[PointsKey(nNodes, pointsType)];
std::shared_ptr<Points<NekDouble> > nodes = PointsManager()[PointsKey(nNodes, pointsType)];
Array<OneD, const NekDouble> zNode = nodes->GetZ();
// Get the interpolation matrix I
......
......@@ -231,7 +231,7 @@ int main(int argc, char *argv[])
for (int i = 0; i < dim; ++i)
{
boost::shared_ptr<NekMatrix<NekDouble> > deriv =
std::shared_ptr<NekMatrix<NekDouble> > deriv =
util->GetDerivMatrix(i);
output = *deriv * input;
NekVector<NekDouble> tmp = output - exact[i];
......@@ -276,7 +276,7 @@ int main(int argc, char *argv[])
exp(r[i]) * exp(s[i]) * exp(t[i]);
}
boost::shared_ptr<NekMatrix<NekDouble> > interp =
std::shared_ptr<NekMatrix<NekDouble> > interp =
util->GetInterpolationMatrix(tmp);
NekVector<NekDouble> output = *interp * input;
......
......@@ -60,8 +60,8 @@ public:
virtual ~FauxComm() {}
void v_SplitComm(int pRows, int pColumns)
{
m_commRow = boost::shared_ptr<FauxComm>(new FauxComm(pColumns));
m_commColumn = boost::shared_ptr<FauxComm>(new FauxComm(pRows));
m_commRow = std::shared_ptr<FauxComm>(new FauxComm(pColumns));
m_commColumn = std::shared_ptr<FauxComm>(new FauxComm(pRows));
}
};
......@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
int nParts = atoi(argv[1]);
vector<string> filenames(argv + 2, argv + argc);
CommSharedPtr vComm = boost::shared_ptr<FauxComm>(
CommSharedPtr vComm = std::shared_ptr<FauxComm>(
new FauxComm(argc, argv, nParts));
char **new_argv = new char*[argc];
......
......@@ -12,7 +12,7 @@
<value tolerance="1e-12">0.000416575</value>
</metric>
<metric type="Linf" id="2">
<value tolerance="1e-12">0.000871589</value>
<value tolerance="1e-8">0.000871589</value>
</metric>
</metrics>
</test>
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<test>
<description>Helmholtz 3D CG, prisms, Neumann BCs, iterative ML, Par(3)</description>
<executable>Helmholtz3D</executable>
......@@ -9,10 +9,10 @@
</files>
<metrics>
<metric type="L2" id="1">
<value tolerance="3e-5">0.000450687</value>
<value tolerance="3e-5">0.000358538</value>
</metric>
<metric type="Linf" id="2">
<value tolerance="1e-9">0.00539787</value>
<value tolerance="1e-9">0.00575378</value>
</metric>
</metrics>
</test>
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<test>
<description>Helmholtz 3D CG, prisms, Neumann BCs, iterative ML, Par(3), Scotch</description>
<executable>Helmholtz3D</executable>
......@@ -9,10 +9,10 @@
</files>
<metrics>
<metric type="L2" id="1">
<value tolerance="3e-5">.000388881</value>
<value tolerance="3e-5">0.000603666</value>
</metric>
<metric type="Linf" id="2">
<value tolerance="1e-9">0.00575378</value>
<value tolerance="1e-9">0.0102924</value>
</metric>
</metrics>
</test>
///////////////////////////////////////////////////////////////////////////////
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_ASSOCIATIVE_TRAITS_HPP
#define EXPRESSION_TEMPLATES_ASSOCIATIVE_TRAITS_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
#include <ExpressionTemplates/Operators.hpp>
#include <boost/type_traits.hpp>
namespace expt
{
/// \brief Traits class indicating whether an operator is associative.
///
/// Given an expression T1 Op1 (T2 Op2 X), where T1 and T2 are data types
/// in an expression, Op1 and Op2 are the operators in the expression, and
/// X is an arbitrary expression, AssociativeTraits initicates whether
/// the expression can be rewritten using the associative property. If
/// it can, then the expression T1 Op1 (T2 Op2 X) can be rewritten as
/// (T1 Op1 T2) Op2 X.
///
/// This trait defaults to false. The class should be specialized for
/// all combinations of operators and data types that are associative.
template<typename T1, typename Op1, typename T2, typename Op2>
struct AssociativeTraits : public boost::false_type {};
/// \brief Specialization indicating multiplication is usually associative.
template<typename T>
struct AssociativeTraits<T, MultiplyOp, T, MultiplyOp> : public boost::true_type {};
/// \brief Specialization indicating addition is usually associative.
template<typename T>
struct AssociativeTraits<T, AddOp, T, AddOp> : public boost::true_type {};
}
#endif // NEKTAR_USE_EXPRESSION_TEMPLATES
#endif //EXPRESSION_TEMPLATES_ASSOCIATIVE_TRAITS_HPP
///////////////////////////////////////////////////////////////////////////////
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef EXPRESSION_TEMPLATES_ASSOCIATIVE_TRANSFORM_HPP
#define EXPRESSION_TEMPLATES_ASSOCIATIVE_TRANSFORM_HPP
#ifdef NEKTAR_USE_EXPRESSION_TEMPLATES
#include <ExpressionTemplates/Operators.hpp>
#include <ExpressionTemplates/AssociativeTraits.hpp>
#include <ExpressionTemplates/Node.hpp>
#include <boost/utility/enable_if.hpp>
namespace expt
{
/// \brief Transforms the given tree using an associative transform if appropriate.
///