oomph::TriangleMeshClosedCurve Class Reference

Base class defining a closed curve for the Triangle mesh generation. More...

#include <unstructured_two_d_mesh_geometry_base.h>

+ Inheritance diagram for oomph::TriangleMeshClosedCurve:

Public Member Functions

 TriangleMeshClosedCurve (const Vector< TriangleMeshCurveSection * > &curve_section_pt, const Vector< double > &internal_point_pt=Vector< double >(0), const bool &is_internal_point_fixed=false)
 Constructor prototype. More...
 
virtual ~TriangleMeshClosedCurve ()
 Empty destructor. More...
 
unsigned nvertices () const
 Number of vertices. More...
 
unsigned nsegments () const
 Total number of segments. More...
 
void output (std::ostream &outfile, const unsigned &n_sample=50)
 Output each sub-boundary at n_sample (default: 50) points. More...
 
Vector< doubleinternal_point () const
 Coordinates of the internal point. More...
 
Vector< double > & internal_point ()
 Coordinates of the internal point. More...
 
void fix_internal_point ()
 
void unfix_internal_point ()
 
bool is_internal_point_fixed () const
 Test whether the internal point is fixed. More...
 
- Public Member Functions inherited from oomph::TriangleMeshCurve
 TriangleMeshCurve (const Vector< TriangleMeshCurveSection * > &curve_section_pt)
 Empty constructor. More...
 
virtual ~TriangleMeshCurve ()
 Empty destructor. More...
 
unsigned max_boundary_id ()
 Return max boundary id of associated curves. More...
 
virtual unsigned ncurve_section () const
 Number of constituent curves. More...
 
void enable_polyline_refinement (const double &tolerance=0.08)
 
void set_polyline_refinement_tolerance (const double &tolerance)
 
double polyline_refinement_tolerance ()
 
void disable_polyline_refinement ()
 Disable refinement of polylines. More...
 
void enable_polyline_unrefinement (const double &tolerance=0.04)
 
void set_polyline_unrefinement_tolerance (const double &tolerance)
 
double polyline_unrefinement_tolerance ()
 
void disable_polyline_unrefinement ()
 Disable unrefinement of polylines. More...
 
virtual TriangleMeshCurveSectioncurve_section_pt (const unsigned &i) const
 Pointer to i-th constituent curve section. More...
 
virtual TriangleMeshCurveSection *& curve_section_pt (const unsigned &i)
 Pointer to i-th constituent curve section. More...
 

Protected Attributes

Vector< doubleInternal_point_pt
 Vector of vertex coordinates. More...
 
bool Is_internal_point_fixed
 Indicate whether the internal point should be updated automatically. More...
 
- Protected Attributes inherited from oomph::TriangleMeshCurve
Vector< TriangleMeshCurveSection * > Curve_section_pt
 Vector of curve sections. More...
 

Detailed Description

Base class defining a closed curve for the Triangle mesh generation.

//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

Constructor & Destructor Documentation

◆ TriangleMeshClosedCurve()

oomph::TriangleMeshClosedCurve::TriangleMeshClosedCurve ( const Vector< TriangleMeshCurveSection * > &  curve_section_pt,
const Vector< double > &  internal_point_pt = Vector<double>(0),
const bool is_internal_point_fixed = false 
)

Constructor prototype.

Class defining a closed curve for the Triangle mesh generation.

//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////

1425  Internal_point_pt(internal_point_pt),
1427  {
1428  // Matching of curve sections i.e. the last vertex of the i curve
1429  // section should match with the first vertex of the i+1 curve
1430  // section
1431 
1432  // Total number of boundaries
1433  const unsigned n_boundaries = Curve_section_pt.size();
1434 
1435  // Need at least two
1436  if (n_boundaries < 2)
1437  {
1438  std::ostringstream error_stream;
1439  error_stream << "Sorry -- I'm afraid we insist that a closed curve is\n"
1440  << "specified by at least two separate CurveSections.\n"
1441  << "You've only specified (" << n_boundaries << ")"
1442  << std::endl;
1443  throw OomphLibError(
1444  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1445  }
1446 
1447  // Check last point of each boundary bit coincides with first point
1448  // on next one
1449  for (unsigned i = 0; i < n_boundaries - 1; i++)
1450  {
1451  // Auxiliary vertex for storing the vertex values of contiguous curves
1452  Vector<double> v1(2);
1453 
1454  // This is for getting the final coordinates of the i curve section
1456 
1457  // Auxiliary vertex for storing the vertex values of contiguous curves
1458  Vector<double> v2(2);
1459 
1460  // This is for the start coordinates of the i+1 curve section
1462 
1463  // Work out error
1464  double error = sqrt(pow(v1[0] - v2[0], 2) + pow(v1[1] - v2[1], 2));
1465 
1467  {
1468  std::ostringstream error_stream;
1469  error_stream
1470  << "The start and end points of curve section boundary parts\n"
1471  << i << " and " << i + 1
1472  << " don't match when judged with the tolerance of "
1474  << " which\nis specified in the namespace variable\n"
1475  << "ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n"
1476  << "These are the vertices coordinates:\n"
1477  << "Curve section (" << i << ") final vertex: (" << v1[0] << ", "
1478  << v1[1] << ")\n"
1479  << "Curve section (" << i + 1 << ") initial vertex: (" << v2[0]
1480  << ", " << v2[1] << ")\n"
1481  << "The distance between the vertices is (" << error << ")\n"
1482  << "Feel free to adjust this or to recompile the code without\n"
1483  << "paranoia if you think this is OK...\n"
1484  << std::endl;
1485  throw OomphLibError(
1486  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1487  }
1488  else
1489  {
1490  // Aligns (only implemented for polylines)
1491  TriangleMeshPolyLine* current_polyline =
1492  dynamic_cast<TriangleMeshPolyLine*>(Curve_section_pt[i]);
1493  TriangleMeshPolyLine* next_polyline =
1494  dynamic_cast<TriangleMeshPolyLine*>(Curve_section_pt[i + 1]);
1495 
1496  // Was it able to do the cast?
1497  if (current_polyline && next_polyline)
1498  {
1499  unsigned last_vertex = current_polyline->nvertex() - 1;
1500  next_polyline->vertex_coordinate(0) =
1501  current_polyline->vertex_coordinate(last_vertex);
1502  }
1503  }
1504 
1505  } // For n_boundaries - 1
1506 
1507  // Check wrap around
1508  // Auxiliary vertex for storing the vertex values of contiguous curves
1509  Vector<double> v1(2);
1510 
1511  // This is for getting the first coordinates of the first curve section
1512  Curve_section_pt[0]->initial_vertex_coordinate(v1);
1513 
1514  // Auxiliary vertex for storing the vertex values of contiguous curves
1515  Vector<double> v2(2);
1516 
1517  // This is for getting the last coordinates of the last curve section
1518  Curve_section_pt[n_boundaries - 1]->final_vertex_coordinate(v2);
1519 
1520  double error = sqrt(pow(v2[0] - v1[0], 2) + pow(v2[1] - v1[1], 2));
1521 
1523  {
1524  std::ostringstream error_stream;
1525  error_stream
1526  << "The start and end points of the first and last curve segment\n"
1527  << "boundary parts don't match when judged \nwith the tolerance of "
1529  << " which is specified in the namespace \nvariable "
1530  << "ToleranceForVertexMismatchInPolygons::Tolerable_error.\n\n"
1531  << "Feel free to adjust this or to recompile the code without\n"
1532  << "paranoia if you think this is OK...\n"
1533  << std::endl;
1534  throw OomphLibError(
1535  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1536  }
1537  else
1538  {
1539  // Aligns (only implemented for polylines)
1540  TriangleMeshPolyLine* first_polyline =
1541  dynamic_cast<TriangleMeshPolyLine*>(Curve_section_pt[0]);
1542  TriangleMeshPolyLine* last_polyline =
1543  dynamic_cast<TriangleMeshPolyLine*>(Curve_section_pt[n_boundaries - 1]);
1544 
1545  // Was it able to do the cast?
1546  if (first_polyline && last_polyline)
1547  {
1548  unsigned last_vertex = last_polyline->nvertex() - 1;
1549  first_polyline->vertex_coordinate(0) =
1550  last_polyline->vertex_coordinate(last_vertex);
1551  }
1552  }
1553  }
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Map< RowVectorXf > v2(M2.data(), M2.size())
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
Vector< double > Internal_point_pt
Vector of vertex coordinates.
Definition: unstructured_two_d_mesh_geometry_base.h:1436
bool is_internal_point_fixed() const
Test whether the internal point is fixed.
Definition: unstructured_two_d_mesh_geometry_base.h:1429
bool Is_internal_point_fixed
Indicate whether the internal point should be updated automatically.
Definition: unstructured_two_d_mesh_geometry_base.h:1439
virtual void initial_vertex_coordinate(Vector< double > &vertex)=0
Get first vertex coordinates.
virtual void final_vertex_coordinate(Vector< double > &vertex)=0
Get last vertex coordinates.
Vector< TriangleMeshCurveSection * > Curve_section_pt
Vector of curve sections.
Definition: unstructured_two_d_mesh_geometry_base.h:1321
TriangleMeshCurve(const Vector< TriangleMeshCurveSection * > &curve_section_pt)
Empty constructor.
Definition: unstructured_two_d_mesh_geometry_base.h:1139
virtual TriangleMeshCurveSection * curve_section_pt(const unsigned &i) const
Pointer to i-th constituent curve section.
Definition: unstructured_two_d_mesh_geometry_base.h:1308
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
int error
Definition: calibrate.py:297
double Tolerable_error
Definition: unstructured_two_d_mesh_geometry_base.cc:1103
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::TriangleMeshCurve::curve_section_pt(), oomph::TriangleMeshCurve::Curve_section_pt, calibrate::error, oomph::TriangleMeshCurveSection::final_vertex_coordinate(), i, oomph::TriangleMeshCurveSection::initial_vertex_coordinate(), oomph::TriangleMeshPolyLine::nvertex(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, Eigen::bfloat16_impl::pow(), sqrt(), oomph::ToleranceForVertexMismatchInPolygons::Tolerable_error, v1(), v2(), and oomph::TriangleMeshPolyLine::vertex_coordinate().

◆ ~TriangleMeshClosedCurve()

virtual oomph::TriangleMeshClosedCurve::~TriangleMeshClosedCurve ( )
inlinevirtual

Empty destructor.

1348 {}

Member Function Documentation

◆ fix_internal_point()

void oomph::TriangleMeshClosedCurve::fix_internal_point ( )
inline

Fix the internal point (i.e. do not allow our automatic machinery to update it)

1417  {
1418  Is_internal_point_fixed = true;
1419  }

References Is_internal_point_fixed.

◆ internal_point() [1/2]

Vector<double>& oomph::TriangleMeshClosedCurve::internal_point ( )
inline

Coordinates of the internal point.

1410  {
1411  return Internal_point_pt;
1412  }

References Internal_point_pt.

◆ internal_point() [2/2]

Vector<double> oomph::TriangleMeshClosedCurve::internal_point ( ) const
inline

Coordinates of the internal point.

1404  {
1405  return Internal_point_pt;
1406  }

References Internal_point_pt.

Referenced by oomph::ImmersedRigidBodyTriangleMeshPolygon::reset_reference_configuration().

◆ is_internal_point_fixed()

bool oomph::TriangleMeshClosedCurve::is_internal_point_fixed ( ) const
inline

Test whether the internal point is fixed.

1430  {
1431  return Is_internal_point_fixed;
1432  }

References Is_internal_point_fixed.

◆ nsegments()

unsigned oomph::TriangleMeshClosedCurve::nsegments ( ) const
inlinevirtual

Total number of segments.

Implements oomph::TriangleMeshCurve.

1370  {
1371  unsigned n_curve_section = ncurve_section();
1372  unsigned nseg = 0;
1373  for (unsigned j = 0; j < n_curve_section; j++)
1374  {
1375  nseg += Curve_section_pt[j]->nsegment();
1376  }
1377  // If there's just one boundary poly line we have another segment
1378  // connecting the last vertex to the first one
1379  if (n_curve_section == 1)
1380  {
1381  nseg += 1;
1382  }
1383  return nseg;
1384  }
virtual unsigned ncurve_section() const
Number of constituent curves.
Definition: unstructured_two_d_mesh_geometry_base.h:1172
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References oomph::TriangleMeshCurve::Curve_section_pt, j, and oomph::TriangleMeshCurve::ncurve_section().

◆ nvertices()

unsigned oomph::TriangleMeshClosedCurve::nvertices ( ) const
inlinevirtual

Number of vertices.

Implements oomph::TriangleMeshCurve.

1352  {
1353  unsigned n_curve_section = ncurve_section();
1354  unsigned n_vertices = 0;
1355  for (unsigned j = 0; j < n_curve_section; j++)
1356  {
1357  // Storing the number of the vertices
1358  n_vertices += Curve_section_pt[j]->nvertex() - 1;
1359  }
1360  // If there's just one boundary. All the vertices should be counted
1361  if (n_curve_section == 1)
1362  {
1363  n_vertices += 1;
1364  }
1365  return n_vertices;
1366  }

References oomph::TriangleMeshCurve::Curve_section_pt, j, and oomph::TriangleMeshCurve::ncurve_section().

◆ output()

void oomph::TriangleMeshClosedCurve::output ( std::ostream &  outfile,
const unsigned n_sample = 50 
)
inlinevirtual

Output each sub-boundary at n_sample (default: 50) points.

Implements oomph::TriangleMeshCurve.

1388  {
1389  unsigned nb = Curve_section_pt.size();
1390  for (unsigned i = 0; i < nb; i++)
1391  {
1392  Curve_section_pt[i]->output(outfile, n_sample);
1393  }
1394 
1395  if (!Internal_point_pt.empty())
1396  {
1397  outfile << "ZONE T=\"Internal point\"\n";
1398  outfile << Internal_point_pt[0] << " " << Internal_point_pt[1] << "\n";
1399  }
1400  }
int nb
Definition: level2_impl.h:286

References oomph::TriangleMeshCurve::Curve_section_pt, i, Internal_point_pt, and nb.

◆ unfix_internal_point()

void oomph::TriangleMeshClosedCurve::unfix_internal_point ( )
inline

Unfix the internal point (i.e. allow our automatic machinery to update it)

1424  {
1425  Is_internal_point_fixed = false;
1426  }

References Is_internal_point_fixed.

Member Data Documentation

◆ Internal_point_pt

Vector<double> oomph::TriangleMeshClosedCurve::Internal_point_pt
protected

Vector of vertex coordinates.

Referenced by internal_point(), output(), and oomph::TriangleMeshPolygon::TriangleMeshPolygon().

◆ Is_internal_point_fixed

bool oomph::TriangleMeshClosedCurve::Is_internal_point_fixed
protected

Indicate whether the internal point should be updated automatically.

Referenced by fix_internal_point(), is_internal_point_fixed(), and unfix_internal_point().


The documentation for this class was generated from the following files: