1#ifndef G_COMPONENT_NEBEM_3D_H
2#define G_COMPONENT_NEBEM_3D_H
19 Medium*
GetMedium(
const double x,
const double y,
const double z)
override;
20 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
21 double& ey,
double& ez,
Medium*& m,
int& status)
override;
22 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
23 double& ey,
double& ez,
double& v,
Medium*& m,
24 int& status)
override;
27 void WeightingField(
const double x,
const double y,
const double z,
28 double& wx,
double& wy,
double& wz,
29 const std::string& label)
override;
31 const double z,
const std::string& label)
override;
34 void AddPlaneX(
const double x,
const double voltage);
36 void AddPlaneY(
const double y,
const double voltage);
38 void AddPlaneZ(
const double z,
const double voltage);
46 bool GetPlaneX(
const unsigned int i,
double& x,
double& v)
const;
48 bool GetPlaneY(
const unsigned int i,
double& y,
double& v)
const;
50 bool GetPlaneZ(
const unsigned int i,
double& z,
double& v)
const;
53 bool GetPrimitive(
const unsigned int i,
double& a,
double& b,
double& c,
54 std::vector<double>& xv, std::vector<double>& yv,
55 std::vector<double>& zv,
int& interface,
double& v,
56 double& q,
double& lambda)
const;
57 bool GetPrimitive(
const unsigned int i,
double& a,
double& b,
double& c,
58 std::vector<double>& xv, std::vector<double>& yv,
59 std::vector<double>& zv,
int& vol1,
int& vol2)
const;
60 bool GetVolume(
const unsigned int vol,
int& shape,
int& material,
61 double& eps,
double& potential,
double& charge,
int& bc);
62 int GetVolume(
const double x,
const double y,
const double z);
66 std::vector<double>& xv, std::vector<double>& yv,
67 std::vector<double>& zv,
int& interface,
double& bc,
68 double& lambda)
const;
80 const unsigned int nmax);
91 const unsigned int nz);
94 unsigned int& nz)
const {
120 m_nThreads = n > 0 ? n : 1;
124 void Reset()
override;
132 std::vector<double> xv;
134 std::vector<double> yv;
136 std::vector<double> zv;
151 std::vector<Primitive> m_primitives;
155 std::array<double, 3> origin;
161 std::array<std::array<double, 3>, 3> dcos;
163 std::vector<double> xv;
165 std::vector<double> yv;
167 std::vector<double> zv;
173 std::array<double, 3> collocationPoint;
182 std::vector<Element> m_elements;
185 std::array<bool, 6> m_ynplan{{
false,
false,
false,
false,
false,
false}};
187 std::array<double, 6> m_coplan{{0., 0., 0., 0., 0., 0.}};
189 std::array<double, 6> m_vtplan{{0., 0., 0., 0., 0., 0.}};
192 unsigned int m_nThreads = 1;
194 static constexpr double MinDist = 1.e-6;
196 double m_targetElementSize = 50.0e-4;
198 unsigned int m_minNbElementsOnLength = 1;
200 unsigned int m_maxNbElementsOnLength = 100;
202 std::array<double, 3> m_periodicLength{{0., 0., 0.}};
204 unsigned int m_nCopiesX = 5;
206 unsigned int m_nCopiesY = 5;
208 unsigned int m_nCopiesZ = 5;
210 enum class Inversion { LU = 0, SVD };
211 Inversion m_inversion = Inversion::LU;
214 std::map<std::string, int> m_wfields;
217 void ShiftPanels(std::vector<Panel>& panels)
const;
219 bool EliminateOverlaps(
const Panel& panel1,
const Panel& panel2,
220 std::vector<Panel>& panelsOut,
221 std::vector<int>& itypo);
223 bool TraceEnclosed(
const std::vector<double>& xl1,
224 const std::vector<double>& yl1,
225 const std::vector<double>& xl2,
226 const std::vector<double>& yl2,
const Panel& originalPanel,
227 std::vector<Panel>& newPanels)
const;
229 void TraceNonOverlap(
230 const std::vector<double>& xp1,
const std::vector<double>& yp1,
231 const std::vector<double>& xl1,
const std::vector<double>& yl1,
232 const std::vector<double>& xl2,
const std::vector<double>& yl2,
233 const std::vector<int>& flags1,
const std::vector<int>& flags2,
234 const std::vector<int>& links1,
const std::vector<int>& links2,
235 std::vector<bool>& mark1,
int ip1,
const Panel& originalPanel,
236 std::vector<Panel>& newPanels)
const;
239 const std::vector<double>& xp1,
const std::vector<double>& yp1,
240 const std::vector<double>& xp2,
const std::vector<double>& yp2,
241 const std::vector<double>& xl1,
const std::vector<double>& yl1,
242 const std::vector<double>& xl2,
const std::vector<double>& yl2,
243 const std::vector<int>& flags1,
const std::vector<int>& links1,
244 const std::vector<int>& links2, std::vector<bool>& mark1,
int ip1,
245 int ip2,
const Panel& originalPanel, std::vector<Panel>& newPanels)
const;
248 bool MakePrimitives(
const Panel& panelIn,
249 std::vector<Panel>& panelsOut)
const;
253 bool SplitTrapezium(
const Panel panelIn, std::vector<Panel>& stack,
254 std::vector<Panel>& panelsOut,
const double epsang)
const;
256 unsigned int NbOfSegments(
const double length,
const double target)
const;
257 bool DiscretizeWire(
const Primitive& primitive,
const double targetSize,
258 std::vector<Element>& elements)
const;
259 bool DiscretizeTriangle(
const Primitive& primitive,
const double targetSize,
260 std::vector<Element>& elements)
const;
261 bool DiscretizeRectangle(
const Primitive& prim,
const double targetSize,
262 std::vector<Element>& elements)
const;
bool GetPlaneZ(const unsigned int i, double &z, double &v) const
Retrieve the parameters of a plane at constant z.
bool GetPlaneY(const unsigned int i, double &y, double &v) const
Retrieve the parameters of a plane at constant y.
void AddPlaneZ(const double z, const double voltage)
Add a plane at constant z.
ComponentNeBem3d()
Constructor.
bool GetPeriodicityX(double &s) const
Get the periodic length in the x-direction.
unsigned int GetNumberOfPrimitives() const
bool GetPeriodicityZ(double &s) const
Get the periodic length in the z-direction.
void Reset() override
Reset the component.
void SetMirrorPeriodicityX(const double s)
Set the periodic length [cm] in the x-direction.
void SetPeriodicityX(const double s)
Set the periodic length [cm] in the x-direction.
void UpdatePeriodicity() override
Verify periodicities.
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
unsigned int GetNumberOfPlanesY() const
Get the number of equipotential planes at constant y.
bool GetPeriodicityY(double &s) const
Get the periodic length in the y-direction.
unsigned int GetNumberOfPlanesZ() const
Get the number of equipotential planes at constant z.
void SetNumberOfThreads(const unsigned int n)
Set the number of threads to be used by neBEM.
void AddPlaneY(const double y, const double voltage)
Add a plane at constant y.
void AddPlaneX(const double x, const double voltage)
Add a plane at constant x.
void SetMirrorPeriodicityZ(const double s)
Set the periodic length [cm] in the z-direction.
void SetPeriodicityZ(const double s)
Set the periodic length [cm] in the z-direction.
bool GetVolume(const unsigned int vol, int &shape, int &material, double &eps, double &potential, double &charge, int &bc)
void SetPeriodicityY(const double s)
Set the periodic length [cm] in the y-direction.
void UseSVDInversion()
Invert the influence matrix using singular value decomposition.
Medium * GetMedium(const double x, const double y, const double z) override
Get the medium at a given location (x, y, z).
unsigned int GetNumberOfPlanesX() const
Get the number of equipotential planes at constant x.
bool GetElement(const unsigned int i, std::vector< double > &xv, std::vector< double > &yv, std::vector< double > &zv, int &interface, double &bc, double &lambda) const
void SetTargetElementSize(const double length)
void SetMirrorPeriodicityY(const double s)
Set the periodic length [cm] in the y-direction.
void SetPeriodicCopies(const unsigned int nx, const unsigned int ny, const unsigned int nz)
~ComponentNeBem3d()
Destructor.
bool GetPrimitive(const unsigned int i, double &a, double &b, double &c, std::vector< double > &xv, std::vector< double > &yv, std::vector< double > &zv, int &interface, double &v, double &q, double &lambda) const
void SetMinMaxNumberOfElements(const unsigned int nmin, const unsigned int nmax)
unsigned int GetNumberOfElements() const
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
void UseLUInversion()
Invert the influence matrix using lower-upper (LU) decomposition.
bool GetPlaneX(const unsigned int i, double &x, double &v) const
Retrieve the parameters of a plane at constant x.
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
void GetPeriodicCopies(unsigned int &nx, unsigned int &ny, unsigned int &nz) const
Retrieve the number of periodic copies used by neBEM.
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
Abstract base class for components.
Abstract base class for media.
ComponentNeBem3d * gComponentNeBem3d
neBEMGLOBAL int * InterfaceType