Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiangrimberg committed May 7, 2024
1 parent 998b55f commit dc0eb1b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
16 changes: 8 additions & 8 deletions palace/drivers/drivensolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ ErrorIndicator DrivenSolver::SweepUniform(SpaceOperator &spaceop, PostOperator &
postop.SetEGridFunction(E);
postop.SetBGridFunction(B);
postop.UpdatePorts(spaceop.GetLumpedPortOp(), spaceop.GetWavePortOp(), omega);
double E_elec = postop.GetEFieldEnergy();
double E_mag = postop.GetHFieldEnergy();
const double E_elec = postop.GetEFieldEnergy();
const double E_mag = postop.GetHFieldEnergy();
Mpi::Print(" Sol. ||E|| = {:.6e} (||RHS|| = {:.6e})\n",
linalg::Norml2(spaceop.GetComm(), E),
linalg::Norml2(spaceop.GetComm(), RHS));
Expand Down Expand Up @@ -273,8 +273,8 @@ ErrorIndicator DrivenSolver::SweepAdaptive(SpaceOperator &spaceop, PostOperator
B *= -1.0 / (1i * omega);
postop.SetEGridFunction(E, false);
postop.SetBGridFunction(B, false);
double E_elec = postop.GetEFieldEnergy();
double E_mag = postop.GetHFieldEnergy();
const double E_elec = postop.GetEFieldEnergy();
const double E_mag = postop.GetHFieldEnergy();
estimator.AddErrorIndicator(E, B, E_elec + E_mag, indicator);
};
promop.SolveHDM(omega0, E);
Expand Down Expand Up @@ -362,8 +362,8 @@ ErrorIndicator DrivenSolver::SweepAdaptive(SpaceOperator &spaceop, PostOperator
postop.SetEGridFunction(E);
postop.SetBGridFunction(B);
postop.UpdatePorts(spaceop.GetLumpedPortOp(), spaceop.GetWavePortOp(), omega);
double E_elec = postop.GetEFieldEnergy();
double E_mag = postop.GetHFieldEnergy();
const double E_elec = postop.GetEFieldEnergy();
const double E_mag = postop.GetHFieldEnergy();
Mpi::Print(" Sol. ||E|| = {:.6e}\n", linalg::Norml2(spaceop.GetComm(), E));
{
const double J = iodata.DimensionalizeValue(IoData::ValueType::ENERGY, 1.0);
Expand Down Expand Up @@ -410,8 +410,8 @@ void DrivenSolver::Postprocess(const PostOperator &postop,
// The internal GridFunctions for PostOperator have already been set from the E and B
// solutions in the main frequency sweep loop.
const double freq = iodata.DimensionalizeValue(IoData::ValueType::FREQUENCY, omega);
double E_cap = postop.GetLumpedCapacitorEnergy(lumped_port_op);
double E_ind = postop.GetLumpedInductorEnergy(lumped_port_op);
const double E_cap = postop.GetLumpedCapacitorEnergy(lumped_port_op);
const double E_ind = postop.GetLumpedInductorEnergy(lumped_port_op);
PostprocessCurrents(postop, surf_j_op, step, omega);
PostprocessPorts(postop, lumped_port_op, step, omega);
if (surf_j_op.Size() == 0)
Expand Down
8 changes: 4 additions & 4 deletions palace/drivers/eigensolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ EigenSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
postop.SetEGridFunction(E);
postop.SetBGridFunction(B);
postop.UpdatePorts(spaceop.GetLumpedPortOp(), omega.real());
double E_elec = postop.GetEFieldEnergy();
double E_mag = postop.GetHFieldEnergy();
const double E_elec = postop.GetEFieldEnergy();
const double E_mag = postop.GetHFieldEnergy();

// Calculate and record the error indicators.
if (i < iodata.solver.eigenmode.n)
Expand All @@ -340,8 +340,8 @@ void EigenSolver::Postprocess(const PostOperator &postop,
{
// The internal GridFunctions for PostOperator have already been set from the E and B
// solutions in the main loop over converged eigenvalues.
double E_cap = postop.GetLumpedCapacitorEnergy(lumped_port_op);
double E_ind = postop.GetLumpedInductorEnergy(lumped_port_op);
const double E_cap = postop.GetLumpedCapacitorEnergy(lumped_port_op);
const double E_ind = postop.GetLumpedInductorEnergy(lumped_port_op);
PostprocessEigen(i, omega, error_bkwd, error_abs, num_conv);
PostprocessPorts(postop, lumped_port_op, i);
PostprocessEPR(postop, lumped_port_op, i, omega, E_elec + E_cap);
Expand Down
2 changes: 1 addition & 1 deletion palace/drivers/electrostaticsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ElectrostaticSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
Grad.AddMult(V[step], E, -1.0);
postop.SetVGridFunction(V[step]);
postop.SetEGridFunction(E);
double E_elec = postop.GetEFieldEnergy();
const double E_elec = postop.GetEFieldEnergy();
Mpi::Print(" Sol. ||V|| = {:.6e} (||RHS|| = {:.6e})\n",
linalg::Norml2(laplaceop.GetComm(), V[step]),
linalg::Norml2(laplaceop.GetComm(), RHS));
Expand Down
2 changes: 1 addition & 1 deletion palace/drivers/magnetostaticsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ MagnetostaticSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
Curl.Mult(A[step], B);
postop.SetAGridFunction(A[step]);
postop.SetBGridFunction(B);
double E_mag = postop.GetHFieldEnergy();
const double E_mag = postop.GetHFieldEnergy();
Mpi::Print(" Sol. ||A|| = {:.6e} (||RHS|| = {:.6e})\n",
linalg::Norml2(curlcurlop.GetComm(), A[step]),
linalg::Norml2(curlcurlop.GetComm(), RHS));
Expand Down
8 changes: 4 additions & 4 deletions palace/drivers/transientsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ TransientSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
postop.SetEGridFunction(E);
postop.SetBGridFunction(B);
postop.UpdatePorts(spaceop.GetLumpedPortOp());
double E_elec = postop.GetEFieldEnergy();
double E_mag = postop.GetHFieldEnergy();
const double E_elec = postop.GetEFieldEnergy();
const double E_mag = postop.GetHFieldEnergy();
Mpi::Print(" Sol. ||E|| = {:.6e}, ||B|| = {:.6e}\n",
linalg::Norml2(spaceop.GetComm(), E), linalg::Norml2(spaceop.GetComm(), B));
{
Expand Down Expand Up @@ -259,8 +259,8 @@ void TransientSolver::Postprocess(const PostOperator &postop,
// The internal GridFunctions for PostOperator have already been set from the E and B
// solutions in the main time integration loop.
const double ts = iodata.DimensionalizeValue(IoData::ValueType::TIME, t);
double E_cap = postop.GetLumpedCapacitorEnergy(lumped_port_op);
double E_ind = postop.GetLumpedInductorEnergy(lumped_port_op);
const double E_cap = postop.GetLumpedCapacitorEnergy(lumped_port_op);
const double E_ind = postop.GetLumpedInductorEnergy(lumped_port_op);
PostprocessCurrents(postop, surf_j_op, step, t, J_coef);
PostprocessPorts(postop, lumped_port_op, step, t, J_coef);
PostprocessDomains(postop, "t (ns)", step, ts, E_elec, E_mag, E_cap, E_ind);
Expand Down
2 changes: 1 addition & 1 deletion palace/linalg/densematrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ mfem::DenseTensor Mult(const mfem::DenseTensor &A, const mfem::DenseTensor &B)
{
MFEM_VERIFY(A.SizeK() == B.SizeK(),
"Size mismatch for product of two DenseTensor objects!");
mfem::DenseTensor C(A);
mfem::DenseTensor C(A.SizeI(), B.SizeJ(), A.SizeK());
for (int k = 0; k < C.SizeK(); k++)
{
Mult(A(k), B(k), C(k));
Expand Down
10 changes: 6 additions & 4 deletions palace/linalg/errorestimator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FluxProjector
void Mult(const VecType &x, VecType &y) const;
};

// Class used for computing gradient flux error estimate, i.e. || ε Eₕ - D ||_K, where D
// Class used for computing gradient flux error estimate, η_K = || ε Eₕ - D ||_K, where D
// denotes a smooth reconstruction of ε Eₕ = ε ∇Vₕ with continuous normal component.
template <typename VecType = Vector>
class GradFluxErrorEstimator
Expand Down Expand Up @@ -86,7 +86,7 @@ class GradFluxErrorEstimator
void AddErrorIndicator(const VecType &E, double Et, ErrorIndicator &indicator) const;
};

// Class used for computing curl flux error estimate, i.e. || μ⁻¹ Bₕ - H ||_K where H
// Class used for computing curl flux error estimate, η_K = || μ⁻¹ Bₕ - H ||_K where H
// denotes a smooth reconstruction of μ⁻¹ Bₕ = μ⁻¹ ∇ × Eₕ with continuous tangential
// component.
template <typename VecType = Vector>
Expand Down Expand Up @@ -118,8 +118,10 @@ class CurlFluxErrorEstimator
void AddErrorIndicator(const VecType &B, double Et, ErrorIndicator &indicator) const;
};

// Class used for computing gradient flux error estimate, i.e. || ε Eₕ - D ||_K, where D
// denotes a smooth reconstruction of ε Eₕ = ε ∇Vₕ with continuous normal component.
// Class used for computing sum of the gradient flux and curl flux error estimates,
// η²_K = || ε Eₕ - D ||²_K + || μ⁻¹ Bₕ - H ||²_K, where D and H denote a smooth
// reconstructions of ε Eₕ = ε ∇Vₕ with continuous normal component and μ⁻¹ Bₕ = μ⁻¹ ∇ × Eₕ
// with continuous tangential component.
template <typename VecType>
class TimeDependentFluxErrorEstimator
{
Expand Down

0 comments on commit dc0eb1b

Please sign in to comment.