Commit f19ee743 authored by Michael Turner's avatar Michael Turner

move orientation so elements can see it

parent 25ec535d
......@@ -199,7 +199,7 @@ void Generator2D::MakeBL(int faceid)
for (vector<unsigned>::iterator it = m_blCurves.begin();
it != m_blCurves.end(); ++it)
{
CADSystem::Orientation edgeo =
CADOrientation::Orientation edgeo =
m_mesh->m_cad->GetCurve(*it)->GetOrienationWRT(faceid);
vector<EdgeSharedPtr> es = m_curvemeshes[*it]->GetMeshEdges();
......@@ -214,7 +214,7 @@ void Generator2D::MakeBL(int faceid)
Array<OneD, NekDouble> p1, p2;
p1 = es[j]->m_n1->GetCADSurfInfo(faceid);
p2 = es[j]->m_n2->GetCADSurfInfo(faceid);
if (edgeo == CADSystem::eBackwards)
if (edgeo == CADOrientation::eBackwards)
{
swap(p1, p2);
}
......@@ -276,7 +276,7 @@ void Generator2D::MakeBL(int faceid)
for (vector<unsigned>::iterator it = m_blCurves.begin();
it != m_blCurves.end(); ++it)
{
CADSystem::Orientation edgeo =
CADOrientation::Orientation edgeo =
m_mesh->m_cad->GetCurve(*it)->GetOrienationWRT(faceid);
vector<NodeSharedPtr> ns = m_curvemeshes[*it]->GetMeshPoints();
......@@ -288,7 +288,7 @@ void Generator2D::MakeBL(int faceid)
m_curvemeshes[*it] =
MemoryManager<CurveMesh>::AllocateSharedPtr(*it, m_mesh, newNs);
if (edgeo == CADSystem::eBackwards)
if (edgeo == CADOrientation::eBackwards)
{
reverse(ns.begin(), ns.end());
}
......
......@@ -120,7 +120,7 @@ public:
/**
* @brief set the ids of the surfaces either side of the curve
*/
void SetAdjSurf(std::pair<CADSurfSharedPtr, CADSystem::Orientation> i)
void SetAdjSurf(std::pair<CADSurfSharedPtr, CADOrientation::Orientation> i)
{
m_adjSurfs.push_back(i);
}
......@@ -128,7 +128,7 @@ public:
/*
* @brief returns the ids of neigbouring surfaces
*/
std::vector<std::pair<CADSurfSharedPtr, CADSystem::Orientation> > GetAdjSurf()
std::vector<std::pair<CADSurfSharedPtr, CADOrientation::Orientation> > GetAdjSurf()
{
return m_adjSurfs;
}
......@@ -163,7 +163,7 @@ public:
*/
virtual NekDouble loct(Array<OneD, NekDouble> xyz) = 0;
CADSystem::Orientation GetOrienationWRT(int surf)
CADOrientation::Orientation GetOrienationWRT(int surf)
{
for(int i = 0; i < m_adjSurfs.size(); i++)
{
......@@ -174,7 +174,7 @@ public:
}
ASSERTL0(false,"surf not in adjecency list");
return CADSystem::eUnknown;
return CADOrientation::eUnknown;
}
virtual Array<OneD, NekDouble> NormalWRT(NekDouble t, int surf)=0;
......@@ -186,7 +186,7 @@ protected:
/// Length of edge
NekDouble m_length;
/// List of surfaces which this curve belongs to.
std::vector<std::pair<CADSurfSharedPtr, CADSystem::Orientation> > m_adjSurfs;
std::vector<std::pair<CADSurfSharedPtr, CADOrientation::Orientation> > m_adjSurfs;
/// list of end vertices
std::vector<CADVertSharedPtr> m_mainVerts;
};
......
......@@ -55,6 +55,16 @@ enum cadType
};
}
namespace CADOrientation
{
enum Orientation
{
eUnknown,
eForwards,
eBackwards
};
}
class CADObject
{
public:
......@@ -67,7 +77,9 @@ public:
{
}
virtual ~CADObject(){}
virtual ~CADObject()
{
}
/**
* @brief Return ID of the vertex
......@@ -82,11 +94,19 @@ public:
return m_type;
}
virtual CADOrientation::Orientation Orientation()
{
ASSERTL0(false,"must be implemented at the cad object level");
return CADOrientation::eUnknown;
}
protected:
/// ID of the vert.
int m_id;
/// type of the cad object
CADType::cadType m_type;
/// orientation of the CADObject
CADOrientation::Orientation m_orientation;
};
typedef boost::shared_ptr<CADObject> CADObjectSharedPtr;
......
......@@ -64,7 +64,7 @@ void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
{
Array<OneD, NekDouble> bnds = ein[i]->edges[j]->GetBounds();
NekDouble dt = (bnds[1] - bnds[0]) / (np - 1);
if (ein[i]->edgeo[j] == CADSystem::eForwards)
if (ein[i]->edgeo[j] == CADOrientation::eForwards)
{
for (int k = 0; k < np-1; k++)
{
......
......@@ -60,9 +60,10 @@ public:
/**
* @brief Default constructor.
*/
CADSurf() : m_orient(CADSystem::eForwards)
CADSurf()
{
m_type = CADType::eSurf;
m_orientation = CADOrientation::eForwards;
}
~CADSurf()
......@@ -155,13 +156,12 @@ public:
/**
* @brief query reversed normal
*/
CADSystem::Orientation Orientation()
CADOrientation::Orientation Orientation()
{
return m_orient;
return m_orientation;
}
protected:
CADSystem::Orientation m_orient;
/// List of bounding edges in loops with orientation.
std::vector<CADSystem::EdgeLoopSharedPtr> m_edges;
......
......@@ -71,13 +71,6 @@ 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
......@@ -85,7 +78,7 @@ public:
struct EdgeLoop
{
std::vector<CADCurveSharedPtr> edges;
std::vector<Orientation> edgeo;
std::vector<CADOrientation::Orientation> edgeo;
Array<OneD, NekDouble> center;
NekDouble area;
};
......
......@@ -131,7 +131,7 @@ Array<OneD, NekDouble> CADCurveOCE::D2(NekDouble t)
Array<OneD, NekDouble> CADCurveOCE::NormalWRT(NekDouble t, int surf)
{
Array<OneD, NekDouble> p = P(t);
pair<CADSurfSharedPtr, CADSystem::Orientation> surface;
pair<CADSurfSharedPtr, CADOrientation::Orientation> surface;
ASSERTL0(m_adjSurfs.size() == 1, "This will only work in 2D for one surface at the moment");
surface = m_adjSurfs[0];
......@@ -141,7 +141,7 @@ Array<OneD, NekDouble> CADCurveOCE::NormalWRT(NekDouble t, int surf)
NekDouble t1 = t - 1e-8;
NekDouble t2 = t + 1e-8;
if(surface.second == CADSystem::eBackwards)
if(surface.second == CADOrientation::eBackwards)
{
swap(t1, t2);
}
......
......@@ -54,7 +54,7 @@ void CADSurfOCE::Initialise(int i, TopoDS_Shape in)
if (in.Orientation() == 1)
{
m_orient = CADSystem::eBackwards;
m_orientation = CADOrientation::eBackwards;
}
gp_Trsf transform;
......@@ -238,7 +238,7 @@ Array<OneD, NekDouble> CADSurfOCE::N(Array<OneD, NekDouble> uv)
Array<OneD, NekDouble> normal(3);
if (m_orient == CADSystem::eBackwards)
if (m_orientation == CADOrientation::eBackwards)
{
d.Reverse();
}
......
......@@ -208,8 +208,8 @@ void CADSystemOCE::AddSurf(int i, TopoDS_Shape in)
int e = mapOfEdges.FindIndex(edge);
edgeloop->edges.push_back(m_curves[e]);
edgeloop->edgeo.push_back(exp.Orientation() == TopAbs_FORWARD
? eForwards
: eBackwards);
? CADOrientation::eForwards
: CADOrientation::eBackwards);
}
exp.Next();
}
......
......@@ -105,14 +105,10 @@ SpatialDomains::SegGeomSharedPtr Edge::GetGeom(int coordDim)
return ret;
}
void Edge::MakeOrder(int order,
SpatialDomains::GeometrySharedPtr geom,
LibUtilities::PointsType edgeType,
int coordDim,
int &id)
void Edge::MakeOrder(int order, SpatialDomains::GeometrySharedPtr geom,
LibUtilities::PointsType edgeType, int coordDim, int &id)
{
int nPoints = order + 1;
int nPoints = order + 1;
StdRegions::StdExpansionSharedPtr xmap = geom->GetXmap();
Array<OneD, NekDouble> edgePoints;
......@@ -137,59 +133,63 @@ void Edge::MakeOrder(int order,
x[j] = xmap->PhysEvaluate(edgePoints + i, phys[j]);
}
m_edgeNodes[i-1] = boost::shared_ptr<Node>(
new Node(id++, x[0], x[1], x[2]));
m_edgeNodes[i - 1] =
boost::shared_ptr<Node>(new Node(id++, x[0], x[1], x[2]));
}
m_curveType = edgeType;
if(m_parentCAD)
if (m_parentCAD)
{
if(m_parentCAD->GetType() == CADType::eCurve)
if (m_parentCAD->GetType() == CADType::eCurve)
{
CADCurveSharedPtr c = boost::dynamic_pointer_cast<CADCurve>(m_parentCAD);
for(int i = 0; i < m_edgeNodes.size(); i++)
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;
loc[0] = m_edgeNodes[i]->m_x;
loc[1] = m_edgeNodes[i]->m_y;
loc[2] = m_edgeNodes[i]->m_z;
NekDouble t = c->loct(loc);
m_edgeNodes[i]->SetCADCurve(c->GetId(),c,t);
loc = c->P(t);
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<std::pair<CADSurfSharedPtr, CADSystem::Orientation> > s = c->GetAdjSurf();
for(int j = 0; j < s.size(); j++)
std::vector<
std::pair<CADSurfSharedPtr, CADOrientation::Orientation> >
s = c->GetAdjSurf();
for (int j = 0; j < s.size(); j++)
{
Array<OneD, NekDouble> uv(2);
s[j].first->ProjectTo(loc,uv);
m_edgeNodes[i]->SetCADSurf(s[j].first->GetId(),s[j].first,uv);
s[j].first->ProjectTo(loc, uv);
m_edgeNodes[i]->SetCADSurf(s[j].first->GetId(), s[j].first,
uv);
}
}
}
else
{
CADSurfSharedPtr s = boost::dynamic_pointer_cast<CADSurf>(m_parentCAD);
for(int i = 0; i < m_edgeNodes.size(); i++)
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(2);
s->ProjectTo(loc,uv);
loc = s->P(uv);
s->ProjectTo(loc, uv);
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(s->GetId(),s,uv);
m_edgeNodes[i]->SetCADSurf(s->GetId(), s, uv);
}
}
}
}
}
}
......@@ -358,7 +358,17 @@ public:
}
}
}
/**
* @brief returns the normal to the element
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> Normal(bool inward = false)
{
ASSERTL0(false,
"This function should be implemented at a shape level.");
return Array<OneD, NekDouble>();
}
CADObjectSharedPtr m_parentCAD;
protected:
......
......@@ -265,5 +265,46 @@ void Triangle::MakeOrder(int order,
m_conf.m_faceNodes = true;
m_conf.m_volumeNodes = false;
}
Array<OneD, NekDouble> Triangle::Normal(bool inward)
{
Array<OneD, NekDouble> ret(3,0.0);
ret[0] = (m_vertex[1]->m_y - m_vertex[0]->m_y) * (m_vertex[2]->m_z - m_vertex[0]->m_z) -
(m_vertex[1]->m_z - m_vertex[0]->m_z) * (m_vertex[2]->m_y - m_vertex[0]->m_y);
ret[1] = (m_vertex[1]->m_z - m_vertex[0]->m_z) * (m_vertex[2]->m_x - m_vertex[0]->m_x) -
(m_vertex[1]->m_x - m_vertex[0]->m_x) * (m_vertex[2]->m_z - m_vertex[0]->m_z);
ret[2] = (m_vertex[1]->m_x - m_vertex[0]->m_x) * (m_vertex[2]->m_y - m_vertex[0]->m_y) -
(m_vertex[1]->m_y - m_vertex[0]->m_y) * (m_vertex[2]->m_x - m_vertex[0]->m_x);
NekDouble mt = ret[0] * ret[0] + ret[1] * ret[1] + ret[2] * ret[2];
mt = sqrt(mt);
ret[0] /= mt;
ret[1] /= mt;
ret[2] /= mt;
if(m_parentCAD)
{
//has cad so can orientate
cout << "hit, partent switch" << endl;
if(m_parentCAD->Orientation() == CADOrientation::eBackwards)
{
ret[0] *= -1.0;
ret[1] *= -1.0;
ret[2] *= -1.0;
}
//by default normals point outwards so if we want inward for BLs
if(inward)
{
ret[0] *= -1.0;
ret[1] *= -1.0;
ret[2] *= -1.0;
}
}
return ret;
}
}
}
......@@ -85,6 +85,7 @@ public:
bool justConfig = false);
NEKMESHUTILS_EXPORT static unsigned int GetNumNodes(ElmtConfig pConf);
NEKMESHUTILS_EXPORT Array<OneD, NekDouble> Normal(bool inward = false);
};
}
......
......@@ -852,7 +852,7 @@ void Octree::CompileSourcePointList()
Array<OneD, NekDouble> loc = curve->P(t);
vector<pair<CADSurfSharedPtr, CADSystem::Orientation> > ss =
vector<pair<CADSurfSharedPtr, CADOrientation::Orientation> > ss =
curve->GetAdjSurf();
Array<OneD, NekDouble> uv = ss[0].first->locuv(loc);
......
......@@ -108,7 +108,7 @@ void CurveMesh::Mesh()
Array<OneD, NekDouble> loc;
vector<CADVertSharedPtr> verts = m_cadcurve->GetVertex();
vector<pair<CADSurfSharedPtr, CADSystem::Orientation> > s = m_cadcurve->GetAdjSurf();
vector<pair<CADSurfSharedPtr, CADOrientation::Orientation> > s = m_cadcurve->GetAdjSurf();
NodeSharedPtr n = verts[0]->GetNode();
t = m_bounds[0];
......
......@@ -1169,7 +1169,7 @@ void FaceMesh::OrientateCurves()
int numPoints = m_curvemeshes[cid]->GetNumPoints();
if (m_edgeloops[i]->edgeo[j] == CADSystem::eForwards)
if (m_edgeloops[i]->edgeo[j] == CADOrientation::eForwards)
{
for (int k = 0; k < numPoints - 1; k++)
{
......
......@@ -257,7 +257,7 @@ void HOSurfaceMesh::Process()
// need to pull the solution out of opti
ti = opti->GetSolution();
}
vector<pair<CADSurfSharedPtr, CADSystem::Orientation> > s = c->GetAdjSurf();
vector<pair<CADSurfSharedPtr, CADOrientation::Orientation> > s = c->GetAdjSurf();
for (int k = 1; k < m_mesh->m_nummode - 1; k++)
{
......
......@@ -192,6 +192,8 @@ inline bool Infont(NodeSharedPtr n, ElementSharedPtr el)
V[1] = n->m_y - ns1[0]->m_y;
V[2] = n->m_z - ns1[0]->m_z;
exit(-1);
NekDouble Nmag = sqrt(N1[0] * N1[0] + N1[1] * N1[1] + N1[2] * N1[2]);
NekDouble Vmag = sqrt(V[0] * V[0] + V[1] * V[1] + V[2] * V[2]);
......@@ -820,7 +822,7 @@ NekDouble BLMesh::Visability(vector<ElementSharedPtr> tris,
for (int i = 0; i < tris.size(); i++)
{
vector<NodeSharedPtr> ns = tris[i]->GetVertexList();
exit(-1);
Array<OneD, NekDouble> tmp(3, 0.0);
tmp[0] = (ns[1]->m_y - ns[0]->m_y) * (ns[2]->m_z - ns[0]->m_z) -
(ns[1]->m_z - ns[0]->m_z) * (ns[2]->m_y - ns[0]->m_y);
......@@ -846,6 +848,8 @@ Array<OneD, NekDouble> BLMesh::GetNormal(vector<ElementSharedPtr> tris)
{
vector<NodeSharedPtr> ns = tris[i]->GetVertexList();
exit(-1);
Array<OneD, NekDouble> tmp(3, 0.0);
tmp[0] = (ns[1]->m_y - ns[0]->m_y) * (ns[2]->m_z - ns[0]->m_z) -
(ns[1]->m_z - ns[0]->m_z) * (ns[2]->m_y - ns[0]->m_y);
......
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