Commit e55a1dec authored by kraus's avatar kraus
Browse files

not required to define a filter for CSR anymore; rename Stencil filter

parent 9462d6e6
......@@ -2,7 +2,7 @@
using namespace std;
void IlyaPogorelovFilter::apply(vector<double> &LineDensity) {
void StencilFilter::apply(vector<double> &LineDensity) {
int size = LineDensity.size();
vector<double> temp1(size + 8, 0.0);
vector<double> temp2(5, 0.0);
......@@ -29,7 +29,7 @@ void IlyaPogorelovFilter::apply(vector<double> &LineDensity) {
LineDensity[i] = (7. * (temp1[i+2] + temp1[i+6]) + 24. * (temp1[i+3] + temp1[i+5]) + 34.*temp1[i+4]) / 96.;
}
void IlyaPogorelovFilter::calc_derivative(vector<double> &LineDensity, const double &h) {
void StencilFilter::calc_derivative(vector<double> &LineDensity, const double &h) {
vector<double> temp(LineDensity.begin(), LineDensity.end());
const double N = LineDensity.size();
LineDensity[0] = (-25.*temp[0] + 48.*temp[1] - 36.*temp[2] + 16.*temp[3] + temp[4]) / (12.*h);
......@@ -40,5 +40,4 @@ void IlyaPogorelovFilter::calc_derivative(vector<double> &LineDensity, const dou
LineDensity[N-2] = (-temp[N-5] + 6.*temp[N-4] - 18.*temp[N-3] + 10.*temp[N-2] + 3.*temp[N-1]) / (12.*h);
LineDensity[N-1] = (3.*temp[N-5] - 16.*temp[N-4] + 36.*temp[N-3] - 48.*temp[N-2] + 25.*temp[N-1]) / (12.*h);
apply(LineDensity);
}
}
\ No newline at end of file
......@@ -3,11 +3,11 @@
#include "Filters/Filter.h"
class IlyaPogorelovFilter: public Filter {
class StencilFilter: public Filter {
public:
IlyaPogorelovFilter() { ;}
StencilFilter() { ;}
void apply(std::vector<double> &histogram);
void calc_derivative(std::vector<double> &histogram, const double &h);
};
#endif // CLASSIC_STENCIL_HH
#endif // CLASSIC_STENCIL_HH
\ No newline at end of file
......@@ -132,7 +132,7 @@ void CSRIGFWakeFunction::calculateLineDensity(PartBunchBase<double, 3> *bunch, s
(*fit)->apply(lineDensity_m);
}
dlineDensitydz_m.assign(lineDensity_m.begin(), lineDensity_m.end());
filters_m.back()->calc_derivative(dlineDensitydz_m, meshInfo.second);
diffOp_m.calc_derivative(dlineDensitydz_m, meshInfo.second);
}
void CSRIGFWakeFunction::calculateGreenFunction(PartBunchBase<double, 3> *bunch, double meshSpacing)
......
......@@ -2,11 +2,13 @@
#define CSRIGFWAKEFUNCTION_HH
#include "Solvers/WakeFunction.hh"
#include "Filters/Stencil.h"
#include <vector>
#include <string>
class ElementBase;
class Filter;
class CSRIGFWakeFunction: public WakeFunction {
public:
......@@ -27,6 +29,7 @@ private:
double calcPsi(const double &psiInitial, const double &x, const double &Ds) const;
std::vector<Filter *> filters_m;
StencilFilter diffOp_m;
LineDensity lineDensity_m;
LineDensity dlineDensitydz_m;
......@@ -61,4 +64,4 @@ private:
};
#endif //CSRIGFWAKEFUNCTION_HH
#endif //CSRIGFWAKEFUNCTION_HH
\ No newline at end of file
......@@ -17,7 +17,6 @@ CSRWakeFunction::CSRWakeFunction(const std::string &name, ElementBase *element,
filters_m(filters.begin(), filters.end()),
lineDensity_m(),
dlineDensitydz_m(),
d2lineDensitydz2_m(),
bendRadius_m(0.0),
totalBendAngle_m(0.0)
{ }
......@@ -126,7 +125,7 @@ void CSRWakeFunction::calculateLineDensity(PartBunchBase<double, 3> *bunch, std:
}
dlineDensitydz_m.assign(lineDensity_m.begin(), lineDensity_m.end());
filters_m.back()->calc_derivative(dlineDensitydz_m, meshInfo.second);
diffOp_m.calc_derivative(dlineDensitydz_m, meshInfo.second);
}
void CSRWakeFunction::calculateContributionInside(size_t sliceNumber, double angleOfSlice, double meshSpacing) {
......
......@@ -2,11 +2,13 @@
#define CSRWAKEFUNCTION_HH
#include "Solvers/WakeFunction.hh"
#include "Filters/Stencil.h"
#include <vector>
#include <string>
class ElementBase;
class Filter;
class CSRWakeFunction: public WakeFunction {
public:
......@@ -26,9 +28,10 @@ private:
double calcPsi(const double &psiInitial, const double &x, const double &Ds) const;
std::vector<Filter *> filters_m;
StencilFilter diffOp_m;
LineDensity lineDensity_m;
LineDensity dlineDensitydz_m;
LineDensity d2lineDensitydz2_m;
// Longitudinal CSR field.
std::vector<double> Ez_m;
......@@ -55,4 +58,4 @@ private:
};
#endif //CSRWAKEFUNCTION_HH
#endif //CSRWAKEFUNCTION_HH
\ No newline at end of file
......@@ -176,7 +176,7 @@ void OpalFilter::initOpalFilter() {
} else if (type == "RELATIVEFFTLOWPASS") {
filter_m = new RelativeFFTLowPassFilter(std::abs(Attributes::getReal(itsAttr[THRESHOLD])));
} else if (type == "STENCIL") {
filter_m = new IlyaPogorelovFilter();
filter_m = new StencilFilter();
} else {
filter_m = 0;
INFOMSG("no filter attached" << endl);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment