Commit 3d1a0e77 authored by Michael Turner's avatar Michael Turner
Browse files

reformat volume meshing

parent a4919b37
......@@ -26,8 +26,9 @@ IF(NEKTAR_USE_MESHGEN)
SurfaceMeshing/OptimiseFunctions.cpp
ExtLibInterface/TriangleInterface.cpp
ExtLibInterface/TetGenInterface.cpp
TetMeshing/TetMesh.cpp
BLMeshing/BLMesh.cpp
VolumeMeshing/VolumeMesh.cpp
VolumeMeshing/TetMeshing/TetMesh.cpp
VolumeMeshing/BLMeshing/BLMesh.cpp
CADSystem/CADSystem.cpp
CADSystem/CADCurve.cpp
CADSystem/CADSurf.cpp
......@@ -69,8 +70,9 @@ IF(NEKTAR_USE_MESHGEN)
SurfaceMeshing/OptimiseFunctions.h
ExtLibInterface/TriangleInterface.h
ExtLibInterface/TetGenInterface.h
TetMeshing/TetMesh.h
BLMeshing/BLMesh.h
VolumeMeshing/VolumeMesh.h
VolumeMeshing/TetMeshing/TetMesh.h
VolumeMeshing/BLMeshing/BLMesh.h
CADSystem/CADObj.h
CADSystem/CADSystem.h
CADSystem/CADVert.h
......
......@@ -48,6 +48,10 @@ namespace Nektar
{
namespace NekMeshUtils
{
class Octree;
typedef boost::shared_ptr<Octree> OctreeSharedPtr;
/**
* Enumeration of condition types (Dirichlet, Neumann, etc).
*/
......@@ -133,6 +137,7 @@ public:
std::string m_CADId;
#ifdef NEKTAR_USE_MESHGEN
CADSystemSharedPtr m_cad;
OctreeSharedPtr m_octree;
#endif
/// Returns the total number of elements in the mesh with
......
......@@ -42,12 +42,7 @@ namespace Nektar
namespace NekMeshUtils
{
ModuleKey Octree::className = GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "octree"),
Octree::create,
"Generates a octree represenation on the geometry with spacing info");
Octree::Octree(MeshSharedPtr m) : ProcessModule(m)
Octree::Octree(MeshSharedPtr m) : m_mesh(m)
{
m_config["mindel"] =
ConfigOption(false, "0", "mindelta.");
......
......@@ -36,10 +36,10 @@
#ifndef NEKTAR_MESHUTILS_OCTREE_OCTREE
#define NEKTAR_MESHUTILS_OCTREE_OCTREE
#include <NekMeshUtils/Module/Module.h>
#include "SourcePoint.hpp"
#include "Octant.h"
#include <NekMeshUtils/MeshElements/Mesh.h>
#include <NekMeshUtils/Module/Module.h>
namespace Nektar
{
......@@ -52,20 +52,14 @@ namespace NekMeshUtils
* This class contains the routines to generate and query a automatically
* generated set of mesh spacing parameters based on the CAD
*/
class Octree : public ProcessModule
class Octree
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(MeshSharedPtr m)
{
return MemoryManager<Octree>::AllocateSharedPtr(m);
}
static ModuleKey className;
Octree(MeshSharedPtr m);
virtual ~Octree();
virtual void Process();
void Process();
/**
* @brief once constructed queryies the octree based on x,y,z location
......@@ -86,6 +80,27 @@ public:
return m_minDelta;
}
void RegisterConfig(std::string key, std::string val)
{
std::map<std::string, ConfigOption>::iterator it = m_config.find(key);
if (it == m_config.end())
{
std::cerr << "WARNING: Unrecognised config option " << key
<< ", proceeding anyway." << std::endl;
}
it->second.beenSet = true;
if (it->second.isBool)
{
it->second.value = "1";
}
else
{
it->second.value = val;
}
}
private:
/**
* @brief populates the mesh m with a invalid hexahedral mesh based on the
......@@ -158,6 +173,10 @@ private:
OctantSharedPtr m_masteroct;
/// number of octants made, used for id index
int m_numoct;
/// Mesh object
MeshSharedPtr m_mesh;
/// List of configuration values.
std::map<std::string, ConfigOption> m_config;
bool m_udsfileset;
std::string m_udsfile;
......
......@@ -127,7 +127,7 @@ void SurfaceMesh::Report()
}
}
void SurfaceMesh::Remesh(BLMeshSharedPtr blmesh)
/*void SurfaceMesh::Remesh(BLMeshSharedPtr blmesh)
{
vector<int> surfs = blmesh->GetSymSurfs();
for(int i = 0; i < surfs.size(); i++)
......@@ -139,7 +139,7 @@ void SurfaceMesh::Remesh(BLMeshSharedPtr blmesh)
}
}
}*/
}
}
......@@ -41,7 +41,6 @@
#include <NekMeshUtils/Octree/Octree.h>
#include <NekMeshUtils/SurfaceMeshing/FaceMesh.h>
#include <NekMeshUtils/SurfaceMeshing/CurveMesh.h>
#include <NekMeshUtils/BLMeshing/BLMesh.h>
namespace Nektar
{
......@@ -79,7 +78,7 @@ public:
/**
* @brief Remesh the linear surfaces based on the addition of the bl
*/
void Remesh(BLMeshSharedPtr blmesh);
//void Remesh(BLMeshSharedPtr blmesh);
void Report();
......
......@@ -34,7 +34,7 @@
////////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/BasicUtils/Progressbar.hpp>
#include <NekMeshUtils/BLMeshing/BLMesh.h>
#include <NekMeshUtils/VolumeMeshing/BLMeshing/BLMesh.h>
#include <NekMeshUtils/CADSystem/CADSurf.h>
#include <ANN/ANN.h>
......
......@@ -33,7 +33,7 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <NekMeshUtils/TetMeshing/TetMesh.h>
#include <NekMeshUtils/VolumeMeshing/TetMeshing/TetMesh.h>
using namespace std;
namespace Nektar
......@@ -67,7 +67,7 @@ void TetMesh::Mesh()
for(it = m_mesh->m_vertexSet.begin(); it != m_mesh->m_vertexSet.end(); it++)
{
IdToNode[(*it)->m_id] = *it;
IdToDelta[(*it)->m_id] = m_octree->Query((*it)->GetLoc());
IdToDelta[(*it)->m_id] = m_mesh->m_octree->Query((*it)->GetLoc());
}
// build surface mesh and node map from all surface elements
for (int i = 0; i < m_mesh->m_element[2].size(); i++)
......@@ -127,7 +127,7 @@ void TetMesh::Mesh()
tri[j] = cnt;
IdToNode[cnt] = n[j];
IdToNodeRev[n[j]] = cnt;
IdToDelta[cnt] = m_octree->Query(n[j]->GetLoc());
IdToDelta[cnt] = m_mesh->m_octree->Query(n[j]->GetLoc());
cnt++;
}
else
......@@ -151,7 +151,7 @@ void TetMesh::Mesh()
tri[j] = cnt;
IdToNode[cnt] = n[j];
IdToNodeRev[n[j]] = cnt;
IdToDelta[cnt] = m_octree->Query(n[j]->GetLoc());
IdToDelta[cnt] = m_mesh->m_octree->Query(n[j]->GetLoc());
cnt++;
}
else
......@@ -200,7 +200,7 @@ void TetMesh::Mesh()
tetgen->GetNewPoints(ctbefore, newp);
for (int i = 0; i < newp.size(); i++)
{
NekDouble d = m_octree->Query(newp[i]);
NekDouble d = m_mesh->m_octree->Query(newp[i]);
IdToDelta[ctbefore + i] = d;
}
tetgen->RefineMesh(IdToDelta);
......
......@@ -45,7 +45,7 @@
#include <NekMeshUtils/CADSystem/CADSystem.h>
#include <NekMeshUtils/Octree/Octree.h>
#include <NekMeshUtils/SurfaceMeshing/SurfaceMesh.h>
#include <NekMeshUtils/BLMeshing/BLMesh.h>
#include <NekMeshUtils/VolumeMeshing/BLMeshing/BLMesh.h>
#include <NekMeshUtils/ExtLibInterface/TetGenInterface.h>
......@@ -65,8 +65,7 @@ public:
/**
* @brief default constructor
*/
TetMesh(MeshSharedPtr m, OctreeSharedPtr oct)
: m_mesh(m), m_octree(oct)
TetMesh(MeshSharedPtr m) : m_mesh(m)
{
m_usePSurface = false;
};
......@@ -74,8 +73,7 @@ public:
/**
* @brief constructor for pseudo surface
*/
TetMesh(MeshSharedPtr m, OctreeSharedPtr oct, BLMeshSharedPtr b)
: m_mesh(m), m_octree(oct), m_blmesh(b)
TetMesh(MeshSharedPtr m, BLMeshSharedPtr b) : m_mesh(m), m_blmesh(b)
{
m_usePSurface = true;
};
......@@ -88,8 +86,6 @@ public:
private:
MeshSharedPtr m_mesh;
/// octree object
OctreeSharedPtr m_octree;
/// bl mesh
BLMeshSharedPtr m_blmesh;
/// mesh the tets using the psuedosurface
......
////////////////////////////////////////////////////////////////////////////////
//
// File: SurfaceMeshing.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: surfacemeshing object methods.
//
////////////////////////////////////////////////////////////////////////////////
#include <NekMeshUtils/VolumeMeshing/BLMeshing/BLMesh.h>
#include <NekMeshUtils/VolumeMeshing/TetMeshing/TetMesh.h>
#include <NekMeshUtils/VolumeMeshing/VolumeMesh.h>
using namespace std;
namespace Nektar
{
namespace NekMeshUtils
{
ModuleKey VolumeMesh::className = GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "volumemesh"),
VolumeMesh::create,
"Generates a volume mesh");
VolumeMesh::VolumeMesh(MeshSharedPtr m) : ProcessModule(m)
{
m_config["blsurfs"] =
ConfigOption(true, "0", "Generate prisms on these surfs");
}
VolumeMesh::~VolumeMesh()
{
}
void VolumeMesh::Process()
{
if (m_mesh->m_verbose)
cout << endl << "Volume meshing" << endl;
/*map<int, FaceSharedPtr> surftopriface;
// map of surface element id to opposite prism
// face for psudo surface in tetmesh
*/
TetMeshSharedPtr tet;/*
if (m_makeBL)
{
BLMeshSharedPtr blmesh = MemoryManager<BLMesh>::AllocateSharedPtr(
m_mesh->m_cad, m_mesh, blsurfs, m_blthick);
blmesh->Mesh();*/
//m_mesh->m_element[2].clear();
//m_mesh->m_expDim = 3;
/*ClearElementLinks();
ProcessVertices();
ProcessEdges();
ProcessFaces();
ProcessElements();
ProcessComposites();
return;*/
//m_surfacemesh->Remesh(m_blmesh);
/*m_mesh->m_nummode = 2;
m_mesh->m_expDim = 3;
m_mesh->m_element[2].clear();
ClearElementLinks();
ProcessVertices();
ProcessEdges();
ProcessFaces();
ProcessElements();
ProcessComposites();
return;*/
//create tet mesh
/*m_mesh->m_expDim = 3;
m_tet = MemoryManager<TetMesh>::AllocateSharedPtr(
m_mesh, blmesh);
}
else
{*/
m_mesh->m_expDim = 3;
tet = MemoryManager<TetMesh>::AllocateSharedPtr(m_mesh);
//}
tet->Mesh();
ClearElementLinks();
ProcessVertices();
ProcessEdges();
ProcessFaces();
ProcessElements();
ProcessComposites();
if (m_mesh->m_verbose)
cout << endl;
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessJac.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: Calculate jacobians of elements.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NEKMESHUTILS_VOLUME
#define NEKMESHUTILS_VOLUME
#include <NekMeshUtils/Module/Module.h>
namespace Nektar
{
namespace NekMeshUtils
{
class VolumeMesh : public ProcessModule
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(MeshSharedPtr m)
{
return MemoryManager<VolumeMesh>::AllocateSharedPtr(m);
}
static ModuleKey className;
VolumeMesh(MeshSharedPtr m);
virtual ~VolumeMesh();
virtual void Process();
};
}
}
#endif
......@@ -43,8 +43,7 @@
#include <NekMeshUtils/CADSystem/CADSystem.h>
#include <NekMeshUtils/Octree/Octree.h>
#include <NekMeshUtils/SurfaceMeshing/SurfaceMesh.h>
#include <NekMeshUtils/BLMeshing/BLMesh.h>
#include <NekMeshUtils/TetMeshing/TetMesh.h>
#include <NekMeshUtils/VolumeMeshing/VolumeMesh.h>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <LibUtilities/Communication/CommSerial.h>
......@@ -173,20 +172,20 @@ void InputCAD::Process()
cout << endl << "\tWith thickness " << m_blthick << endl;
}
ModuleSharedPtr octr = GetModuleFactory().CreateInstance(
ModuleKey(eProcessModule, "octree"), m_mesh);
octr->RegisterConfig("mindel",boost::lexical_cast<std::string>(m_minDelta));
octr->RegisterConfig("maxdel",boost::lexical_cast<std::string>(m_maxDelta));
octr->RegisterConfig("eps",boost::lexical_cast<std::string>(m_eps));
m_mesh->m_octree = boost::shared_ptr<Octree>(new Octree(m_mesh));
m_mesh->m_octree->RegisterConfig("mindel",boost::lexical_cast<std::string>(m_minDelta));
m_mesh->m_octree->RegisterConfig("maxdel",boost::lexical_cast<std::string>(m_maxDelta));
m_mesh->m_octree->RegisterConfig("eps",boost::lexical_cast<std::string>(m_eps));
if(pSession->DefinesSolverInfo("SourcePoints"))
{
ASSERTL0(boost::filesystem::exists(pSession->GetSolverInfo("SourcePoints").c_str()),
"sourcepoints file does not exist");
octr->RegisterConfig("sourcefile",pSession->GetSolverInfo("SourcePoints"));
m_mesh->m_octree->RegisterConfig("sourcefile",pSession->GetSolverInfo("SourcePoints"));
NekDouble sp;
pSession->LoadParameter("SPSize", sp);
octr->RegisterConfig("sourcesize",boost::lexical_cast<std::string>(sp));
m_mesh->m_octree->RegisterConfig("sourcesize",boost::lexical_cast<std::string>(sp));
}
if (pSession->DefinesSolverInfo("UserDefinedSpacing"))
......@@ -195,17 +194,15 @@ void InputCAD::Process()
ASSERTL0(boost::filesystem::exists(udsName.c_str()),
"UserDefinedSpacing file does not exist");
octr->RegisterConfig("udsfile",udsName);
m_mesh->m_octree->RegisterConfig("udsfile",udsName);
}
if (pSession->DefinesSolverInfo("WriteOctree"))
{
octr->RegisterConfig("writeoctree",fn + "_oct.xml");
m_mesh->m_octree->RegisterConfig("writeoctree",fn + "_oct.xml");
}
octr->Process();
OctreeSharedPtr octree = boost::dynamic_pointer_cast<Octree>(octr);
m_mesh->m_octree->Process();
m_mesh->m_expDim = 3;
m_mesh->m_spaceDim = 3;
......@@ -222,7 +219,7 @@ void InputCAD::Process()
//create surface mesh
m_mesh->m_expDim--; //just to make it easier to surface mesh for now
SurfaceMeshSharedPtr m_surfacemesh = MemoryManager<SurfaceMesh>::
AllocateSharedPtr(m_mesh, m_mesh->m_cad, octree);
AllocateSharedPtr(m_mesh, m_mesh->m_cad, m_mesh->m_octree);
m_surfacemesh->Mesh();
......@@ -234,103 +231,16 @@ void InputCAD::Process()
m_surfacemesh->Report();
EdgeSet::iterator eit;
int count = 0;
for(eit = m_mesh->m_edgeSet.begin(); eit != m_mesh->m_edgeSet.end(); eit++)
{
if((*eit)->m_elLink.size() != 2)
{
count++;
}
}
if (count > 0)
{
cerr << "Error: mesh contains unconnected edges and is not valid"
<< endl;
abort();
}
map<int, FaceSharedPtr> surftopriface;
// map of surface element id to opposite prism
// face for psudo surface in tetmesh
TetMeshSharedPtr m_tet;
if (m_makeBL)
{
BLMeshSharedPtr m_blmesh = MemoryManager<BLMesh>::AllocateSharedPtr(
m_mesh->m_cad, m_mesh, blsurfs, m_blthick);
m_blmesh->Mesh();
//m_mesh->m_element[2].clear();
//m_mesh->m_expDim = 3;
/*ClearElementLinks();
ProcessVertices();
ProcessEdges();
ProcessFaces();
ProcessElements();
ProcessComposites();
return;*/
m_surfacemesh->Remesh(m_blmesh);
/*m_mesh->m_nummode = 2;
m_mesh->m_expDim = 3;
m_mesh->m_element[2].clear();
ClearElementLinks();
ProcessVertices();
ProcessEdges();
ProcessFaces();
ProcessElements();
ProcessComposites();
return;*/
//create tet mesh
m_mesh->m_expDim = 3;
m_tet = MemoryManager<TetMesh>::AllocateSharedPtr(
m_mesh, octree, m_blmesh);
}
else
{
m_mesh->m_expDim = 3;
m_tet = MemoryManager<TetMesh>::AllocateSharedPtr(m_mesh, octree);
}
m_tet->Mesh();
//m_mesh->m_element[2].clear();
ClearElementLinks();
ProcessVertices();
ProcessEdges();
ProcessFaces();
ProcessElements();
ProcessComposites();
FaceSet::iterator fit;
count = 0;
for(fit = m_mesh->m_faceSet.begin(); fit != m_mesh->m_faceSet.end(); fit++)
ModuleSharedPtr vol = GetModuleFactory().CreateInstance(
ModuleKey(eProcessModule, "volumemesh"), m_mesh);
/*if(pSession->DefinesSolverInfo("SurfaceOpt"))
{
if((*fit)->m_elLink.size() != 2)
{
count++;
}
}
if (count - m_mesh->m_element[2].size() > 0)