44 std::map<Node*, bool> done;
51 for (
unsigned e = 0;
e < nelem;
e++)
54 for (
unsigned j = 0; j < nnod_el; j++)
64 std::ostringstream error_stream;
66 unsigned nnod=
nnode();
67 for (
unsigned j=0;j<nnod;j++)
72 <<
"Scaffold node " << j
73 <<
" does not seem to be attached to any element";
80 OOMPH_CURRENT_FUNCTION,
81 OOMPH_EXCEPTION_LOCATION);
100 std::ifstream element_file(ele_file_name.c_str(),std::ios_base::in);
103 if(!element_file.is_open())
105 std::string error_msg(
"Failed to open element file: ");
106 error_msg +=
"\"" + ele_file_name +
"\".";
108 OOMPH_EXCEPTION_LOCATION);
113 element_file>>n_element;
116 unsigned n_local_node;
117 element_file>>n_local_node;
120 std::ostringstream error_stream;
122 <<
"Triangle should only be used to generate 3-noded triangles!\n" 123 <<
"Your triangle input file, contains data for " 124 << n_local_node <<
"-noded triangles" << std::endl;
127 OOMPH_CURRENT_FUNCTION,
128 OOMPH_EXCEPTION_LOCATION);
132 unsigned dummy_attribute;
138 unsigned dummy_element_number;
144 std::map<unsigned,bool> global_node_done;
151 unsigned attribute_flag;
152 element_file>>attribute_flag;
155 if(attribute_flag==0)
157 for(
unsigned i=0;
i<n_element;
i++)
159 element_file>>dummy_element_number;
160 for(
unsigned j=0;j<n_local_node;j++)
164 global_node_done[Global_node[k]-1]=
true;
172 for(
unsigned i=0;
i<n_element;
i++)
174 element_file>>dummy_element_number;
175 for(
unsigned j=0;j<n_local_node;j++)
179 global_node_done[Global_node[k]-1]=
true;
186 element_file.close();
195 std::string err(
"Triangle is using 0-based indexing, ");
196 err +=
"however the oomph-lib interface can only handle 1-based indexing in Triangle.\n";
197 err +=
"This is likely to be due to the input file using 0-based indexing.";
198 err +=
"Alternatively you may have specified the -z flag when running Triangle.";
200 OOMPH_EXCEPTION_LOCATION);
209 std::ifstream node_file(node_file_name.c_str(),std::ios_base::in);
212 if(!node_file.is_open())
214 std::string error_msg(
"Failed to open node file: ");
215 error_msg +=
"\"" + node_file_name +
"\".";
217 OOMPH_EXCEPTION_LOCATION);
225 std::vector<bool> done(n_node,
false);
232 node_file>>dimension;
238 OOMPH_CURRENT_FUNCTION,
239 OOMPH_EXCEPTION_LOCATION);
244 node_file>> attribute_flag;
247 unsigned boundary_markers_flag;
248 node_file>>boundary_markers_flag;
251 unsigned dummy_node_number;
259 if (attribute_flag==0)
261 if(boundary_markers_flag==1)
263 for(
unsigned i=0;
i<n_node;
i++)
265 node_file>>dummy_node_number;
266 node_file>>x_node[
i];
267 node_file>>y_node[
i];
274 for(
unsigned i=0;
i<n_node;
i++)
276 node_file>>dummy_node_number;
277 node_file>>x_node[
i];
278 node_file>>y_node[
i];
286 if(boundary_markers_flag==1)
288 for(
unsigned i=0;
i<n_node;
i++)
290 node_file>>dummy_node_number;
291 node_file>>x_node[
i];
292 node_file>>y_node[
i];
293 node_file>>dummy_attribute;
300 for(
unsigned i=0;
i<n_node;
i++)
302 node_file>>dummy_node_number;
303 node_file>>x_node[
i];
304 node_file>>y_node[
i];
305 node_file>>dummy_attribute;
316 if(boundary_markers_flag==1)
319 for(
unsigned i=1;
i<n_node;
i++)
321 if (bound[
i]>n_bound)
332 std::ifstream poly_file(poly_file_name.c_str(),std::ios_base::in);
335 if(!poly_file.is_open())
337 std::string error_msg(
"Failed to open poly file: ");
338 error_msg +=
"\"" + poly_file_name +
"\".";
340 OOMPH_EXCEPTION_LOCATION);
344 unsigned n_node_poly;
345 poly_file>>n_node_poly;
348 poly_file>>dimension;
351 poly_file>> attribute_flag;
354 poly_file>>boundary_markers_flag;
362 if (attribute_flag==0)
364 if(boundary_markers_flag==1)
366 for(
unsigned i=0;
i<n_node_poly;
i++)
376 for(
unsigned i=0;
i<n_node_poly;
i++)
386 if(boundary_markers_flag==1)
388 for(
unsigned i=0;
i<n_node_poly;
i++)
399 for(
unsigned i=0;
i<n_node_poly;
i++)
416 poly_file>>n_segment;
419 poly_file>>boundary_markers_flag;
430 unsigned dummy_segment_number;
437 for(
unsigned i=0;
i<n_segment;
i++)
439 poly_file >> dummy_segment_number;
440 poly_file >> first_node[
i];
441 poly_file >> second_node[
i];
442 poly_file >> segment_boundary[
i];
444 if(segment_boundary[
i] > n_bound) {n_bound = segment_boundary[
i];}
446 node_on_edges[first_node[
i]].insert(
i);
447 node_on_edges[second_node[
i]].insert(
i);
460 for(
unsigned ihole=0;ihole<nhole;ihole++)
465 poly_file >> dummy_hole;
467 poly_file >> Hole_centre[ihole][1];
489 for(
unsigned e=0;
e<n_element;
e++)
492 for(
unsigned j=0;j<n_local_node;j++)
495 if(done[global_node_number-1]==
false)
499 if((boundary_markers_flag==1) &&
500 (bound[global_node_number-1]>0))
503 Node_pt[global_node_number-1] =
507 Node_pt[global_node_number-1]);
514 done[global_node_number-1]=
true;
515 Node_pt[global_node_number-1]->x(0)=x_node[global_node_number-1];
516 Node_pt[global_node_number-1]->x(1)=y_node[global_node_number-1];
534 unsigned glob_num[3]={0,0,0};
544 for(
unsigned e=0;
e<n_element;
e++)
550 for(
unsigned i=0;
i<3;
i++)
556 const unsigned element_offset =
e*n_local_node;
557 for(
unsigned i=0;
i<3;
i++)
569 for(
unsigned i=0;
i<3;
i++)
571 std::vector<unsigned> local_edge_index;
575 std::set_intersection(node_on_edges[glob_num[
i]].begin(),
576 node_on_edges[glob_num[
i]].end(),
577 node_on_edges[glob_num[(
i+1)%3]].begin(),
578 node_on_edges[glob_num[(
i+1)%3]].end(),
579 std::insert_iterator<std::vector<unsigned> >(
580 local_edge_index,local_edge_index.begin()));
584 if(local_edge_index.size() > 1)
587 "Nodes in scaffold mesh share more than one global edge",
588 OOMPH_CURRENT_FUNCTION,
589 OOMPH_EXCEPTION_LOCATION);
594 if(local_edge_index.size()==0)
605 else if(local_edge_index.size()==1)
610 if(local_edge_index[0] < n_segment)
628 std::ostringstream error_stream;
630 unsigned nnod=
nnode();
631 error_stream <<
"Checking presence of " << nnod <<
" global nodes\n";
632 for (
unsigned j=0;j<nnod;j++)
634 if (!global_node_done[j])
636 error_stream <<
"Global node " << j <<
" was not listed in *.ele file\n";
643 OOMPH_CURRENT_FUNCTION,
644 OOMPH_EXCEPTION_LOCATION);
653 #ifdef OOMPH_HAS_TRIANGLE_LIB 665 unsigned n_local_node =
static_cast<unsigned>(triangle_data.
numberofcorners);
668 std::ostringstream error_stream;
670 <<
"Triangle should only be used to generate 3-noded triangles!\n" 671 <<
"Your triangle input file, contains data for " 672 << n_local_node <<
"-noded triangles" << std::endl;
675 OOMPH_CURRENT_FUNCTION,
676 OOMPH_EXCEPTION_LOCATION);
686 std::map<unsigned,bool> global_node_done;
693 unsigned attribute_flag =
697 if(attribute_flag==0)
699 for(
unsigned i=0;
i<n_element;
i++)
701 for(
unsigned j=0;j<n_local_node;j++)
713 for(
unsigned i=0;
i<n_element;
i++)
715 for(
unsigned j=0;j<n_local_node;j++)
734 std::vector<bool> done(n_node,
false);
740 unsigned boundary_markers_flag = 0;
749 if(boundary_markers_flag==1)
751 for(
unsigned i=0;
i<n_node;
i++)
760 for(
unsigned i=0;
i<n_node;
i++)
771 if(boundary_markers_flag==1)
774 for(
unsigned i=1;
i<n_node;
i++)
776 if (bound[
i]>n_bound)
803 for(
unsigned i=0;
i<n_segment;
i++)
805 first_node[
i] =
static_cast<unsigned>(triangle_data.
segmentlist[2*
i]);
806 second_node[
i] =
static_cast<unsigned>(triangle_data.
segmentlist[2*
i+1]);
807 segment_boundary[
i] =
810 if(segment_boundary[
i] > n_bound) {n_bound = segment_boundary[
i];}
812 node_on_edges[first_node[
i]].insert(
i);
813 node_on_edges[second_node[
i]].insert(
i);
823 unsigned count_coords=0;
826 for(
unsigned ihole=0;ihole<nhole;ihole++)
856 for(
unsigned e=0;
e<n_element;
e++)
859 for(
unsigned j=0;j<n_local_node;j++)
862 if(done[global_node_number-1]==
false)
866 if((boundary_markers_flag==1) &&
867 (bound[global_node_number-1]>0))
870 Node_pt[global_node_number-1] =
875 Node_pt[global_node_number-1]);
882 done[global_node_number-1]=
true;
883 Node_pt[global_node_number-1]->x(0)=x_node[global_node_number-1];
884 Node_pt[global_node_number-1]->x(1)=y_node[global_node_number-1];
902 unsigned glob_num[3]={0,0,0};
912 for(
unsigned e=0;
e<n_element;
e++)
918 for(
unsigned i=0;
i<3;
i++)
924 const unsigned element_offset =
e*n_local_node;
925 for(
unsigned i=0;
i<3;
i++)
937 for(
unsigned i=0;
i<3;
i++)
939 std::vector<unsigned> local_edge_index;
943 std::set_intersection(node_on_edges[glob_num[
i]].begin(),
944 node_on_edges[glob_num[
i]].end(),
945 node_on_edges[glob_num[(
i+1)%3]].begin(),
946 node_on_edges[glob_num[(
i+1)%3]].end(),
947 std::insert_iterator<std::vector<unsigned> >(
948 local_edge_index,local_edge_index.begin()));
952 if(local_edge_index.size() > 1)
955 "Nodes in scaffold mesh share more than one global edge",
956 OOMPH_CURRENT_FUNCTION,
957 OOMPH_EXCEPTION_LOCATION);
963 if(local_edge_index.size()==0)
974 else if(local_edge_index.size()==1)
979 if(local_edge_index[0] < n_segment)
997 std::ostringstream error_stream;
999 unsigned nnod=
nnode();
1000 error_stream <<
"Checking presence of " << nnod <<
" global nodes\n";
1001 for (
unsigned j=0;j<nnod;j++)
1003 if (!global_node_done[j])
1005 error_stream <<
"Global node " << j <<
" was not listed in *.ele file\n";
1012 "This error means that some of the nodes are not connected \n" <<
1013 " to (bulk) elements. This can happen if there is an isolated\n" <<
1014 " boundary line in the mesh. One possible cause for this is\n" <<
1015 " specifying a hole coordinate in the wrong place so that there\n" <<
1016 " a gap between the mesh and the outer boundary.\n";
1018 OOMPH_CURRENT_FUNCTION,
1019 OOMPH_EXCEPTION_LOCATION);
double * pointlist
Pointer to list of points x coordinate followed by y coordinate.
Vector< Node * > Node_pt
Vector of pointers to nodes.
int * pointmarkerlist
Pointer to list of point markers.
void add_boundary_node(const unsigned &b, Node *const &node_pt)
Add a (pointer to) a node to the b-th boundary.
unsigned global_node_number(const unsigned &i)
Return the global node of each local node listed element-by-element e*n_local_node + n_local Note tha...
unsigned Nglobal_edge
Number of internal edges.
Vector< double > Element_attribute
Vector of double attributes for each element.
Vector< Vector< double > > Hole_centre
Vectors of hole centre coordinates.
Vector< Vector< unsigned > > Edge_index
Vector of vectors containing the global edge index of.
virtual Node * construct_boundary_node(const unsigned &n)
Construct the local node n as a boundary node; that is a node that MAY be placed on a mesh boundary a...
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
unsigned long nelement() const
Return number of elements in the mesh.
Vector< unsigned > Global_node
Storage for global node numbers listed element-by-element.
TriangleScaffoldMesh()
Empty constructor.
void check_mesh_integrity()
virtual Node * construct_node(const unsigned &n)
Construct the local node n and return a pointer to the newly created node object. ...
double * triangleattributelist
void set_nboundary(const unsigned &nbound)
Set the number of boundaries in the mesh.
Vector< GeneralisedElement * > Element_pt
Vector of pointers to generalised elements.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Node *& node_pt(const unsigned long &n)
Return pointer to global node n.
unsigned long nnode() const
Return number of nodes in the mesh.
int numberoftriangleattributes
FiniteElement * finite_element_pt(const unsigned &e) const
Upcast (downcast?) to FiniteElement (needed to access FiniteElement member functions).
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
unsigned nnode() const
Return the number of nodes.
Vector< Vector< unsigned > > Edge_boundary
Vector of vectors containing the boundary ids of the elements' edges.