Commit 32a754b8 authored by Dave Moxey's avatar Dave Moxey

Merge branch 'feature/meshing_tools' into 'master'

Feature/meshing release

This merge request is the massive clean up, reformatting and documenting (WIP) of the mesh generation routines.
This is the release candidate we can iterate on with smaller branches in the future.

See merge request !704
parents 8a902627 32f0248b
......@@ -78,6 +78,7 @@ v4.4.0
- 2D to 3D mesh extrusion module (!715)
- Add a mesh extract option to the linearise module to visualise the result
(!712)
- Refactor library to use NekMesh modules for CAD generation (!704)
**FieldConvert:**
- Move all modules to a new library, FieldUtils, to support post-processing
......
......@@ -296,10 +296,6 @@ ELSE( NEKTAR_USE_MEMORY_POOLS )
REMOVE_DEFINITIONS(-DNEKTAR_MEMORY_POOL_ENABLED)
ENDIF( NEKTAR_USE_MEMORY_POOLS )
IF (NEKTAR_USE_MESHGEN)
ADD_DEFINITIONS(-DNEKTAR_USE_MESHGEN)
ENDIF()
SET(Boost_USE_STATIC_LIBS OFF)
IF( WIN32 )
# The auto-linking feature has problems with USE_STATIC_LIBS off, so we use
......
This diff is collapsed.
......@@ -36,7 +36,7 @@
#ifndef NEKMESHUTILS_CADSYSTEM_CADCURVE
#define NEKMESHUTILS_CADSYSTEM_CADCURVE
#include <NekMeshUtils/CADSystem/CADObj.h>
#include <NekMeshUtils/CADSystem/CADObject.h>
#include <NekMeshUtils/CADSystem/CADVert.h>
#include <NekMeshUtils/CADSystem/CADSurf.h>
......@@ -49,7 +49,7 @@ namespace NekMeshUtils
* @brief base class for CAD curves.
*
*/
class CADCurve : public CADObj
class CADCurve : public CADObject
{
public:
friend class MemoryManager<CADCurve>;
......@@ -57,7 +57,10 @@ public:
/**
* @brief Default constructor.
*/
CADCurve(){};
CADCurve()
{
m_type = CADType::eCurve;
}
~CADCurve()
{
......
......@@ -45,26 +45,29 @@ namespace Nektar
namespace NekMeshUtils
{
namespace CADType
{
enum cadType
{
vert,
curve,
surf
eVert,
eCurve,
eSurf
};
}
class CADObj
class CADObject
{
public:
friend class MemoryManager<CADObj>;
friend class MemoryManager<CADObject>;
/**
* @brief Default constructor.
*/
CADObj()
CADObject()
{
}
virtual ~CADObj(){}
virtual ~CADObject(){}
/**
* @brief Return ID of the vertex
......@@ -74,7 +77,7 @@ public:
return m_id;
}
cadType GetType()
CADType::cadType GetType()
{
return m_type;
}
......@@ -83,10 +86,10 @@ protected:
/// ID of the vert.
int m_id;
/// type of the cad object
cadType m_type;
CADType::cadType m_type;
};
typedef boost::shared_ptr<CADObj> CADObjSharedPtr;
typedef boost::shared_ptr<CADObject> CADObjectSharedPtr;
}
}
......
......@@ -36,7 +36,7 @@
#ifndef NekMeshUtils_CADSYSTEM_CADSURF
#define NekMeshUtils_CADSYSTEM_CADSURF
#include <NekMeshUtils/CADSystem/CADObj.h>
#include <NekMeshUtils/CADSystem/CADObject.h>
#include <NekMeshUtils/CADSystem/CADVert.h>
#include <NekMeshUtils/CADSystem/CADSystem.h>
......@@ -52,7 +52,7 @@ typedef boost::shared_ptr<CADCurve> CADCurveSharedPtr;
* @brief base class for a cad surface
*/
class CADSurf : public CADObj
class CADSurf : public CADObject
{
public:
friend class MemoryManager<CADSurf>;
......@@ -62,6 +62,7 @@ public:
*/
CADSurf()
{
m_type = CADType::eSurf;
}
~CADSurf()
......
......@@ -43,6 +43,8 @@
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include "CADObject.h"
namespace Nektar
{
namespace NekMeshUtils
......
......@@ -41,7 +41,7 @@
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/Memory/NekMemoryManager.hpp>
#include <NekMeshUtils/CADSystem/CADObj.h>
#include <NekMeshUtils/CADSystem/CADObject.h>
#include <NekMeshUtils/MeshElements/Node.h>
namespace Nektar
......@@ -53,7 +53,7 @@ namespace NekMeshUtils
* @brief base class for CAD verticies.
*
*/
class CADVert : public CADObj
class CADVert : public CADObject
{
public:
friend class MemoryManager<CADVert>;
......@@ -63,6 +63,7 @@ public:
*/
CADVert()
{
m_type = CADType::eVert;
}
~CADVert(){};
......
......@@ -91,7 +91,6 @@ public:
m_c = BRep_Tool::Curve(TopoDS::Edge(cp), b[0], b[1]);
m_id = i;
m_type = curve;
}
private:
......
......@@ -59,7 +59,6 @@ void CADSurfOCE::Initialise(int i, TopoDS_Shape in, vector<EdgeLoop> ein)
m_occSurface = BRepAdaptor_Surface(TopoDS::Face(in));
m_correctNormal = true;
m_id = i;
m_type = surf;
}
Array<OneD, NekDouble> CADSurfOCE::GetBounds()
......
......@@ -61,7 +61,6 @@ void CADVertOCE::Initialise(int i, TopoDS_Shape in)
new Node(i - 1, m_occVert.X(), m_occVert.Y(), m_occVert.Z()));
degen = false;
m_type = vert;
}
}
......
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessLoadCAD.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: Load CAD module
//
////////////////////////////////////////////////////////////////////////////////
#include "ProcessLoadCAD.h"
#include <NekMeshUtils/CADSystem/CADSystem.h>
using namespace std;
namespace Nektar
{
namespace NekMeshUtils
{
ModuleKey ProcessLoadCAD::className = GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "loadcad"),
ProcessLoadCAD::create,
"Loads cad into m_mesh");
ProcessLoadCAD::ProcessLoadCAD(MeshSharedPtr m) : ProcessModule(m)
{
m_config["filename"] =
ConfigOption(false, "", "Generate prisms on these surfs");
}
ProcessLoadCAD::~ProcessLoadCAD()
{
}
void ProcessLoadCAD::Process()
{
m_mesh->m_CADId = m_config["filename"].as<string>();
if (m_mesh->m_verbose)
{
cout << "Loading CAD for " << m_mesh->m_CADId << endl;
}
m_mesh->m_cad = GetEngineFactory().CreateInstance("oce",m_mesh->m_CADId);
ASSERTL0(m_mesh->m_cad->LoadCAD(), "Failed to load CAD");
m_mesh->m_hasCAD = true;
if (m_mesh->m_verbose)
{
m_mesh->m_cad->Report();
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessLoadCAD.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: Load CAD module
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NEKMESHUTILS_NEKMESH_PROCESSLOADCAD
#define NEKMESHUTILS_NEKMESH_PROCESSLOADCAD
#include <NekMeshUtils/Module/Module.h>
namespace Nektar
{
namespace NekMeshUtils
{
class ProcessLoadCAD : public ProcessModule
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(MeshSharedPtr m)
{
return MemoryManager<ProcessLoadCAD>::AllocateSharedPtr(m);
}
static ModuleKey className;
ProcessLoadCAD(MeshSharedPtr m);
virtual ~ProcessLoadCAD();
virtual void Process();
};
}
}
#endif
SET(NEKMESHUTILS_SOURCES
Module/Module.cpp
MeshElements/Mesh.cpp
MeshElements/Element.cpp
MeshElements/Edge.cpp
......@@ -12,6 +13,8 @@ SET(NEKMESHUTILS_SOURCES
MeshElements/Pyramid.cpp
MeshElements/Prism.cpp
MeshElements/Hexahedron.cpp
CADSystem/CADSystem.cpp
CADSystem/ProcessLoadCAD.cpp
)
IF(NEKTAR_USE_MESHGEN)
......@@ -19,17 +22,18 @@ IF(NEKTAR_USE_MESHGEN)
SurfaceMeshing/CurveMesh.cpp
Octree/Octant.cpp
Octree/Octree.cpp
Octree/ProcessLoadOctree.cpp
SurfaceMeshing/SurfaceMesh.cpp
SurfaceMeshing/SurfaceMeshHOMesh.cpp
SurfaceMeshing/HOSurfaceMesh.cpp
SurfaceMeshing/FaceMesh.cpp
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
Optimisation/BGFS-B.cpp
Triangle/Triangle.cpp
CADSystem/CADSystem.cpp
CADSystem/OCE/CADSystemOCE.cpp
CADSystem/OCE/CADVertOCE.cpp
CADSystem/OCE/CADCurveOCE.cpp
......@@ -39,6 +43,7 @@ ENDIF()
SET(NEKMESHUTILS_HEADERS
NekMeshUtilsDeclspec.h
Module/Module.h
MeshElements/Node.h
MeshElements/Edge.h
MeshElements/Face.h
......@@ -55,6 +60,12 @@ SET(NEKMESHUTILS_HEADERS
MeshElements/Hexahedron.h
MeshElements/HOAlignment.h
MeshElements/ElementConfig.h
CADSystem/CADObject.h
CADSystem/CADSystem.h
CADSystem/CADVert.h
CADSystem/CADCurve.h
CADSystem/CADSurf.h
CADSystem/ProcessLoadCAD.h
)
IF(NEKTAR_USE_MESHGEN)
......@@ -63,18 +74,16 @@ IF(NEKTAR_USE_MESHGEN)
SurfaceMeshing/CurveMesh.h
Octree/Octant.h
Octree/Octree.h
Octree/ProcessLoadOctree.h
SurfaceMeshing/SurfaceMesh.h
SurfaceMeshing/HOSurfaceMesh.h
SurfaceMeshing/FaceMesh.h
SurfaceMeshing/OptimiseFunctions.h
ExtLibInterface/TriangleInterface.h
ExtLibInterface/TetGenInterface.h
TetMeshing/TetMesh.h
BLMeshing/BLMesh.h
CADSystem/CADObj.h
CADSystem/CADSystem.h
CADSystem/CADVert.h
CADSystem/CADCurve.h
CADSystem/CADSurf.h
VolumeMeshing/VolumeMesh.h
VolumeMeshing/TetMeshing/TetMesh.h
VolumeMeshing/BLMeshing/BLMesh.h
CADSystem/OCE/OpenCascade.h
CADSystem/OCE/CADSystemOCE.h
CADSystem/OCE/CADVertOCE.h
......
......@@ -118,7 +118,7 @@ void TetGenInterface::RefineMesh(std::map<int, NekDouble> delta)
input.pointmtrlist[i] = delta[i];
}
tetrahedralize("pYrmzqQO2/7o/120", &input, &output);
tetrahedralize("pYrmzq1.1/0QO2/7", &input, &output);
}
vector<Array<OneD, int> > TetGenInterface::Extract()
......
......@@ -43,7 +43,7 @@ namespace Nektar
namespace NekMeshUtils
{
void TriangleInterface::Mesh(bool Quiet, bool Quality)
void TriangleInterface::Mesh(bool Quality)
{
SetUp();
......@@ -116,11 +116,11 @@ void TriangleInterface::Mesh(bool Quiet, bool Quality)
if (Quality)
{
dt.triangulate("pqYY");
dt.triangulate("pqY");
}
else if (!Quality)
{
dt.triangulate("pYY");
dt.triangulate("pY");
}
}
......
......@@ -84,7 +84,7 @@ public:
/**
* @brief Execute meshing
*/
void Mesh(bool Quiet = true, bool Quality = false);
void Mesh(bool Quality = false);
/**
* @brief Extract mesh
......
......@@ -35,10 +35,8 @@
#include <NekMeshUtils/MeshElements/Edge.h>
#ifdef NEKTAR_USE_MESHGEN
#include <NekMeshUtils/CADSystem/CADCurve.h>
#include <NekMeshUtils/CADSystem/CADSurf.h>
#endif
#include <LibUtilities/Foundations/ManagerAccess.h>
......@@ -145,25 +143,25 @@ void Edge::MakeOrder(int order,
m_curveType = edgeType;
#ifdef NEKTAR_USE_MESHGEN
if(onSurf || onCurve)
if(m_parentCAD)
{
if(onCurve)
if(m_parentCAD->GetType() == CADType::eCurve)
{
CADCurveSharedPtr c = boost::dynamic_pointer_cast<CADCurve>(m_parentCAD);
for(int i = 0; i < m_edgeNodes.size(); i++)
{
Array<OneD, NekDouble> loc(3);
loc[0] = m_edgeNodes[i]->m_x;
loc[1] = m_edgeNodes[i]->m_y;
loc[2] = m_edgeNodes[i]->m_z;
NekDouble t = CADCurve->loct(loc);
m_edgeNodes[i]->SetCADCurve(CADCurveId,CADCurve,t);
loc = CADCurve->P(t);
NekDouble t = c->loct(loc);
m_edgeNodes[i]->SetCADCurve(c->GetId(),c,t);
loc = c->P(t);
m_edgeNodes[i]->m_x = loc[0];
m_edgeNodes[i]->m_y = loc[1];
m_edgeNodes[i]->m_z = loc[2];
std::vector<CADSurfSharedPtr> s = CADCurve->GetAdjSurf();
std::vector<CADSurfSharedPtr> s = c->GetAdjSurf();
for(int j = 0; j < s.size(); j++)
{
Array<OneD, NekDouble> uv = s[j]->locuv(loc);
......@@ -173,22 +171,22 @@ void Edge::MakeOrder(int order,
}
else
{
CADSurfSharedPtr s = boost::dynamic_pointer_cast<CADSurf>(m_parentCAD);
for(int i = 0; i < m_edgeNodes.size(); i++)
{
Array<OneD, NekDouble> loc(3);
loc[0] = m_edgeNodes[i]->m_x;
loc[1] = m_edgeNodes[i]->m_y;
loc[2] = m_edgeNodes[i]->m_z;
Array<OneD, NekDouble> uv = CADSurf->locuv(loc);
loc = CADSurf->P(uv);
Array<OneD, NekDouble> uv = s->locuv(loc);
loc = s->P(uv);
m_edgeNodes[i]->m_x = loc[0];
m_edgeNodes[i]->m_y = loc[1];
m_edgeNodes[i]->m_z = loc[2];
m_edgeNodes[i]->SetCADSurf(CADSurfId,CADSurf,uv);
m_edgeNodes[i]->SetCADSurf(s->GetId(),s,uv);
}
}
}
#endif
}
}
......
......@@ -64,23 +64,12 @@ public:
std::vector<NodeSharedPtr> pEdgeNodes,
LibUtilities::PointsType pCurveType)
: m_n1(pVertex1), m_n2(pVertex2), m_edgeNodes(pEdgeNodes),
m_curveType(pCurveType), m_geom()
{
#ifdef NEKTAR_USE_MESHGEN
onCurve = false;
onSurf = false;
#endif
}
m_curveType(pCurveType), m_geom(){}
/// Creates a new linear edge.
NEKMESHUTILS_EXPORT Edge(NodeSharedPtr pVertex1, NodeSharedPtr pVertex2)
: m_n1(pVertex1), m_n2(pVertex2), m_edgeNodes(), m_curveType(), m_geom()
{
#ifdef NEKTAR_USE_MESHGEN
onCurve = false;
onSurf = false;
#endif
}
{}
/// Copies an existing edge.
NEKMESHUTILS_EXPORT Edge(const Edge &pSrc)
......@@ -137,14 +126,7 @@ public:
/// Element(s) which are linked to this edge.
std::vector<std::pair<ElementSharedPtr, int> > m_elLink;
#ifdef NEKTAR_USE_MESHGEN
bool onCurve;
int CADCurveId;
CADCurveSharedPtr CADCurve;
bool onSurf;
int CADSurfId;
CADSurfSharedPtr CADSurf;
#endif
CADObjectSharedPtr m_parentCAD;
private:
SpatialDomains::SegGeomSharedPtr m_geom;
......
......@@ -365,9 +365,7 @@ public:
std::swap(m_vertex[0],m_vertex[1]);
}
#ifdef NEKTAR_USE_MESHGEN
int CADSurfId;
#endif
CADObjectSharedPtr m_parentCAD;
protected:
/// ID of the element.
......
......@@ -35,9 +35,7 @@
#include <NekMeshUtils/MeshElements/Face.h>
#ifdef NEKTAR_USE_MESHGEN
#include <NekMeshUtils/CADSystem/CADSurf.h>
#endif
#include <LibUtilities/Foundations/ManagerAccess.h>
......@@ -255,24 +253,24 @@ void Face::MakeOrder(int order,
{
ASSERTL0(false, "Unknown number of vertices");
}
#ifdef NEKTAR_USE_MESHGEN
if(onSurf)
if(m_parentCAD)
{
CADSurfSharedPtr s = boost::dynamic_pointer_cast<CADSurf>(m_parentCAD);
for(int i = 0; i < m_faceNodes.size(); i++)
{
Array<OneD, NekDouble> loc(3);
loc[0] = m_faceNodes[i]->m_x;
loc[1] = m_faceNodes[i]->m_y;
loc[2] = m_faceNodes[i]->m_z;
Array<OneD, NekDouble> uv = CADSurf->locuv(loc);
loc = CADSurf->P(uv);
Array<OneD, NekDouble> uv = s->locuv(loc);
loc = s->P(uv);
m_faceNodes[i]->m_x = loc[0];
m_faceNodes[i]->m_y = loc[1];
m_faceNodes[i]->m_z = loc[2];
m_faceNodes[i]->SetCADSurf(CADSurfId,CADSurf,uv);
m_faceNodes[i]->SetCADSurf(s->GetId(),s,uv);
}
}
#endif
}
SpatialDomains::Geometry2DSharedPtr Face::GetGeom(int coordDim)
......
......@@ -67,23 +67,14 @@ public:
std::vector<EdgeSharedPtr> pEdgeList,
LibUtilities::PointsType pCurveType)
: m_vertexList(pVertexList), m_edgeList(pEdgeList),
m_faceNodes(pFaceNodes), m_curveType(pCurveType), m_geom()
{
#ifdef NEKTAR_USE_MESHGEN
onSurf = false;
#endif
}
m_faceNodes(pFaceNodes), m_curveType(pCurveType), m_geom(){}
/// Copy an existing face.
NEKMESHUTILS_EXPORT Face(const Face &pSrc)
: m_vertexList(pSrc.m_vertexList), m_edgeList(pSrc.m_edgeList),
m_faceNodes(pSrc.m_faceNodes), m_curveType(pSrc.m_curveType),
m_geom(pSrc.m_geom)
{
#ifdef NEKTAR_USE_MESHGEN
onSurf = false;