Skip to content

Commit

Permalink
Avoid default: cases when switching over enum to reveal compiler warn…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
sebastiangrimberg committed Jul 13, 2023
1 parent 09965f5 commit 995020d
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 70 deletions.
2 changes: 0 additions & 2 deletions palace/drivers/transientsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ std::function<double(double)> TransientSolver::GetTimeExcitation(bool dot) const
return F{[=](double t) { return pulse_smootherstep(t, data.pulse_tau, delay); }};
}
break;
default:
MFEM_ABORT("Unsupported source excitation type!");
}
return F{};
}
Expand Down
12 changes: 4 additions & 8 deletions palace/fem/coefficient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ enum class DielectricInterfaceType
DEFAULT,
MA,
MS,
SA,
INVALID = -1
SA
};

template <DielectricInterfaceType Type>
Expand Down Expand Up @@ -337,8 +336,7 @@ enum class MaterialPropertyType
CONDUCTIVITY,
INV_LONDON_DEPTH,
INV_Z0,
INV_PERMEABILITY_C0,
INVALID = -1
INV_PERMEABILITY_C0
};

template <MaterialPropertyType Type>
Expand Down Expand Up @@ -457,14 +455,12 @@ enum class EnergyDensityType
{
ELECTRIC,
ELECTRIC_LOSS,
MAGNETIC,
INVALID = -1
MAGNETIC
};
enum class EnergyDensityValueType
{
COMPLEX,
REAL,
INVALID = -1
REAL
};

template <EnergyDensityType Type, EnergyDensityValueType ValueType>
Expand Down
6 changes: 0 additions & 6 deletions palace/linalg/arpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ void ArpackEigenSolver::SetWhichEigenpairs(EigenSolverBase::WhichType type)
MFEM_ABORT("ARPACK eigenvalue solver does not implement TARGET_REAL or "
"TARGET_IMAGINARY for SetWhichEigenpairs!");
break;
default:
MFEM_ABORT("Which eigenpair not implemented!");
break;
}
}

Expand Down Expand Up @@ -516,9 +513,6 @@ void ArpackEigenSolver::GetError(int i, EigenSolverBase::ErrorType type, double
case ErrorType::BACKWARD:
err = res[j] / GetBackwardScaling(eig[j]);
break;
default:
MFEM_ABORT("Eigenpair error type not implemented!");
break;
}
}

Expand Down
3 changes: 0 additions & 3 deletions palace/linalg/feast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,6 @@ void FeastEigenSolver::GetError(int i, EigenSolverBase::ErrorType type, double &
case ErrorType::BACKWARD:
err = res[j] / GetBackwardScaling(eig[j]);
break;
default:
MFEM_ABORT("Eigenpair error type not implemented!");
break;
}
}

Expand Down
6 changes: 0 additions & 6 deletions palace/linalg/ksp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ void KspSolver::Configure(const IoData &iodata)
case config::LinearSolverData::KspType::TFQMR:
SetType(Type::TFQMR);
break;
default:
MFEM_ABORT("Unexpected type for KspSolver configuration!");
break;
}
SetTol(iodata.solver.linear.tol);
SetMaxIter(iodata.solver.linear.max_it);
Expand Down Expand Up @@ -189,9 +186,6 @@ void KspSolver::SetType(KspSolver::Type type, bool piped)
SetCheckFinal(false);
}
break;
default:
MFEM_ABORT("Unexpected type for KspSolver!");
break;
}
}

Expand Down
3 changes: 0 additions & 3 deletions palace/linalg/pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ ConfigurePreconditioner(const IoData &iodata, const mfem::Array<int> &dbc_marker
"Solver was not built with MUMPS support, please choose a different solver!");
#endif
break;
default:
MFEM_ABORT("Unexpected type for KspPreconditioner configuration!");
break;
}
if (iodata.solver.linear.mat_gmg)
{
Expand Down
4 changes: 0 additions & 4 deletions palace/linalg/petsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,6 @@ void PetscParMatrix::AXPY(PetscScalar alpha, const PetscParMatrix &B,
case NNZStructure::SUBSET:
PalacePetscCall(MatAXPY(A, alpha, B, SUBSET_NONZERO_PATTERN));
break;
default:
MFEM_ABORT("Nonzero type for MatAXPY not implemented!");
break;
}
}

Expand Down Expand Up @@ -2393,7 +2390,6 @@ PetscErrorCode __mat_shell_get_diagonal(Mat A, Vec diag)
// #endif
// break;
// case NORM_1: // Max absolute column sum (not supported yet)
// default:
// MFEM_ABORT("Unsupported matrix norm type!");
// }
// PetscFunctionReturn(0);
Expand Down
21 changes: 0 additions & 21 deletions palace/linalg/slepc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,6 @@ void SlepcEigenSolver::GetError(int i, EigenSolverBase::ErrorType type, double &
case ErrorType::BACKWARD:
err = res[i] / GetBackwardScaling(eig);
break;
default:
MFEM_ABORT("Eigenpair error type not implemented!");
break;
}
}

Expand Down Expand Up @@ -401,9 +398,6 @@ void SlepcEPSSolverBase::SetWhichEigenpairs(EigenSolverBase::WhichType type)
case WhichType::TARGET_IMAGINARY:
PalacePetscCall(EPSSetWhichEigenpairs(eps, EPS_TARGET_IMAGINARY));
break;
default:
MFEM_ABORT("Which eigenpair not implemented!");
break;
}
}

Expand All @@ -427,9 +421,6 @@ void SlepcEPSSolverBase::SetProblemType(SlepcEigenSolver::ProblemType type)
PalacePetscCall(EPSSetProblemType(eps, EPS_GNHEP));
// PalacePetscCall(EPSSetProblemType(eps, EPS_PGNHEP)); // If B is SPD
break;
default:
MFEM_ABORT("Problem type not implemented!");
break;
}
}

Expand All @@ -453,9 +444,6 @@ void SlepcEPSSolverBase::SetType(SlepcEigenSolver::Type type)
PalacePetscCall(EPSSetType(eps, EPSJD));
region = false;
break;
default:
MFEM_ABORT("Eigenvalue solver type not implemented!");
break;
}
}

Expand Down Expand Up @@ -970,9 +958,6 @@ void SlepcPEPSolverBase::SetWhichEigenpairs(EigenSolverBase::WhichType type)
case WhichType::TARGET_IMAGINARY:
PalacePetscCall(PEPSetWhichEigenpairs(pep, PEP_TARGET_IMAGINARY));
break;
default:
MFEM_ABORT("Which eigenpair not implemented!");
break;
}
}

Expand All @@ -995,9 +980,6 @@ void SlepcPEPSolverBase::SetProblemType(SlepcEigenSolver::ProblemType type)
case ProblemType::GYROSCOPIC:
PalacePetscCall(PEPSetProblemType(pep, PEP_GYROSCOPIC));
break;
default:
MFEM_ABORT("Problem type not implemented!");
break;
}
}

Expand All @@ -1018,9 +1000,6 @@ void SlepcPEPSolverBase::SetType(SlepcEigenSolver::Type type)
PalacePetscCall(PEPSetType(pep, PEPJD));
region = false;
break;
default:
MFEM_ABORT("Eigenvalue solver type not implemented!");
break;
}
}

Expand Down
2 changes: 0 additions & 2 deletions palace/linalg/strumpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ GetCompressionType(config::LinearSolverData::CompressionType type)
return strumpack::CompressionType::ZFP_BLR_HODLR;
break;
case config::LinearSolverData::CompressionType::NONE:
default:
return strumpack::CompressionType::NONE;
}
}
Expand Down Expand Up @@ -97,7 +96,6 @@ StrumpackSolverBase<StrumpackSolverType>::StrumpackSolverBase(
this->SetCompressionRelTol(lr_tol);
break;
case config::LinearSolverData::CompressionType::NONE:
default:
break;
}
}
Expand Down
3 changes: 0 additions & 3 deletions palace/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ int main(int argc, char *argv[])
solver = std::make_unique<TransientSolver>(iodata, world_root, world_size, num_thread,
git_tag);
break;
default:
Mpi::Print(world_comm, "Error: Unsupported problem type!\n\n");
return 1;
}

// Read the mesh from file, refine, partition, and distribute it. Then nondimensionalize
Expand Down
3 changes: 0 additions & 3 deletions palace/models/spaceoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ SpaceOperator::GetSystemMatrixPetsc(SpaceOperator::OperatorType type, double ome
AddExtraSystemBdrCoefficients(omega, dfbr, dfbi, fbr, fbi);
str = "A2";
break;
default:
MFEM_ABORT("Invalid GetSystemMatrix matrix type!");
}
std::unique_ptr<mfem::HypreParMatrix> hAr, hAi;
bool has_real = false, has_imag = false;
Expand Down Expand Up @@ -348,7 +346,6 @@ SpaceOperator::GetSystemMatrix(SpaceOperator::OperatorType type, double omega,
break;
case OperatorType::COMPLETE:
case OperatorType::EXTRA:
default:
MFEM_ABORT("Invalid GetSystemMatrix matrix type for HypreParMatrix output!");
}
if (df.empty() && f.empty() && fb.empty())
Expand Down
1 change: 0 additions & 1 deletion palace/models/surfacepostoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ SurfacePostOperator::InterfaceDielectricData::GetCoefficient(
return std::make_unique<DielectricInterfaceCoefficient<DielectricInterfaceType::SA>>(
U, mat_op, ts, epsilon, sides[i], local_to_shared);
case DielectricInterfaceType::DEFAULT:
default:
return std::make_unique<
DielectricInterfaceCoefficient<DielectricInterfaceType::DEFAULT>>(
U, mat_op, ts, epsilon, sides[i], local_to_shared);
Expand Down
4 changes: 0 additions & 4 deletions palace/models/timeoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,6 @@ TimeOperator::TimeOperator(const IoData &iodata, SpaceOperator &spaceop,
type = mfem::TimeDependentOperator::EXPLICIT;
}
break;
default:
MFEM_ABORT("Invalid transient solver type!");
type = mfem::TimeDependentOperator::EXPLICIT; // For compiler warning
break;
}

// Set up time-dependent operator for 2nd-order curl-curl equation for E.
Expand Down
4 changes: 0 additions & 4 deletions palace/utils/iodata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,6 @@ double IoData::DimensionalizeValue(IoData::ValueType type, double v) const
case ValueType::CONDUCTIVITY:
sf = 1.0 / (electromagnetics::Z0_ * Lc); // [S/m]
break;
default:
MFEM_ABORT("Unsupported value type for dimensionalization!");
sf = 1.0; // For compiler warning
break;
}
return v * sf;
}
Expand Down

0 comments on commit 995020d

Please sign in to comment.