Commit 035273e9 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

moved UpdateParallel of SampleVariance

parent bde9b9c2
Pipeline #157966 passed with stages
in 11 minutes and 39 seconds
......@@ -10,13 +10,6 @@ void StochasticCollocation::Method() {
mout.EndBlock(verbose == 0);
}
void StochasticCollocation::updateSampleIds(SampleSolution &fSol, SampleSolution &cSol) {
fineId.number = aggregate.index();
coarseId.number = aggregate.index();
fSol.id = fineId;
cSol.id = coarseId;
}
void StochasticCollocation::method() {
std::unique_ptr<Meshes> meshes = meshesCreator.
WithMeshName(pdeSolverCreator.GetMeshName()).
......@@ -41,4 +34,11 @@ void StochasticCollocation::method() {
aggregate.Update(fineSolution, coarseSolution);
}
}
\ No newline at end of file
}
void StochasticCollocation::updateSampleIds(SampleSolution &fSol, SampleSolution &cSol) {
fineId.number = aggregate.index();
coarseId.number = aggregate.index();
fSol.id = fineId;
cSol.id = coarseId;
}
......@@ -86,7 +86,10 @@ struct SVar {
Ycomm = Y2comm / (ctr.Mcomm - 1);
}
void UpdateParallel(int commSplit) {
void UpdateParallel(double C2, double Q2, double Y2, SampleCounter ctr) {
C = C2 / (ctr.M - 1);
Q = Q2 / (ctr.M - 1);
Y = Y2 / (ctr.M - 1);
}
friend Logging &operator<<(Logging &s, const SVar &sVar) {
......@@ -136,7 +139,8 @@ struct Kurtosis {
double Ycomm = 0.0;
void Update() {//Averages avgs, Variances vars) {
void Update() {
//Averages avgs, Variances vars) {
// Q = (avgs.Q4 - 4.0 * avgs.Q3 * avgs.Q + 6.0 * avgs.Q2 * avgs.Q * avgs.Q -
// 3.0 * avgs.Q * avgs.Q * avgs.Q * avgs.Q) / vars.Q / vars.Q;
// Y = (avgs.Y4 - 4.0 * avgs.Y3 * avgs.Y + 6.0 * avgs.Y2 * avgs.Y * avgs.Y -
......@@ -233,24 +237,11 @@ public:
Q2 = PPM->SumAcrossComm(Q2comm, commSplit);
Y2 = PPM->SumAcrossComm(Y2comm, commSplit);
// delta = avg_b - avg_a
// M2 = M2_a + M2_b + delta ** 2 * n_a * n_b / n
sVar.C = C2 / (ctr.M - 1);
sVar.Q = Q2 / (ctr.M - 1);
sVar.Y = Y2 / (ctr.M - 1);
// def parallel_variance(n_a, avg_a, M2_a, n_b, avg_b, M2_b):
// n = n_a + n_b
// delta = avg_b - avg_a
// M2 = M2_a + M2_b + delta ** 2 * n_a * n_b / n
// var_ab = M2 / (n - 1)
// return var_ab
sVar.UpdateParallel(C2, Q2, Y2, ctr);
}
int index() const {
return ctr.M + ctr.Mcomm + ctr.dMcomm * PPM->Proc(0);
// return M + dMcomm * PPM->Proc(0);
}
void UpdateSampleCounter(int dM) {
......
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