Start of solver, missing connection, density interpolation, cpu sync
This commit is contained in:
committed by
Jonas Kellerer
parent
83fd2e5d7e
commit
da5d7e27db
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#ifndef POISSON_SOLVER_H
|
||||
#define POISSON_SOLVER_H
|
||||
|
||||
#include "blitz/array.h"
|
||||
|
||||
class Geometry;
|
||||
class CylinderBinning;
|
||||
|
||||
enum class BoundaryType {
|
||||
no_boundary,
|
||||
dirichlet,
|
||||
neumann_to_top,
|
||||
neumann_to_bottom,
|
||||
neumann_to_hull
|
||||
};
|
||||
|
||||
struct PotentialGridPoint {
|
||||
BoundaryType type;
|
||||
double value;
|
||||
};
|
||||
|
||||
struct GlobalBoundary {
|
||||
double boundary_value;
|
||||
BoundaryType type
|
||||
};
|
||||
|
||||
class PoissonSolver {
|
||||
public:
|
||||
PoissonSolver(GlobalBoundary bottom_boundary,
|
||||
GlobalBoundary top_boundary,
|
||||
GlobalBoundary hull_boundary,
|
||||
std::shared_ptr<Geometry> geometry,
|
||||
std::shared_ptr<CylinderBinning> density_binning,
|
||||
std::vector<std::shared_ptr<Electrode>> electrodes,
|
||||
double target_accuracy,
|
||||
int num_cycles);
|
||||
|
||||
void solvePotential(const blitz::Array<double, 3> charge_density);
|
||||
blitz::Array<double, 3> potential();
|
||||
|
||||
private:
|
||||
Boundary bottom_boundary_;
|
||||
Boundary top_boundary_;
|
||||
Boundary hull_boundary_;
|
||||
std::shared_ptr<Geometry> geometry_;
|
||||
std::vector<std::shared_ptr<Electrode>> electrodes_;
|
||||
std::shared_ptr<CylinderBinning> density_binning_;
|
||||
double target_accuracy_;
|
||||
int num_cycles_;
|
||||
|
||||
blitz::Array<PotentialGridPoint, 3> potential_;
|
||||
|
||||
blitz::Array<double, 3> interpolateDensityToPotentialGrid(
|
||||
const blitz::Array<double, 3> charge_density);
|
||||
|
||||
void solverIteration(const blitz::Array<double, 3>& interpolated_density);
|
||||
bool converged(const blitz::Array<double, 3>& interpolated_density);
|
||||
};
|
||||
|
||||
class Electrode {
|
||||
public:
|
||||
Electrode(double potential);
|
||||
virtual bool isOnElectrode(Coordinate* position) = 0;
|
||||
double electrodePotential();
|
||||
|
||||
private:
|
||||
const double potential_;
|
||||
};
|
||||
|
||||
class RearWall : public Electrode {
|
||||
public:
|
||||
RearWall(double potential);
|
||||
bool isOnElectrode(Coordinate* position);
|
||||
};
|
||||
|
||||
#endif /* POISSON_SOLVER_H */
|
||||
Reference in New Issue
Block a user