27 #ifndef OOMPH_QUAD_FROM_TRIANGLE_MESH_TEMPLATE_HEADER
28 #define OOMPH_QUAD_FROM_TRIANGLE_MESH_TEMPLATE_HEADER
43 #ifdef OOMPH_HAS_FPUCONTROLH
44 #include <fpu_control.h>
48 #include "../generic/problem.h"
49 #include "../generic/quad_mesh.h"
51 #include "../generic/triangle_scaffold_mesh.h"
52 #include "../generic/unstructured_two_d_mesh_geometry_base.h"
53 #include "../generic/refineable_quad_mesh.h"
54 #include "../generic/Qelements.h"
69 template<
class ELEMENT>
77 #ifdef OOMPH_HAS_TRIANGLE_LIB
84 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(2);
93 const bool& use_attributes =
false,
94 const bool& allow_automatic_creation_of_vertices_on_boundaries =
true)
97 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(2);
101 allow_automatic_creation_of_vertices_on_boundaries;
111 node_file_name, element_file_name, poly_file_name);
122 for (
unsigned ibound = 0; ibound < nbound; ibound++)
124 this->
template setup_boundary_coordinates<ELEMENT>(ibound);
128 #ifdef OOMPH_HAS_TRIANGLE_LIB
138 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(2);
142 triangle_mesh_parameters
156 unsigned max_boundary_id = 0;
169 if (outer_boundary_pt.size() == 0)
171 std::stringstream error_message;
173 <<
"There are no outer boundaries defined.\n"
174 <<
"Verify that you have specified the outer boundaries in the\n"
175 <<
"Triangle_mesh_parameter object\n\n";
177 OOMPH_CURRENT_FUNCTION,
178 OOMPH_EXCEPTION_LOCATION);
184 unsigned n_outer_boundaries = outer_boundary_pt.size();
191 for (
unsigned i = 0;
i < n_outer_boundaries; ++
i)
198 outer_boundary_pt[
i], max_boundary_id);
210 unsigned n_internal_closed_curves = internal_closed_curve_pt.size();
216 n_internal_closed_curves);
219 for (
unsigned i = 0;
i < n_internal_closed_curves; ++
i)
224 internal_closed_curve_pt[
i], max_boundary_id);
236 unsigned n_internal_open_curves = internal_open_curve_pt.size();
240 n_internal_open_curves);
243 for (
unsigned i = 0;
i < n_internal_open_curves;
i++)
248 internal_open_curve_poly_pt[
i] =
250 internal_open_curve_pt[
i], max_boundary_id);
260 for (
unsigned i = 0;
i < n_outer_boundaries;
i++)
263 outer_boundary_pt[
i]);
269 for (
unsigned i = 0;
i < n_internal_closed_curves;
i++)
272 internal_closed_curve_pt[
i]);
278 for (
unsigned i = 0;
i < n_internal_open_curves;
i++)
281 internal_open_curve_pt[
i]);
290 const double element_area = triangle_mesh_parameters.
element_area();
297 std::map<unsigned, Vector<double>> regions =
303 const bool refine_boundary =
306 const bool refine_internal_boundary =
309 if (!refine_internal_boundary && refine_boundary)
311 std::ostringstream error_stream;
313 <<
"You have specified that Triangle may refine the outer boundary, "
315 <<
"not internal boundaries. Triangle does not support this "
317 <<
"If you do not want Triangle to refine internal boundaries, it "
319 <<
"refine outer boundaries either!\n"
320 <<
"Please either disable all boundary refinement\n"
321 <<
"(call TriangleMeshParameters::disable_boundary_refinement()\n"
322 <<
"or enable internal boundary refinement (the default)\n";
325 OOMPH_CURRENT_FUNCTION,
326 OOMPH_EXCEPTION_LOCATION);
330 outer_boundary_polygon_pt,
332 internal_open_curve_poly_pt,
334 extra_holes_coordinates,
340 refine_internal_boundary);
356 for (
unsigned b = 0; b < nb; b++)
358 this->
template setup_boundary_coordinates<ELEMENT>(b);
372 const double& element_area,
375 std::map<unsigned, double>& regions_areas,
377 const bool& use_attributes,
378 const bool& refine_boundary,
379 const bool& refine_internal_boundary)
383 if (element_area < 10
e-14)
385 std::ostringstream warning_message;
387 <<
"The current elements area was stated to (" << element_area
388 <<
").\nThe current precision to generate the input to triangle "
389 <<
"is fixed to 14 digits\n\n";
391 OOMPH_CURRENT_FUNCTION,
392 OOMPH_EXCEPTION_LOCATION);
431 extra_holes_coordinates,
440 std::stringstream input_string_stream;
441 input_string_stream.precision(14);
442 input_string_stream.setf(std::ios_base::fixed, std::ios_base::floatfield);
448 input_string_stream <<
"-pA -a -a" << element_area <<
" -q30"
454 input_string_stream <<
" -YY";
458 if (refine_boundary ==
false)
460 input_string_stream <<
"-Y";
463 if (refine_internal_boundary ==
false)
465 input_string_stream <<
"Y";
470 char triswitches[100];
471 sprintf(triswitches,
"%s", input_string_stream.str().c_str());
474 triangulate(triswitches, &triangulate_io, &triangulate_out, 0);
476 #ifdef OOMPH_HAS_FPUCONTROLH
478 fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
487 if (!regions_coordinates.empty())
507 bool clear_hole_data =
false;
523 #ifdef OOMPH_HAS_TRIANGLE_LIB
525 std::set<TriangleMeshCurveSection*>::iterator it_polyline;
530 delete (*it_polyline);
533 std::set<TriangleMeshPolygon*>::iterator it_polygon;
538 delete (*it_polygon);
541 std::set<TriangleMeshOpenCurve*>::iterator it_open_polyline;
546 delete (*it_open_polyline);
555 const bool& use_attributes);
574 template<
class ELEMENT>
580 #ifdef OOMPH_HAS_TRIANGLE_LIB
589 this->setup_quadtree_forest();
600 refine_uniformly(doc_info);
607 unsigned nelem = this->nelement();
627 node_file_name, element_file_name, poly_file_name, time_stepper_pt)
629 this->setup_quadtree_forest();
645 template<
class ELEMENT>
656 const bool& use_attributes =
false)
664 set_lagrangian_nodal_coordinates();
667 #ifdef OOMPH_HAS_TRIANGLE_LIB
678 set_lagrangian_nodal_coordinates();
696 template<
class ELEMENT>
709 const bool& use_attributes =
false)
717 set_lagrangian_nodal_coordinates();
720 #ifdef OOMPH_HAS_TRIANGLE_LIB
733 set_lagrangian_nodal_coordinates();
Information for documentation of results: Directory and file number to enable output in the form RESL...
void disable_doc()
Disable documentation.
std::string directory() const
Output directory.
static Steady< 0 > Default_TimeStepper
Default Steady Timestepper, to be used in default arguments to Mesh constructors.
unsigned nboundary() const
Return number of boundaries.
void set_communicator_pt(OomphCommunicator *comm_pt)
Function to set communicator (mesh is assumed to be distributed if the communicator pointer is non-nu...
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
Quad mesh built on top of triangle scaffold mesh coming from the triangle mesh generator Triangle....
void generic_constructor(Vector< TriangleMeshPolygon * > &outer_boundary_pt, Vector< TriangleMeshPolygon * > &internal_polygon_pt, Vector< TriangleMeshOpenCurve * > &open_polylines_pt, const double &element_area, Vector< Vector< double >> &extra_holes_coordinates, std::map< unsigned, Vector< double >> ®ions_coordinates, std::map< unsigned, double > ®ions_areas, TimeStepper *time_stepper_pt, const bool &use_attributes, const bool &refine_boundary, const bool &refine_internal_boundary)
A general-purpose construction function that builds the mesh once the different specific constructors...
TimeStepper * Time_stepper_pt
Timestepper used to build elements.
QuadFromTriangleMesh(TriangleMeshParameters &triangle_mesh_parameters, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Build mesh, based on the specifications on TriangleMeshParameters. All the actual work is done in Uns...
void operator=(const QuadFromTriangleMesh &)=delete
Broken assignment operator.
~QuadFromTriangleMesh()
Empty destructor.
QuadFromTriangleMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &poly_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false, const bool &allow_automatic_creation_of_vertices_on_boundaries=true)
Constructor with the input files.
bool Use_attributes
Boolean flag to indicate whether to use attributes or not (required for multidomain meshes)
void build_from_scaffold(TriangleScaffoldMesh *tmp_mesh_pt, TimeStepper *time_stepper_pt, const bool &use_attributes)
Build the quad mesh from the given scaffold mesh.
QuadFromTriangleMesh(const QuadFromTriangleMesh &dummy)=delete
Broken copy constructor.
QuadFromTriangleMesh()
Empty constructor.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
///////////////////////////////////////////////////////////////// ///////////////////////////////////...
virtual void refine_uniformly()
Refine mesh uniformly.
RefineableQuadFromTriangleMesh(TriangleMeshParameters &triangle_mesh_parameters, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Build mesh, based on the specifications on TriangleMeshParameters.
RefineableQuadFromTriangleMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &poly_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Build mesh, based on the polyfiles.
virtual ~RefineableQuadFromTriangleMesh()
Empty Destructor.
void refine_uniformly(DocInfo &doc_info)
Refine mesh uniformly and doc process.
Intermediate mesh class that implements the mesh adaptation functions specified in the TreeBasedRefin...
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
virtual ~RefineableSolidQuadFromTriangleMesh()
Empty Destructor.
RefineableSolidQuadFromTriangleMesh(TriangleMeshParameters &triangle_mesh_parameters, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Build mesh, based on the specifications on TriangleMeshParameter.
RefineableSolidQuadFromTriangleMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &poly_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Build mesh from specified triangulation and associated target areas for elements in it.
///////////////////////////////////////////////////////////////// ///////////////////////////////////...
SolidQuadFromTriangleMesh(TriangleMeshParameters &triangle_mesh_parameters, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Build mesh, based on closed curve that specifies the outer boundary of the domain and any number of i...
SolidQuadFromTriangleMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &poly_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
virtual ~SolidQuadFromTriangleMesh()
Empty Destructor.
////////////////////////////////////////////////////////////////////// //////////////////////////////...
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
Vector< TriangleMeshClosedCurve * > internal_closed_curve_pt() const
Helper function for getting the internal closed boundaries.
bool is_automatic_creation_of_vertices_on_boundaries_allowed()
Returns the status of the variable Allow_automatic_creation_of_vertices_on_boundaries.
Vector< Vector< double > > extra_holes_coordinates() const
Helper function for getting the extra holes.
std::map< unsigned, double > & target_area_for_region()
Helper function for getting access to the region's target areas.
bool is_mesh_distributed() const
Boolean to indicate if Mesh has been distributed.
bool is_use_attributes() const
Helper function for getting the status of use_attributes variable.
Vector< TriangleMeshClosedCurve * > outer_boundary_pt() const
Helper function for getting the outer boundary.
OomphCommunicator * communicator_pt() const
Read-only access fct to communicator (Null if mesh is not distributed)
double element_area() const
Helper function for getting the element area.
Vector< TriangleMeshOpenCurve * > internal_open_curves_pt() const
Helper function for getting the internal open boundaries.
std::map< unsigned, Vector< double > > & regions_coordinates()
Helper function for getting access to the regions coordinates.
bool is_boundary_refinement_allowed() const
Helper function for getting the status of boundary refinement.
bool is_internal_boundary_refinement_allowed() const
Helper function for getting the status of boundary refinement.
Triangle Mesh that is based on input files generated by the triangle mesh generator Triangle.
Contains functions which define the geometry of the mesh, i.e. regions, boundaries,...
Vector< TriangleMeshOpenCurve * > Internal_open_curve_pt
Vector of open polylines that define internal curves.
bool is_automatic_creation_of_vertices_on_boundaries_allowed()
Returns the status of the variable Allow_automatic_creation_of_vertices_on_boundaries.
Vector< TriangleMeshPolygon * > Outer_boundary_pt
Polygon that defines outer boundaries.
Vector< TriangleMeshPolygon * > Internal_polygon_pt
Vector of polygons that define internal polygons.
void snap_nodes_onto_geometric_objects()
Snap the boundary nodes onto any curvilinear boundaries defined by geometric objects.
TriangleMeshOpenCurve * create_open_curve_with_polyline_helper(TriangleMeshOpenCurve *open_curve_pt, unsigned &max_bnd_id_local)
Helper function that creates and returns an open curve with the polyline representation of its consti...
std::map< unsigned, Vector< double > > Regions_coordinates
Storage for extra coordinates for regions. The key on the map is the region id.
Vector< Vector< double > > Extra_holes_coordinates
Storage for extra coordinates for holes.
bool Allow_automatic_creation_of_vertices_on_boundaries
Flag to indicate whether the automatic creation of vertices along the boundaries by Triangle is allow...
std::set< TriangleMeshOpenCurve * > Free_open_curve_pt
A set that contains the open curves created by this object therefore it is necessary to free their as...
TriangleMeshPolygon * closed_curve_to_polygon_helper(TriangleMeshClosedCurve *closed_curve_pt, unsigned &max_bnd_id_local)
Helper function that returns a polygon representation for the given closed curve, it also computes th...
void build_triangulateio(Vector< TriangleMeshPolygon * > &outer_polygons_pt, Vector< TriangleMeshPolygon * > &internal_polygons_pt, Vector< TriangleMeshOpenCurve * > &open_curves_pt, Vector< Vector< double >> &extra_holes_coordinates, std::map< unsigned, Vector< double >> ®ions_coordinates, std::map< unsigned, double > ®ions_areas, TriangulateIO &triangulate_io)
Create TriangulateIO object from outer boundaries, internal boundaries, and open curves....
std::set< TriangleMeshCurveSection * > Free_curve_section_pt
A set that contains the curve sections created by this object therefore it is necessary to free their...
std::set< TriangleMeshPolygon * > Free_polygon_pt
A set that contains the polygons created by this object therefore it is necessary to free their assoc...
void set_geom_objects_and_coordinate_limits_for_open_curve(TriangleMeshOpenCurve *input_open_curve_pt)
Stores the geometric objects associated to the curve sections that compound the open curve....
void set_geom_objects_and_coordinate_limits_for_close_curve(TriangleMeshClosedCurve *input_closed_curve_pt)
Stores the geometric objects associated to the curve sections that compound the closed curve....
A slight extension to the standard template vector class so that we can include "graceful" array rang...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
void initialise_triangulateio(TriangulateIO &triangle_io)
Initialise TriangulateIO structure.
void clear_triangulateio(TriangulateIO &triangulate_io, const bool &clear_hole_data)
Clear TriangulateIO structure.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
void triangulate(char *triswitches, struct oomph::TriangulateIO *in, struct oomph::TriangulateIO *out, struct oomph::TriangulateIO *vorout)
The Triangle data structure, modified from the triangle.h header supplied with triangle 1....