Skip to content

Commit

Permalink
Remove normalization from ErrorIndicator class (not used, the stored …
Browse files Browse the repository at this point in the history
…indicators are already relative quantities)
  • Loading branch information
sebastiangrimberg authored and hughcars committed Oct 11, 2023
1 parent 6cd38ea commit 565d90c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
15 changes: 6 additions & 9 deletions palace/drivers/basesolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,26 +578,23 @@ void BaseSolver::PostprocessErrorIndicator(const PostOperator &postop,
return;
}
MPI_Comm comm = postop.GetComm();
std::array<double, 5> data = {indicator.Norml2(comm), indicator.Min(comm),
indicator.Max(comm), indicator.Mean(comm),
indicator.Normalization()};
std::array<double, 4> data = {indicator.Norml2(comm), indicator.Min(comm),
indicator.Max(comm), indicator.Mean(comm)};
if (root)
{
std::string path = post_dir + "error-indicators.csv";
auto output = OutputFile(path, false);
// clang-format off
output.print("{:>{}s},{:>{}s},{:>{}s},{:>{}s},{:>{}s}\n",
output.print("{:>{}s},{:>{}s},{:>{}s},{:>{}s}\n",
"Norm", table.w,
"Minimum", table.w,
"Maximum", table.w,
"Mean", table.w,
"Normalization", table.w);
output.print("{:+{}.{}e},{:+{}.{}e},{:+{}.{}e},{:+{}.{}e},{:+{}.{}e}\n",
"Mean", table.w);
output.print("{:+{}.{}e},{:+{}.{}e},{:+{}.{}e},{:+{}.{}e}\n",
data[0], table.w, table.p,
data[1], table.w, table.p,
data[2], table.w, table.p,
data[3], table.w, table.p,
data[4], table.w, table.p);
data[3], table.w, table.p);
// clang-format on
}
}
Expand Down
3 changes: 0 additions & 3 deletions palace/fem/errorindicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ void ErrorIndicator::AddIndicator(const ErrorIndicator &indicator)
if (n == 0)
{
local = indicator.local;
normalization = indicator.normalization;
n = indicator.n;
return;
}
Expand Down Expand Up @@ -45,8 +44,6 @@ void ErrorIndicator::AddIndicator(const ErrorIndicator &indicator)
});

// More samples have been added, update for the running average.
normalization =
(normalization * n + indicator.normalization * indicator.n) / (n + indicator.n);
n += indicator.n;
}

Expand Down
13 changes: 2 additions & 11 deletions palace/fem/errorindicator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@ class ErrorIndicator
// refinement and coarsening.
Vector local;

// Normalization constant.
double normalization;

// Number of samples.
int n;

public:
ErrorIndicator(Vector &&local, double normalization)
: local(std::move(local)), normalization(normalization), n(1)
{
}
ErrorIndicator() : normalization(0.0), n(0) {}
ErrorIndicator(Vector &&local) : local(std::move(local)), n(1) {}
ErrorIndicator() : n(0) {}

// Add an indicator to the running total.
void AddIndicator(const ErrorIndicator &indicator);
Expand Down Expand Up @@ -68,9 +62,6 @@ class ErrorIndicator
Mpi::GlobalSum(1, &sum, comm);
return sum / linalg::GlobalSize(comm, local);
}

// Return the normalization constant for the absolute error.
auto Normalization() const { return normalization; }
};

} // namespace palace
Expand Down
4 changes: 2 additions & 2 deletions palace/linalg/errorestimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ ErrorIndicator CurlFluxErrorEstimator<VecType>::ComputeIndicators(const VecType
{
estimates *= 1.0 / normalization;
}
return ErrorIndicator(std::move(estimates), normalization);
return ErrorIndicator(std::move(estimates));
}

GradFluxErrorEstimator::GradFluxErrorEstimator(
Expand Down Expand Up @@ -331,7 +331,7 @@ ErrorIndicator GradFluxErrorEstimator::ComputeIndicators(const Vector &U) const
{
estimates *= 1.0 / normalization;
}
return ErrorIndicator(std::move(estimates), normalization);
return ErrorIndicator(std::move(estimates));
}

template void FluxProjector::Mult(const Vector &, Vector &) const;
Expand Down

0 comments on commit 565d90c

Please sign in to comment.