Commit 1d2c6b2f authored by Michael Turner's avatar Michael Turner
Browse files

rework of edgeloop and bug fix in orientations

parent 31b7f095
......@@ -104,6 +104,8 @@ void Generator2D::Process()
m_curvemeshes[i]->Mesh();
}
////////////////////////////////////////
EdgeSet::iterator it;
for (it = m_mesh->m_edgeSet.begin(); it != m_mesh->m_edgeSet.end(); it++)
{
......@@ -126,6 +128,15 @@ void Generator2D::Process()
m_mesh->m_element[1].push_back(E2);
}
for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
{
m_facemeshes[i] = MemoryManager<FaceMesh>::AllocateSharedPtr(
i, m_mesh, m_curvemeshes, 100);
m_facemeshes[i]->OrientateCurves();
}
if (m_config["blcurves"].beenSet)
{
// we need to do the boundary layer generation in a face by face basis
......@@ -138,10 +149,6 @@ void Generator2D::Process()
// orienation
for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
{
m_facemeshes[i] = MemoryManager<FaceMesh>::AllocateSharedPtr(
i, m_mesh, m_curvemeshes, 100);
m_facemeshes[i]->OrientateCurves();
MakeBL(i, m_facemeshes[i]->GetEdges());
}
}
......@@ -154,18 +161,26 @@ void Generator2D::Process()
}
// linear mesh all surfaces
for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
map<int,FaceMeshSharedPtr>::iterator fit;
int i = 1;
for(fit = m_facemeshes.begin(); fit != m_facemeshes.end(); fit++)
{
if (m_mesh->m_verbose)
{
LibUtilities::PrintProgressbar(i, m_mesh->m_cad->GetNumSurf(),
"Face progress");
LibUtilities::PrintProgressbar(
i, m_mesh->m_cad->GetNumSurf(), "Face progress");
}
m_facemeshes[i] = MemoryManager<FaceMesh>::AllocateSharedPtr(
i, m_mesh, m_curvemeshes, 100);
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();
}
m_facemeshes[i]->Mesh();
fit->second->Mesh();
i++;
}
ProcessVertices();
......@@ -196,14 +211,14 @@ void Generator2D::MakeBLPrep()
}
}
void Generator2D::MakeBL(int faceid, vector<EdgeLoop> e)
void Generator2D::MakeBL(int faceid, vector<EdgeLoopSharedPtr> e)
{
map<int, int> edgeToOrient;
for (vector<EdgeLoop>::iterator lit = e.begin(); lit != e.end(); ++lit)
for (int j = 0; j < e.size(); j++)
{
for (int i = 0; i < lit->edges.size(); ++i)
for (int i = 0; i < e[j]->edges.size(); ++i)
{
edgeToOrient[lit->edges[i]->GetId()] = lit->edgeo[i];
edgeToOrient[e[j]->edges[i]->GetId()] = e[j]->edgeo[i];
}
}
......
......@@ -67,7 +67,7 @@ private:
void MakeBLPrep();
void MakeBL(int faceid, std::vector<EdgeLoop> e);
void MakeBL(int faceid, std::vector<EdgeLoopSharedPtr> e);
void Report();
/// map of individual surface meshes from parametric surfaces
......
......@@ -72,7 +72,7 @@ public:
/**
* @brief Get the loop structures which bound the cad surface
*/
std::vector<EdgeLoop> GetEdges()
std::vector<EdgeLoopSharedPtr> GetEdges()
{
return m_edges;
}
......@@ -164,7 +164,7 @@ protected:
/// normal
bool m_correctNormal;
/// List of bounding edges in loops with orientation.
std::vector<EdgeLoop> m_edges;
std::vector<EdgeLoopSharedPtr> m_edges;
/// Function which tests the the value of uv used is within the surface
virtual void Test(Array<OneD, NekDouble> uv) = 0;
......
......@@ -70,6 +70,8 @@ struct EdgeLoop
NekDouble area;
};
typedef boost::shared_ptr<EdgeLoop> EdgeLoopSharedPtr;
/**
* @brief Base class for CAD interface system.
*
......
......@@ -45,7 +45,8 @@ namespace NekMeshUtils
std::string CADSurfOCE::key = GetCADSurfFactory().RegisterCreatorFunction(
"oce", CADSurfOCE::create, "CADSurfOCE");
void CADSurfOCE::Initialise(int i, TopoDS_Shape in, vector<EdgeLoop> ein)
void CADSurfOCE::Initialise(int i, TopoDS_Shape in,
vector<EdgeLoopSharedPtr> ein)
{
// this bit of code changes the units of the cad from mm opencascade
// defualt to m
......
......@@ -63,7 +63,7 @@ public:
{
}
void Initialise(int i, TopoDS_Shape in, std::vector<EdgeLoop> ein);
void Initialise(int i, TopoDS_Shape in, std::vector<EdgeLoopSharedPtr> ein);
virtual Array<OneD, NekDouble> GetBounds();
virtual Array<OneD, NekDouble> N (Array<OneD, NekDouble> uv);
......
......@@ -190,12 +190,12 @@ bool CADSystemOCE::LoadCAD()
}
}
vector<EdgeLoop> edgeloops;
vector<EdgeLoopSharedPtr> edgeloops;
// now we acutally analyse the loops for cad building
for (int j = 1; j <= mapOfWires.Extent(); j++)
{
EdgeLoop edgeloop;
EdgeLoopSharedPtr edgeloop = boost::shared_ptr<EdgeLoop>(new EdgeLoop);
TopoDS_Shape wire = mapOfWires.FindKey(j);
......@@ -217,7 +217,7 @@ bool CADSystemOCE::LoadCAD()
Array<OneD, NekDouble> cen(2);
cen[0] = p2.X();
cen[1] = p2.Y();
edgeloop.center = cen;
edgeloop->center = cen;
BRepTools_WireExplorer exp;
......@@ -230,8 +230,8 @@ bool CADSystemOCE::LoadCAD()
if (mapOfEdges.Contains(edge))
{
int e = mapOfEdges.FindIndex(edge);
edgeloop.edges.push_back(m_curves[e]);
edgeloop.edgeo.push_back(exp.Orientation());
edgeloop->edges.push_back(m_curves[e]);
edgeloop->edgeo.push_back(exp.Orientation());
adjsurfmap[e].push_back(i);
}
......@@ -310,7 +310,8 @@ void CADSystemOCE::AddCurve(int i, TopoDS_Shape in, int fv, int lv)
m_curves[i]->SetVert(vs);
}
void CADSystemOCE::AddSurf(int i, TopoDS_Shape in, vector<EdgeLoop> ein)
void CADSystemOCE::AddSurf(int i, TopoDS_Shape in,
vector<EdgeLoopSharedPtr> ein)
{
CADSurfSharedPtr newSurf = GetCADSurfFactory().CreateInstance(key);
boost::static_pointer_cast<CADSurfOCE>(newSurf)->Initialise(i, in, ein);
......@@ -324,7 +325,7 @@ void CADSystemOCE::AddSurf(int i, TopoDS_Shape in, vector<EdgeLoop> ein)
int tote = 0;
for (int i = 0; i < ein.size(); i++)
{
tote += ein[i].edges.size();
tote += ein[i]->edges.size();
}
ASSERTL0(tote != 1, "cannot handle periodic curves");
......
......@@ -71,7 +71,7 @@ private:
/// Function to add curve to CADSystem::m_curves.
void AddCurve(int i, TopoDS_Shape in, int fv, int lv);
/// Function to add surface to CADSystem::m_surfs.
void AddSurf(int i, TopoDS_Shape in, std::vector<EdgeLoop> ein);
void AddSurf(int i, TopoDS_Shape in, std::vector<EdgeLoopSharedPtr> ein);
TopoDS_Shape BuildNACA(std::string naca);
/// OCC master object
......
......@@ -49,9 +49,9 @@ bool FaceMesh::ValidateCurves()
vector<int> curvesInSurface;
for(int i = 0; i < m_edgeloops.size(); i++)
{
for(int j = 0; j < m_edgeloops[i].edges.size(); j++)
for(int j = 0; j < m_edgeloops[i]->edges.size(); j++)
{
curvesInSurface.push_back(m_edgeloops[i].edges[j]->GetId());
curvesInSurface.push_back(m_edgeloops[i]->edges[j]->GetId());
}
}
......@@ -125,7 +125,6 @@ bool FaceMesh::ValidateCurves()
void FaceMesh::Mesh()
{
Stretching();
OrientateCurves();
int numPoints = 0;
for (int i = 0; i < orderedLoops.size(); i++)
......@@ -143,9 +142,9 @@ void FaceMesh::Mesh()
ss << "curves: ";
for (int i = 0; i < m_edgeloops.size(); i++)
{
for (int j = 0; j < m_edgeloops[i].edges.size(); j++)
for (int j = 0; j < m_edgeloops[i]->edges.size(); j++)
{
ss << m_edgeloops[i].edges[j]->GetId() << " ";
ss << m_edgeloops[i]->edges[j]->GetId() << " ";
}
}
......@@ -158,7 +157,7 @@ void FaceMesh::Mesh()
vector<Array<OneD, NekDouble> > centers;
for (int i = 0; i < m_edgeloops.size(); i++)
{
centers.push_back(m_edgeloops[i].center);
centers.push_back(m_edgeloops[i]->center);
}
pplanemesh->Assign(orderedLoops, centers, m_id, m_str);
......@@ -1022,19 +1021,22 @@ void FaceMesh::AddNewPoint(Array<OneD, NekDouble> uv)
void FaceMesh::OrientateCurves()
{
//this could be a second run on orentate so clear some info
orderedLoops.clear();
// create list of bounding loop nodes
for (int i = 0; i < m_edgeloops.size(); i++)
{
vector<NodeSharedPtr> cE;
for (int j = 0; j < m_edgeloops[i].edges.size(); j++)
for (int j = 0; j < m_edgeloops[i]->edges.size(); j++)
{
int cid = m_edgeloops[i].edges[j]->GetId();
int cid = m_edgeloops[i]->edges[j]->GetId();
vector<NodeSharedPtr> edgePoints =
m_curvemeshes[cid]->GetMeshPoints();
int numPoints = m_curvemeshes[cid]->GetNumPoints();
if (m_edgeloops[i].edgeo[j] == 0)
if (m_edgeloops[i]->edgeo[j] == 0)
{
for (int k = 0; k < numPoints - 1; k++)
{
......@@ -1056,17 +1058,23 @@ void FaceMesh::OrientateCurves()
for (int i = 0; i < orderedLoops.size(); i++)
{
NekDouble area = 0.0;
for (int j = 0; j < orderedLoops[i].size() - 1; j++)
vector<Array<OneD, NekDouble> > info;
for (int j = 0; j < orderedLoops[i].size(); j++)
{
Array<OneD, NekDouble> n1info, n2info;
n1info = orderedLoops[i][j]->GetCADSurfInfo(m_id);
n2info = orderedLoops[i][j + 1]->GetCADSurfInfo(m_id);
info.push_back(orderedLoops[i][j]->GetCADSurfInfo(m_id));
}
area += -n2info[1] * (n2info[0] - n1info[0]) +
n1info[0] * (n2info[1] - n1info[1]);
for (int j = 0; j < info.size() - 1; j++)
{
area += -info[j+1][1] * (info[j+1][0] - info[j][0]) +
info[j][0] * (info[j+1][1] - info[j][1]);
}
area += -info[0][1] * (info[0][0] - info[info.size() - 1][0]) +
info[info.size() - 1][0] * (info[0][1] - info[info.size() - 1][1]);
area *= 0.5;
m_edgeloops[i].area = area;
m_edgeloops[i]->area = area;
}
int ct = 0;
......@@ -1076,18 +1084,11 @@ void FaceMesh::OrientateCurves()
ct = 0;
for (int i = 0; i < m_edgeloops.size() - 1; i++)
{
if (fabs(m_edgeloops[i].area) < fabs(m_edgeloops[i + 1].area))
if (fabs(m_edgeloops[i]->area) < fabs(m_edgeloops[i + 1]->area))
{
// swap
vector<NodeSharedPtr> orderedlooptmp = orderedLoops[i];
EdgeLoop edgeLoopstmp = m_edgeloops[i];
orderedLoops[i] = orderedLoops[i + 1];
m_edgeloops[i] = m_edgeloops[i + 1];
orderedLoops[i + 1] = orderedlooptmp;
m_edgeloops[i + 1] = edgeLoopstmp;
swap(orderedLoops[i],orderedLoops[i+1]);
swap(m_edgeloops[i],m_edgeloops[i+1]);
ct += 1;
}
}
......@@ -1204,46 +1205,47 @@ void FaceMesh::OrientateCurves()
}
}
m_edgeloops[i].center = P;
m_edgeloops[i]->center = P;
}
if (m_edgeloops[0].area < 0) // reverse the first uvLoop
if (m_edgeloops[0]->area < 0) // reverse the first uvLoop
{
vector<NodeSharedPtr> tmp = orderedLoops[0];
reverse(tmp.begin(), tmp.end());
orderedLoops[0] = tmp;
reverse(m_edgeloops[0]->edgeo.begin(),m_edgeloops[0]->edgeo.end());
reverse(m_edgeloops[0]->edges.begin(),m_edgeloops[0]->edges.end());
reverse(orderedLoops[0].begin(), orderedLoops[0].end());
//need to flip edgeo
for(int i = 0; i < m_edgeloops[0].edgeo.size(); i++)
for(int i = 0; i < m_edgeloops[0]->edgeo.size(); i++)
{
if(m_edgeloops[0].edgeo[i] == 0)
if(m_edgeloops[0]->edgeo[i] == 0)
{
m_edgeloops[0].edgeo[i] = 1;
m_edgeloops[0]->edgeo[i] = 1;
}
else
{
m_edgeloops[0].edgeo[i] = 0;
m_edgeloops[0]->edgeo[i] = 0;
}
}
}
for (int i = 1; i < orderedLoops.size(); i++)
{
if (m_edgeloops[i].area > 0) // reverse the loop
if (m_edgeloops[i]->area > 0) // reverse the loop
{
vector<NodeSharedPtr> tmp = orderedLoops[i];
reverse(tmp.begin(), tmp.end());
orderedLoops[i] = tmp;
m_edgeloops[i]->area*=-1.0;
reverse(m_edgeloops[i]->edgeo.begin(),m_edgeloops[i]->edgeo.end());
reverse(m_edgeloops[i]->edges.begin(),m_edgeloops[i]->edges.end());
reverse(orderedLoops[i].begin(), orderedLoops[i].end());
//need to flip edgeo
for(int j = 0; j < m_edgeloops[i].edgeo.size(); j++)
for(int j = 0; j < m_edgeloops[i]->edgeo.size(); j++)
{
if(m_edgeloops[i].edgeo[j] == 0)
if(m_edgeloops[i]->edgeo[j] == 0)
{
m_edgeloops[i].edgeo[j] = 1;
m_edgeloops[i]->edgeo[j] = 1;
}
else
{
m_edgeloops[i].edgeo[j] = 0;
m_edgeloops[i]->edgeo[j] = 0;
}
}
}
......
......@@ -78,13 +78,18 @@ public:
*/
bool ValidateCurves();
void ResetCurvemeshes(const std::map<int, CurveMeshSharedPtr> &cmeshes)
{
m_curvemeshes = cmeshes;
}
/**
* @brief Get the boundries of the surface and extracts the nodes from
* the curve meshes in the correct order
*/
void OrientateCurves();
std::vector<EdgeLoop> GetEdges()
std::vector<EdgeLoopSharedPtr> GetEdges()
{
return m_edgeloops;
}
......@@ -139,7 +144,7 @@ private:
std::map<int, CurveMeshSharedPtr> m_curvemeshes;
/// data structure containing the edges, their order and oreientation for
/// the surface
std::vector<EdgeLoop> m_edgeloops;
std::vector<EdgeLoopSharedPtr> m_edgeloops;
/// id of the surface mesh
int m_id;
/// list of boundary nodes in their order loops
......
......@@ -99,6 +99,7 @@ void SurfaceMesh::Process()
MemoryManager<FaceMesh>::AllocateSharedPtr(i,m_mesh,
m_curvemeshes, i);
m_facemeshes[i]->OrientateCurves();
validError = validError ? true : m_facemeshes[i]->ValidateCurves();
}
......
......@@ -145,13 +145,13 @@ void VolumeMesh::Process()
for (int i = 0; i < symsurfs.size(); i++)
{
set<int> cIds;
vector<EdgeLoop> e =
vector<EdgeLoopSharedPtr> e =
m_mesh->m_cad->GetSurf(symsurfs[i])->GetEdges();
for (int i = 0; i < e.size(); i++)
{
for (int j = 0; j < e[i].edges.size(); j++)
for (int j = 0; j < e[i]->edges.size(); j++)
{
cIds.insert(e[i].edges[j]->GetId());
cIds.insert(e[i]->edges[j]->GetId());
}
}
......
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