35 #include <boost/geometry.hpp> 36 #include <boost/geometry/geometries/point.hpp> 37 #include <boost/geometry/geometries/box.hpp> 38 #include <boost/geometry/index/rtree.hpp> 43 namespace bg = boost::geometry;
44 namespace bgi = boost::geometry::index;
56 ProcessInsertSurface::create,
57 "Insert high-order surface mesh into current working mesh.");
64 ConfigOption(
false,
"",
"Relax tests for nonconforming boundries");
73 typedef bg::model::point<NekDouble, 3, bg::cs::cartesian>
Point;
74 typedef pair<Point, unsigned int> PointI;
78 cout <<
"ProcessInsertSurface: Inserting mesh... " << endl;
81 string file =
m_config[
"mesh"].as<
string>();
82 bool nonconform =
m_config[
"nonconforming"].beenSet;
86 cout <<
"inserting surface from " << file << endl;
89 inMsh->m_verbose =
m_mesh->m_verbose;
92 mod->RegisterConfig(
"infile", file);
102 for(
int i = 0; i < inMsh->m_element[2].size(); i++)
104 vector<NodeSharedPtr> ns = inMsh->m_element[2][i]->GetVertexList();
105 for(
int j = 0; j < ns.size(); j++)
107 surfaceNodes.insert(ns[j]);
111 vector<NodeSharedPtr> inMshnodeList(surfaceNodes.begin(), surfaceNodes.end());
113 vector<PointI> dataPts;
114 for(
int i = 0; i < inMshnodeList.size(); i++)
116 dataPts.push_back(make_pair(Point( inMshnodeList[i]->m_x,
117 inMshnodeList[i]->m_y,
118 inMshnodeList[i]->m_z), i));
122 bgi::rtree<PointI, bgi::rstar<16> > rtree;
123 rtree.insert(dataPts.begin(), dataPts.end());
125 surfaceNodes.clear();
126 for(
int i = 0; i <
m_mesh->m_element[2].size(); i++)
128 vector<NodeSharedPtr> ns =
m_mesh->m_element[2][i]->GetVertexList();
129 for(
int j = 0; j < ns.size(); j++)
131 surfaceNodes.insert(ns[j]);
137 ASSERTL0(surfaceNodes.size() == inMshnodeList.size(),
138 "surface mesh node count mismatch, will not work");
142 for(
int i = 0; i <
m_mesh->m_element[2].size(); i++)
145 vector<EdgeSharedPtr> es = f->m_edgeList;
146 for(
int j = 0; j < es.size(); j++)
148 surfEdges.insert(es[j]);
152 for(
auto &it : surfEdges)
154 Point queryPt1(it->m_n1->m_x, it->m_n1->m_y, it->m_n1->m_z);
155 vector<PointI> result;
156 rtree.query(bgi::nearest(queryPt1, 1), std::back_inserter(result));
158 NekDouble dist1 = bg::distance(result[0].first, queryPt1);
168 ASSERTL0(dist1 < tol,
"cannot locate point accurately enough");
173 Point queryPt2(it->m_n2->m_x, it->m_n2->m_y, it->m_n2->m_z);
175 rtree.query(bgi::nearest(queryPt2, 1), std::back_inserter(result));
177 NekDouble dist2 = bg::distance(result[0].first, queryPt2);
187 ASSERTL0(dist2 < tol,
"cannot locate point accurately enough");
193 auto f = inMsh->m_edgeSet.find(tst);
195 ASSERTL0(f != inMsh->m_edgeSet.end(),
"could not find edge in input");
197 it->m_edgeNodes = (*f)->m_edgeNodes;
198 it->m_curveType = (*f)->m_curveType;
200 if((*f)->m_n1->Distance(it->m_n1) > tol)
202 reverse(it->m_edgeNodes.begin(), it->m_edgeNodes.end());
#define ASSERTL0(condition, msg)
Represents an edge which joins two points.
std::unordered_set< EdgeSharedPtr, EdgeHash > EdgeSet
std::shared_ptr< Module > ModuleSharedPtr
MeshSharedPtr m_mesh
Mesh object.
virtual void Process()
Write mesh to output file.
std::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
std::shared_ptr< Node > NodeSharedPtr
std::unordered_set< NodeSharedPtr, NodeHash > NodeSet
std::shared_ptr< Face > FaceSharedPtr
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
std::pair< ModuleType, std::string > ModuleKey
Represents a command-line configuration option.
std::map< std::string, ConfigOption > m_config
List of configuration values.
virtual ~ProcessInsertSurface()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()