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;
22 void AddPlaneX(
const double x,
const double voltage);
24 void AddPlaneY(
const double y,
const double voltage);
26 void AddPlaneZ(
const double z,
const double voltage);
34 bool GetPlaneX(
const unsigned int i,
double& x,
double& v)
const;
36 bool GetPlaneY(
const unsigned int i,
double& y,
double& v)
const;
38 bool GetPlaneZ(
const unsigned int i,
double& z,
double& v)
const;
41 bool GetPrimitive(
const unsigned int i,
double& a,
double& b,
double& c,
42 std::vector<double>& xv, std::vector<double>& yv,
43 std::vector<double>& zv,
int& interface,
double& v,
44 double& q,
double& lambda)
const;
45 bool GetPrimitive(
const unsigned int i,
double& a,
double& b,
double& c,
46 std::vector<double>& xv, std::vector<double>& yv,
47 std::vector<double>& zv,
int& vol1,
int& vol2)
const;
48 bool GetVolume(
const unsigned int vol,
int& shape,
int& material,
double& eps,
49 double& potential,
double& charge,
int& bc);
50 int GetVolume(
const double x,
const double y,
const double z);
53 bool GetElement(
const unsigned int i, std::vector<double>& xv,
54 std::vector<double>& yv, std::vector<double>& zv,
55 int& interface,
double& bc,
double& lambda)
const;
67 const unsigned int nmax);
74 const unsigned int NewBC,
const unsigned int NewPP);
155 const unsigned int nz);
158 unsigned int& nz)
const {
198 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
199 double& ey,
double& ez,
Medium*& m,
int& status)
override;
200 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
201 double& ey,
double& ez,
double& v,
Medium*& m,
202 int& status)
override;
206 void WeightingField(
const double x,
const double y,
const double z,
207 double& wx,
double& wy,
double& wz,
208 const std::string& label)
override;
210 const std::string& label)
override;
213 void Reset()
override;
221 std::vector<double> xv;
223 std::vector<double> yv;
225 std::vector<double> zv;
240 std::vector<Primitive> m_primitives;
244 std::array<double, 3> origin;
250 std::array<std::array<double, 3>, 3> dcos;
252 std::vector<double> xv;
254 std::vector<double> yv;
256 std::vector<double> zv;
262 std::array<double, 3> collocationPoint;
266 double assigned = 0.;
268 double solution = 0.;
271 std::vector<Element> m_elements;
274 std::array<bool, 6> m_ynplan{{
false,
false,
false,
false,
false,
false}};
276 std::array<double, 6> m_coplan{{0., 0., 0., 0., 0., 0.}};
278 std::array<double, 6> m_vtplan{{0., 0., 0., 0., 0., 0.}};
281 unsigned int m_newModel = 1;
282 unsigned int m_newMesh = 1;
283 unsigned int m_newBC = 1;
284 unsigned int m_newPP = 1;
287 unsigned int m_optStoreInflMatrix = 0;
288 unsigned int m_optReadInflMatrix = 0;
289 unsigned int m_optStoreInvMatrix = 1;
290 unsigned int m_optReadInvMatrix = 0;
291 unsigned int m_optStorePrimitives = 0;
292 unsigned int m_optReadPrimitives = 0;
293 unsigned int m_optStoreElements = 0;
294 unsigned int m_optReadElements = 0;
295 unsigned int m_optStoreFormatted = 1;
296 unsigned int m_optStoreUnformatted = 0;
305 unsigned int m_optSystemChargeZero = 1;
306 unsigned int m_optValidateSolution = 1;
307 unsigned int m_optForceValidation = 0;
308 unsigned int m_optRepeatLHMatrix = 0;
311 unsigned int m_optFastVol = 0;
312 unsigned int m_optCreateFastPF = 0;
313 unsigned int m_optReadFastPF = 0;
314 unsigned int m_versionFV = 0;
315 unsigned int m_nbBlocksFV = 0;
318 unsigned int m_idWtField = 0;
319 unsigned int m_optWtFldFastVol[11];
320 unsigned int m_optCreateWtFldFastPF[11];
321 unsigned int m_optReadWtFldFastPF[11];
322 unsigned int m_versionWtFldFV[11];
323 unsigned int m_nbBlocksWtFldFV[11];
326 unsigned int m_optKnownCharge = 0;
329 unsigned int m_optChargingUp = 0;
332 unsigned int m_nThreads = 1;
336 int m_primAfter = -1;
341 int m_wtFldPrimAfter = -1;
345 unsigned int m_optRmPrim = 0;
347 static constexpr double MinDist = 1.e-6;
349 double m_targetElementSize = 50.0e-4;
351 unsigned int m_minNbElementsOnLength = 1;
353 unsigned int m_maxNbElementsOnLength = 100;
355 std::array<double, 3> m_periodicLength{{0., 0., 0.}};
357 unsigned int m_nCopiesX = 5;
359 unsigned int m_nCopiesY = 5;
361 unsigned int m_nCopiesZ = 5;
363 enum class Inversion { LU = 0, SVD };
364 Inversion m_inversion = Inversion::LU;
367 std::map<std::string, int> m_wfields;
371 void ShiftPanels(std::vector<Panel>& panels)
const;
373 bool EliminateOverlaps(
const Panel& panel1,
const Panel& panel2,
374 std::vector<Panel>& panelsOut,
375 std::vector<int>& itypo);
377 bool TraceEnclosed(
const std::vector<double>& xl1,
378 const std::vector<double>& yl1,
379 const std::vector<double>& xl2,
380 const std::vector<double>& yl2,
const Panel& originalPanel,
381 std::vector<Panel>& newPanels)
const;
383 void TraceNonOverlap(
384 const std::vector<double>& xp1,
const std::vector<double>& yp1,
385 const std::vector<double>& xl1,
const std::vector<double>& yl1,
386 const std::vector<double>& xl2,
const std::vector<double>& yl2,
387 const std::vector<int>& flags1,
const std::vector<int>& flags2,
388 const std::vector<int>& links1,
const std::vector<int>& links2,
389 std::vector<bool>& mark1,
int ip1,
const Panel& originalPanel,
390 std::vector<Panel>& newPanels)
const;
393 const std::vector<double>& xp1,
const std::vector<double>& yp1,
394 const std::vector<double>& xp2,
const std::vector<double>& yp2,
395 const std::vector<double>& xl1,
const std::vector<double>& yl1,
396 const std::vector<double>& xl2,
const std::vector<double>& yl2,
397 const std::vector<int>& flags1,
const std::vector<int>& links1,
398 const std::vector<int>& links2, std::vector<bool>& mark1,
int ip1,
399 int ip2,
const Panel& originalPanel, std::vector<Panel>& newPanels)
const;
402 bool MakePrimitives(
const Panel& panelIn,
403 std::vector<Panel>& panelsOut)
const;
407 bool SplitTrapezium(
const Panel panelIn, std::vector<Panel>& stack,
408 std::vector<Panel>& panelsOut,
const double epsang)
const;
410 unsigned int NbOfSegments(
const double length,
const double target)
const;
411 bool DiscretizeWire(
const Primitive& primitive,
const double targetSize,
412 std::vector<Element>& elements)
const;
413 bool DiscretizeTriangle(
const Primitive& primitive,
const double targetSize,
414 std::vector<Element>& elements)
const;
415 bool DiscretizeRectangle(
const Primitive& prim,
const double targetSize,
416 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 SetSystemChargeZero(const unsigned int OptSystemChargeZero)
void SetWtFldPrimAfter(const int n)
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.
void SetPrimAfter(const int n)
unsigned int GetNumberOfPrimitives() const
void SetFastVolBlocks(const unsigned int NbBlocksFV)
void SetStoreElements(const unsigned int OptStoreElements)
void SetWtFldFastVolVersion(const unsigned int IdWtField, const unsigned int VersionWtFldFV)
bool GetPeriodicityZ(double &s) const
Get the periodic length in the z-direction.
void Reset() override
Reset the component.
void SetUnformattedFile(const unsigned int OptUnformattedFile)
void SetMirrorPeriodicityX(const double s)
Set the periodic length [cm] in the x-direction.
void SetOptRmPrim(const unsigned int n)
Set option related to removal of primitives.
void SetPeriodicityX(const double s)
Set the periodic length [cm] in the x-direction.
void SetWtFldFastVolOptions(const unsigned int IdWtField, const unsigned int OptWtFldFastVol, const unsigned int OptCreateWtFldFastPF, const unsigned int OptReadWtFldFastPF)
void UpdatePeriodicity() override
Verify periodicities.
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
void SetStoreReadOptions(const unsigned int OptStoreInflMatrix, const unsigned int OptReadInflMatrix, const unsigned int OptStoreInvMatrix, const unsigned int OptReadInvMatrix, const unsigned int OptStorePrimitives, const unsigned int OptReadPrimitives, const unsigned int OptStoreElements, const unsigned int OptReadElements, const unsigned int OptFormattedFile, const unsigned int OptUnformattedFile)
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.
void SetReadPrimitives(const unsigned int OptReadPrimitives)
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 SetReadInvMatrix(const unsigned int OptReadInvMatrix)
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 SetForceValidation(const unsigned int OptForceValidation)
void SetRepeatLHMatrix(const unsigned int OptRepeatLHMatrix)
void SetValidateSolution(const unsigned int OptValidateSolution)
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).
void SetNewMesh(const unsigned int NewMesh)
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 SetStoreInvMatrix(const unsigned int OptStoreInvMatrix)
void SetWtFldFastVolBlocks(const unsigned int IdWtField, const unsigned int NbBlocksWtFldFV)
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)
void SetComputeOptions(const unsigned int OptSystemChargeZero, const unsigned int OptValidateSolution, const unsigned int OptForceValidation, const unsigned int OptRepeatLHMatrix)
~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 SetFastVolOptions(const unsigned int OptFastVol, const unsigned int OptCreateFastPF, const unsigned int OptReadFastPF)
void SetMinMaxNumberOfElements(const unsigned int nmin, const unsigned int nmax)
void SetReadInflMatrix(const unsigned int OptReadInflMatrix)
void SetChargingUpOptions(const unsigned int OptChargingUp)
unsigned int GetNumberOfElements() const
void SetNewBC(const unsigned int NewBC)
void SetModelOptions(const unsigned int NewModel, const unsigned int NewMesh, const unsigned int NewBC, const unsigned int NewPP)
void SetFastVolVersion(const unsigned int VersionFV)
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
void SetStoreInflMatrix(const unsigned int OptStoreInflMatrix)
void UseLUInversion()
Invert the influence matrix using lower-upper (LU) decomposition.
void SetNewPP(const unsigned int NewPP)
void SetNewModel(const unsigned int NewModel)
void SetReadElements(const unsigned int OptReadElements)
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 SetKnownChargeOptions(const unsigned int OptKnownCharge)
void GetPeriodicCopies(unsigned int &nx, unsigned int &ny, unsigned int &nz) const
Retrieve the number of periodic copies used by neBEM.
void SetStorePrimitives(const unsigned int OptStorePrimitives)
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
void SetFormattedFile(const unsigned int OptFormattedFile)
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
Component()=delete
Default constructor.
Abstract base class for media.
ComponentNeBem3d * gComponentNeBem3d
neBEMGLOBAL int OptRepeatLHMatrix
neBEMGLOBAL int OptReadPrimitives
neBEMGLOBAL int OptStorePrimitives
neBEMGLOBAL int OptFormattedFile
neBEMGLOBAL int OptChargingUp
neBEMGLOBAL int OptWtFldFastVol[MAXWtFld]
neBEMGLOBAL int NbBlocksWtFldFV[MAXWtFld]
neBEMGLOBAL int VersionFV
neBEMGLOBAL int OptCreateFastPF
neBEMGLOBAL int OptSystemChargeZero
neBEMGLOBAL int OptCreateWtFldFastPF[MAXWtFld]
neBEMGLOBAL int OptFastVol
neBEMGLOBAL int * InterfaceType
neBEMGLOBAL int OptReadFastPF
neBEMGLOBAL int OptStoreInflMatrix
neBEMGLOBAL int OptReadInflMatrix
neBEMGLOBAL int OptForceValidation
neBEMGLOBAL int OptUnformattedFile
neBEMGLOBAL int OptReadInvMatrix
neBEMGLOBAL int NbBlocksFV
neBEMGLOBAL int VersionWtFldFV[MAXWtFld]
neBEMGLOBAL int OptValidateSolution
neBEMGLOBAL int OptReadElements
neBEMGLOBAL int OptStoreElements
neBEMGLOBAL int OptStoreInvMatrix
neBEMGLOBAL int OptReadWtFldFastPF[MAXWtFld]