Fixing errors when compiling without c++11, changing GNU to use c++98
This commit is contained in:
parent
49c013c3bb
commit
02a0b42c03
@ -103,6 +103,8 @@ IF ( NOT ONLY_BUILD_DOCS )
|
|||||||
CONFIGURE_LBPM()
|
CONFIGURE_LBPM()
|
||||||
CONFIGURE_TIMER( 0 "${${PROJ}_INSTALL_DIR}/null_timer" )
|
CONFIGURE_TIMER( 0 "${${PROJ}_INSTALL_DIR}/null_timer" )
|
||||||
CONFIGURE_LINE_COVERAGE()
|
CONFIGURE_LINE_COVERAGE()
|
||||||
|
INCLUDE( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/SharedPtr.cmake" )
|
||||||
|
CONFIGURE_SHARED_PTR( "${LBPM_INSTALL_DIR}/include" "" )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
54
IO/Mesh.cpp
54
IO/Mesh.cpp
@ -2,7 +2,7 @@
|
|||||||
#include "common/Utilities.h"
|
#include "common/Utilities.h"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace IO {
|
namespace IO {
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ PointList::~PointList( )
|
|||||||
size_t PointList::numberPointsVar( VariableType type ) const
|
size_t PointList::numberPointsVar( VariableType type ) const
|
||||||
{
|
{
|
||||||
size_t N = 0;
|
size_t N = 0;
|
||||||
if ( type == VariableType::NodeVariable )
|
if ( type == NodeVariable )
|
||||||
N = points.size();
|
N = points.size();
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
@ -121,9 +121,9 @@ TriList::~TriList( )
|
|||||||
size_t TriList::numberPointsVar( VariableType type ) const
|
size_t TriList::numberPointsVar( VariableType type ) const
|
||||||
{
|
{
|
||||||
size_t N = 0;
|
size_t N = 0;
|
||||||
if ( type==VariableType::NodeVariable )
|
if ( type==NodeVariable )
|
||||||
N = 3*A.size();
|
N = 3*A.size();
|
||||||
else if ( type==VariableType::SurfaceVariable || type==VariableType::VolumeVariable )
|
else if ( type==SurfaceVariable || type==VolumeVariable )
|
||||||
N = A.size();
|
N = A.size();
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ TriMesh::TriMesh( size_t N_tri, size_t N_point )
|
|||||||
B.resize(N_tri,-1);
|
B.resize(N_tri,-1);
|
||||||
C.resize(N_tri,-1);
|
C.resize(N_tri,-1);
|
||||||
}
|
}
|
||||||
TriMesh::TriMesh( size_t N_tri, std::shared_ptr<PointList> points )
|
TriMesh::TriMesh( size_t N_tri, shared_ptr<PointList> points )
|
||||||
{
|
{
|
||||||
vertices = points;
|
vertices = points;
|
||||||
A.resize(N_tri,-1);
|
A.resize(N_tri,-1);
|
||||||
@ -226,9 +226,9 @@ TriMesh::~TriMesh( )
|
|||||||
size_t TriMesh::numberPointsVar( VariableType type ) const
|
size_t TriMesh::numberPointsVar( VariableType type ) const
|
||||||
{
|
{
|
||||||
size_t N = 0;
|
size_t N = 0;
|
||||||
if ( type==VariableType::NodeVariable )
|
if ( type==NodeVariable )
|
||||||
N = vertices->points.size();
|
N = vertices->points.size();
|
||||||
else if ( type==VariableType::SurfaceVariable || type==VariableType::VolumeVariable )
|
else if ( type==SurfaceVariable || type==VolumeVariable )
|
||||||
N = A.size();
|
N = A.size();
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
@ -293,45 +293,45 @@ void TriMesh::unpack( const std::pair<size_t,void*>& data_in )
|
|||||||
/****************************************************
|
/****************************************************
|
||||||
* Converters *
|
* Converters *
|
||||||
****************************************************/
|
****************************************************/
|
||||||
std::shared_ptr<PointList> getPointList( std::shared_ptr<Mesh> mesh )
|
shared_ptr<PointList> getPointList( shared_ptr<Mesh> mesh )
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<PointList>(mesh);
|
return dynamic_pointer_cast<PointList>(mesh);
|
||||||
}
|
}
|
||||||
std::shared_ptr<TriMesh> getTriMesh( std::shared_ptr<Mesh> mesh )
|
shared_ptr<TriMesh> getTriMesh( shared_ptr<Mesh> mesh )
|
||||||
{
|
{
|
||||||
std::shared_ptr<TriMesh> mesh2;
|
shared_ptr<TriMesh> mesh2;
|
||||||
if ( std::dynamic_pointer_cast<TriMesh>(mesh) != NULL ) {
|
if ( dynamic_pointer_cast<TriMesh>(mesh) != NULL ) {
|
||||||
mesh2 = std::dynamic_pointer_cast<TriMesh>(mesh);
|
mesh2 = dynamic_pointer_cast<TriMesh>(mesh);
|
||||||
} else if ( std::dynamic_pointer_cast<TriList>(mesh) != NULL ) {
|
} else if ( dynamic_pointer_cast<TriList>(mesh) != NULL ) {
|
||||||
std::shared_ptr<TriList> trilist = std::dynamic_pointer_cast<TriList>(mesh);
|
shared_ptr<TriList> trilist = dynamic_pointer_cast<TriList>(mesh);
|
||||||
ASSERT(trilist!=NULL);
|
ASSERT(trilist!=NULL);
|
||||||
mesh2.reset( new TriMesh(*trilist) );
|
mesh2.reset( new TriMesh(*trilist) );
|
||||||
}
|
}
|
||||||
return mesh2;
|
return mesh2;
|
||||||
}
|
}
|
||||||
std::shared_ptr<TriList> getTriList( std::shared_ptr<Mesh> mesh )
|
shared_ptr<TriList> getTriList( shared_ptr<Mesh> mesh )
|
||||||
{
|
{
|
||||||
std::shared_ptr<TriList> mesh2;
|
shared_ptr<TriList> mesh2;
|
||||||
if ( std::dynamic_pointer_cast<TriList>(mesh) != NULL ) {
|
if ( dynamic_pointer_cast<TriList>(mesh) != NULL ) {
|
||||||
mesh2 = std::dynamic_pointer_cast<TriList>(mesh);
|
mesh2 = dynamic_pointer_cast<TriList>(mesh);
|
||||||
} else if ( std::dynamic_pointer_cast<TriMesh>(mesh) != NULL ) {
|
} else if ( dynamic_pointer_cast<TriMesh>(mesh) != NULL ) {
|
||||||
std::shared_ptr<TriMesh> trimesh = std::dynamic_pointer_cast<TriMesh>(mesh);
|
shared_ptr<TriMesh> trimesh = dynamic_pointer_cast<TriMesh>(mesh);
|
||||||
ASSERT(trimesh!=NULL);
|
ASSERT(trimesh!=NULL);
|
||||||
mesh2.reset( new TriList(*trimesh) );
|
mesh2.reset( new TriList(*trimesh) );
|
||||||
}
|
}
|
||||||
return mesh2;
|
return mesh2;
|
||||||
}
|
}
|
||||||
std::shared_ptr<const PointList> getPointList( std::shared_ptr<const Mesh> mesh )
|
shared_ptr<const PointList> getPointList( shared_ptr<const Mesh> mesh )
|
||||||
{
|
{
|
||||||
return getPointList( std::const_pointer_cast<Mesh>(mesh) );
|
return getPointList( const_pointer_cast<Mesh>(mesh) );
|
||||||
}
|
}
|
||||||
std::shared_ptr<const TriMesh> getTriMesh( std::shared_ptr<const Mesh> mesh )
|
shared_ptr<const TriMesh> getTriMesh( shared_ptr<const Mesh> mesh )
|
||||||
{
|
{
|
||||||
return getTriMesh( std::const_pointer_cast<Mesh>(mesh) );
|
return getTriMesh( const_pointer_cast<Mesh>(mesh) );
|
||||||
}
|
}
|
||||||
std::shared_ptr<const TriList> getTriList( std::shared_ptr<const Mesh> mesh )
|
shared_ptr<const TriList> getTriList( shared_ptr<const Mesh> mesh )
|
||||||
{
|
{
|
||||||
return getTriList( std::const_pointer_cast<Mesh>(mesh) );
|
return getTriList( const_pointer_cast<Mesh>(mesh) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
90
IO/Mesh.h
90
IO/Mesh.h
@ -3,17 +3,19 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/PointList.h"
|
#include "common/PointList.h"
|
||||||
|
#include "shared_ptr.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace IO {
|
namespace IO {
|
||||||
|
|
||||||
|
|
||||||
//! Possible variable types
|
//! Possible variable types
|
||||||
enum class VariableType : unsigned char { NodeVariable=1, EdgeVariable=2, SurfaceVariable=2, VolumeVariable=3, Null=0 };
|
//enum class VariableType : unsigned char { NodeVariable=1, EdgeVariable=2, SurfaceVariable=2, VolumeVariable=3, Null=0 };
|
||||||
|
enum VariableType { NodeVariable=1, EdgeVariable=2, SurfaceVariable=2, VolumeVariable=3, NullVariable=0 };
|
||||||
|
|
||||||
|
|
||||||
/*! \class Mesh
|
/*! \class Mesh
|
||||||
@ -65,42 +67,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*! \class TriMesh
|
|
||||||
\brief A class used to hold a list of trianges specified by their vertex number and list of coordiantes
|
|
||||||
*/
|
|
||||||
class TriList;
|
|
||||||
class TriMesh: public Mesh
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! TriMesh constructor
|
|
||||||
TriMesh();
|
|
||||||
//! Constructor for Nt triangles and Np points
|
|
||||||
TriMesh( size_t N_tri, size_t N_point );
|
|
||||||
//! Constructor for Nt triangles and the given points
|
|
||||||
TriMesh( size_t N_tri, std::shared_ptr<PointList> points );
|
|
||||||
//! Constructor from TriList
|
|
||||||
TriMesh( const TriList& );
|
|
||||||
//! Destructor
|
|
||||||
virtual ~TriMesh();
|
|
||||||
//! Mesh class name
|
|
||||||
virtual std::string className() const { return "TriMesh"; }
|
|
||||||
//! Number of points for the given variable type
|
|
||||||
virtual size_t numberPointsVar( VariableType type ) const;
|
|
||||||
//! Pack the data
|
|
||||||
virtual std::pair<size_t,void*> pack( int level ) const;
|
|
||||||
//! Unpack the data
|
|
||||||
virtual void unpack( const std::pair<size_t,void*>& data );
|
|
||||||
public:
|
|
||||||
std::shared_ptr<PointList> vertices; //!< List of verticies
|
|
||||||
std::vector<int> A; //!< First vertex
|
|
||||||
std::vector<int> B; //!< Second vertex
|
|
||||||
std::vector<int> C; //!< Third vertex
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*! \class TriList
|
/*! \class TriList
|
||||||
\brief A class used to hold a list of triangles specified by their vertex coordinates
|
\brief A class used to hold a list of triangles specified by their vertex coordinates
|
||||||
*/
|
*/
|
||||||
|
class TriMesh;
|
||||||
class TriList: public Mesh
|
class TriList: public Mesh
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -127,6 +97,38 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*! \class TriMesh
|
||||||
|
\brief A class used to hold a list of trianges specified by their vertex number and list of coordiantes
|
||||||
|
*/
|
||||||
|
class TriMesh: public Mesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! TriMesh constructor
|
||||||
|
TriMesh();
|
||||||
|
//! Constructor for Nt triangles and Np points
|
||||||
|
TriMesh( size_t N_tri, size_t N_point );
|
||||||
|
//! Constructor for Nt triangles and the given points
|
||||||
|
TriMesh( size_t N_tri, shared_ptr<PointList> points );
|
||||||
|
//! Constructor from TriList
|
||||||
|
TriMesh( const TriList& );
|
||||||
|
//! Destructor
|
||||||
|
virtual ~TriMesh();
|
||||||
|
//! Mesh class name
|
||||||
|
virtual std::string className() const { return "TriMesh"; }
|
||||||
|
//! Number of points for the given variable type
|
||||||
|
virtual size_t numberPointsVar( VariableType type ) const;
|
||||||
|
//! Pack the data
|
||||||
|
virtual std::pair<size_t,void*> pack( int level ) const;
|
||||||
|
//! Unpack the data
|
||||||
|
virtual void unpack( const std::pair<size_t,void*>& data );
|
||||||
|
public:
|
||||||
|
shared_ptr<PointList> vertices; //!< List of verticies
|
||||||
|
std::vector<int> A; //!< First vertex
|
||||||
|
std::vector<int> B; //!< Second vertex
|
||||||
|
std::vector<int> C; //!< Third vertex
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*! \class Variable
|
/*! \class Variable
|
||||||
\brief A base class fore variables
|
\brief A base class fore variables
|
||||||
@ -140,7 +142,7 @@ public:
|
|||||||
std::string name; //!< Variable name
|
std::string name; //!< Variable name
|
||||||
std::vector<double> data; //!< Variable data
|
std::vector<double> data; //!< Variable data
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
Variable(): type(VariableType::Null) {}
|
Variable(): type(NullVariable) {}
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~Variable() {}
|
virtual ~Variable() {}
|
||||||
protected:
|
protected:
|
||||||
@ -156,18 +158,18 @@ protected:
|
|||||||
*/
|
*/
|
||||||
struct MeshDataStruct {
|
struct MeshDataStruct {
|
||||||
std::string meshName;
|
std::string meshName;
|
||||||
std::shared_ptr<Mesh> mesh;
|
shared_ptr<Mesh> mesh;
|
||||||
std::vector<std::shared_ptr<Variable> > vars;
|
std::vector<shared_ptr<Variable> > vars;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! Convert the mesh to a TriMesh (will return NULL if this is invalid)
|
//! Convert the mesh to a TriMesh (will return NULL if this is invalid)
|
||||||
std::shared_ptr<PointList> getPointList( std::shared_ptr<Mesh> mesh );
|
shared_ptr<PointList> getPointList( shared_ptr<Mesh> mesh );
|
||||||
std::shared_ptr<TriMesh> getTriMesh( std::shared_ptr<Mesh> mesh );
|
shared_ptr<TriMesh> getTriMesh( shared_ptr<Mesh> mesh );
|
||||||
std::shared_ptr<TriList> getTriList( std::shared_ptr<Mesh> mesh );
|
shared_ptr<TriList> getTriList( shared_ptr<Mesh> mesh );
|
||||||
std::shared_ptr<const PointList> getPointList( std::shared_ptr<const Mesh> mesh );
|
shared_ptr<const PointList> getPointList( shared_ptr<const Mesh> mesh );
|
||||||
std::shared_ptr<const TriMesh> getTriMesh( std::shared_ptr<const Mesh> mesh );
|
shared_ptr<const TriMesh> getTriMesh( shared_ptr<const Mesh> mesh );
|
||||||
std::shared_ptr<const TriList> getTriList( std::shared_ptr<const Mesh> mesh );
|
shared_ptr<const TriList> getTriList( shared_ptr<const Mesh> mesh );
|
||||||
|
|
||||||
|
|
||||||
} // IO namespace
|
} // IO namespace
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
#include <ProfilerApp.h>
|
#include <ProfilerApp.h>
|
||||||
|
|
||||||
|
|
||||||
@ -397,13 +399,13 @@ std::vector<MeshDatabase> read( const std::string& filename )
|
|||||||
|
|
||||||
|
|
||||||
// Return the mesh type
|
// Return the mesh type
|
||||||
IO::MeshType meshType( std::shared_ptr<IO::Mesh> mesh )
|
IO::MeshType meshType( shared_ptr<IO::Mesh> mesh )
|
||||||
{
|
{
|
||||||
IO::MeshType type = IO::MeshType::Unknown;
|
IO::MeshType type = IO::Unknown;
|
||||||
if ( std::dynamic_pointer_cast<IO::PointList>(mesh)!=NULL ) {
|
if ( dynamic_pointer_cast<IO::PointList>(mesh)!=NULL ) {
|
||||||
type = IO::MeshType::PointMesh;
|
type = IO::PointMesh;
|
||||||
} else if ( std::dynamic_pointer_cast<IO::TriList>(mesh)!=NULL || std::dynamic_pointer_cast<IO::TriMesh>(mesh)!=NULL ) {
|
} else if ( dynamic_pointer_cast<IO::TriList>(mesh)!=NULL || dynamic_pointer_cast<IO::TriMesh>(mesh)!=NULL ) {
|
||||||
type = IO::MeshType::SurfaceMesh;
|
type = IO::SurfaceMesh;
|
||||||
} else {
|
} else {
|
||||||
ERROR("Unknown mesh");
|
ERROR("Unknown mesh");
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
#include "IO/Mesh.h"
|
#include "IO/Mesh.h"
|
||||||
#include "common/MPI_Helpers.h"
|
#include "common/MPI_Helpers.h"
|
||||||
|
#include "shared_ptr.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -17,7 +17,8 @@ class Mesh;
|
|||||||
|
|
||||||
|
|
||||||
//! Enum to identify mesh type
|
//! Enum to identify mesh type
|
||||||
enum class MeshType : char { PointMesh=1, SurfaceMesh=2, VolumeMesh=3, Unknown=-1 };
|
//enum class MeshType : char { PointMesh=1, SurfaceMesh=2, VolumeMesh=3, Unknown=-1 };
|
||||||
|
enum MeshType { PointMesh=1, SurfaceMesh=2, VolumeMesh=3, Unknown=-1 };
|
||||||
|
|
||||||
|
|
||||||
//! Helper struct for containing offsets for the mesh info
|
//! Helper struct for containing offsets for the mesh info
|
||||||
@ -80,7 +81,7 @@ std::vector<MeshDatabase> read( const std::string& filename );
|
|||||||
|
|
||||||
|
|
||||||
//! Return the mesh type
|
//! Return the mesh type
|
||||||
IO::MeshType meshType( std::shared_ptr<IO::Mesh> mesh );
|
IO::MeshType meshType( shared_ptr<IO::Mesh> mesh );
|
||||||
|
|
||||||
|
|
||||||
} // IO namespace
|
} // IO namespace
|
||||||
|
@ -7,10 +7,9 @@
|
|||||||
#include <ProfilerApp.h>
|
#include <ProfilerApp.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
|
||||||
// List the timesteps in the given directors (dumps.LBPM)
|
// List the timesteps in the given directors (dumps.LBPM)
|
||||||
@ -44,11 +43,11 @@ std::vector<IO::MeshDatabase> IO::getMeshList( const std::string& path, const st
|
|||||||
|
|
||||||
|
|
||||||
// Read the given mesh domain
|
// Read the given mesh domain
|
||||||
std::shared_ptr<IO::Mesh> IO::getMesh( const std::string& path, const std::string& timestep,
|
shared_ptr<IO::Mesh> IO::getMesh( const std::string& path, const std::string& timestep,
|
||||||
const IO::MeshDatabase& meshDatabase, int domain )
|
const IO::MeshDatabase& meshDatabase, int domain )
|
||||||
{
|
{
|
||||||
PROFILE_START("getMesh");
|
PROFILE_START("getMesh");
|
||||||
std::shared_ptr<IO::Mesh> mesh;
|
shared_ptr<IO::Mesh> mesh;
|
||||||
if ( meshDatabase.format==1 ) {
|
if ( meshDatabase.format==1 ) {
|
||||||
// Old format (binary doubles)
|
// Old format (binary doubles)
|
||||||
std::string filename = path + "/" + timestep + "/" + meshDatabase.domains[domain].file;
|
std::string filename = path + "/" + timestep + "/" + meshDatabase.domains[domain].file;
|
||||||
@ -63,9 +62,9 @@ std::shared_ptr<IO::Mesh> IO::getMesh( const std::string& path, const std::strin
|
|||||||
fclose(fid);
|
fclose(fid);
|
||||||
if ( count%3 != 0 )
|
if ( count%3 != 0 )
|
||||||
ERROR("Error reading file");
|
ERROR("Error reading file");
|
||||||
if ( meshDatabase.type==IO::MeshType::PointMesh ) {
|
if ( meshDatabase.type==IO::PointMesh ) {
|
||||||
size_t N = count/3;
|
size_t N = count/3;
|
||||||
std::shared_ptr<PointList> pointlist( new PointList(N) );
|
shared_ptr<PointList> pointlist( new PointList(N) );
|
||||||
std::vector<Point>& P = pointlist->points;
|
std::vector<Point>& P = pointlist->points;
|
||||||
for (size_t i=0; i<N; i++) {
|
for (size_t i=0; i<N; i++) {
|
||||||
P[i].x = data[3*i+0];
|
P[i].x = data[3*i+0];
|
||||||
@ -73,11 +72,11 @@ std::shared_ptr<IO::Mesh> IO::getMesh( const std::string& path, const std::strin
|
|||||||
P[i].z = data[3*i+2];
|
P[i].z = data[3*i+2];
|
||||||
}
|
}
|
||||||
mesh = pointlist;
|
mesh = pointlist;
|
||||||
} else if ( meshDatabase.type==IO::MeshType::SurfaceMesh ) {
|
} else if ( meshDatabase.type==IO::SurfaceMesh ) {
|
||||||
if ( count%9 != 0 )
|
if ( count%9 != 0 )
|
||||||
ERROR("Error reading file (2)");
|
ERROR("Error reading file (2)");
|
||||||
size_t N_tri = count/9;
|
size_t N_tri = count/9;
|
||||||
std::shared_ptr<TriList> trilist( new TriList(N_tri) );
|
shared_ptr<TriList> trilist( new TriList(N_tri) );
|
||||||
std::vector<Point>& A = trilist->A;
|
std::vector<Point>& A = trilist->A;
|
||||||
std::vector<Point>& B = trilist->B;
|
std::vector<Point>& B = trilist->B;
|
||||||
std::vector<Point>& C = trilist->C;
|
std::vector<Point>& C = trilist->C;
|
||||||
@ -131,14 +130,14 @@ std::shared_ptr<IO::Mesh> IO::getMesh( const std::string& path, const std::strin
|
|||||||
|
|
||||||
|
|
||||||
// Read the given variable for the given mesh domain
|
// Read the given variable for the given mesh domain
|
||||||
std::shared_ptr<IO::Variable> IO::getVariable( const std::string& path, const std::string& timestep,
|
shared_ptr<IO::Variable> IO::getVariable( const std::string& path, const std::string& timestep,
|
||||||
const MeshDatabase& meshDatabase, int domain, const std::string& variable )
|
const MeshDatabase& meshDatabase, int domain, const std::string& variable )
|
||||||
{
|
{
|
||||||
std::pair<std::string,std::string> key(meshDatabase.domains[domain].name,variable);
|
std::pair<std::string,std::string> key(meshDatabase.domains[domain].name,variable);
|
||||||
std::map<std::pair<std::string,std::string>,DatabaseEntry>::const_iterator it;
|
std::map<std::pair<std::string,std::string>,DatabaseEntry>::const_iterator it;
|
||||||
it = meshDatabase.variable_data.find(key);
|
it = meshDatabase.variable_data.find(key);
|
||||||
if ( it==meshDatabase.variable_data.end() )
|
if ( it==meshDatabase.variable_data.end() )
|
||||||
return std::shared_ptr<IO::Variable>();
|
return shared_ptr<IO::Variable>();
|
||||||
const DatabaseEntry& database = it->second;
|
const DatabaseEntry& database = it->second;
|
||||||
std::string filename = path + "/" + timestep + "/" + database.file;
|
std::string filename = path + "/" + timestep + "/" + database.file;
|
||||||
FILE *fid = fopen(filename.c_str(),"rb");
|
FILE *fid = fopen(filename.c_str(),"rb");
|
||||||
@ -158,12 +157,14 @@ std::shared_ptr<IO::Variable> IO::getVariable( const std::string& path, const st
|
|||||||
size_t count = fread(data,1,bytes,fid);
|
size_t count = fread(data,1,bytes,fid);
|
||||||
fclose(fid);
|
fclose(fid);
|
||||||
ASSERT(count==bytes);
|
ASSERT(count==bytes);
|
||||||
std::shared_ptr<IO::Variable> var( new IO::Variable() );
|
shared_ptr<IO::Variable> var( new IO::Variable() );
|
||||||
var->dim = dim;
|
var->dim = dim;
|
||||||
var->type = static_cast<IO::VariableType>(type);
|
var->type = static_cast<IO::VariableType>(type);
|
||||||
var->name = variable;
|
var->name = variable;
|
||||||
var->data.resize(N);
|
var->data.resize(N);
|
||||||
double *var_data = var->data.data();
|
double *var_data = NULL;
|
||||||
|
if ( !var->data.empty() )
|
||||||
|
var_data = &var->data[0];
|
||||||
if ( precision=="double" ) {
|
if ( precision=="double" ) {
|
||||||
memcpy(var_data,data,bytes);
|
memcpy(var_data,data,bytes);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "IO/Mesh.h"
|
#include "IO/Mesh.h"
|
||||||
#include "IO/MeshDatabase.h"
|
#include "IO/MeshDatabase.h"
|
||||||
|
#include "shared_ptr.h"
|
||||||
|
|
||||||
|
|
||||||
namespace IO {
|
namespace IO {
|
||||||
@ -22,12 +22,12 @@ std::vector<IO::MeshDatabase> getMeshList( const std::string& path, const std::s
|
|||||||
|
|
||||||
|
|
||||||
//! Read the given mesh domain
|
//! Read the given mesh domain
|
||||||
std::shared_ptr<IO::Mesh> getMesh( const std::string& path, const std::string& timestep,
|
shared_ptr<IO::Mesh> getMesh( const std::string& path, const std::string& timestep,
|
||||||
const MeshDatabase& meshDatabase, int domain );
|
const MeshDatabase& meshDatabase, int domain );
|
||||||
|
|
||||||
|
|
||||||
//! Read the given mesh domain
|
//! Read the given mesh domain
|
||||||
std::shared_ptr<IO::Variable> getVariable( const std::string& path, const std::string& timestep,
|
shared_ptr<IO::Variable> getVariable( const std::string& path, const std::string& timestep,
|
||||||
const MeshDatabase& meshDatabase, int domain, const std::string& variable );
|
const MeshDatabase& meshDatabase, int domain, const std::string& variable );
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "IO/IOHelpers.h"
|
#include "IO/IOHelpers.h"
|
||||||
#include "common/MPI_Helpers.h"
|
#include "common/MPI_Helpers.h"
|
||||||
#include "common/Utilities.h"
|
#include "common/Utilities.h"
|
||||||
|
#include "shared_ptr.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -25,7 +26,7 @@ static std::vector<IO::MeshDatabase> writeMeshesOrigFormat( const std::vector<IO
|
|||||||
sprintf(fullpath,"%s/%s",path,filename);
|
sprintf(fullpath,"%s/%s",path,filename);
|
||||||
FILE *fid = fopen(fullpath,"wb");
|
FILE *fid = fopen(fullpath,"wb");
|
||||||
INSIST(fid!=NULL,std::string("Error opening file: ")+fullpath);
|
INSIST(fid!=NULL,std::string("Error opening file: ")+fullpath);
|
||||||
std::shared_ptr<IO::Mesh> mesh = meshData[i].mesh;
|
shared_ptr<IO::Mesh> mesh = meshData[i].mesh;
|
||||||
IO::MeshDatabase mesh_entry;
|
IO::MeshDatabase mesh_entry;
|
||||||
mesh_entry.name = meshData[i].meshName;
|
mesh_entry.name = meshData[i].meshName;
|
||||||
mesh_entry.type = meshType(mesh);
|
mesh_entry.type = meshType(mesh);
|
||||||
@ -41,18 +42,18 @@ static std::vector<IO::MeshDatabase> writeMeshesOrigFormat( const std::vector<IO
|
|||||||
//for (size_t j=0; j<meshData[i].vars.size(); j++)
|
//for (size_t j=0; j<meshData[i].vars.size(); j++)
|
||||||
// mesh_entry.variables.push_back( meshData[i].vars[j]->name );
|
// mesh_entry.variables.push_back( meshData[i].vars[j]->name );
|
||||||
}
|
}
|
||||||
if ( std::dynamic_pointer_cast<IO::PointList>(mesh)!=NULL ) {
|
if ( dynamic_pointer_cast<IO::PointList>(mesh)!=NULL ) {
|
||||||
// List of points
|
// List of points
|
||||||
std::shared_ptr<IO::PointList> pointlist = std::dynamic_pointer_cast<IO::PointList>(mesh);
|
shared_ptr<IO::PointList> pointlist = dynamic_pointer_cast<IO::PointList>(mesh);
|
||||||
const std::vector<Point>& P = pointlist->points;
|
const std::vector<Point>& P = pointlist->points;
|
||||||
for (size_t i=0; i<P.size(); i++) {
|
for (size_t i=0; i<P.size(); i++) {
|
||||||
double x[3];
|
double x[3];
|
||||||
x[0] = P[i].x; x[1] = P[i].y; x[2] = P[i].z;
|
x[0] = P[i].x; x[1] = P[i].y; x[2] = P[i].z;
|
||||||
fwrite(x,sizeof(double),3,fid);
|
fwrite(x,sizeof(double),3,fid);
|
||||||
}
|
}
|
||||||
} else if ( std::dynamic_pointer_cast<IO::TriList>(mesh)!=NULL || std::dynamic_pointer_cast<IO::TriMesh>(mesh)!=NULL ) {
|
} else if ( dynamic_pointer_cast<IO::TriList>(mesh)!=NULL || dynamic_pointer_cast<IO::TriMesh>(mesh)!=NULL ) {
|
||||||
// Triangle mesh
|
// Triangle mesh
|
||||||
std::shared_ptr<IO::TriList> trilist = IO::getTriList(mesh);
|
shared_ptr<IO::TriList> trilist = IO::getTriList(mesh);
|
||||||
const std::vector<Point>& A = trilist->A;
|
const std::vector<Point>& A = trilist->A;
|
||||||
const std::vector<Point>& B = trilist->B;
|
const std::vector<Point>& B = trilist->B;
|
||||||
const std::vector<Point>& C = trilist->C;
|
const std::vector<Point>& C = trilist->C;
|
||||||
@ -117,7 +118,7 @@ static IO::MeshDatabase write_domain( FILE *fid, const std::string& filename,
|
|||||||
int type = static_cast<int>(mesh.vars[i]->type);
|
int type = static_cast<int>(mesh.vars[i]->type);
|
||||||
size_t N = mesh.vars[i]->data.size();
|
size_t N = mesh.vars[i]->data.size();
|
||||||
const void* data = N==0 ? 0:&mesh.vars[i]->data[0];
|
const void* data = N==0 ? 0:&mesh.vars[i]->data[0];
|
||||||
if ( type == static_cast<int>(IO::VariableType::Null) ) {
|
if ( type == static_cast<int>(IO::NullVariable) ) {
|
||||||
ERROR("Variable type not set");
|
ERROR("Variable type not set");
|
||||||
}
|
}
|
||||||
size_t N_mesh = mesh.mesh->numberPointsVar(mesh.vars[i]->type);
|
size_t N_mesh = mesh.mesh->numberPointsVar(mesh.vars[i]->type);
|
||||||
@ -143,7 +144,7 @@ static std::vector<IO::MeshDatabase> writeMeshesNewFormat(
|
|||||||
sprintf(fullpath,"%s/%s",path,filename);
|
sprintf(fullpath,"%s/%s",path,filename);
|
||||||
FILE *fid = fopen(fullpath,"wb");
|
FILE *fid = fopen(fullpath,"wb");
|
||||||
for (size_t i=0; i<meshData.size(); i++) {
|
for (size_t i=0; i<meshData.size(); i++) {
|
||||||
std::shared_ptr<IO::Mesh> mesh = meshData[i].mesh;
|
shared_ptr<IO::Mesh> mesh = meshData[i].mesh;
|
||||||
meshes_written.push_back( write_domain(fid,filename,meshData[i],format) );
|
meshes_written.push_back( write_domain(fid,filename,meshData[i],format) );
|
||||||
}
|
}
|
||||||
fclose(fid);
|
fclose(fid);
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "IO/Mesh.h"
|
#include "IO/Mesh.h"
|
||||||
|
156
cmake/SharedPtr.cmake
Normal file
156
cmake/SharedPtr.cmake
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
# Create a shared_ptr.h file in the include directory that contains
|
||||||
|
# a shared_ptr class (hopefully Tdef to a compiler basic)
|
||||||
|
# Arguements:
|
||||||
|
# INSTALL_DIR - Directory to install shared_ptr.h
|
||||||
|
# NAMESPACE - Namespace to contain the shared_ptr class (may be empty)
|
||||||
|
INCLUDE( CheckCXXSourceCompiles )
|
||||||
|
FUNCTION( CONFIGURE_SHARED_PTR INSTALL_DIR NAMESPACE )
|
||||||
|
SET( CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS} )
|
||||||
|
CHECK_CXX_SOURCE_COMPILES(
|
||||||
|
" #include <memory>
|
||||||
|
namespace ${NAMESPACE} { using std::shared_ptr; }
|
||||||
|
int main() {
|
||||||
|
${NAMESPACE}::shared_ptr<int> ptr;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
MEMORY_SHARED_PTR )
|
||||||
|
CHECK_CXX_SOURCE_COMPILES(
|
||||||
|
" #include <memory>
|
||||||
|
namespace ${NAMESPACE} { using std::tr1::shared_ptr; }
|
||||||
|
int main() {
|
||||||
|
${NAMESPACE}::shared_ptr<int> ptr;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
MEMORY_TR1_SHARED_PTR )
|
||||||
|
CHECK_CXX_SOURCE_COMPILES(
|
||||||
|
" #include <tr1/memory>
|
||||||
|
namespace ${NAMESPACE} { using std::tr1::shared_ptr; }
|
||||||
|
int main() {
|
||||||
|
${NAMESPACE}::shared_ptr<int> ptr;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
TR1_MEMORY_TR1_SHARED_PTR )
|
||||||
|
SET( CMAKE_REQUIRED_INCLUDES "${BOOST_INCLUDE}" )
|
||||||
|
CHECK_CXX_SOURCE_COMPILES(
|
||||||
|
" #include \"boost/shared_ptr.hpp\"
|
||||||
|
namespace ${NAMESPACE} { using boost::shared_ptr; }
|
||||||
|
int main() {
|
||||||
|
${NAMESPACE}::shared_ptr<int> ptr;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
BOOST_SHARED_PTR )
|
||||||
|
WRITE_DUMMY_SHARED_PTR( "${NAMESPACE}" "${CMAKE_CURRENT_BINARY_DIR}/tmp/dummy_shared_ptr.h" )
|
||||||
|
CHECK_CXX_SOURCE_COMPILES(
|
||||||
|
" #include <iostream>
|
||||||
|
#include \"${CMAKE_CURRENT_BINARY_DIR}/tmp/dummy_shared_ptr.h\"
|
||||||
|
int main() {
|
||||||
|
${NAMESPACE}::shared_ptr<int> ptr;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
DUMMY_SHARED_PTR )
|
||||||
|
IF ( BOOST_SHARED_PTR )
|
||||||
|
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "#include \"boost/shared_ptr.hpp\"\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "#include \"boost/weak_ptr.hpp\"\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "#include \"boost/enable_shared_from_this.hpp\"\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "namespace ${NAMESPACE} {\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using boost::shared_ptr; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using boost::dynamic_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using boost::const_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using boost::weak_ptr; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using boost::enable_shared_from_this; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "}\n")
|
||||||
|
ELSEIF ( MEMORY_SHARED_PTR )
|
||||||
|
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "#include <memory>\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "namespace ${NAMESPACE} {\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::shared_ptr; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::dynamic_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::const_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::weak_ptr; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::enable_shared_from_this; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "}\n")
|
||||||
|
ELSEIF ( MEMORY_TR1_SHARED_PTR )
|
||||||
|
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "#include <memory>\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "namespace ${NAMESPACE} {\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::shared_ptr; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::dynamic_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::const_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::weak_ptr; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::enable_shared_from_this; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "}\n")
|
||||||
|
ELSEIF ( TR1_MEMORY_TR1_SHARED_PTR )
|
||||||
|
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "#include <tr1/memory>\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "namespace ${NAMESPACE} {\n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::shared_ptr; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::dynamic_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::const_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::weak_ptr; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" " using std::tr1::enable_shared_from_this; \n")
|
||||||
|
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "}\n")
|
||||||
|
ELSEIF ( DUMMY_SHARED_PTR )
|
||||||
|
MESSAGE("Warning: No valid shared_ptr found, using dummy shared_ptr" )
|
||||||
|
WRITE_DUMMY_SHARED_PTR( "${NAMESPACE}" "${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" )
|
||||||
|
ELSE()
|
||||||
|
MESSAGE(FATAL_ERROR "No shared_ptr availible")
|
||||||
|
ENDIF()
|
||||||
|
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/tmp/shared_ptr.h" "${INSTALL_DIR}/shared_ptr.h" )
|
||||||
|
ENDFUNCTION()
|
||||||
|
|
||||||
|
|
||||||
|
FUNCTION( WRITE_DUMMY_SHARED_PTR NAMESPACE FILENAME )
|
||||||
|
FILE(WRITE "${FILENAME}" "#ifndef DUMMY_SHARED_PTR_INC\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "#define DUMMY_SHARED_PTR_INC\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "namespace dummy {\n\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "template<class T> class shared_ptr {\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "public:\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " shared_ptr( ): obj(NULL), count(NULL) {}\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " shared_ptr( T *ptr ): obj(ptr), count(NULL) { if (ptr) { count = new int; (*count)=1; } } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " shared_ptr( const shared_ptr<T>& rhs ): \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " obj(rhs.get()), count(rhs.count) { if ( count!=NULL ) { ++(*count); } } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " template<class U> shared_ptr( const shared_ptr<U>& rhs ): \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " obj(rhs.get()), count(rhs.count) { if ( count!=NULL ) { ++(*count); } } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " shared_ptr& operator=( const shared_ptr<T>& rhs ) { obj=rhs.obj; count=rhs.count; ++(*count); return *this; } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " ~shared_ptr( ) { reset(); }\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " void reset( T *ptr ) { reset(); obj=ptr; count=new int; (*count)=1; }\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " void reset( void ) { \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " if ( count!=NULL) { int tmp=--(*count); if ( tmp==0 ) { delete obj; delete count; } } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " obj=NULL; count=NULL; \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " }\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " T* get( ) const { return obj; } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " T* operator->( ) const { return obj; } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " const T& operator*( ) const { return *obj; } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " bool operator==( const T * rhs ) const { return obj==rhs; } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " bool operator!=( const T * rhs ) const { return obj!=rhs; } \n")
|
||||||
|
FILE(APPEND "${FILENAME}" "protected:\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " T *obj;\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " volatile int *count;\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "template<class T1, class U> friend shared_ptr<T1> dynamic_pointer_cast( shared_ptr<U> const & );\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "template<class T1, class U> friend shared_ptr<T1> const_pointer_cast( shared_ptr<U> const & );\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "template<class Y> friend class shared_ptr;\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "};\n\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "template<class T, class U> shared_ptr<T> dynamic_pointer_cast( shared_ptr<U> const & rhs ) {\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " T* obj = dynamic_cast<T*>(rhs.obj);\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " shared_ptr<T> ptr;\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " if ( obj!=NULL ) { ptr.obj = obj; ptr.count=rhs.count; ++(*ptr.count); }\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " return ptr;\n}\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "template<class T, class U> shared_ptr<T> const_pointer_cast( shared_ptr<U> const & rhs ) {\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " T* obj = const_cast<T*>(rhs.obj);\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " shared_ptr<T> ptr;\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " if ( obj!=NULL ) { ptr.obj = obj; ptr.count=rhs.count; ++(*ptr.count); }\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " return ptr;\n}\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "\n} // namespace dummy\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "\n\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "namespace ${NAMESPACE} {\n")
|
||||||
|
FILE(APPEND "${FILENAME}" " using dummy::shared_ptr; \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " using dummy::dynamic_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${FILENAME}" " using dummy::const_pointer_cast; \n")
|
||||||
|
FILE(APPEND "${FILENAME}" "}\n\n")
|
||||||
|
FILE(APPEND "${FILENAME}" "#endif\n")
|
||||||
|
ENDFUNCTION()
|
||||||
|
|
||||||
|
|
@ -202,7 +202,7 @@ MACRO ( SET_COMPILER_FLAGS )
|
|||||||
IF ( USING_GCC )
|
IF ( USING_GCC )
|
||||||
# Add gcc specific compiler options
|
# Add gcc specific compiler options
|
||||||
# -Wno-reorder: warning: "" will be initialized after "" when initialized here
|
# -Wno-reorder: warning: "" will be initialized after "" when initialized here
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-char-subscripts -Wno-comment -Wno-unused-variable -Wno-unused-but-set-variable")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-char-subscripts -Wno-comment -Wno-unused-variable -Wno-unused-but-set-variable")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-char-subscripts -Wno-comment -Wno-unused-variable -Wno-unused-but-set-variable")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-char-subscripts -Wno-comment -Wno-unused-variable -Wno-unused-but-set-variable")
|
||||||
ELSEIF ( USING_MICROSOFT )
|
ELSEIF ( USING_MICROSOFT )
|
||||||
|
@ -1155,7 +1155,9 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int bubbleCount=0; bubbleCount<4; bubbleCount++){
|
for (int bubbleCount=0; bubbleCount<4; bubbleCount++){
|
||||||
|
char bubbleCountName[20];
|
||||||
|
sprintf(bubbleCountName,"bubbleCount-%i",bubbleCount);
|
||||||
|
PROFILE_START(bubbleCountName);
|
||||||
BubbleRadius = BubRad[bubbleCount]; // Radius of the current bubble
|
BubbleRadius = BubRad[bubbleCount]; // Radius of the current bubble
|
||||||
|
|
||||||
// Initialize the bubble
|
// Initialize the bubble
|
||||||
@ -1356,6 +1358,7 @@ int main(int argc, char **argv)
|
|||||||
sendtag = recvtag = 5;
|
sendtag = recvtag = 5;
|
||||||
|
|
||||||
//************ MAIN ITERATION LOOP ***************************************/
|
//************ MAIN ITERATION LOOP ***************************************/
|
||||||
|
PROFILE_START("Time-loop");
|
||||||
while (timestep < timestepMax){
|
while (timestep < timestepMax){
|
||||||
|
|
||||||
|
|
||||||
@ -1760,6 +1763,7 @@ int main(int argc, char **argv)
|
|||||||
WriteCheckpoint(LocalRestartFile, cDen, cDistEven, cDistOdd, N);
|
WriteCheckpoint(LocalRestartFile, cDen, cDistEven, cDistOdd, N);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PROFILE_STOP("Time-loop");
|
||||||
// End the bubble loop
|
// End the bubble loop
|
||||||
//...........................................................................
|
//...........................................................................
|
||||||
// Copy the phase indicator field for the later timestep
|
// Copy the phase indicator field for the later timestep
|
||||||
@ -2094,7 +2098,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef USE_NEW_WRITER
|
#ifdef USE_NEW_WRITER
|
||||||
std::shared_ptr<IO::TriList> mesh( new IO::TriList() );
|
shared_ptr<IO::TriList> mesh( new IO::TriList() );
|
||||||
mesh->A.reserve(8*ncubes);
|
mesh->A.reserve(8*ncubes);
|
||||||
mesh->B.reserve(8*ncubes);
|
mesh->B.reserve(8*ncubes);
|
||||||
mesh->C.reserve(8*ncubes);
|
mesh->C.reserve(8*ncubes);
|
||||||
@ -2163,10 +2167,10 @@ int main(int argc, char **argv)
|
|||||||
meshData[0].meshName = "wn-tris";
|
meshData[0].meshName = "wn-tris";
|
||||||
meshData[0].mesh = mesh;
|
meshData[0].mesh = mesh;
|
||||||
for (size_t k=0; k<meshData.size(); k++) {
|
for (size_t k=0; k<meshData.size(); k++) {
|
||||||
std::shared_ptr<IO::Variable> dist( new IO::Variable() );
|
shared_ptr<IO::Variable> dist( new IO::Variable() );
|
||||||
dist->name = "distance";
|
dist->name = "distance";
|
||||||
dist->dim = 1;
|
dist->dim = 1;
|
||||||
dist->type = IO::VariableType::NodeVariable;
|
dist->type = IO::NodeVariable;
|
||||||
dist->data.resize(3*mesh->A.size());
|
dist->data.resize(3*mesh->A.size());
|
||||||
for (size_t i=0; i<mesh->A.size(); i++) {
|
for (size_t i=0; i<mesh->A.size(); i++) {
|
||||||
const Point& a = mesh->A[i];
|
const Point& a = mesh->A[i];
|
||||||
@ -2183,7 +2187,9 @@ int main(int argc, char **argv)
|
|||||||
fclose(WN_TRIS);
|
fclose(WN_TRIS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PROFILE_STOP(bubbleCountName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//************************************************************************/
|
//************************************************************************/
|
||||||
DeviceBarrier();
|
DeviceBarrier();
|
||||||
MPI_Barrier(MPI_COMM_WORLD);
|
MPI_Barrier(MPI_COMM_WORLD);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
#include "shared_ptr.h"
|
||||||
#include "common/UnitTest.h"
|
#include "common/UnitTest.h"
|
||||||
#include "common/Utilities.h"
|
#include "common/Utilities.h"
|
||||||
#include "common/MPI_Helpers.h"
|
#include "common/MPI_Helpers.h"
|
||||||
@ -55,19 +55,19 @@ int main(int argc, char **argv)
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create the meshes
|
// Create the meshes
|
||||||
std::shared_ptr<IO::PointList> set1( new IO::PointList(N_points) );
|
shared_ptr<IO::PointList> set1( new IO::PointList(N_points) );
|
||||||
for (int i=0; i<N_points; i++) {
|
for (int i=0; i<N_points; i++) {
|
||||||
set1->points[i].x = x[i];
|
set1->points[i].x = x[i];
|
||||||
set1->points[i].y = y[i];
|
set1->points[i].y = y[i];
|
||||||
set1->points[i].z = z[i];
|
set1->points[i].z = z[i];
|
||||||
}
|
}
|
||||||
std::shared_ptr<IO::TriMesh> trimesh( new IO::TriMesh(N_tri,set1) );
|
shared_ptr<IO::TriMesh> trimesh( new IO::TriMesh(N_tri,set1) );
|
||||||
for (int i=0; i<N_tri; i++) {
|
for (int i=0; i<N_tri; i++) {
|
||||||
trimesh->A[i] = tri[i][0];
|
trimesh->A[i] = tri[i][0];
|
||||||
trimesh->B[i] = tri[i][1];
|
trimesh->B[i] = tri[i][1];
|
||||||
trimesh->C[i] = tri[i][2];
|
trimesh->C[i] = tri[i][2];
|
||||||
}
|
}
|
||||||
std::shared_ptr<IO::TriList> trilist( new IO::TriList(*trimesh) );
|
shared_ptr<IO::TriList> trilist( new IO::TriList(*trimesh) );
|
||||||
for (int i=0; i<N_tri; i++) {
|
for (int i=0; i<N_tri; i++) {
|
||||||
Point A(x[tri[i][0]],y[tri[i][0]],z[tri[i][0]]);
|
Point A(x[tri[i][0]],y[tri[i][0]],z[tri[i][0]]);
|
||||||
Point B(x[tri[i][1]],y[tri[i][1]],z[tri[i][1]]);
|
Point B(x[tri[i][1]],y[tri[i][1]],z[tri[i][1]]);
|
||||||
@ -80,14 +80,14 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the variables
|
// Create the variables
|
||||||
std::shared_ptr<IO::Variable> dist_set1( new IO::Variable() );
|
shared_ptr<IO::Variable> dist_set1( new IO::Variable() );
|
||||||
std::shared_ptr<IO::Variable> dist_list( new IO::Variable() );
|
shared_ptr<IO::Variable> dist_list( new IO::Variable() );
|
||||||
dist_set1->dim = 1;
|
dist_set1->dim = 1;
|
||||||
dist_list->dim = 1;
|
dist_list->dim = 1;
|
||||||
dist_set1->name = "Distance";
|
dist_set1->name = "Distance";
|
||||||
dist_list->name = "Distance";
|
dist_list->name = "Distance";
|
||||||
dist_set1->type = IO::VariableType::NodeVariable;
|
dist_set1->type = IO::NodeVariable;
|
||||||
dist_list->type = IO::VariableType::NodeVariable;
|
dist_list->type = IO::NodeVariable;
|
||||||
dist_set1->data.resize( N_points );
|
dist_set1->data.resize( N_points );
|
||||||
for (int i=0; i<N_points; i++)
|
for (int i=0; i<N_points; i++)
|
||||||
dist_set1->data[i] = distance(set1->points[i]);
|
dist_set1->data[i] = distance(set1->points[i]);
|
||||||
@ -143,7 +143,7 @@ int main(int argc, char **argv)
|
|||||||
// For each domain, load the mesh and check its data
|
// For each domain, load the mesh and check its data
|
||||||
for (size_t j=0; j<list.size(); j++) {
|
for (size_t j=0; j<list.size(); j++) {
|
||||||
for (size_t k=0; k<list[i].domains.size(); k++) {
|
for (size_t k=0; k<list[i].domains.size(); k++) {
|
||||||
std::shared_ptr<IO::Mesh> mesh = IO::getMesh(".",timesteps[i],list[j],k);
|
shared_ptr<IO::Mesh> mesh = IO::getMesh(".",timesteps[i],list[j],k);
|
||||||
if ( mesh==NULL ) {
|
if ( mesh==NULL ) {
|
||||||
printf("Failed to load %s\n",meshData[i].meshName.c_str());
|
printf("Failed to load %s\n",meshData[i].meshName.c_str());
|
||||||
pass = false;
|
pass = false;
|
||||||
@ -151,7 +151,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if ( meshData[j].meshName=="pointmesh" ) {
|
if ( meshData[j].meshName=="pointmesh" ) {
|
||||||
// Check the pointmesh
|
// Check the pointmesh
|
||||||
std::shared_ptr<IO::PointList> pmesh = IO::getPointList(mesh);
|
shared_ptr<IO::PointList> pmesh = IO::getPointList(mesh);
|
||||||
if ( pmesh==NULL ) {
|
if ( pmesh==NULL ) {
|
||||||
pass = false;
|
pass = false;
|
||||||
break;
|
break;
|
||||||
@ -163,8 +163,8 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if ( meshData[j].meshName=="trimesh" || meshData[j].meshName=="trilist" ) {
|
if ( meshData[j].meshName=="trimesh" || meshData[j].meshName=="trilist" ) {
|
||||||
// Check the trimesh/trilist
|
// Check the trimesh/trilist
|
||||||
std::shared_ptr<IO::TriMesh> mesh1 = IO::getTriMesh(mesh);
|
shared_ptr<IO::TriMesh> mesh1 = IO::getTriMesh(mesh);
|
||||||
std::shared_ptr<IO::TriList> mesh2 = IO::getTriList(mesh);
|
shared_ptr<IO::TriList> mesh2 = IO::getTriList(mesh);
|
||||||
if ( mesh1==NULL || mesh2==NULL ) {
|
if ( mesh1==NULL || mesh2==NULL ) {
|
||||||
pass = false;
|
pass = false;
|
||||||
break;
|
break;
|
||||||
@ -213,7 +213,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
for (size_t v=0; v<list[i].variables.size(); v++) {
|
for (size_t v=0; v<list[i].variables.size(); v++) {
|
||||||
for (size_t k=0; k<list[i].domains.size(); k++) {
|
for (size_t k=0; k<list[i].domains.size(); k++) {
|
||||||
std::shared_ptr<const IO::Variable> variable =
|
shared_ptr<const IO::Variable> variable =
|
||||||
IO::getVariable(".",timesteps[i],list[j],k,list[j].variables[v].name);
|
IO::getVariable(".",timesteps[i],list[j],k,list[j].variables[v].name);
|
||||||
const IO::Variable& var1 = *mesh0->vars[v];
|
const IO::Variable& var1 = *mesh0->vars[v];
|
||||||
const IO::Variable& var2 = *variable;
|
const IO::Variable& var2 = *variable;
|
||||||
|
Loading…
Reference in New Issue
Block a user