Commit 6132bf3e authored by Michael Turner's avatar Michael Turner

Merge branch 'feature/tp-triangle' into 'master'

feature/tp-triangle

See merge request !883
parents e5c5f076 00e4df10
......@@ -48,6 +48,8 @@ v5.0.0
- Additional curve types in GEO reader: BSpline, Circle, Ellipse (!800)
- Fix default command line argument value (!823)
- Add projection meshing module which can curve linear meshes with CAD (!826)
- Revert triangle code to ThirdParty library (!883)
- Fix coinciding nodes issue with very fine meshes (!883)
**FieldConvert**:
- Add input module for Semtex field files (!777)
......
......@@ -245,6 +245,7 @@ INCLUDE (ThirdPartyArpack)
INCLUDE (ThirdPartyMPI)
INCLUDE (ThirdPartyVTK)
INCLUDE (ThirdPartyOCE)
INCLUDE (ThirdPartyTriangle)
INCLUDE (ThirdPartyTetGen)
INCLUDE (ThirdPartyCCM)
INCLUDE (FindCFI)
......
########################################################################
#
# ThirdParty configuration for Nektar++
#
# TRIANGLE
#
########################################################################
IF(NEKTAR_USE_MESHGEN)
SET(BUILD_TRIANGLE ON)
OPTION(THIRDPARTY_BUILD_TRIANGLE
"Build Triangle library from ThirdParty." ${BUILD_TRIANGLE})
IF (THIRDPARTY_BUILD_TRIANGLE)
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
triangle-1.6
PREFIX ${TPSRC}
URL ${TPURL}/triangle.zip
URL_MD5 357cb7107f51f3f89940c47435d4fa49
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/triangle-1.6
BINARY_DIR ${TPBUILD}/triangle-1.6
TMP_DIR ${TPBUILD}/triangle-1.6-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_GENERATOR}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
${TPSRC}/triangle-1.6
)
THIRDPARTY_LIBRARY(TRIANGLE_LIBRARY STATIC triangle
DESCRIPTION "Triangle library")
SET(TRIANGLE_INCLUDE_DIR ${TPDIST}/include CACHE FILEPATH
"Triangle include" FORCE)
MESSAGE(STATUS "Build Triangle: ${TRIANGLE_LIBRARY}")
SET(TRIANGLE_CONFIG_INCLUDE_DIR ${TPINC})
ELSE()
ADD_CUSTOM_TARGET(triangle-1.6 ALL)
MESSAGE(STATUS "Found Triangle: ${TRIANGLE_LIBRARY}")
SET(TRIANGLE_CONFIG_INCLUDE_DIR ${TRIANGLE_INCLUDE_DIR})
ENDIF (THIRDPARTY_BUILD_TRIANGLE)
MARK_AS_ADVANCED(TRIANGLE_LIBRARY)
MARK_AS_ADVANCED(TRIANGLE_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${TRIANGLE_INCLUDE_DIR})
ENDIF(NEKTAR_USE_MESHGEN)
......@@ -188,7 +188,7 @@ void Generator2D::Process()
nodes);
}
}
if (m_mesh->m_verbose)
{
cout << endl << "\tFace meshing:" << endl << endl;
......@@ -226,9 +226,6 @@ void Generator2D::Process()
m_mesh->m_element[1].push_back(E2);
}
// m_mesh->m_expDim = 1;
// m_mesh->m_element[2].clear();
ProcessVertices();
ProcessEdges();
ProcessFaces();
......
......@@ -61,24 +61,9 @@ void CADCurveOCE::Initialise(int i, TopoDS_Shape in)
NekDouble CADCurveOCE::tAtArcLength(NekDouble s)
{
NekDouble dt = (m_b[1] - m_b[0]) / (1000);
NekDouble t = m_b[0];
NekDouble len = 0.0;
while (len <= s)
{
gp_Pnt P1, P2;
gp_Vec drdt1, drdt2;
m_c->D1(t, P1, drdt1);
t += dt;
m_c->D1(t, P2, drdt2);
len += (drdt1.Magnitude() + drdt2.Magnitude()) / 2.0 * dt / 1000.0;
}
return t - dt;
GeomAdaptor_Curve c(m_c);
GCPnts_AbscissaPoint ap(c, s*1000.0, m_b[0]);
return ap.Parameter();
}
NekDouble CADCurveOCE::Length(NekDouble ti, NekDouble tf)
......
......@@ -68,6 +68,7 @@
#include <ShapeAnalysis_Curve.hxx>
#include <BRepBndLib.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <GCPnts_AbscissaPoint.hxx>
/// Shape fixing classes
#include <ShapeFix_Face.hxx>
......
......@@ -36,7 +36,6 @@ IF(NEKTAR_USE_MESHGEN)
VolumeMeshing/TetMeshing/TetMesh.cpp
VolumeMeshing/BLMeshing/BLMesh.cpp
Optimisation/BGFS-B.cpp
Triangle/Triangle.cpp
CADSystem/OCE/CADSystemOCE.cpp
CADSystem/OCE/CADVertOCE.cpp
CADSystem/OCE/CADCurveOCE.cpp
......@@ -95,7 +94,6 @@ IF(NEKTAR_USE_MESHGEN)
CADSystem/OCE/CADSurfOCE.h
Optimisation/BGFS-B.h
Optimisation/OptimiseObj.h
Triangle/Triangle.h
# 2DGenerator/2DGenerator.h
)
ENDIF()
......@@ -128,13 +126,14 @@ ADD_NEKTAR_LIBRARY(NekMeshUtils
IF(NEKTAR_USE_MESHGEN)
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PRIVATE ${TETGEN_LIBRARY})
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PRIVATE ${TRIANGLE_LIBRARY})
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PRIVATE ${OCC_LIBRARIES})
ADD_DEPENDENCIES(NekMeshUtils oce-0.17 tetgen-1.5)
ENDIF()
ADD_DEPENDENCIES(NekMeshUtils oce-0.17 tetgen-1.5 triangle-1.6)
IF(NEKTAR_USE_CFI)
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PRIVATE ${CFI_LIBRARIES})
IF(NEKTAR_USE_CFI)
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PRIVATE ${CFI_LIBRARIES})
ENDIF()
ENDIF()
INSTALL(DIRECTORY ./
......
......@@ -116,16 +116,16 @@ void TriangleInterface::Mesh(bool Quality)
string cmd;
if (Quality)
{
cmd = "pqY";
cmd = "pqzQY";
}
else if (!Quality)
{
cmd = "pY";
cmd = "pzQY";
}
char *cstr = new char[cmd.length() + 1];
strcpy(cstr, cmd.c_str());
dt.triangulate(cstr);
dt.Run(cstr);
}
void TriangleInterface::SetUp()
......
......@@ -42,7 +42,13 @@
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/Memory/NekMemoryManager.hpp>
#include <NekMeshUtils/Triangle/Triangle.h>
#define ANSI_DECLARATORS
#define REAL double
#define VOID void
extern "C"
{
#include <triangle.h>
}
namespace Nektar
{
......@@ -97,6 +103,16 @@ private:
*/
void SetUp();
struct DelaunayTriangle
{
public:
void Run(char* cmd)
{
triangulate(cmd, &in, &out, NULL);
}
struct triangulateio in, out;
};
/// List of bounding nodes to the surface
std::vector<std::vector<NodeSharedPtr> > m_boundingloops;
/// List of additional nodes
......
......@@ -836,14 +836,25 @@ int Octree::CountElemt()
void Octree::CompileSourcePointList()
{
int totalEnt = m_mesh->m_cad->GetNumSurf();
int preEnt = 0;
if(m_mesh->m_cad->Is2D())
{
totalEnt += m_mesh->m_cad->GetNumCurve();
preEnt += m_mesh->m_cad->GetNumCurve();
for (int i = 1; i <= m_mesh->m_cad->GetNumCurve(); i++)
{
if (m_mesh->m_verbose)
{
LibUtilities::PrintProgressbar(i, totalEnt,
"\tCompiling source points");
}
CADCurveSharedPtr curve = m_mesh->m_cad->GetCurve(i);
Array<OneD, NekDouble> bds = curve->GetBounds();
int samples = 100;
//this works assuming the curves are not distorted
int samples = ceil(curve->Length(bds[0],bds[1]) / m_minDelta) * 2;
samples = max(40, samples);
NekDouble dt = (bds[1] - bds[0]) / (samples + 1);
for (int j = 1; j < samples - 1; j++) // dont want first and last point
{
......@@ -891,7 +902,7 @@ void Octree::CompileSourcePointList()
{
if (m_mesh->m_verbose)
{
LibUtilities::PrintProgressbar(i, m_mesh->m_cad->GetNumSurf(),
LibUtilities::PrintProgressbar(preEnt + i, totalEnt,
"\tCompiling source points");
}
......@@ -959,8 +970,10 @@ void Octree::CompileSourcePointList()
// these are the acutal number of sample points in each parametric
// direction
int nu = ceil(DeltaU / m_minDelta) * 40 * 2;
int nv = ceil(DeltaV / m_minDelta) * 40 * 2;
int nu = ceil(DeltaU * 40 / m_minDelta) * 2;
int nv = ceil(DeltaV * 40 / m_minDelta) * 2;
nu = max(40, nu);
nv = max(40, nv);
for (int j = 0; j < nu; j++)
{
......
......@@ -420,7 +420,7 @@ void HOSurfaceMesh::Process()
}
// just add the face interior nodes through interp and project
/*vector<NodeSharedPtr> vertices = f->m_vertexList;
vector<NodeSharedPtr> vertices = f->m_vertexList;
SpatialDomains::GeometrySharedPtr geom = f->GetGeom(3);
geom->FillGeom();
......@@ -452,10 +452,8 @@ void HOSurfaceMesh::Process()
loc[1] = xmap->PhysEvaluate(xp, yc);
loc[2] = xmap->PhysEvaluate(xp, zc);
Array<OneD, NekDouble> uv(2);
s->locuv(loc,uv);
Array<OneD, NekDouble> uv = s->locuv(loc);
uvi.push_back(uv);
}
vector<NodeSharedPtr> honodes;
......@@ -489,10 +487,8 @@ void HOSurfaceMesh::Process()
loc[1] = xmap->PhysEvaluate(xp, yc);
loc[2] = xmap->PhysEvaluate(xp, zc);
Array<OneD, NekDouble> uv(2);
s->locuv(loc,uv);
Array<OneD, NekDouble> uv = s->locuv(loc);
uvi.push_back(uv);
}
}
......@@ -509,7 +505,7 @@ void HOSurfaceMesh::Process()
f->m_faceNodes = honodes;
f->m_curveType = LibUtilities::eGaussLobattoLegendre;
}*/
}
}
if (m_mesh->m_verbose)
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment