Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_EB2_IF_Spline.H
Go to the documentation of this file.
1
2#ifndef AMREX_EB2_IF_SPLINE_H_
3#define AMREX_EB2_IF_SPLINE_H_
4#include <AMReX_Config.H>
5
6#include <AMReX_EB2_IF_Base.H>
7#include <AMReX_RealVect.H>
8#include <AMReX.H>
9#include <AMReX_Vector.H>
10#include <AMReX_Array.H>
12
19namespace amrex::EB2 {
20
22class SplineIF {
23 public:
24
30 void addSplineElement(std::vector<amrex::RealVect> pts) {
31 auto* theSpline = new SplineDistFcnElement2d();
32 theSpline->set_control_points(std::move(pts));
33 theSpline->calc_D();
34 geomElements.push_back(theSpline);
35 }
36
40 void addLineElement(std::vector<amrex::RealVect> pts) {
41 auto* theLine = new LineDistFcnElement2d();
42 theLine->set_control_points(std::move(pts));
43 geomElements.push_back(theLine);
44 }
45
51 [[nodiscard]] amrex::Real operator() (const amrex::RealArray& p) const {
53 distFcnElement2d * closesetGeomElement = nullptr;
54 amrex::Real dist;
55 dist = 1.0e29_rt;
56 amrex::RealVect x(AMREX_D_DECL(p[0], p[1], p[2]));
57 for (auto * geom : geomElements ) {
58 amrex::Real d = geom->cpdist(x, cp);
59 if (d < dist) {
60 dist = d;
61 closesetGeomElement = geom;
62 }
63 }
64 amrex::Real side = closesetGeomElement ? closesetGeomElement->cpside(x,cp) : Real(0.0);
65 return dist*side;
66 }
67
70};
71
72}
73#endif
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Implicit function that measures distance to a poly-spline curve in 2-D.
Definition AMReX_EB2_IF_Spline.H:22
void addSplineElement(std::vector< amrex::RealVect > pts)
Append a spline segment described by control points pts.
Definition AMReX_EB2_IF_Spline.H:30
void addLineElement(std::vector< amrex::RealVect > pts)
Append a straight line segment with endpoints/control points pts.
Definition AMReX_EB2_IF_Spline.H:40
amrex::Vector< distFcnElement2d * > geomElements
Collection of geometry elements that define the curve.
Definition AMReX_EB2_IF_Spline.H:69
amrex::Real operator()(const amrex::RealArray &p) const
Signed distance to the closest spline/line element through p.
Definition AMReX_EB2_IF_Spline.H:51
Distance function defined by a polyline.
Definition AMReX_distFcnElement.H:37
Distance function defined by a cubic spline.
Definition AMReX_distFcnElement.H:67
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
Abstract base for 2-D distance-function elements.
Definition AMReX_distFcnElement.H:18
virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect &cp) const =0
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
Definition AMReX_FabArrayBase.H:33
Array< Real, 3 > RealArray
Definition AMReX_Array.H:28