Advanced Multi-Physics (AMP)
On-Line Documentation
GeometryHelpers.h
Go to the documentation of this file.
1#ifndef included_AMP_GeometryHelpers
2#define included_AMP_GeometryHelpers
3
4#include "AMP/utils/MeshPoint.h"
5
6#include <array>
7#include <vector>
8
9
10namespace AMP::Mesh {
12} // namespace AMP::Mesh
13
15
16
17using Point1D = std::array<double, 1>;
18using Point2D = std::array<double, 2>;
19using Point3D = std::array<double, 3>;
20
21
39Point2D map_logical_circle( double R, int method, double x, double y );
40
41
59Point2D map_circle_logical( double R, int method, double x, double y );
60
61
72Point2D map_logical_poly( int N, double R, double x, double y );
73
74
85Point2D map_poly_logical( int N, double R, double x, double y );
86
87
96std::vector<Point2D> get_poly_vertices( int N, double R );
97
98
112Point3D map_logical_sphere( double R, double x, double y, double z );
113
114
128Point3D map_sphere_logical( double R, double x, double y, double z );
129
130
147Point3D map_logical_sphere_surface( int method, double R, double x, double y );
148
166Point2D map_sphere_surface_logical( int method, double R, double x, double y, double z );
167
168
183Point3D map_logical_shell( double r1, double r2, double x, double y, double z );
184
185
200Point3D map_shell_logical( double r1, double r2, double x, double y, double z );
201
202
210double distance( const Point3D &x1, const Point3D &x2 );
211
212
223double
224distanceToLine( const Point2D &pos, const Point2D &ang, const Point2D &v1, const Point2D &v2 );
225
226
237double
238distanceToLine( const Point3D &pos, const Point3D &ang, const Point3D &v1, const Point3D &v2 );
239
240
251template<std::size_t NDIM>
252double distanceToBox( const std::array<double, NDIM> &pos,
253 const std::array<double, NDIM> &ang,
254 const std::array<double, NDIM> &lb,
255 const std::array<double, NDIM> &ub );
256
257
269double
270distanceToPlane( const Point3D &n, const Point3D &p0, const Point3D &pos, const Point3D &ang );
271
272
284double distanceToCircle( double r, const Point2D &pos, const Point2D &ang );
285
286
299double distanceToCylinder( double r, double h, const Point3D &pos, const Point3D &ang );
300
301
316double distanceToTube( double r1, double r2, double h, const Point3D &pos, const Point3D &ang );
317
318
330double distanceToSphere( double r, const Point3D &pos, const Point3D &ang );
331
332
345double distanceToCone( const Point3D &V, double theta, const Point3D &pos, const Point3D &ang );
346
347
358double
359distanceToTriangle( const std::array<Point2D, 3> &tri, const Point2D &pos, const Point2D &ang );
360
361
372double
373distanceToTriangle( const std::array<Point3D, 3> &tri, const Point3D &pos, const Point3D &ang );
374
375
386double
387distanceToTetrahedron( const std::array<Point3D, 4> &tet, const Point3D &pos, const Point3D &ang );
388
389
399Point3D normalToQuadrilateral( const std::array<Point3D, 4> &quad );
400
411double distanceToQuadrilateral( const std::array<Point2D, 4> &quad,
412 const Point2D &pos,
413 const Point2D &ang );
414
415
426double distanceToQuadrilateral( const std::array<Point3D, 4> &quad,
427 const Point3D &pos,
428 const Point3D &ang );
429
430
445double
446distanceToCircularFrustum( double rb, double rt, double h, const Point3D &pos, const Point3D &ang );
447
448
457template<int NP, int NDIM>
458std::array<double, NP> barycentric( const std::array<std::array<double, NDIM>, NP> &x,
459 const std::array<double, NDIM> &p );
460
461
471Point2D normal( const Point2D &a, const Point2D &b );
472
473
484Point3D normal( const Point3D &a, const Point3D &b, const Point3D &c );
485
486
495Point2D nearest( const Point2D &v1, const Point2D &v2, const Point2D &p );
496
497
506Point3D nearest( const Point3D &v1, const Point3D &v2, const Point3D &p );
507
508
517Point3D nearest( const std::array<Point3D, 3> &v, const Point3D &p );
518
519
528Point3D nearest( const std::array<Point3D, 4> &v, const Point3D &p );
529
530
539std::vector<AMP::Mesh::Point> subdivide( const std::array<AMP::Mesh::Point, 3> &v, double res );
540
541
551std::vector<Point3D> sampleLine( const std::array<Point3D, 2> &v, double d0, bool interior = true );
552
553
563std::vector<Point3D> sampleTri( const std::array<Point3D, 3> &v, double d0, bool interior = true );
564
565
575std::vector<Point3D> sampleQuad( const std::array<Point3D, 4> &v, double d0, bool interior = true );
576
577
587std::vector<Point3D> sampleTet( const std::array<Point3D, 4> &v, double d0, bool interior = true );
588
589
598std::vector<int> assignRanks( const std::vector<double> &x, int N_ranks );
599
608std::vector<int> assignRanks( const std::vector<Point1D> &x, int N_ranks );
609
618std::vector<int> assignRanks( const std::vector<Point2D> &x, int N_ranks );
619
628std::vector<int> assignRanks( const std::vector<Point3D> &x, int N_ranks );
629
630
631} // namespace AMP::Geometry::GeometryHelpers
632
633#endif
std::vector< Point3D > sampleQuad(const std::array< Point3D, 4 > &v, double d0, bool interior=true)
Sample a line.
std::vector< int > assignRanks(const std::vector< double > &x, int N_ranks)
Assign ranks to a point cloud.
double distanceToTriangle(const std::array< Point2D, 3 > &tri, const Point2D &pos, const Point2D &ang)
Compute the intersection of a ray and triangle.
std::array< double, 2 > Point2D
double distanceToSphere(double r, const Point3D &pos, const Point3D &ang)
Compute the intersection of a ray and sphere.
Point3D map_logical_shell(double r1, double r2, double x, double y, double z)
Map logical coordinates to a shell.
std::array< double, 1 > Point1D
std::vector< Point3D > sampleTet(const std::array< Point3D, 4 > &v, double d0, bool interior=true)
Sample a line.
double distanceToQuadrilateral(const std::array< Point2D, 4 > &quad, const Point2D &pos, const Point2D &ang)
Compute the intersection of a ray and quadrilateral.
double distanceToCone(const Point3D &V, double theta, const Point3D &pos, const Point3D &ang)
Compute the intersection of a ray and cone.
double distanceToTube(double r1, double r2, double h, const Point3D &pos, const Point3D &ang)
Compute the intersection of a ray and tube.
Point3D map_logical_sphere(double R, double x, double y, double z)
Map logical coordinates to a sphere.
Point2D map_logical_poly(int N, double R, double x, double y)
Map logical coordinates to a regular polygon.
std::array< double, 3 > Point3D
double distanceToCylinder(double r, double h, const Point3D &pos, const Point3D &ang)
Compute the intersection of a ray and cylinder.
double distanceToCircularFrustum(double rb, double rt, double h, const Point3D &pos, const Point3D &ang)
Compute the intersection of a ray and circular frustum.
Point2D nearest(const Point2D &v1, const Point2D &v2, const Point2D &p)
Find the nearest point to a line segment.
double distanceToLine(const Point2D &pos, const Point2D &ang, const Point2D &v1, const Point2D &v2)
Compute the intersection of a ray and a line segment.
Point2D map_logical_circle(double R, int method, double x, double y)
Map logical coordinates to a circle.
double distanceToTetrahedron(const std::array< Point3D, 4 > &tet, const Point3D &pos, const Point3D &ang)
Compute the intersection of a ray and tetrahedron.
std::vector< Point3D > sampleTri(const std::array< Point3D, 3 > &v, double d0, bool interior=true)
Sample a line.
Point2D map_sphere_surface_logical(int method, double R, double x, double y, double z)
Map coordinates from the surface of a sphere to logical.
Point3D normalToQuadrilateral(const std::array< Point3D, 4 > &quad)
Compute the normal to a quadrilateral.
Point3D map_logical_sphere_surface(int method, double R, double x, double y)
Map logical coordinates to the surface of a sphere.
Point3D map_sphere_logical(double R, double x, double y, double z)
Map logical coordinates to a sphere.
Point2D map_poly_logical(int N, double R, double x, double y)
Map physical coordinates to the logical coordinates.
Point2D map_circle_logical(double R, int method, double x, double y)
Map physical coordinates to the logical coordinates.
double distanceToBox(const std::array< double, NDIM > &pos, const std::array< double, NDIM > &ang, const std::array< double, NDIM > &lb, const std::array< double, NDIM > &ub)
Compute the intersection of a ray and a box.
std::vector< Point2D > get_poly_vertices(int N, double R)
Get the Vertices of a regular polygon.
std::vector< Point3D > sampleLine(const std::array< Point3D, 2 > &v, double d0, bool interior=true)
Sample a line.
double distanceToCircle(double r, const Point2D &pos, const Point2D &ang)
Compute the intersection of a ray and circle (2D)
std::vector< AMP::Mesh::Point > subdivide(const std::array< AMP::Mesh::Point, 3 > &v, double res)
Subdivide a triangle.
double distance(const Point3D &x1, const Point3D &x2)
Compute the distance between two points.
Point2D normal(const Point2D &a, const Point2D &b)
Compute the normal to a line defined by 2 points.
double distanceToPlane(const Point3D &n, const Point3D &p0, const Point3D &pos, const Point3D &ang)
Compute the intersection of a ray and an infinite plane.
std::array< double, NP > barycentric(const std::array< std::array< double, NDIM >, NP > &x, const std::array< double, NDIM > &p)
Compute the barycentric coordinates.
Point3D map_shell_logical(double r1, double r2, double x, double y, double z)
Map a shell to logical coordinates.



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:40.
Comments on this page