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
13#include <memory>
14
21namespace amrex::EB2 {
22
24class SplineIF {
25 public:
26
32 void addSplineElement(std::vector<amrex::RealVect> pts) {
33 auto theSpline = std::make_shared<SplineDistFcnElement2d>();
34 theSpline->set_control_points(std::move(pts));
35 theSpline->calc_D();
36 geomElements.push_back(std::move(theSpline));
37 }
38
42 void addLineElement(std::vector<amrex::RealVect> pts) {
43 auto theLine = std::make_shared<LineDistFcnElement2d>();
44 theLine->set_control_points(std::move(pts));
45 geomElements.push_back(std::move(theLine));
46 }
47
53 [[nodiscard]] amrex::Real operator() (const amrex::RealArray& p) const {
55 distFcnElement2d * closesetGeomElement = nullptr;
56 amrex::Real dist;
57 dist = 1.0e29_rt;
58 amrex::RealVect x(AMREX_D_DECL(p[0], p[1], p[2]));
59 for (auto const& geom : geomElements ) {
60 amrex::Real d = geom->cpdist(x, cp);
61 if (d < dist) {
62 dist = d;
63 closesetGeomElement = geom.get();
64 }
65 }
66 amrex::Real side = closesetGeomElement ? closesetGeomElement->cpside(x,cp) : Real(0.0);
67 return dist*side;
68 }
69
72};
73
74}
75#endif
Runtime initialization/finalization helpers and global diagnostics.
Fixed-size array types for use on GPU and CPU.
#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:24
amrex::Vector< std::shared_ptr< distFcnElement2d > > geomElements
Collection of geometry elements that define the curve.
Definition AMReX_EB2_IF_Spline.H:71
void addSplineElement(std::vector< amrex::RealVect > pts)
Append a spline segment described by control points pts.
Definition AMReX_EB2_IF_Spline.H:32
void addLineElement(std::vector< amrex::RealVect > pts)
Append a straight line segment with endpoints/control points pts.
Definition AMReX_EB2_IF_Spline.H:42
amrex::Real operator()(const amrex::RealArray &p) const
Signed distance to the closest spline/line element through p.
Definition AMReX_EB2_IF_Spline.H:53
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
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:80
Array< Real, 3 > RealArray
Definition AMReX_Array.H:35
Definition AMReX_FabArrayBase.H:38