Skip to content

Commit f2907a6

Browse files
author
Roberto Di Remigio
committed
Creation of integrator deferred to creation of Green's function
1 parent b7d0806 commit f2907a6

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

src/green/IonicLiquid.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
class DiagonalIntegrator;
3737

3838
#include "DerivativeTypes.hpp"
39+
#include "DiagonalIntegratorFactory.hpp"
3940
#include "ForIdGreen.hpp"
4041
#include "GreenData.hpp"
4142
#include "GreensFunction.hpp"
@@ -107,7 +108,9 @@ namespace
107108
struct buildIonicLiquid {
108109
template <typename DerivativeType>
109110
IGreensFunction * operator()(const greenData & _data) {
110-
return new IonicLiquid<DerivativeType>(_data.epsilon, _data.kappa, _data.integrator);
111+
DiagonalIntegrator * integrator =
112+
DiagonalIntegratorFactory::TheDiagonalIntegratorFactory().createDiagonalIntegrator(_data.integratorType);
113+
return new IonicLiquid<DerivativeType>(_data.epsilon, _data.kappa, integrator);
111114
}
112115
};
113116

src/green/UniformDielectric.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
class DiagonalIntegrator;
3737

3838
#include "DerivativeTypes.hpp"
39+
#include "DiagonalIntegratorFactory.hpp"
3940
#include "ForIdGreen.hpp"
4041
#include "GreenData.hpp"
4142
#include "GreensFunction.hpp"
@@ -105,7 +106,9 @@ namespace
105106
struct buildUniformDielectric {
106107
template <typename DerivativeType>
107108
IGreensFunction * operator()(const greenData & _data) {
108-
return new UniformDielectric<DerivativeType>(_data.epsilon, _data.integrator);
109+
DiagonalIntegrator * integrator =
110+
DiagonalIntegratorFactory::TheDiagonalIntegratorFactory().createDiagonalIntegrator(_data.integratorType);
111+
return new UniformDielectric<DerivativeType>(_data.epsilon, integrator);
109112
}
110113
};
111114

src/green/Vacuum.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
class DiagonalIntegrator;
3737

3838
#include "DerivativeTypes.hpp"
39+
#include "DiagonalIntegratorFactory.hpp"
3940
#include "ForIdGreen.hpp"
4041
#include "GreenData.hpp"
4142
#include "GreensFunction.hpp"
@@ -104,7 +105,9 @@ namespace
104105
struct buildVacuum {
105106
template <typename DerivativeType>
106107
IGreensFunction * operator()(const greenData & _data) {
107-
return new Vacuum<DerivativeType>(_data.integrator);
108+
DiagonalIntegrator * integrator =
109+
DiagonalIntegratorFactory::TheDiagonalIntegratorFactory().createDiagonalIntegrator(_data.integratorType);
110+
return new Vacuum<DerivativeType>(integrator);
108111
}
109112
};
110113

src/interface/Interface.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,25 +512,21 @@ void initCavity()
512512

513513
void initSolver()
514514
{
515-
// First of all create the integrator for the diagonal elements of the S and D operators
516-
// in principle it could be a different integrator for the inside/outside Green's function
517-
std::string integratorType("COLLOCATION");
518-
DiagonalIntegrator * integrator = DiagonalIntegratorFactory::TheDiagonalIntegratorFactory().createDiagonalIntegrator(integratorType);
519515
GreensFunctionFactory & factory = GreensFunctionFactory::TheGreensFunctionFactory();
520516
// Get the input data for generating the inside & outside Green's functions
521517
// INSIDE
522518
double epsilon = parsedInput->epsilonInside();
523519
std::string greenType = parsedInput->greenInsideType();
524520
int greenDer = parsedInput->derivativeInsideType();
525-
greenData inside(greenDer, epsilon, integrator);
521+
greenData inside(greenDer, epsilon);
526522

527523
IGreensFunction * gfInside = factory.createGreensFunction(greenType, inside);
528524

529525
// OUTSIDE, reuse the variables holding the parameters for the Green's function inside.
530526
epsilon = parsedInput->epsilonOutside();
531527
greenType = parsedInput->greenOutsideType();
532528
greenDer = parsedInput->derivativeOutsideType();
533-
greenData outside(greenDer, epsilon, integrator);
529+
greenData outside(greenDer, epsilon);
534530

535531
IGreensFunction * gfOutside = factory.createGreensFunction(greenType, outside);
536532
// And all this to finally create the solver!

src/utils/GreenData.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,23 @@ class DiagonalIntegrator;
5555
struct greenData {
5656
int how;
5757
double epsilon;
58+
std::string integratorType;
5859
double kappa;
5960
double epsilonReal;
6061
double epsilonImaginary;
6162
std::vector<double> spherePosition;
6263
double sphereRadius;
63-
std::string integratorType;
6464
bool empty;
6565

6666
greenData() { empty = true;}
67-
greenData(int _how, double _epsilon = 1.0,
67+
greenData(int _how, double _epsilon = 1.0, const std::string & _diag = "COLLOCATION",
6868
double _kappa = 0.0,
6969
double _epsReal = 0.0, double _epsImaginary = 0.0,
7070
const std::vector<double> & _sphere = std::vector<double>(),
71-
double _sphRadius = 0.0, const std::string & _diag) :
72-
how(_how), epsilon(_epsilon), kappa(_kappa), epsilonReal(_epsReal),
73-
epsilonImaginary(_epsImaginary),
74-
spherePosition(_sphere), sphereRadius(_sphRadius), integratorType(_diag) { empty = false; }
71+
double _sphRadius = 0.0) :
72+
how(_how), epsilon(_epsilon), integratorType(_diag), kappa(_kappa),
73+
epsilonReal(_epsReal), epsilonImaginary(_epsImaginary),
74+
spherePosition(_sphere), sphereRadius(_sphRadius) { empty = false; }
7575
};
7676

7777
#endif // GREENDATA_HPP

tests/green/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(list_of_libraries green)
1+
set(list_of_libraries green bi_operators)
22

33
list(APPEND external_libraries)
44
add_boosttest(green_vacuum "${list_of_libraries}" "${external_libraries}")

0 commit comments

Comments
 (0)