34 #ifdef OOMPH_HAS_TRIANGLE_LIB
54 for (
unsigned b = 0; b < nb; b++)
58 dump_file <<
"1 # Boundary coordinate for boundary " << b
61 dump_file << nnod <<
" # Number of dumped boundary nodes\n";
62 for (
unsigned j = 0; j < nnod; j++)
66 dump_file << zeta[0] << std::endl;
68 dump_file <<
"-999 # Done boundary coords for boundary " << b <<
"\n";
72 dump_file <<
"0 # Boundary coordinate for boundary " << b
73 <<
" does not exist\n";
112 if (nbound_new != nbound_old)
114 std::ostringstream error_stream;
116 <<
"Number of boundaries before remesh from triangulateio, "
117 << nbound_new <<
",\ndoesn't match number boundaries afterwards, "
119 <<
". Have you messed \naround with boundary nodes in the "
120 <<
"derived mesh constructor (or after calling \nit)? If so,"
121 <<
" the dump/restart won't work as written at the moment.";
123 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
133 for (
unsigned b = 0; b < nb; b++)
136 getline(restart_file, input_string,
'#');
139 restart_file.ignore(80,
'\n');
142 const unsigned bound_coord_exists = atoi(input_string.c_str());
143 if (bound_coord_exists == 1)
149 getline(restart_file, input_string,
'#');
152 restart_file.ignore(80,
'\n');
155 const unsigned nnod_dumped = atoi(input_string.c_str());
159 if (nnod != nnod_dumped)
161 std::ostringstream error_stream;
162 error_stream <<
"Number of dumped boundary nodes " << nnod_dumped
163 <<
" doesn't match number of nodes on boundary " << b
164 <<
": " << nnod << std::endl;
166 OOMPH_CURRENT_FUNCTION,
167 OOMPH_EXCEPTION_LOCATION);
171 for (
unsigned j = 0; j < nnod; j++)
174 getline(restart_file, input_string);
177 zeta[0] = atof(input_string.c_str());
185 getline(restart_file, input_string,
'#');
188 restart_file.ignore(80,
'\n');
191 const int check = atoi(input_string.c_str());
194 std::ostringstream error_stream;
195 error_stream <<
"Haven't read all nodes on boundary " << b
198 OOMPH_CURRENT_FUNCTION,
199 OOMPH_EXCEPTION_LOCATION);
204 oomph_info <<
"Restart: Boundary coordinate for boundary " << b
205 <<
" does not exist.\n";
224 std::ofstream outfile;
227 sprintf(filename,
"Triangulateio_object_%s.dat",
s.c_str());
228 outfile.open(filename);
229 outfile <<
"# Triangulateio object values:\n\n" << std::endl;
234 outfile <<
"# Triangulateio number of points is:"
239 outfile <<
"# Vertex coordinates are:" << std::endl;
242 outfile << (k * 0.5) + 1 <<
" " << triangle.
pointlist[k] <<
" "
243 << triangle.
pointlist[k + 1] << std::endl;
250 outfile <<
"# Triangulateio number of points attributelist is:"
255 outfile <<
"# Vertex attribute are:" << std::endl;
265 outfile <<
"# Vertex Markers are:" << std::endl;
273 std::ofstream nodefile;
276 sprintf(nodename,
"file_%s.1.node",
s.c_str());
277 nodefile.open(nodename);
282 nodefile << (j / 2) + 1 <<
" " << triangle.
pointlist[j] <<
" "
283 << triangle.
pointlist[j + 1] << std::endl;
296 outfile <<
"# Segments are:" << std::endl;
307 outfile <<
"# Segments Markers are:" << std::endl;
324 outfile <<
"# The number of holes is:" << triangle.
numberofholes
329 outfile <<
"# Holes are:" << std::endl;
340 outfile <<
"# Triangulateio number of triangles:"
345 outfile <<
"# Triangulateio number of corners:"
350 outfile <<
"# Triangulateio number of triangles attributes:"
355 outfile <<
"# Traingles are:" << std::endl;
366 outfile <<
"# Triangle's areas are:" << std::endl;
376 std::ofstream elefile;
379 sprintf(elename,
"file_%s.1.ele",
s.c_str());
380 elefile.open(elename);
384 elefile << (j / 3) + 1 <<
" " << triangle.
trianglelist[j] <<
" "
405 if (outfile)
doc =
true;
419 vector_of_boundary_element_pt.resize(nbound);
434 std::map<Edge, unsigned> edge_count;
435 std::map<Edge, TriangleBoundaryHelper::BCInfo> edge_bcinfo;
436 std::map<Edge, TriangleBoundaryHelper::BCInfo> face_info;
442 std::map<Edge, Vector<TriangleBoundaryHelper::BCInfo>> edge_internal_bnd;
444 for (
unsigned e = 0;
e < nel;
e++)
451 outfile <<
"Element: " <<
e <<
" " << fe_pt << std::endl;
455 if (fe_pt->
dim() == 2)
462 for (
unsigned i = 0;
i < 3;
i++)
473 if (boundaries_pt[1] && boundaries_pt[2])
483 std::set_intersection(boundaries_pt[1]->begin(),
484 boundaries_pt[1]->end(),
485 boundaries_pt[2]->begin(),
486 boundaries_pt[2]->end(),
487 std::insert_iterator<std::set<unsigned>>(
488 edge_boundary[0], edge_boundary[0].begin()));
489 std::set<unsigned>::iterator it0 = edge_boundary[0].begin();
492 if (edge_boundary[0].size() > 0)
500 edge_bcinfo.insert(std::make_pair(edge0, info));
503 edge_internal_bnd[edge0].push_back(info);
510 if (boundaries_pt[0] && boundaries_pt[2])
512 std::set_intersection(boundaries_pt[0]->begin(),
513 boundaries_pt[0]->end(),
514 boundaries_pt[2]->begin(),
515 boundaries_pt[2]->end(),
516 std::insert_iterator<std::set<unsigned>>(
517 edge_boundary[1], edge_boundary[1].begin()));
526 std::set<unsigned>::iterator it1 = edge_boundary[1].begin();
529 if (edge_boundary[1].size() > 0)
537 edge_bcinfo.insert(std::make_pair(edge1, info));
540 edge_internal_bnd[edge1].push_back(info);
547 if (boundaries_pt[0] && boundaries_pt[1])
549 std::set_intersection(boundaries_pt[0]->begin(),
550 boundaries_pt[0]->end(),
551 boundaries_pt[1]->begin(),
552 boundaries_pt[1]->end(),
553 std::insert_iterator<std::set<unsigned>>(
554 edge_boundary[2], edge_boundary[2].begin()));
563 std::set<unsigned>::iterator it2 = edge_boundary[2].begin();
566 if (edge_boundary[2].size() > 0)
574 edge_bcinfo.insert(std::make_pair(edge2, info));
577 edge_internal_bnd[edge2].push_back(info);
587 for (
unsigned i = 0;
i < 3;
i++)
594 for (std::set<unsigned>::iterator it = edge_boundary[
i].begin();
595 it != edge_boundary[
i].end();
604 std::ostringstream error_stream;
605 error_stream <<
"Edge " <<
i <<
" is located on " << count
607 error_stream <<
"This is rather strange, so I'm going to die\n";
609 OOMPH_CURRENT_FUNCTION,
610 OOMPH_EXCEPTION_LOCATION);
617 for (
unsigned i = 0;
i < 3;
i++)
619 boundaries_pt[
i] = 0;
625 typedef std::map<Edge, TriangleBoundaryHelper::BCInfo>::iterator ITE;
626 for (ITE it = edge_bcinfo.begin(); it != edge_bcinfo.end(); it++)
628 Edge current_edge = it->first;
629 unsigned bound = it->second.Boundary;
632 if (edge_count[current_edge] == 1)
635 face_count(
static_cast<unsigned>(bound), it->second.FE_pt) =
636 face_count(
static_cast<unsigned>(bound), it->second.FE_pt) + 1;
639 if (face_count(bound, it->second.FE_pt) > 1)
643 info.
Face_id = it->second.Face_id;
644 info.
FE_pt = it->second.FE_pt;
645 info.
Boundary = it->second.Boundary;
648 face_info.insert(std::make_pair(current_edge, info));
658 vector_of_boundary_element_pt[
static_cast<unsigned>(bound)].begin(),
659 vector_of_boundary_element_pt[
static_cast<unsigned>(bound)].end(),
664 vector_of_boundary_element_pt[
static_cast<unsigned>(bound)].end())
666 vector_of_boundary_element_pt[
static_cast<unsigned>(bound)]
667 .push_back(it->second.FE_pt);
672 face_identifier(
static_cast<unsigned>(bound), it->second.FE_pt) =
684 for (
unsigned i = 0;
i < nbound;
i++)
688 unsigned bonus1 = bonus[
i];
691 unsigned nel = vector_of_boundary_element_pt[
i].size() + bonus1;
696 unsigned e_count = 0;
698 for (IT it = vector_of_boundary_element_pt[
i].begin();
699 it != vector_of_boundary_element_pt[
i].end();
714 for (ITE itt = face_info.begin(); itt != face_info.end(); itt++)
716 if (itt->second.Boundary ==
i)
734 for (
unsigned i = 0;
i < nbound;
i++)
737 outfile <<
"Boundary: " <<
i <<
" is adjacent to " << nel <<
" elements"
741 for (
unsigned e = 0;
e < nel;
e++)
744 outfile <<
"Boundary element:" << fe_pt
745 <<
" Face index of boundary is "
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
A general Finite Element class.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
MapMatrixMixed is a generalised, STL-map-based, sparse(ish) matrix class with mixed indices.
unsigned long nboundary_node(const unsigned &ibound) const
Return number of nodes on a particular boundary.
bool is_mesh_distributed() const
Boolean to indicate if Mesh has been distributed.
Vector< Vector< FiniteElement * > > Boundary_element_pt
Vector of Vector of pointers to elements on the boundaries: Boundary_element_pt(b,...
bool Lookup_for_elements_next_boundary_is_setup
Flag to indicate that the lookup schemes for elements that are adjacent to the boundaries has been se...
std::vector< bool > Boundary_coordinate_exists
Vector of boolean data that indicates whether the boundary coordinates have been set for the boundary...
FiniteElement * finite_element_pt(const unsigned &e) const
Upcast (downcast?) to FiniteElement (needed to access FiniteElement member functions).
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...
unsigned nboundary() const
Return number of boundaries.
Node *& boundary_node_pt(const unsigned &b, const unsigned &n)
Return pointer to node n on boundary b.
unsigned long nelement() const
Return number of elements in the mesh.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
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...
virtual void set_coordinates_on_boundary(const unsigned &b, const unsigned &k, const Vector< double > &boundary_zeta)
Set the vector of the k-th generalised boundary coordinates on mesh boundary b. Broken virtual interf...
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....
An OomphLibError object which should be thrown when an run-time error is encountered....
virtual void remesh_from_internal_triangulateio()
Virtual function that is used for specific remeshing from the triangulateio.
void dump_triangulateio(std::ostream &dump_file)
Dump the triangulateio structure to a dump file and record boundary coordinates of boundary nodes.
TriangulateIO Triangulateio
TriangulateIO representation of the mesh.
void remesh_from_triangulateio(std::istream &restart_file)
Regenerate the mesh from a dumped triangulateio file and dumped boundary coordinates of boundary node...
void setup_boundary_element_info()
Setup lookup schemes which establish whic elements are located next to mesh's boundaries (wrapper to ...
void write_triangulateio(TriangulateIO &triangulate_io, std::string &s)
Helper function. Write a TriangulateIO object file with all the triangulateio fields....
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
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.
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 clear_triangulateio(TriangulateIO &triangulate_io, const bool &clear_hole_data)
Clear TriangulateIO structure.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...
Structure for Boundary Informations.
FiniteElement * FE_pt
Pointer to bulk finite element.
unsigned Boundary
Boundary ID.
The Triangle data structure, modified from the triangle.h header supplied with triangle 1....
double * pointlist
Pointer to list of points x coordinate followed by y coordinate.
int numberoftriangleattributes
int * pointmarkerlist
Pointer to list of point markers.
double * trianglearealist
double * pointattributelist
Pointer to list of point attributes.
int numberofpointattributes