Commit 659324a9 authored by Michael Turner's avatar Michael Turner

organise 2D

parent 5a1c15ad
......@@ -114,7 +114,7 @@ void Generator2D::Process()
// orienation
for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
{
MakeBL(i, m_facemeshes[i]->GetEdges());
MakeBL(i);
}
}
......@@ -124,9 +124,7 @@ void Generator2D::Process()
}
// linear mesh all surfaces
map<int, FaceMeshSharedPtr>::iterator fit;
int i = 1;
for (fit = m_facemeshes.begin(); fit != m_facemeshes.end(); fit++)
for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
{
if (m_mesh->m_verbose)
{
......@@ -134,16 +132,10 @@ void Generator2D::Process()
"Face progress");
}
if (m_config["blcurves"].beenSet)
{
// for bl surfaces orientate curves needs to be run again to
// push nodes to the edges of the system
fit->second->ResetCurvemeshes(m_curvemeshes);
fit->second->OrientateCurves();
}
fit->second->Mesh();
i++;
m_facemeshes[i] =
MemoryManager<FaceMesh>::AllocateSharedPtr(i,m_mesh,
m_curvemeshes, i);
m_facemeshes[i]->Mesh();
}
////////////////////////////////////
......@@ -202,17 +194,8 @@ void Generator2D::MakeBLPrep()
}
}
void Generator2D::MakeBL(int faceid, vector<EdgeLoopSharedPtr> e)
void Generator2D::MakeBL(int faceid)
{
map<int, int> edgeToOrient;
for (int j = 0; j < e.size(); j++)
{
for (int i = 0; i < e[j]->edges.size(); ++i)
{
edgeToOrient[e[j]->edges[i]->GetId()] = e[j]->edgeo[i];
}
}
map<int, Array<OneD, NekDouble> > edgeNormals;
int eid = 0;
......@@ -220,7 +203,7 @@ void Generator2D::MakeBL(int faceid, vector<EdgeLoopSharedPtr> e)
for (vector<unsigned>::iterator it = m_blCurves.begin();
it != m_blCurves.end(); ++it)
{
int edgeo = edgeToOrient[*it];
CADSystem::Orientation edgeo = m_mesh->m_cad->GetCurve(*it)->GetOrienationWRT(faceid);
vector<EdgeSharedPtr> es = m_curvemeshes[*it]->GetMeshEdges();
......@@ -229,10 +212,13 @@ void Generator2D::MakeBL(int faceid, vector<EdgeLoopSharedPtr> e)
for (int j = 0; j < es.size(); j++)
{
es[j]->m_id = eid++;
Array<OneD, NekDouble> p1 =
(edgeo == 0) ? es[j]->m_n1->GetLoc() : es[j]->m_n2->GetLoc();
Array<OneD, NekDouble> p2 =
(edgeo == 0) ? es[j]->m_n2->GetLoc() : es[j]->m_n1->GetLoc();
Array<OneD, NekDouble> p1, p2;
p1 = es[j]->m_n1->GetLoc();
p2 = es[j]->m_n2->GetLoc();
if(edgeo == CADSystem::eBackwards)
{
swap(p1, p2);
}
Array<OneD, NekDouble> n(2);
n[0] = p1[1] - p2[1];
n[1] = p2[0] - p1[0];
......@@ -277,7 +263,7 @@ void Generator2D::MakeBL(int faceid, vector<EdgeLoopSharedPtr> e)
for (vector<unsigned>::iterator it = m_blCurves.begin();
it != m_blCurves.end(); ++it)
{
int edgeo = edgeToOrient[*it];
CADSystem::Orientation edgeo = m_mesh->m_cad->GetCurve(*it)->GetOrienationWRT(faceid);
vector<NodeSharedPtr> ns = m_curvemeshes[*it]->GetMeshPoints();
vector<NodeSharedPtr> newNs;
......@@ -288,7 +274,7 @@ void Generator2D::MakeBL(int faceid, vector<EdgeLoopSharedPtr> e)
m_curvemeshes[*it] =
MemoryManager<CurveMesh>::AllocateSharedPtr(*it, m_mesh, newNs);
if (edgeo == 1)
if (edgeo == CADSystem::eBackwards)
{
reverse(ns.begin(), ns.end());
}
......
......@@ -69,7 +69,7 @@ private:
void MakeBLPrep();
void MakeBL(int faceid, std::vector<EdgeLoopSharedPtr> e);
void MakeBL(int faceid);
void Report();
/// map of individual surface meshes from parametric surfaces
......
......@@ -120,7 +120,7 @@ public:
/**
* @brief set the ids of the surfaces either side of the curve
*/
void SetAdjSurf(std::pair<CADSurfSharedPtr, Orientation> i)
void SetAdjSurf(std::pair<CADSurfSharedPtr, CADSystem::Orientation> i)
{
m_adjSurfs.push_back(i);
}
......@@ -128,7 +128,7 @@ public:
/*
* @brief returns the ids of neigbouring surfaces
*/
std::vector<std::pair<CADSurfSharedPtr, Orientation> > GetAdjSurf()
std::vector<std::pair<CADSurfSharedPtr, CADSystem::Orientation> > GetAdjSurf()
{
return m_adjSurfs;
}
......@@ -163,12 +163,27 @@ public:
*/
virtual NekDouble loct(Array<OneD, NekDouble> xyz) = 0;
CADSystem::Orientation GetOrienationWRT(int surf)
{
for(int i = 0; i < m_adjSurfs.size(); i++)
{
if(m_adjSurfs[i].first->GetId() == surf)
{
return m_adjSurfs[i].second;
}
}
ASSERTL0(false,"surf not in adjecency list");
return CADSystem::eUnknown;
}
protected:
/// Length of edge
NekDouble m_length;
/// List of surfaces which this curve belongs to.
std::vector<std::pair<CADSurfSharedPtr, Orientation> > m_adjSurfs;
std::vector<std::pair<CADSurfSharedPtr, CADSystem::Orientation> > m_adjSurfs;
/// list of end vertices
std::vector<CADVertSharedPtr> m_mainVerts;
};
......
......@@ -44,7 +44,7 @@ namespace NekMeshUtils
{
void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
vector<EdgeLoopSharedPtr> &ein)
vector<CADSystem::EdgeLoopSharedPtr> &ein)
{
// this piece of code orientates the surface,
// it used to be face mesh but its easier to have it here
......@@ -56,7 +56,7 @@ void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
{
Array<OneD, NekDouble> bnds = ein[i]->edges[j]->GetBounds();
NekDouble dt = (bnds[1] - bnds[0]) / (20 - 1);
if (ein[i]->edgeo[j] == eForwards)
if (ein[i]->edgeo[j] == CADSystem::eForwards)
{
for (int k = 0; k < 20; k++)
{
......@@ -238,13 +238,13 @@ void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
// need to flip edgeo
for (int i = 0; i < ein[0]->edgeo.size(); i++)
{
if (ein[0]->edgeo[i] == eForwards)
if (ein[0]->edgeo[i] == CADSystem::eForwards)
{
ein[0]->edgeo[i] = eBackwards;
ein[0]->edgeo[i] = CADSystem::eBackwards;
}
else
{
ein[0]->edgeo[i] = eForwards;
ein[0]->edgeo[i] = CADSystem::eForwards;
}
}
}
......@@ -260,13 +260,13 @@ void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
// need to flip edgeo
for (int j = 0; j < ein[i]->edgeo.size(); j++)
{
if (ein[i]->edgeo[j] == eForwards)
if (ein[i]->edgeo[j] == CADSystem::eForwards)
{
ein[i]->edgeo[j] = eBackwards;
ein[i]->edgeo[j] = CADSystem::eBackwards;
}
else
{
ein[i]->edgeo[j] = eForwards;
ein[i]->edgeo[j] = CADSystem::eForwards;
}
}
}
......
......@@ -70,17 +70,17 @@ public:
}
static void OrientateEdges(
CADSurfSharedPtr surf, std::vector<EdgeLoopSharedPtr> &ein);
CADSurfSharedPtr surf, std::vector<CADSystem::EdgeLoopSharedPtr> &ein);
/**
* @brief Get the loop structures which bound the cad surface
*/
std::vector<EdgeLoopSharedPtr> GetEdges()
std::vector<CADSystem::EdgeLoopSharedPtr> GetEdges()
{
return m_edges;
}
void SetEdges(std::vector<EdgeLoopSharedPtr> ein)
void SetEdges(std::vector<CADSystem::EdgeLoopSharedPtr> ein)
{
m_edges = ein;
}
......@@ -174,7 +174,7 @@ protected:
/// normal
bool m_correctNormal;
/// List of bounding edges in loops with orientation.
std::vector<EdgeLoopSharedPtr> m_edges;
std::vector<CADSystem::EdgeLoopSharedPtr> m_edges;
/// Function which tests the the value of uv used is within the surface
virtual void Test(Array<OneD, NekDouble> uv) = 0;
......
......@@ -58,25 +58,7 @@ typedef boost::shared_ptr<CADCurve> CADCurveSharedPtr;
class CADSurf;
typedef boost::shared_ptr<CADSurf> CADSurfSharedPtr;
enum Orientation
{
eForwards,
eBackwards
};
/**
* @brief struct which descibes a collection of cad edges which are a
* loop on the cad surface
*/
struct EdgeLoop
{
std::vector<CADCurveSharedPtr> edges;
std::vector<Orientation> edgeo;
Array<OneD, NekDouble> center;
NekDouble area;
};
typedef boost::shared_ptr<EdgeLoop> EdgeLoopSharedPtr;
/**
* @brief Base class for CAD interface system.
......@@ -89,6 +71,27 @@ class CADSystem
public:
friend class MemoryManager<CADSystem>;
enum Orientation
{
eUnknown,
eForwards,
eBackwards
};
/**
* @brief struct which descibes a collection of cad edges which are a
* loop on the cad surface
*/
struct EdgeLoop
{
std::vector<CADCurveSharedPtr> edges;
std::vector<Orientation> edgeo;
Array<OneD, NekDouble> center;
NekDouble area;
};
typedef boost::shared_ptr<EdgeLoop> EdgeLoopSharedPtr;
/**
* @brief Default constructor.
*/
......
......@@ -161,7 +161,7 @@ void Edge::MakeOrder(int order,
m_edgeNodes[i]->m_y = loc[1];
m_edgeNodes[i]->m_z = loc[2];
std::vector<std::pair<CADSurfSharedPtr, Orientation> > s = c->GetAdjSurf();
std::vector<std::pair<CADSurfSharedPtr, CADSystem::Orientation> > s = c->GetAdjSurf();
for(int j = 0; j < s.size(); j++)
{
Array<OneD, NekDouble> uv(2);
......
......@@ -99,12 +99,6 @@ void Octree::Process()
}
}
NekDouble Octree::QueryR(Array<OneD, NekDouble> loc)
{
NekDouble d = Query(loc);
return d / 2.0 / (sqrt(m_eps * (2.0 - m_eps)));
}
NekDouble Octree::Query(Array<OneD, NekDouble> loc)
{
// starting at master octant 0 move through succsesive m_octants which
......@@ -856,8 +850,9 @@ void Octree::CompileSourcePointList()
Array<OneD, NekDouble> loc = curve->P(t);
vector<pair<CADSurfSharedPtr, Orientation> > ss = curve->GetAdjSurf();
Array<OneD, NekDouble> uv = ss[0].first->locuv(loc);
vector<pair<CADSurfSharedPtr, CADSystem::Orientation> > ss =
curve->GetAdjSurf();
Array<OneD, NekDouble> uv = ss[0].first->locuv(loc);
if (C != 0.0)
{
......
......@@ -127,8 +127,6 @@ public:
*/
NekDouble Query(Array<OneD, NekDouble> loc);
NekDouble QueryR(Array<OneD, NekDouble> loc);
/**
* @brief returns the miminum spacing in the octree (for meshing purposes)
*
......
......@@ -108,7 +108,7 @@ void CurveMesh::Mesh()
Array<OneD, NekDouble> loc;
vector<CADVertSharedPtr> verts = m_cadcurve->GetVertex();
vector<pair<CADSurfSharedPtr, Orientation> > s = m_cadcurve->GetAdjSurf();
vector<pair<CADSurfSharedPtr, CADSystem::Orientation> > s = m_cadcurve->GetAdjSurf();
NodeSharedPtr n = verts[0]->GetNode();
t = m_bounds[0];
......
......@@ -69,6 +69,12 @@ public:
m_cadcurve = m_mesh->m_cad->GetCurve(m_id);
}
CurveMesh(int id, MeshSharedPtr m, std::vector<NodeSharedPtr> ns)
: m_id(id), m_mesh(m), m_meshpoints(ns)
{
m_cadcurve = m_mesh->m_cad->GetCurve(m_id);
}
/**
* @brief execute meshing
*/
......
......@@ -1158,7 +1158,7 @@ void FaceMesh::OrientateCurves()
int numPoints = m_curvemeshes[cid]->GetNumPoints();
if (m_edgeloops[i]->edgeo[j] == eForwards)
if (m_edgeloops[i]->edgeo[j] == CADSystem::eForwards)
{
for (int k = 0; k < numPoints - 1; k++)
{
......
......@@ -135,7 +135,7 @@ private:
std::map<int, CurveMeshSharedPtr> m_curvemeshes;
/// data structure containing the edges, their order and oreientation for
/// the surface
std::vector<EdgeLoopSharedPtr> m_edgeloops;
std::vector<CADSystem::EdgeLoopSharedPtr> m_edgeloops;
/// id of the surface mesh
int m_id;
/// list of boundary nodes in their order loops
......
......@@ -257,7 +257,7 @@ void HOSurfaceMesh::Process()
// need to pull the solution out of opti
ti = opti->GetSolution();
}
vector<pair<CADSurfSharedPtr, Orientation> > s = c->GetAdjSurf();
vector<pair<CADSurfSharedPtr, CADSystem::Orientation> > s = c->GetAdjSurf();
for (int k = 1; k < m_mesh->m_nummode - 1; k++)
{
......
......@@ -98,7 +98,7 @@ void SurfaceMesh::Process()
m_facemeshes[i] =
MemoryManager<FaceMesh>::AllocateSharedPtr(i,m_mesh,
m_curvemeshes, i);
validError = validError ? true : m_facemeshes[i]->ValidateCurves();
}
......
......@@ -145,7 +145,7 @@ void VolumeMesh::Process()
for (int i = 0; i < symsurfs.size(); i++)
{
set<int> cIds;
vector<EdgeLoopSharedPtr> e =
vector<CADSystem::EdgeLoopSharedPtr> e =
m_mesh->m_cad->GetSurf(symsurfs[i])->GetEdges();
for (int i = 0; i < e.size(); i++)
{
......
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