Commit 3d06545d authored by Kenneth Leiter's avatar Kenneth Leiter

Updates to allow for compilation with Intel compilers.

parent 8b08e697
......@@ -261,11 +261,12 @@ if(APPLE)
PARENT_SCOPE)
endif()
file(GLOB_RECURSE
file(GLOB
XdmfCoreHeaders
"*.hpp" "*.tpp" "*.i"
"../CMake/VersionSuite/*.hpp")
file(GLOB LokiHeaders loki/*.h)
file(GLOB MapboxHeaders mapbox/*.hpp)
set(XdmfCoreHeaders
${XdmfCoreHeaders}
......@@ -273,6 +274,7 @@ set(XdmfCoreHeaders
if (NOT XDMF_INSTALL_NO_DEVELOPMENT)
install(FILES ${XdmfCoreHeaders} DESTINATION include)
install(FILES ${LokiHeaders} DESTINATION include/loki)
install(FILES ${MapboxHeaders} DESTINATION include/mapbox)
endif()
install(TARGETS XdmfCore
RUNTIME DESTINATION bin
......
......@@ -1481,6 +1481,7 @@ private:
class GetCapacity;
template <typename T> class GetValue;
template <typename T> class GetValues;
template <typename T> class GetValuesInternal;
class GetValuesPointer;
class GetValuesString;
template <typename T> class Insert;
......@@ -1492,6 +1493,7 @@ private:
class Reserve;
template <typename T> class Resize;
class Size;
template <typename T> class Swap;
/**
* After setValues() is called, XdmfArray stores a pointer that is
......
......@@ -26,6 +26,8 @@
#include <sstream>
#include "XdmfArray.hpp"
#include <iostream>
template <typename T>
class XdmfArray::GetValue {
public:
......@@ -227,6 +229,49 @@ private:
const unsigned int mValuesStride;
};
template <typename T>
class XdmfArray::GetValuesInternal {
public:
GetValuesInternal(XdmfArray * const array) :
mArray(array)
{
}
shared_ptr<std::vector<T> >
operator()(const Empty &) const
{
return shared_ptr<std::vector<T> >();
}
shared_ptr<std::vector<T> >
operator()(shared_ptr<std::vector<T> > & array) const
{
return array;
}
template<typename U>
shared_ptr<std::vector<T> >
operator()(shared_ptr<std::vector<U> > &) const
{
return shared_ptr<std::vector<T> >();
}
template<typename U>
shared_ptr<std::vector<T> >
operator()(const shared_ptr<const U> &) const
{
mArray->internalizeArrayPointer();
return mapbox::util::apply_visitor(*this,
mArray->mArray);
}
private:
XdmfArray * mArray;
};
template <typename T>
class XdmfArray::Insert {
public:
......@@ -590,6 +635,55 @@ private:
const std::string & mVal;
};
template <typename T>
class XdmfArray::Swap {
public:
Swap(XdmfArray * const array,
std::vector<T> & swapArray) :
mArray(array),
mSwapArray(swapArray)
{
}
bool
operator()(const Empty &) const
{
mArray->initialize<T>();
return mapbox::util::apply_visitor(*this,
mArray->mArray);
}
bool
operator()(shared_ptr<std::vector<T> > & array) const
{
array->swap(mSwapArray);
return true;
}
template<typename U>
bool
operator()(shared_ptr<std::vector<U> > &) const
{
// Arrays of different types, return failure
return false;
}
template<typename U>
bool
operator()(const shared_ptr<const U> &) const
{
// Not storing std::vector, return failure
return false;
}
private:
XdmfArray * mArray;
std::vector<T> & mSwapArray;
};
template <typename T>
struct XdmfArray::ArrayDeleter
{
......@@ -638,6 +732,11 @@ template <typename T>
shared_ptr<std::vector<T> >
XdmfArray::getValuesInternal()
{
std::cout << "HERE" << std::endl;
return mapbox::util::apply_visitor(GetValuesInternal<T>(this),
mArray);
/*
this->internalizeArrayPointer();
try {
shared_ptr<std::vector<T> > currArray =
......@@ -647,6 +746,7 @@ XdmfArray::getValuesInternal()
catch(const mapbox::util::bad_variant_access & exception) {
return shared_ptr<std::vector<T> >();
}
*/
}
template <typename T>
......@@ -669,9 +769,11 @@ shared_ptr<std::vector<T> >
XdmfArray::initialize(const std::vector<unsigned int> & dimensions)
{
mDimensions = dimensions;
const unsigned int size = static_cast<unsigned int>(
std::accumulate(dimensions.begin(), dimensions.end(), 1,
std::multiplies<unsigned int>()));
const unsigned int size =
static_cast<unsigned int>(std::accumulate(dimensions.begin(),
dimensions.end(),
1,
std::multiplies<unsigned int>()));
return this->initialize<T>(size);
}
......@@ -736,8 +838,11 @@ void
XdmfArray::resize(const std::vector<unsigned int> & dimensions,
const T & value)
{
const unsigned int size = static_cast<unsigned int>(std::accumulate(dimensions.begin(), dimensions.end(), 1,
std::multiplies<unsigned int>()));
const unsigned int size =
static_cast<unsigned int>(std::accumulate(dimensions.begin(),
dimensions.end(),
1,
std::multiplies<unsigned int>()));
this->resize(size, value);
mDimensions = dimensions;
this->setIsChanged(true);
......@@ -790,6 +895,12 @@ template <typename T>
bool
XdmfArray::swap(std::vector<T> & array)
{
std::cout << "HERE" << std::endl;
this->setIsChanged(true);
return mapbox::util::apply_visitor(Swap<T>(this,
array),
mArray);
/*
this->internalizeArrayPointer();
if(!this->isInitialized()) {
this->initialize<T>();
......@@ -803,7 +914,7 @@ XdmfArray::swap(std::vector<T> & array)
catch(const mapbox::util::bad_variant_access & exception) {
return false;
}
this->setIsChanged(true);
*/
}
template <typename T>
......
......@@ -42,7 +42,7 @@
# ifdef NDEBUG
# define VARIANT_INLINE //inline __attribute__((always_inline))
# else
# define VARIANT_INLINE __attribute__((noinline))
# define VARIANT_INLINE //__attribute__((noinline))
# endif
#endif
// clang-format on
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment