Commit 89f9bb4e authored by Michael Turner's avatar Michael Turner
Browse files

remove pyfr and hdf5 from this branch

parent efe900ee
......@@ -185,7 +185,6 @@ INCLUDE (ThirdPartySMV)
INCLUDE (ThirdPartyTetGen)
INCLUDE (ThirdPartyANN)
INCLUDE (ThirdPartyCCM)
INCLUDE (ThirdPartyHDF5)
INCLUDE (Doxygen)
......
########################################################################
#
# ThirdParty configuration for Nektar++
#
# HDF5
#
########################################################################
OPTION(NEKTAR_USE_HDF5
"Enable HDF5 I/O support." OFF)
IF (NEKTAR_USE_HDF5)
set( HDF5_FIND_COMPONENTS "CXX" )
INCLUDE(FindHDF5)
IF(HDF5_FOUND)
MESSAGE(STATUS "Found HDF5")
ELSE()
MESSAGE(SEND_ERROR "Cannot find HDF5")
ENDIF(HDF5_FOUND)
INCLUDE_DIRECTORIES(SYSTEM ${HDF5_INCLUDE_DIRS})
ENDIF (NEKTAR_USE_HDF5)
......@@ -54,11 +54,6 @@ IF (NEKTAR_USE_CCM)
SET(NekMeshSources ${NekMeshSources} InputModules/InputStar.cpp)
ENDIF (NEKTAR_USE_CCM)
IF(NEKTAR_USE_HDF5)
SET(NekMeshHeaders ${NekMeshHeaders} InputModules/InputPYFR.h OutputModules/OutputPYFR.h)
SET(NekMeshSources ${NekMeshSources} InputModules/InputPYFR.cpp OutputModules/OutputPYFR.cpp)
ENDIF (NEKTAR_USE_HDF5)
IF (NEKTAR_USE_VTK)
SET(NekMeshHeaders ${NekMeshHeaders} InputModules/InputVtk.h OutputModules/OutputVtk.h)
SET(NekMeshSources ${NekMeshSources} InputModules/InputVtk.cpp OutputModules/OutputVtk.cpp)
......@@ -86,10 +81,6 @@ IF (NEKTAR_USE_CCM)
LINK_DIRECTORIES(${CCMIO_LIBRARY_PATH})
ENDIF (NEKTAR_USE_CCM)
IF (NEKTAR_USE_HDF5)
TARGET_LINK_LIBRARIES(NekMesh ${HDF5_CXX_LIBRARIES})
ENDIF()
IF (NEKTAR_USE_VTK)
IF (VTK_MAJOR_VERSION LESS 6)
TARGET_LINK_LIBRARIES(NekMesh vtkCommon vtkIO vtkGraphics)
......
////////////////////////////////////////////////////////////////////////////////
//
// File: InputNekpp.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: GMSH converter.
//
////////////////////////////////////////////////////////////////////////////////
#include <boost/algorithm/string.hpp>
#include <H5Cpp.h>
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
#include "InputPYFR.h"
using namespace std;
namespace Nektar
{
namespace Utilities
{
ModuleKey InputPYFR::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "pyfrm"), InputPYFR::create,
"PYFR mesh files.");
/**
* @brief Set up InputNekpp object.
*/
InputPYFR::InputPYFR(MeshSharedPtr m) : InputModule(m)
{
}
InputPYFR::~InputPYFR()
{
}
void InputPYFR::Process()
{
string filename = m_config["infile"].as<string>();
H5std_string FILE_NAME( filename );
H5File file( FILE_NAME, H5F_ACC_RDONLY );
vector<string> elements;
vector<string> bcs;
string con, uuid;
Group g = file.openGroup("/");
for(int i = 0; i < g.getNumObjs(); i++)
{
string obj = g.getObjnameByIdx(i);
string pre = obj.substr(0, obj.find("_"));
if(pre == "bcon")
{
bcs.push_back(obj);
}
else if(pre == "spt")
{
elements.push_back(obj);
}
else if(pre == "mesh")
{
uuid = obj;
}
else if(pre == "con")
{
con = obj;
}
else
{
ASSERTL0(false, "hdf5 object not recognised");
}
}
//there is no way to tell the dim of the mesh other than to figure out
//which element types are used
//will not be able to read mainfold meshes in this format
vector<string> tmp;
boost::split(tmp, elements[0], boost::is_any_of("_"));
LibUtilities::ShapeType st;
if(boost::iequals(tmp[1], "quad") || boost::iequals(tmp[1], "tri"))
{
m_mesh->m_expDim = 2;
m_mesh->m_spaceDim = 2;
}
else
{
m_mesh->m_expDim = 3;
m_mesh->m_spaceDim = 3;
}
m_mesh->m_nummode = 5; //cheaty needs to be removed
map<string, vector<ElementSharedPtr> > elmap;
int nct = 0;
for(int i = 0; i < elements.size(); i++)
{
// all this is to just get the data out of hdf5, why so complicated!!!
DataSet d = g.openDataSet(elements[i]);
DataSpace s = d.getSpace();
int rank = s.getSimpleExtentNdims();
hsize_t* dims_out = new hsize_t[rank];
int ndims = s.getSimpleExtentDims( dims_out, NULL);
hsize_t* offset = new hsize_t[ndims]; // hyperslab offset in the file
memset(offset, 0, rank * sizeof(hsize_t)) ;
s.selectHyperslab( H5S_SELECT_SET, dims_out, offset);
DataSpace memspace( ndims, dims_out); //describe hyperslab in memory space
memspace.selectHyperslab( H5S_SELECT_SET, dims_out, offset);
hsize_t totSize = 1 ;
for(int j = 0 ; j < ndims ; j++)
{
totSize *= dims_out[j];
}
float* data = new float[totSize] ;
d.read( data, PredType::NATIVE_FLOAT, memspace, s );
Array<ThreeD, NekDouble> dataArray(dims_out[0],dims_out[1],dims_out[2]);
for(int j = 0; j < dims_out[0]; j++) //verteices
{
for(int k = 0; k < dims_out[1]; k++) //elements
{
for(int l = 0; l < dims_out[2]; l++) //dims
{
dataArray[j][k][l] = data[j*dims_out[1]*dims_out[2] + k*dims_out[2] + l];
}
}
}
vector<string> tmp;
boost::split(tmp, elements[i], boost::is_any_of("_"));
LibUtilities::ShapeType st;
if(boost::iequals(tmp[1], "quad"))
{
st = LibUtilities::eQuadrilateral;
}
else if(boost::iequals(tmp[1], "tri"))
{
st = LibUtilities::eTriangle;
}
else
{
ASSERTL0(false,"element type not recognised");
}
map<int, int> nodemap; //nektar order to pyfr
int np = dims_out[0];
int nq;
if(st == LibUtilities::eQuadrilateral)
{
nq = sqrt(np);
nodemap = GetQuadMap(sqrt(np));
}
else if(st == LibUtilities::eTriangle)
{
nq = 0.5*(-1+sqrt(1+8*np));
nodemap = GetTriMap(nq);
}
for(int j = 0; j < dims_out[1]; j++) //loop over all elements
{
vector<NodeSharedPtr> ns(np);
for(int k = 0; k < np; k++)
{
ns[k] = boost::shared_ptr<Node>(new Node(nct++, dataArray[nodemap[k]][j][0],
dataArray[nodemap[k]][j][1], 0.0));
}
vector<int> tags;
tags.push_back(i);
ElmtConfig conf(st, nq-1, true, false);
ElementSharedPtr E = GetElementFactory().CreateInstance(
st, conf, ns, tags);
m_mesh->m_element[m_mesh->m_expDim].push_back(E);
elmap[tmp[1]].push_back(E);
}
}
/*typedef struct conec
{
char el[5];
int id;
int fc;
int bl;
} conec;
StrType strdatatype(PredType::C_S1, 5);
//con
{
// all this is to just get the data out of hdf5, why so complicated!!!
DataSet d = g.openDataSet(con);
DataSpace s = d.getSpace();
int rank = s.getSimpleExtentNdims();
hsize_t* dims_out = new hsize_t[rank];
int ndims = s.getSimpleExtentDims( dims_out, NULL);
hsize_t* offset = new hsize_t[ndims]; // hyperslab offset in the file
memset(offset, 0, rank * sizeof(hsize_t)) ;
s.selectHyperslab( H5S_SELECT_SET, dims_out, offset);
DataSpace memspace( ndims, dims_out); //describe hyperslab in memory space
memspace.selectHyperslab( H5S_SELECT_SET, dims_out, offset);
CompType cn( sizeof(conec) );
cn.insertMember( "f0", HOFFSET(conec, el), strdatatype);
cn.insertMember( "f1", HOFFSET(conec, id), PredType::NATIVE_INT);
cn.insertMember( "f2", HOFFSET(conec, fc), PredType::NATIVE_INT);
cn.insertMember( "f3", HOFFSET(conec, bl), PredType::NATIVE_INT);
hsize_t totSize = 1 ;
for(int j = 0 ; j < ndims ; j++)
{
totSize *= dims_out[j];
}
conec* data = new conec[totSize];
d.read( data, cn );
for(int k = 0; k < dims_out[1]; k++)
{
ElementSharedPtr e1 = elmap[data[0*dims_out[1] + k].el][data[0*dims_out[1] + k].id];
ElementSharedPtr e2 = elmap[data[1*dims_out[1] + k].el][data[1*dims_out[1] + k].id];
e2->SetEdge(data[1*dims_out[1] + k].fc, e1->GetEdge(data[0*dims_out[1] + k].fc));
}
}*/
ProcessVertices();
ProcessEdges();
ProcessFaces();
ProcessElements();
ProcessComposites();
/*for(int i = 0; i < bcs.size(); i++)
{
// all this is to just get the data out of hdf5, why so complicated!!!
DataSet d = g.openDataSet(bcs[i]);
DataSpace s = d.getSpace();
int rank = s.getSimpleExtentNdims();
hsize_t* dims_out = new hsize_t[rank];
int ndims = s.getSimpleExtentDims( dims_out, NULL);
hsize_t* offset = new hsize_t[ndims]; // hyperslab offset in the file
memset(offset, 0, rank * sizeof(hsize_t)) ;
s.selectHyperslab( H5S_SELECT_SET, dims_out, offset);
DataSpace memspace( ndims, dims_out); //describe hyperslab in memory space
memspace.selectHyperslab( H5S_SELECT_SET, dims_out, offset);
CompType cn( sizeof(conec) );
cn.insertMember( "f0", HOFFSET(conec, el), strdatatype);
cn.insertMember( "f1", HOFFSET(conec, id), PredType::NATIVE_INT);
cn.insertMember( "f2", HOFFSET(conec, fc), PredType::NATIVE_INT);
cn.insertMember( "f3", HOFFSET(conec, bl), PredType::NATIVE_INT);
hsize_t totSize = 1 ;
for(int j = 0 ; j < ndims ; j++)
{
totSize *= dims_out[j];
}
conec* data = new conec[totSize];
d.read( data, cn );
for(int k = 0; k < dims_out[0]; k++)
{
ElementSharedPtr e1 = elmap[data[k].el][data[k].id];
EdgeSharedPtr e = e1->GetEdge(data[k].fc);
vector<NodeSharedPtr> ns(2);
ns[0] = e->m_n1;
ns[1] = e->m_n2;
vector<int> tags;
tags.push_back(elements.size()+i);
ElmtConfig conf(LibUtilities::eSegment, 1, false, false);
ElementSharedPtr E = GetElementFactory().CreateInstance(
LibUtilities::eSegment, conf, ns, tags);
m_mesh->m_element[m_mesh->m_expDim-1].push_back(E);
}
}*/
ClearElementLinks();
ProcessVertices();
ProcessEdges();
ProcessFaces();
ProcessElements();
ProcessComposites();
}
map<int, int> InputPYFR::GetQuadMap(int n)
{
map<int,int > nodeList;
// Vertices and edges
nodeList[0] = 0;
if (n > 1)
{
nodeList[1] = n-1;
nodeList[2] = n*n-1;
nodeList[3] = n*(n-1);
}
for (int i = 1; i < n-1; ++i)
{
nodeList[4+i-1] = i;
}
for (int i = 1; i < n-1; ++i)
{
nodeList[4+2*(n-2)+i-1] = n*n-1-i;
}
for (int i = 1; i < n-1; ++i)
{
nodeList[4+(n-2)+i-1] = 2*n-1+(i-1)*n;
}
for (int i = 1; i < n-1; ++i)
{
nodeList[4+3*(n-2)+i-1] = n*(n-2) - (i-1)*n;
}
if(n > 2)
{
//face interior
for(int j = 0; j < n -2; j++)
{
for (int i = 1; i < n-1; ++i)
{
nodeList[4+4*(n-2)+i-1 + j*(n-2)] = n*(j+1) + i;
}
}
}
return nodeList;
}
map<int, int> InputPYFR::GetTriMap(int n)
{
map<int,int> nodeList;
nodeList[0] = 0;
if(n > 1)
{
nodeList[1] = n - 1;
nodeList[2] = n*(n+1)/2 - 1;
}
int cnt = n;
for (int i = 1; i < n-1; ++i)
{
nodeList[3+i-1] = i;
nodeList[3+3*(n-2)-i] = cnt;
nodeList[3+(n-2)+i-1] = cnt+n-i-1;
cnt += n-i;
}
int todo = n - 3;
int k = 3+3*(n-2);
int l = n + 1;
for(int j = 0; j < n - 3; j++)
{
for(int i = 0; i < todo; i++)
{
nodeList[k++] = l++;
}
l += 2;
todo--;
}
return nodeList;
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: InputNekpp.h
//
// 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: Nektar++ converter.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef UTILITIES_MESHCONVERT_INPUTPYFR
#define UTILITIES_MESHCONVERT_INPUTPYFR
#include "../Module.h"
namespace Nektar
{
namespace Utilities
{
class InputPYFR : public InputModule
{
public:
InputPYFR(MeshSharedPtr m);
virtual ~InputPYFR();
virtual void Process();
/// Creates an instance of this class
static ModuleSharedPtr create(MeshSharedPtr m) {
return MemoryManager<InputPYFR>::AllocateSharedPtr(m);
}
/// %ModuleKey for class.
static ModuleKey className;
private:
map<int,int> GetQuadMap(int n);
map<int,int> GetTriMap(int n);
};
}
}
#endif
////////////////////////////////////////////////////////////////////////////////
//
// File: OutputGmsh.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: Gmsh file format output.
//
////////////////////////////////////////////////////////////////////////////////
#include <NekMeshUtils/MeshElements/Element.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
#include <H5Cpp.h>
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
#include <boost/uuid/uuid.hpp> // uuid class
#include <boost/uuid/uuid_generators.hpp> // generators
#include <boost/uuid/uuid_io.hpp> // streaming operators etc.
#include "OutputPYFR.h"
using namespace std;
using namespace Nektar::NekMeshUtils;
namespace Nektar
{
namespace Utilities
{
ModuleKey OutputPYFR::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eOutputModule, "pyfrm"), OutputPYFR::create,
"Writes PYFR pyfrm file.");
OutputPYFR::OutputPYFR(MeshSharedPtr m) : OutputModule(m)
{
}
OutputPYFR::~OutputPYFR()
{
}
vector<Array<OneD, NekDouble> > GetPyFrStandardTet(int n)
{
vector<Array<OneD, NekDouble> > ret;
NekDouble du = 2.0 / (n-1);
for(int z = 0; z < n; z++)