38 #ifdef OOMPH_HAS_TRIANGLE_LIB 52 #endif // #ifdef OOMPH_HAS_MPI 58 for (
unsigned b=0;b<nb;b++)
62 dump_file <<
"1 # Boundary coordinate for boundary " << b
65 dump_file << nnod <<
" # Number of dumped boundary nodes\n";
66 for (
unsigned j=0;j<nnod;j++)
70 dump_file << zeta[0] << std::endl;
72 dump_file <<
"-999 # Done boundary coords for boundary " << b <<
"\n";
76 dump_file <<
"0 # Boundary coordinate for boundary " << b
77 <<
" does not exist\n";
84 #endif // #ifdef OOMPH_HAS_MPI 116 #endif // #ifdef OOMPH_HAS_MPI 121 if (nbound_new!=nbound_old)
123 std::ostringstream error_stream;
124 error_stream <<
"Number of boundaries before remesh from triangulateio, " 126 <<
",\ndoesn't match number boundaries afterwards, " 128 <<
". Have you messed \naround with boundary nodes in the " 129 <<
"derived mesh constructor (or after calling \nit)? If so," 130 <<
" the dump/restart won't work as written at the moment.";
132 OOMPH_CURRENT_FUNCTION,
133 OOMPH_EXCEPTION_LOCATION);
143 for (
unsigned b=0;b<nb;b++)
146 getline(restart_file,input_string,
'#');
149 restart_file.ignore(80,
'\n');
152 const unsigned bound_coord_exists=atoi(input_string.c_str());
153 if (bound_coord_exists==1)
159 getline(restart_file,input_string,
'#');
162 restart_file.ignore(80,
'\n');
165 const unsigned nnod_dumped=atoi(input_string.c_str());
169 if (nnod!=nnod_dumped)
171 std::ostringstream error_stream;
172 error_stream <<
"Number of dumped boundary nodes " 174 <<
" doesn't match number of nodes on boundary " 175 << b <<
": " << nnod << std::endl;
177 OOMPH_CURRENT_FUNCTION,
178 OOMPH_EXCEPTION_LOCATION);
182 for (
unsigned j=0;j<nnod;j++)
185 getline(restart_file,input_string);
188 zeta[0]=atof(input_string.c_str());
192 nod_pt->set_coordinates_on_boundary(b,zeta);
196 getline(restart_file,input_string,
'#');
199 restart_file.ignore(80,
'\n');
202 const int check=atoi(input_string.c_str());
205 std::ostringstream error_stream;
206 error_stream <<
"Haven't read all nodes on boundary "<< b
209 OOMPH_CURRENT_FUNCTION,
210 OOMPH_EXCEPTION_LOCATION);
215 oomph_info <<
"Restart: Boundary coordinate for boundary " << b
216 <<
" does not exist.\n";
222 #endif // #ifdef OOMPH_HAS_MPI 241 std::ofstream outfile;
244 sprintf(filename,
"Triangulateio_object_%s.dat",s.c_str());
245 outfile.open(filename);
246 outfile <<
"# Triangulateio object values:\n\n"<<std::endl;
251 outfile <<
"# Triangulateio number of points is:" 256 outfile <<
"# Vertex coordinates are:"<<std::endl;
259 outfile << (k*0.5)+1 <<
" " 268 outfile <<
"# Triangulateio number of points attributelist is:" 274 outfile <<
"# Vertex attribute are:"<<std::endl;
284 outfile <<
"# Vertex Markers are:"<<std::endl;
292 std::ofstream nodefile;
295 sprintf(nodename,
"file_%s.1.node",s.c_str());
296 nodefile.open(nodename);
302 nodefile <<(j/2)+1<<
" " << triangle.
pointlist[j] <<
" " 311 outfile <<
"# The number of segments is:" 316 outfile <<
"# Segments are:"<<std::endl;
327 outfile <<
"# Segments Markers are:"<<std::endl;
337 outfile <<
"# The number of region is:" 344 outfile <<
"# The number of holes is:" 349 outfile <<
"# Holes are:"<<std::endl;
352 outfile << triangle.
holelist[k] <<
" " 353 << triangle.
holelist[k+1] <<std::endl;
360 outfile <<
"# Triangulateio number of triangles:" 365 outfile <<
"# Triangulateio number of corners:" 370 outfile <<
"# Triangulateio number of triangles attributes:" 376 outfile <<
"# Traingles are:"<<std::endl;
387 outfile <<
"# Triangle's areas are:"<<std::endl;
398 std::ofstream elefile;
401 sprintf(elename,
"file_%s.1.ele",s.c_str());
402 elefile.open(elename);
406 elefile <<(j/3)+1<<
" "<< triangle.
trianglelist[j] <<
" " 428 if(outfile) doc =
true;
442 vector_of_boundary_element_pt.resize(nbound);
458 std::map<Edge,unsigned > edge_count;
459 std::map<Edge,TriangleBoundaryHelper::BCInfo>
461 std::map<Edge,TriangleBoundaryHelper::BCInfo>
468 std::map<Edge,Vector<TriangleBoundaryHelper::BCInfo> > edge_internal_bnd;
470 for (
unsigned e=0;
e<nel;
e++)
475 if (doc) {outfile <<
"Element: " <<
e <<
" " << fe_pt << std::endl;}
484 for(
unsigned i=0;
i<3;
i++)
495 if(boundaries_pt[1] && boundaries_pt[2])
505 std::set_intersection(boundaries_pt[1]->begin(),boundaries_pt[1]->end(),
506 boundaries_pt[2]->begin(),boundaries_pt[2]->end(),
507 std::insert_iterator<std::set<unsigned> >(
508 edge_boundary[0],edge_boundary[0].begin()));
509 std::set<unsigned>::iterator it0=edge_boundary[0].begin();
512 if ( edge_boundary[0].size() > 0 )
520 edge_bcinfo.insert(std::make_pair(edge0,info));
523 edge_internal_bnd[edge0].push_back(info);
530 if(boundaries_pt[0] && boundaries_pt[2])
532 std::set_intersection(boundaries_pt[0]->begin(),boundaries_pt[0]->end(),
533 boundaries_pt[2]->begin(),boundaries_pt[2]->end(),
534 std::insert_iterator<std::set<unsigned> >(
535 edge_boundary[1],edge_boundary[1].begin()));
544 std::set<unsigned>::iterator it1=edge_boundary[1].begin();
547 if ( edge_boundary[1].size() > 0)
555 edge_bcinfo.insert(std::make_pair(edge1,info));
558 edge_internal_bnd[edge1].push_back(info);
565 if(boundaries_pt[0] && boundaries_pt[1])
567 std::set_intersection(boundaries_pt[0]->begin(),boundaries_pt[0]->end(),
568 boundaries_pt[1]->begin(),boundaries_pt[1]->end(),
569 std::insert_iterator<std::set<unsigned> >(
570 edge_boundary[2],edge_boundary[2].begin()));
579 std::set<unsigned>::iterator it2=edge_boundary[2].begin();
582 if ( edge_boundary[2].size() > 0)
590 edge_bcinfo.insert(std::make_pair(edge2,info));
593 edge_internal_bnd[edge2].push_back(info);
603 for(
unsigned i=0;
i<3;
i++)
610 for(std::set<unsigned>::iterator it=edge_boundary[
i].begin();
611 it!=edge_boundary[
i].end();++it)
619 std::ostringstream error_stream;
620 error_stream <<
"Edge " <<
i <<
" is located on " <<
621 count <<
" boundaries.\n";
622 error_stream <<
"This is rather strange, so I'm going to die\n";
625 OOMPH_CURRENT_FUNCTION,
626 OOMPH_EXCEPTION_LOCATION);
633 for(
unsigned i=0;
i<3;
i++) {boundaries_pt[
i] = 0;}
639 typedef std::map<Edge,TriangleBoundaryHelper::BCInfo>::iterator ITE;
640 for (ITE it=edge_bcinfo.begin();
641 it!=edge_bcinfo.end();
644 Edge current_edge = it->first;
645 unsigned bound=it->second.Boundary;
648 if(edge_count[current_edge]==1)
651 face_count(static_cast<unsigned>(bound),it->second.FE_pt)=
652 face_count(static_cast<unsigned>(bound),it->second.FE_pt) + 1;
655 if( face_count(bound,it->second.FE_pt) > 1)
659 info.
Face_id=it->second.Face_id;
660 info.
FE_pt = it->second.FE_pt;
664 face_info.insert(std::make_pair(current_edge,info));
674 std::find(vector_of_boundary_element_pt[
675 static_cast<unsigned>(bound)].begin(),
676 vector_of_boundary_element_pt[
677 static_cast<unsigned>(bound)].end(),
681 if(b_el_it == vector_of_boundary_element_pt[
682 static_cast<unsigned>(bound)].end())
684 vector_of_boundary_element_pt[
static_cast<unsigned>(bound)].
685 push_back(it->second.FE_pt);
690 face_identifier(static_cast<unsigned>(bound),it->second.FE_pt) =
703 for (
unsigned i=0;
i<nbound;
i++)
707 unsigned bonus1=bonus[
i];
710 unsigned nel=vector_of_boundary_element_pt[
i].size() + bonus1;
717 for (IT it=vector_of_boundary_element_pt[
i].begin();
718 it!=vector_of_boundary_element_pt[
i].end();
734 for (ITE itt= face_info.begin(); itt!= face_info.end(); itt++)
736 if (itt->second.Boundary==
i)
755 for (
unsigned i=0;
i<nbound;
i++)
758 outfile <<
"Boundary: " <<
i 759 <<
" is adjacent to " << nel
760 <<
" elements" << std::endl;
763 for (
unsigned e=0;
e<nel;
e++)
766 outfile <<
"Boundary element:" << fe_pt
767 <<
" Face index of boundary is " TriangulateIO Triangulateio
TriangulateIO representation of the mesh.
double * pointlist
Pointer to list of points x coordinate followed by y coordinate.
double * pointattributelist
Pointer to list of point attributes.
Node *& boundary_node_pt(const unsigned &b, const unsigned &n)
Return pointer to node n on boundary b.
int * pointmarkerlist
Pointer to list of point markers.
std::vector< bool > Boundary_coordinate_exists
Vector of boolean data that indicates whether the boundary coordinates have been set for the boundary...
A general Finite Element class.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
unsigned long nboundary_node(const unsigned &ibound) const
Return number of nodes on a particular boundary.
bool Lookup_for_elements_next_boundary_is_setup
virtual void get_coordinates_on_boundary(const unsigned &b, const unsigned &k, Vector< double > &boundary_zeta)
Return the vector of the k-th generalised boundary coordinates on mesh boundary b. Broken virtual interface provides run-time error checking.
unsigned long nelement() const
Return number of elements in the mesh.
virtual void get_boundaries_pt(std::set< unsigned > *&boundaries_pt)
Return a pointer to set of mesh boundaries that this node occupies; this will be overloaded by Bounda...
Vector< Vector< int > > Face_index_at_boundary
For the e-th finite element on boundary b, this is the index of the face that lies along that boundar...
void clear_triangulateio(TriangulateIO &triangulate_io, const bool &clear_hole_data)
Clear TriangulateIO structure.
bool is_mesh_distributed() const
Boolean to indicate if Mesh has been distributed.
unsigned nboundary() const
Return number of boundaries.
void remesh_from_triangulateio(std::istream &restart_file)
Regenerate the mesh from a dumped triangulateio file and dumped boundary coordinates of boundary node...
Structure for Boundary Informations.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
FiniteElement * FE_pt
Pointer to bulk finite element.
Vector< Vector< FiniteElement * > > Boundary_element_pt
Vector of Vector of pointers to elements on the boundaries: Boundary_element_pt(b,e)
int numberoftriangleattributes
int numberofpointattributes
FiniteElement * finite_element_pt(const unsigned &e) const
Upcast (downcast?) to FiniteElement (needed to access FiniteElement member functions).
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
void dump_triangulateio(TriangulateIO &triangle_io, std::ostream &dump_file)
Write all the triangulateio data to disk in a dump file that can then be used to restart simulations...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
double * trianglearealist
void write_triangulateio(TriangulateIO &triangulate_io, std::string &s)
Helper function. Write a TriangulateIO object file with all the triangulateio fields. String s is add to assign a different value for the input and/or output structure.
virtual void remesh_from_internal_triangulateio()
Virtual function that is used for specific remeshing from the triangulateio.
void read_triangulateio(std::istream &restart_file, TriangulateIO &triangle_io)
Read the triangulateio data from a dump file on disk, which can then be used to restart simulations...
void dump_triangulateio(std::ostream &dump_file)
Dump the triangulateio structure to a dump file and record boundary coordinates of boundary nodes...
void setup_boundary_element_info()
unsigned Boundary
Boundary ID.