Skip to content

Commit aa77517

Browse files
author
Roberto Di Remigio
committed
Change way quadratureLevel_ is initialized and remove some useless constructors.
quadratureLevel_ is set to 0 in ConAF and LinAF constructor and HAS to be set to the right value in initWEMMembers (this is done already)
1 parent 05d0db3 commit aa77517

22 files changed

+42
-428
lines changed

src/bin/benzene_wavelet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include <Eigen/Dense>
3434

35+
#include "Compression.hpp"
3536
#include "DerivativeTypes.hpp"
3637
#include "PWCSolver.hpp"
3738
#include "UniformDielectric.hpp"
@@ -50,7 +51,8 @@ void read_sphere() {
5051
UniformDielectric<AD_directional> * gfOutside = new
5152
UniformDielectric<AD_directional>(permittivity);
5253
int firstKind = 0;
53-
PWCSolver solver(gfInside, gfOutside, firstKind);
54+
Compression comp(1.0, 1.25, 0.001);
55+
PWCSolver solver(gfInside, gfOutside, comp, firstKind);
5456
solver.buildSystemMatrix(cavity);
5557
}
5658

@@ -94,7 +96,6 @@ void pwc_C6H6()
9496
#endif
9597
Compression comp(2.5, 2.5, 0.001);
9698
PWCSolver solver(gfInside, gfOutside, comp, firstKind);
97-
//PWCSolver solver(gfInside, gfOutside, firstKind);
9899
solver.buildSystemMatrix(cavity);
99100
cavity.uploadPoints(solver.getQuadratureLevel(), solver.getT_());
100101

src/bin/profile_pwc.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ void pwc_NH3(int patchLevel)
8181
FILE* debugFile = fopen("debug.out","w");
8282
fclose(debugFile);
8383
#endif
84-
PWCSolver solver(gfInside, gfOutside, firstKind);
84+
Compression comp(2.5, 2.5, 0.001);
85+
PWCSolver solver(gfInside, gfOutside, comp, firstKind);
8586
solver.buildSystemMatrix(cavity);
8687
cavity.uploadPoints(solver.getQuadratureLevel(), solver.getT_());
8788

@@ -179,7 +180,8 @@ void pwc_C6H6(int patchLevel)
179180
FILE* debugFile = fopen("debug.out","w");
180181
fclose(debugFile);
181182
#endif
182-
PWCSolver solver(gfInside, gfOutside, firstKind);
183+
Compression comp(2.5, 2.5, 0.001);
184+
PWCSolver solver(gfInside, gfOutside, comp, firstKind);
183185
solver.buildSystemMatrix(cavity);
184186
cavity.uploadPoints(solver.getQuadratureLevel(), solver.getT_());
185187

src/bin/profile_pwl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ void pwl_NH3(int patchLevel)
8282
FILE* debugFile = fopen("debug.out","w");
8383
fclose(debugFile);
8484
#endif
85-
PWLSolver solver(gfInside, gfOutside, firstKind);
85+
Compression comp(2.5, 2.5, 0.001);
86+
PWLSolver solver(gfInside, gfOutside, comp, firstKind);
8687
solver.buildSystemMatrix(cavity);
8788
cavity.uploadPoints(solver.getQuadratureLevel(), solver.getT_());
8889

@@ -180,7 +181,8 @@ void pwl_C6H6(int patchLevel)
180181
FILE* debugFile = fopen("debug.out","w");
181182
fclose(debugFile);
182183
#endif
183-
PWLSolver solver(gfInside, gfOutside, firstKind);
184+
Compression comp(2.5, 2.5, 0.001);
185+
PWLSolver solver(gfInside, gfOutside, comp, firstKind);
184186
solver.buildSystemMatrix(cavity);
185187
cavity.uploadPoints(solver.getQuadratureLevel(), solver.getT_());
186188

src/interface/Interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,13 @@ void initNonEqSolver()
583583
// (...not our fault, but should remedy somehow)
584584
#if defined (DEVELOPMENT_CODE)
585585
if (modelType == "WAVELET") {
586-
_noneqPWCSolver = new PWCSolver(gfInside, gfOutside);
586+
_noneqPWCSolver = new PWCSolver(gfInside, gfOutside, comp);
587587
_noneqPWCSolver->buildSystemMatrix(*_waveletCavity);
588588
_waveletCavity->uploadPoints(_noneqPWCSolver->getQuadratureLevel(), _noneqPWCSolver->getT_());
589589
_cavity = _waveletCavity;
590590
_noneqSolver = _noneqPWCSolver;
591591
} else if (modelType == "LINEAR") {
592-
_noneqPWLSolver = new PWLSolver(gfInside, gfOutside);
592+
_noneqPWLSolver = new PWLSolver(gfInside, gfOutside, comp);
593593
_noneqPWLSolver->buildSystemMatrix(*_waveletCavity);
594594
_waveletCavity->uploadPoints(_noneqPWLSolver->getQuadratureLevel(), _noneqPWLSolver->getT_());
595595
_cavity = _waveletCavity;

src/solver/PWCSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void PWCSolver::initWEMMembers()
104104
// T_ = NULL;
105105
systemMatricesInitialized_ = false;
106106
threshold = 1e-10;
107-
//af->quadratureLevel_ = 1; // set in constructor of AnsatzFunction
107+
af->quadratureLevel_ = std::ceil(0.5 * (af->td - op)) - 1;
108108
//af->nQuadPoints = 0; //??? what is this for?
109109
af->elementTree.element = NULL;
110110
af->elementTree.nop = 0;

src/solver/PWCSolver.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ class PWCSolver : public PCMSolver
6464
void initWEMMembers();
6565
virtual std::ostream & printSolver(std::ostream & os);
6666
public:
67-
PWCSolver(IGreensFunction * gfInside_, IGreensFunction * gfOutside_, int integralEquation_ = SecondKind)
68-
: PCMSolver(gfInside_, gfOutside_), interpolationGrade(2), interpolationType(1),
69-
af( new ConAnsatzFunction() ), integralEquation(integralEquation_) {
70-
initWEMMembers();
71-
}
7267
PWCSolver(IGreensFunction * gfInside_, IGreensFunction * gfOutside_, const Compression & _comp, int integralEquation_ = SecondKind)
7368
: PCMSolver(gfInside_, gfOutside_), interpolationGrade(2), interpolationType(1),
7469
af( new ConAnsatzFunction(_comp) ), integralEquation(integralEquation_) {
@@ -120,7 +115,7 @@ namespace
120115
{
121116
PCMSolver * createPWCSolver(const solverData & _data)
122117
{
123-
return new PWCSolver(_data.gfInside, _data.gfOutside, _data.integralEquation);
118+
return new PWCSolver(_data.gfInside, _data.gfOutside, _data.compressionParameters, _data.integralEquation);
124119
}
125120
const std::string PWCSOLVER("WAVELET"); // Stands for piecewise constant functions
126121
const bool registeredPWCSolver = SolverFactory::TheSolverFactory().registerSolver(

src/solver/PWLSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void PWLSolver::initWEMMembers()
105105
// T_ = NULL;
106106
systemMatricesInitialized_ = false;
107107
threshold = 1e-10;
108-
//af->quadratureLevel_ = 1; // set in constructor of AnsatzFunction
108+
af->quadratureLevel_ = std::ceil(0.5 * (af->td - op)) - 1;
109109
//af->nQuadPoints = 0; //??? what is this for?
110110
af->elementTree.element = NULL;
111111
af->elementTree.nop = 0;

src/solver/PWLSolver.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ class PWLSolver : public PCMSolver
6464
void initWEMMembers();
6565
virtual std::ostream & printSolver(std::ostream & os);
6666
public:
67-
PWLSolver(IGreensFunction * gfInside_, IGreensFunction * gfOutside_, int integralEquation_ = SecondKind)
68-
: PCMSolver(gfInside_, gfOutside_), interpolationGrade(3), interpolationType(1),
69-
af( new LinAnsatzFunction() ), integralEquation(integralEquation_) {
70-
initWEMMembers();
71-
}
7267
PWLSolver(IGreensFunction * gfInside_, IGreensFunction * gfOutside_, const Compression & _comp, int integralEquation_ = SecondKind)
7368
: PCMSolver(gfInside_, gfOutside_), interpolationGrade(3), interpolationType(1),
7469
af( new LinAnsatzFunction(_comp) ), integralEquation(integralEquation_) {
@@ -120,7 +115,7 @@ namespace
120115
{
121116
PCMSolver * createPWLSolver(const solverData & _data)
122117
{
123-
return new PWLSolver(_data.gfInside, _data.gfOutside, _data.integralEquation);
118+
return new PWLSolver(_data.gfInside, _data.gfOutside, _data.compressionParameters, _data.integralEquation);
124119
}
125120
const std::string PWLSOLVER("LINEAR"); // Stands for piecewise linear
126121
const bool registeredPWLSolver = SolverFactory::TheSolverFactory().registerSolver(

src/wemFiles/ConAnsatzFunction.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@
99
#include <cstdio>
1010
#include "string.h"
1111

12-
ConAnsatzFunction :: ConAnsatzFunction(){
13-
nLevels = 0;
14-
nFunctions = 0;
15-
nPatches = 0;
16-
minLevel = 1;
17-
noPhi = 1;
18-
19-
B = NULL;
20-
B2 = NULL;
21-
22-
td = 3;
23-
dp = 1.25;
24-
a = 1.0; ///< compression constant, a > 1
25-
b = 0.01; ///< compression constant, 0 < b < 1
26-
27-
quadratureLevel_ = 0;
28-
G = (SparseMatrix*) malloc(sizeof(SparseMatrix));
29-
}
30-
3112
ConAnsatzFunction :: ConAnsatzFunction(const Compression & _comp){
3213
nLevels = 0;
3314
nFunctions = 0;
@@ -43,49 +24,6 @@ ConAnsatzFunction :: ConAnsatzFunction(const Compression & _comp){
4324
a = _comp.aPrioriA; ///< compression constant, a > 1
4425
b = _comp.aPosterioriB; ///< compression constant, 0 < b < 1
4526

46-
quadratureLevel_ = 1;
47-
G = (SparseMatrix*) malloc(sizeof(SparseMatrix));
48-
}
49-
50-
// NOTE the parameters must be initialized in the same order as declared in the header, otherwise a warning appears
51-
ConAnsatzFunction :: ConAnsatzFunction(unsigned int _p, unsigned int _m, unsigned int _nf, Vector3*** pPointsIn){
52-
nLevels = _m;
53-
nFunctions = _nf;
54-
nPatches = _p;
55-
56-
interCoeff = new Interpolation(pPointsIn, 1, NEWTON, nLevels, nPatches);
57-
minLevel = 1;
58-
noPhi = 1;
59-
60-
B = NULL;
61-
B2 = NULL;
62-
63-
td = 3;
64-
dp = 1.25;
65-
a = 1.25; ///< compression constant, a > 1
66-
b = 0.001; ///< compression constant, 0 < b < 1
67-
68-
quadratureLevel_ = 0;
69-
G = (SparseMatrix*) malloc(sizeof(SparseMatrix));
70-
}
71-
72-
ConAnsatzFunction :: ConAnsatzFunction(unsigned int _p, unsigned int _m, unsigned int _nf, double _a, double _b, double _dp, Vector3*** pPointsIn){
73-
nLevels = _m;
74-
nFunctions = _nf;
75-
nPatches = _p;
76-
77-
interCoeff = new Interpolation(pPointsIn, 1, NEWTON, nLevels, nPatches);
78-
minLevel = 1;
79-
noPhi = 1;
80-
81-
B = NULL;
82-
B2 = NULL;
83-
84-
td = 3;
85-
dp = _dp;
86-
a = _a; ///< compression constant, a > 1
87-
b = _b; ///< compression constant, 0 < b < 1
88-
8927
quadratureLevel_ = 0;
9028
G = (SparseMatrix*) malloc(sizeof(SparseMatrix));
9129
}

src/wemFiles/ConAnsatzFunction.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ class ConAnsatzFunction : public GenericAnsatzFunction {
1818
// characteristic variable, found only in this function
1919
BoundingBoxSquare *B2;
2020

21-
/// constructor of the class ConAnsatzFunction
22-
ConAnsatzFunction();
21+
/*! \brief constructor of the class ConAnsatzFunction
22+
* \warning quadratureLevel_ is set to zero in the constructor.
23+
* Remember to set it to the proper value within the solver:
24+
* ceil(0.5*(td - op)) - 1
25+
*/
2326
ConAnsatzFunction(const Compression & _comp);
24-
ConAnsatzFunction(unsigned int p, unsigned int m, unsigned int nf, Vector3*** pPointsIn);
25-
ConAnsatzFunction(unsigned int _p, unsigned int _m, unsigned int _nf, double _a, double _b, double _dp, Vector3 *** pPointsIn);
2627

2728
void quadratureGrade(signed int *g1, signed int*g2, int level1, int level2, double dist, double alpha);
2829

0 commit comments

Comments
 (0)