Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing a range of compiler warnings for shadow/unused variables #77

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions palace/drivers/eigensolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void EigenSolver::Solve(std::vector<std::unique_ptr<mfem::ParMesh>> &mesh,
std::unique_ptr<KspSolver> ksp;
std::unique_ptr<KspPreconditioner> pc;
#if defined(PALACE_WITH_SLEPC)
auto *feast = dynamic_cast<feast::FeastEigenSolver *>(eigen.get());
auto *const feast = dynamic_cast<feast::FeastEigenSolver *>(eigen.get());
if (feast)
{
// Configure the FEAST integration contour. The linear solvers are set up inside the
Expand Down Expand Up @@ -339,8 +339,7 @@ void EigenSolver::Solve(std::vector<std::unique_ptr<mfem::ParMesh>> &mesh,
#if defined(PALACE_WITH_SLEPC)
if (!ksp)
{
const auto &feast = dynamic_cast<const feast::FeastEigenSolver &>(*eigen);
SaveMetadata(feast.GetTotalKspMult(), feast.GetTotalKspIter());
SaveMetadata(feast->GetTotalKspMult(), feast->GetTotalKspIter());
}
else
#endif
Expand Down
11 changes: 5 additions & 6 deletions palace/fem/coefficient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ class DielectricInterfaceCoefficient : public mfem::Coefficient,
const mfem::Vector side;
mutable mfem::Vector C1, V, nor;

int Initialize(mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip,
mfem::Vector &V)
int Initialize(mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip)
{
// Get neighboring elements.
mfem::ElementTransformation *T1, *T2;
Expand Down Expand Up @@ -277,7 +276,7 @@ inline double DielectricInterfaceCoefficient<DielectricInterfaceType::MA>::Eval(
mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip)
{
// Get single-sided solution and neighboring element attribute.
Initialize(T, ip, V);
Initialize(T, ip);
GetNormal(T, ip, nor);

// Metal-air interface: 0.5 * t / ϵ_MA * |E_n|² .
Expand All @@ -290,7 +289,7 @@ inline double DielectricInterfaceCoefficient<DielectricInterfaceType::MS>::Eval(
mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip)
{
// Get single-sided solution and neighboring element attribute.
int attr = Initialize(T, ip, V);
int attr = Initialize(T, ip);
GetNormal(T, ip, nor);

// Metal-substrate interface: 0.5 * t * (ϵ_S)² / ϵ_MS * |E_n|² .
Expand All @@ -304,7 +303,7 @@ inline double DielectricInterfaceCoefficient<DielectricInterfaceType::SA>::Eval(
mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip)
{
// Get single-sided solution and neighboring element attribute.
Initialize(T, ip, V);
Initialize(T, ip);
GetNormal(T, ip, nor);

// Substrate-air interface: 0.5 * t * (ϵ_SA * |E_t|² + 1 / ϵ_MS * |E_n|²) .
Expand All @@ -318,7 +317,7 @@ inline double DielectricInterfaceCoefficient<DielectricInterfaceType::DEFAULT>::
mfem::ElementTransformation &T, const mfem::IntegrationPoint &ip)
{
// Get single-sided solution and neighboring element attribute.
Initialize(T, ip, V);
Initialize(T, ip);

// No specific interface, use full field evaluation: 0.5 * t * ϵ * |E|² .
return 0.5 * ts * epsilon * (V * V);
Expand Down
30 changes: 15 additions & 15 deletions palace/linalg/feast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class FeastLinearSolver
Q.RestoreColumn(j, q);
if (M > 1)
{
petsc::PetscParVector q = Q.GetColumn(j + m0);
q = Q.GetColumn(j + m0);
q.AXPY(zk / gamma, v);
Q.RestoreColumn(j + m0, q);
}
Expand Down Expand Up @@ -182,8 +182,8 @@ FeastEigenSolver::FeastEigenSolver(MPI_Comm comm, const IoData &iodata,
print = print_lvl;
info = 0;
nev = m0 = mQ = 0;
M = iodata.solver.eigenmode.feast_moments;
MFEM_VERIFY(M == 1 || M == 2,
N_moments = iodata.solver.eigenmode.feast_moments;
MFEM_VERIFY(N_moments == 1 || N_moments == 2,
"FEAST eigensolver only supports up to 2 subspace moments!");
rtol = 0.0;
max_it = 0;
Expand Down Expand Up @@ -268,7 +268,7 @@ void FeastEigenSolver::SetNumModes(int numeig, int numvec)
m0 = std::max(nev + 3, nev + (nev + 1) / 2);
}
}
mQ = 2 * M * m0; // Real-valued basis splitting leads to factor of 2
mQ = 2 * N_moments * m0; // Real-valued basis splitting leads to factor of 2
}

void FeastEigenSolver::SetTol(double tol)
Expand Down Expand Up @@ -381,7 +381,7 @@ int FeastEigenSolver::SolveInternal(RG rg)
for (PetscInt j = 1; j < mQ / 2; j++)
{
// Ensure homogeneous Dirichlet BC are satisfied by the starting subspace.
petsc::PetscParVector q = Q.GetColumn(j);
q = Q.GetColumn(j);
q.PointwiseMult(*r0, false);
Q.RestoreColumn(j, q);
}
Expand Down Expand Up @@ -458,27 +458,27 @@ int FeastEigenSolver::SolveInternal(RG rg)
x.Normalize();
}
GetResidual(sigma, x, r);
PetscReal res = r.Norml2() / (x.Norml2() * PetscAbsScalar(sigma));
PetscReal local_res = r.Norml2() / (x.Norml2() * PetscAbsScalar(sigma));
// PetscReal res = r.Norml2()/x.Norml2();
X->RestoreColumn(j, x);
R.RestoreColumn(j, r);
if (res < rtol)
if (local_res < rtol)
{
// Mark converged even for eigenvalues outside the contour.
converged[j] = true;
nconv++;
if (res > rmax)
if (local_res > rmax)
{
rmax = res;
rmax = local_res;
jmax = j;
}
}
else
{
converged[j] = false;
if (res < rmin)
if (local_res < rmin)
{
rmin = res;
rmin = local_res;
jmin = j;
}
}
Expand All @@ -493,7 +493,7 @@ int FeastEigenSolver::SolveInternal(RG rg)

// Debug
// Mpi::Print(comm, " res[{:d}] = {:e} (eig = {:+e}{:+e}i, inside = {:d})\n",
// j, res, PetscRealPart(sigma),
// j, local_res, PetscRealPart(sigma),
// PetscImaginaryPart(sigma), inside[j]);
}
if (print > 0)
Expand Down Expand Up @@ -1198,10 +1198,10 @@ void FeastPEPSolver::SolveProjectedProblem(const petsc::PetscDenseMatrix &Q_,
for (PetscInt i = 0; i < m0; i++)
{
eig_[i] = alpha[sort[i]];
const PetscScalar *pXQ = XQ->GetArrayRead();
const PetscScalar *const local_pXQ = XQ->GetArrayRead();
PetscScalar *pXQ0 = XQ0->GetArray();
PalacePetscCall(PetscArraycpy(pXQ0 + mQ * i, pXQ + 2 * mQ * sort[i], mQ));
XQ->RestoreArrayRead(pXQ);
PalacePetscCall(PetscArraycpy(pXQ0 + mQ * i, local_pXQ + 2 * mQ * sort[i], mQ));
XQ->RestoreArrayRead(local_pXQ);
XQ0->RestoreArray(pXQ0);
}

Expand Down
4 changes: 2 additions & 2 deletions palace/linalg/feast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FeastEigenSolver : public EigenSolverBase
PetscInt nev, m0, mQ;

// Number of moments to consider for subspace construction.
PetscInt M;
PetscInt N_moments;

// Relative eigenvalue error convergence tolerance for the solver.
PetscReal rtol;
Expand Down Expand Up @@ -192,7 +192,7 @@ class FeastEigenSolver : public EigenSolverBase
{
MFEM_ABORT("SetWhichEigenpairs not defined for FeastEigenSolver!");
}
void SetShiftInvert(double tr, double ti, bool precond = false) override
void SetShiftInvert(double tr_in, double ti_in, bool precond = false) override
{
MFEM_ABORT("SetShiftInvert not defined for FeastEigenSolver!");
}
Expand Down
4 changes: 3 additions & 1 deletion palace/linalg/ksp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ void KspSolver::Configure(const IoData &iodata)
}
}

void KspSolver::ConfigureVerbose(int print, const std::string &prefix)
void KspSolver::ConfigureVerbose(int print_input, const std::string &prefix)
{
print = print_input;

// Manage debugging output.
if (print > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion palace/linalg/superlu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int GetNpDep(int np, bool use_3d)

SuperLUSolver::SuperLUSolver(MPI_Comm comm, config::LinearSolverData::SymFactType reorder,
bool use_3d, int print)
: mfem::Solver(), comm(comm), A(nullptr), solver(comm, GetNpDep(Mpi::Size(comm), use_3d))
: mfem::Solver(), A(nullptr), solver(comm, GetNpDep(Mpi::Size(comm), use_3d))
{
// Configure the solver.
if (print > 1)
Expand Down
1 change: 0 additions & 1 deletion palace/linalg/superlu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace palace
class SuperLUSolver : public mfem::Solver
{
private:
MPI_Comm comm;
std::unique_ptr<mfem::SuperLURowLocMatrix> A;
mfem::SuperLUSolver solver;

Expand Down
2 changes: 2 additions & 0 deletions palace/models/romoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ double RomOperator::ComputeError(double omega)
return num / den;
}

// static
void RomOperator::BVMatProjectInternal(petsc::PetscDenseMatrix &V, petsc::PetscParMatrix &A,
petsc::PetscDenseMatrix &Ar,
petsc::PetscParVector &r, int n0, int n)
Expand Down Expand Up @@ -515,6 +516,7 @@ void RomOperator::BVMatProjectInternal(petsc::PetscDenseMatrix &V, petsc::PetscP
}
}

// static
void RomOperator::BVDotVecInternal(petsc::PetscDenseMatrix &V, petsc::PetscParVector &b,
petsc::PetscParVector &br, int n0, int n)
{
Expand Down
10 changes: 5 additions & 5 deletions palace/models/romoperator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class RomOperator
double ComputeError(double omega);

// Helper functions for reduced-order matrix or vector construction/update.
void BVMatProjectInternal(petsc::PetscDenseMatrix &V, petsc::PetscParMatrix &A,
petsc::PetscDenseMatrix &Ar, petsc::PetscParVector &r, int n0,
int n);
void BVDotVecInternal(petsc::PetscDenseMatrix &V, petsc::PetscParVector &b,
petsc::PetscParVector &br, int n0, int n);
static void BVMatProjectInternal(petsc::PetscDenseMatrix &V, petsc::PetscParMatrix &A,
petsc::PetscDenseMatrix &Ar, petsc::PetscParVector &r,
int n0, int n);
static void BVDotVecInternal(petsc::PetscDenseMatrix &V, petsc::PetscParVector &b,
petsc::PetscParVector &br, int n0, int n);

public:
RomOperator(const IoData &iodata, SpaceOperator &sp, int nmax);
Expand Down
72 changes: 39 additions & 33 deletions palace/models/surfacepostoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace palace
{

SurfacePostOperator::InterfaceDielectricData::InterfaceDielectricData(
InterfaceDielectricData::InterfaceDielectricData(
const config::InterfaceDielectricData &data, mfem::ParMesh &mesh)
: ts(data.ts), tandelta(data.tandelta)
{
Expand Down Expand Up @@ -101,9 +101,9 @@ SurfacePostOperator::InterfaceDielectricData::InterfaceDielectricData(
}

std::unique_ptr<mfem::Coefficient>
SurfacePostOperator::InterfaceDielectricData::GetCoefficient(
int i, const mfem::ParGridFunction &U, const MaterialOperator &mat_op,
const std::map<int, int> &local_to_shared) const
InterfaceDielectricData::GetCoefficient(int i, const mfem::ParGridFunction &U,
const MaterialOperator &mat_op,
const std::map<int, int> &local_to_shared) const
{
switch (type)
{
Expand All @@ -124,22 +124,22 @@ SurfacePostOperator::InterfaceDielectricData::GetCoefficient(
return {}; // For compiler warning
}

SurfacePostOperator::SurfaceChargeData::SurfaceChargeData(
const config::CapacitanceData &data, mfem::ParMesh &mesh)
SurfaceChargeData::SurfaceChargeData(const config::CapacitanceData &data,
mfem::ParMesh &mesh)
{
attr_markers.emplace_back();
mesh::AttrToMarker(mesh.bdr_attributes.Max(), data.attributes, attr_markers.back());
}

std::unique_ptr<mfem::Coefficient> SurfacePostOperator::SurfaceChargeData::GetCoefficient(
int i, const mfem::ParGridFunction &U, const MaterialOperator &mat_op,
const std::map<int, int> &local_to_shared) const
std::unique_ptr<mfem::Coefficient>
SurfaceChargeData::GetCoefficient(int i, const mfem::ParGridFunction &U,
const MaterialOperator &mat_op,
const std::map<int, int> &local_to_shared) const
{
return std::make_unique<BdrChargeCoefficient>(U, mat_op, local_to_shared);
}

SurfacePostOperator::SurfaceFluxData::SurfaceFluxData(const config::InductanceData &data,
mfem::ParMesh &mesh)
SurfaceFluxData::SurfaceFluxData(const config::InductanceData &data, mfem::ParMesh &mesh)
{
// Check inputs.
MFEM_VERIFY(data.direction.length() == 2 &&
Expand Down Expand Up @@ -177,13 +177,35 @@ SurfacePostOperator::SurfaceFluxData::SurfaceFluxData(const config::InductanceDa
mesh::AttrToMarker(mesh.bdr_attributes.Max(), data.attributes, attr_markers.back());
}

std::unique_ptr<mfem::Coefficient> SurfacePostOperator::SurfaceFluxData::GetCoefficient(
int i, const mfem::ParGridFunction &U, const MaterialOperator &mat_op,
const std::map<int, int> &local_to_shared) const
std::unique_ptr<mfem::Coefficient>
SurfaceFluxData::GetCoefficient(int i, const mfem::ParGridFunction &U,
const MaterialOperator &mat_op,
const std::map<int, int> &local_to_shared) const
{
return std::make_unique<BdrFluxCoefficient>(U, direction, local_to_shared);
}

namespace
{
double GetSurfaceIntegral(const SurfaceData &data, const mfem::ParGridFunction &U,
const mfem::ParGridFunction &ones, const MaterialOperator &mat_op,
const std::map<int, int> &local_to_shared)
{
// Integrate the coefficient over the boundary attributes making up this surface index.
std::vector<std::unique_ptr<mfem::Coefficient>> fb;
mfem::ParLinearForm s(ones.ParFESpace());
for (int i = 0; i < static_cast<int>(data.attr_markers.size()); i++)
{
fb.emplace_back(data.GetCoefficient(i, U, mat_op, local_to_shared));
s.AddBoundaryIntegrator(new BoundaryLFIntegrator(*fb.back()), data.attr_markers[i]);
}
s.UseFastAssembly(true);
s.Assemble();
return s(ones);
}

} // namespace

SurfacePostOperator::SurfacePostOperator(const IoData &iodata, const MaterialOperator &mat,
const std::map<int, int> &l2s,
mfem::ParFiniteElementSpace &h1_fespace)
Expand Down Expand Up @@ -219,7 +241,7 @@ SurfacePostOperator::GetInterfaceElectricFieldEnergy(int idx,
auto it = eps_surfs.find(idx);
MFEM_VERIFY(it != eps_surfs.end(),
"Unknown dielectric loss postprocessing surface index requested!");
return GetSurfaceIntegral(it->second, E);
return GetSurfaceIntegral(it->second, E, ones, mat_op, local_to_shared);
}

double SurfacePostOperator::GetInterfaceLossTangent(int idx) const
Expand All @@ -236,7 +258,7 @@ double SurfacePostOperator::GetSurfaceElectricCharge(int idx,
auto it = charge_surfs.find(idx);
MFEM_VERIFY(it != charge_surfs.end(),
"Unknown capacitance postprocessing surface index requested!");
return GetSurfaceIntegral(it->second, E);
return GetSurfaceIntegral(it->second, E, ones, mat_op, local_to_shared);
}

double SurfacePostOperator::GetSurfaceMagneticFlux(int idx,
Expand All @@ -245,23 +267,7 @@ double SurfacePostOperator::GetSurfaceMagneticFlux(int idx,
auto it = flux_surfs.find(idx);
MFEM_VERIFY(it != flux_surfs.end(),
"Unknown inductance postprocessing surface index requested!");
return GetSurfaceIntegral(it->second, B);
}

double SurfacePostOperator::GetSurfaceIntegral(const SurfaceData &data,
const mfem::ParGridFunction &U) const
{
// Integrate the coefficient over the boundary attributes making up this surface index.
std::vector<std::unique_ptr<mfem::Coefficient>> fb;
mfem::ParLinearForm s(ones.ParFESpace());
for (int i = 0; i < static_cast<int>(data.attr_markers.size()); i++)
{
fb.emplace_back(data.GetCoefficient(i, U, mat_op, local_to_shared));
s.AddBoundaryIntegrator(new BoundaryLFIntegrator(*fb.back()), data.attr_markers[i]);
}
s.UseFastAssembly(true);
s.Assemble();
return s(ones);
return GetSurfaceIntegral(it->second, B, ones, mat_op, local_to_shared);
}

} // namespace palace
Loading