Skip to content

Commit 9c11986

Browse files
authored
Merge pull request #384 from awslabs/hughcars/refactor-labels
Move enums from config into labels.hpp
2 parents 360de9a + be49c4c commit 9c11986

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+890
-965
lines changed

palace/drivers/drivensolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ErrorIndicator DrivenSolver::SweepUniform(SpaceOperator &space_op,
7070
{
7171
// Initialize postprocessing for measurement and printers.
7272
// Initialize write directory with default path; will be changed if multiple excitations.
73-
PostOperator<config::ProblemData::Type::DRIVEN> post_op(iodata, space_op);
73+
PostOperator<ProblemType::DRIVEN> post_op(iodata, space_op);
7474
auto excitation_helper = space_op.GetPortExcitations();
7575

7676
// Construct the system matrices defining the linear operator. PEC boundaries are handled
@@ -186,7 +186,7 @@ ErrorIndicator DrivenSolver::SweepAdaptive(SpaceOperator &space_op,
186186
const std::vector<double> &omega_sample) const
187187
{
188188
// Initialize postprocessing for measurement and printers.
189-
PostOperator<config::ProblemData::Type::DRIVEN> post_op(iodata, space_op);
189+
PostOperator<ProblemType::DRIVEN> post_op(iodata, space_op);
190190
auto excitation_helper = space_op.GetPortExcitations();
191191

192192
// Configure PROM parameters if not specified.

palace/drivers/drivensolver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace palace
1414

1515
class ErrorIndicator;
1616
class Mesh;
17-
template <config::ProblemData::Type>
17+
template <ProblemType>
1818
class PostOperator;
1919
class SpaceOperator;
2020

palace/drivers/eigensolver.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ EigenSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
4343
SaveMetadata(space_op.GetNDSpaces());
4444

4545
// Configure objects for postprocessing.
46-
PostOperator<config::ProblemData::Type::EIGENMODE> post_op(iodata, space_op);
46+
PostOperator<ProblemType::EIGENMODE> post_op(iodata, space_op);
4747
ComplexVector E(Curl.Width()), B(Curl.Height());
4848
E.UseDevice(true);
4949
B.UseDevice(true);
@@ -52,28 +52,28 @@ EigenSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
5252
// (K + λ C + λ² M) u = 0 or K u = -λ² M u
5353
// with λ = iω. In general, the system matrices are complex and symmetric.
5454
std::unique_ptr<EigenvalueSolver> eigen;
55-
config::EigenSolverData::Type type = iodata.solver.eigenmode.type;
55+
EigenSolverBackend type = iodata.solver.eigenmode.type;
5656
#if defined(PALACE_WITH_ARPACK) && defined(PALACE_WITH_SLEPC)
57-
if (type == config::EigenSolverData::Type::DEFAULT)
57+
if (type == EigenSolverBackend::DEFAULT)
5858
{
59-
type = config::EigenSolverData::Type::SLEPC;
59+
type = EigenSolverBackend::SLEPC;
6060
}
6161
#elif defined(PALACE_WITH_ARPACK)
62-
if (iodata.solver.eigenmode.type == config::EigenSolverData::Type::SLEPC)
62+
if (iodata.solver.eigenmode.type == EigenSolverBackend::SLEPC)
6363
{
6464
Mpi::Warning("SLEPc eigensolver not available, using ARPACK!\n");
6565
}
66-
type = config::EigenSolverData::Type::ARPACK;
66+
type = EigenSolverBackend::ARPACK;
6767
#elif defined(PALACE_WITH_SLEPC)
68-
if (iodata.solver.eigenmode.type == config::EigenSolverData::Type::ARPACK)
68+
if (iodata.solver.eigenmode.type == EigenSolverBackend::ARPACK)
6969
{
7070
Mpi::Warning("ARPACK eigensolver not available, using SLEPc!\n");
7171
}
72-
type = config::EigenSolverData::Type::SLEPC;
72+
type = EigenSolverBackend::SLEPC;
7373
#else
7474
#error "Eigenmode solver requires building with ARPACK or SLEPc!"
7575
#endif
76-
if (type == config::EigenSolverData::Type::ARPACK)
76+
if (type == EigenSolverBackend::ARPACK)
7777
{
7878
#if defined(PALACE_WITH_ARPACK)
7979
Mpi::Print("\nConfiguring ARPACK eigenvalue solver:\n");
@@ -89,7 +89,7 @@ EigenSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
8989
}
9090
#endif
9191
}
92-
else // config::EigenSolverData::Type::SLEPC
92+
else // EigenSolverBackend::SLEPC
9393
{
9494
#if defined(PALACE_WITH_SLEPC)
9595
Mpi::Print("\nConfiguring SLEPc eigenvalue solver:\n");
@@ -116,9 +116,8 @@ EigenSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
116116
slepc->SetType(slepc::SlepcEigenvalueSolver::Type::KRYLOVSCHUR);
117117
}
118118
slepc->SetProblemType(slepc::SlepcEigenvalueSolver::ProblemType::GEN_NON_HERMITIAN);
119-
slepc->SetOrthogonalization(
120-
iodata.solver.linear.gs_orthog_type == config::LinearSolverData::OrthogType::MGS,
121-
iodata.solver.linear.gs_orthog_type == config::LinearSolverData::OrthogType::CGS2);
119+
slepc->SetOrthogonalization(iodata.solver.linear.gs_orthog == Orthogonalization::MGS,
120+
iodata.solver.linear.gs_orthog == Orthogonalization::CGS2);
122121
eigen = std::move(slepc);
123122
#endif
124123
}
@@ -221,7 +220,7 @@ EigenSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
221220
{
222221
// Search for eigenvalues closest to λ = iσ.
223222
eigen->SetShiftInvert(1i * target);
224-
if (type == config::EigenSolverData::Type::ARPACK)
223+
if (type == EigenSolverBackend::ARPACK)
225224
{
226225
// ARPACK searches based on eigenvalues of the transformed problem. The eigenvalue
227226
// 1 / (λ - σ) will be a large-magnitude negative imaginary number for an eigenvalue
@@ -237,7 +236,7 @@ EigenSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
237236
{
238237
// Linear EVP has eigenvalues μ = -λ² = ω². Search for eigenvalues closest to μ = σ².
239238
eigen->SetShiftInvert(target * target);
240-
if (type == config::EigenSolverData::Type::ARPACK)
239+
if (type == EigenSolverBackend::ARPACK)
241240
{
242241
// ARPACK searches based on eigenvalues of the transformed problem. 1 / (μ - σ²)
243242
// will be a large-magnitude positive real number for an eigenvalue μ with frequency

palace/drivers/electrostaticsolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ElectrostaticSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
3737

3838
// Terminal indices are the set of boundaries over which to compute the capacitance
3939
// matrix. Terminal boundaries are aliases for ports.
40-
PostOperator<config::ProblemData::Type::ELECTROSTATIC> post_op(iodata, laplace_op);
40+
PostOperator<ProblemType::ELECTROSTATIC> post_op(iodata, laplace_op);
4141
int n_step = static_cast<int>(laplace_op.GetSources().size());
4242
MFEM_VERIFY(n_step > 0, "No terminal boundaries specified for electrostatic simulation!");
4343

@@ -98,7 +98,7 @@ ElectrostaticSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
9898
}
9999

100100
void ElectrostaticSolver::PostprocessTerminals(
101-
PostOperator<config::ProblemData::Type::ELECTROSTATIC> &post_op,
101+
PostOperator<ProblemType::ELECTROSTATIC> &post_op,
102102
const std::map<int, mfem::Array<int>> &terminal_sources,
103103
const std::vector<Vector> &V) const
104104
{

palace/drivers/electrostaticsolver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace palace
2424

2525
class ErrorIndicator;
2626
class Mesh;
27-
template <config::ProblemData::Type>
27+
template <ProblemType>
2828
class PostOperator;
2929

3030
//
@@ -33,7 +33,7 @@ class PostOperator;
3333
class ElectrostaticSolver : public BaseSolver
3434
{
3535
private:
36-
void PostprocessTerminals(PostOperator<config::ProblemData::Type::ELECTROSTATIC> &post_op,
36+
void PostprocessTerminals(PostOperator<ProblemType::ELECTROSTATIC> &post_op,
3737
const std::map<int, mfem::Array<int>> &terminal_sources,
3838
const std::vector<Vector> &V) const;
3939

palace/drivers/magnetostaticsolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ MagnetostaticSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
3636
ksp.SetOperators(*K, *K);
3737

3838
// Terminal indices are the set of boundaries over which to compute the inductance matrix.
39-
PostOperator<config::ProblemData::Type::MAGNETOSTATIC> post_op(iodata, curlcurl_op);
39+
PostOperator<ProblemType::MAGNETOSTATIC> post_op(iodata, curlcurl_op);
4040
int n_step = static_cast<int>(curlcurl_op.GetSurfaceCurrentOp().Size());
4141
MFEM_VERIFY(n_step > 0,
4242
"No surface current boundaries specified for magnetostatic simulation!");
@@ -103,7 +103,7 @@ MagnetostaticSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
103103
}
104104

105105
void MagnetostaticSolver::PostprocessTerminals(
106-
PostOperator<config::ProblemData::Type::MAGNETOSTATIC> &post_op,
106+
PostOperator<ProblemType::MAGNETOSTATIC> &post_op,
107107
const SurfaceCurrentOperator &surf_j_op, const std::vector<Vector> &A,
108108
const std::vector<double> &I_inc) const
109109
{

palace/drivers/magnetostaticsolver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace palace
1515

1616
class ErrorIndicator;
1717
class Mesh;
18-
template <config::ProblemData::Type>
18+
template <ProblemType>
1919
class PostOperator;
2020
class SurfaceCurrentOperator;
2121

@@ -25,7 +25,7 @@ class SurfaceCurrentOperator;
2525
class MagnetostaticSolver : public BaseSolver
2626
{
2727
private:
28-
void PostprocessTerminals(PostOperator<config::ProblemData::Type::MAGNETOSTATIC> &post_op,
28+
void PostprocessTerminals(PostOperator<ProblemType::MAGNETOSTATIC> &post_op,
2929
const SurfaceCurrentOperator &surf_j_op,
3030
const std::vector<Vector> &A,
3131
const std::vector<double> &I_inc) const;

palace/drivers/transientsolver.cpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TransientSolver::Solve(const std::vector<std::unique_ptr<Mesh>> &mesh) const
3838

3939
// Time stepping is uniform in the time domain. Index sets are for computing things like
4040
// port voltages and currents in postprocessing.
41-
PostOperator<config::ProblemData::Type::TRANSIENT> post_op(iodata, space_op);
41+
PostOperator<ProblemType::TRANSIENT> post_op(iodata, space_op);
4242

4343
// Transient solver only supports a single excitation, this is check in SpaceOperator.
4444
Mpi::Print("\nComputing transient response for:\n{}",
@@ -100,30 +100,25 @@ std::function<double(double)> TransientSolver::GetTimeExcitation(bool dot) const
100100
using namespace excitations;
101101
using F = std::function<double(double)>;
102102
const config::TransientSolverData &data = iodata.solver.transient;
103-
const config::TransientSolverData::ExcitationType &type = data.excitation;
104-
if (type == config::TransientSolverData::ExcitationType::SINUSOIDAL ||
105-
type == config::TransientSolverData::ExcitationType::MOD_GAUSSIAN)
103+
const Excitation &type = data.excitation;
104+
if (type == Excitation::SINUSOIDAL || type == Excitation::MOD_GAUSSIAN)
106105
{
107106
MFEM_VERIFY(data.pulse_f > 0.0,
108107
"Excitation frequency is missing for transient simulation!");
109108
}
110-
if (type == config::TransientSolverData::ExcitationType::GAUSSIAN ||
111-
type == config::TransientSolverData::ExcitationType::DIFF_GAUSSIAN ||
112-
type == config::TransientSolverData::ExcitationType::MOD_GAUSSIAN ||
113-
type == config::TransientSolverData::ExcitationType::SMOOTH_STEP)
109+
if (type == Excitation::GAUSSIAN || type == Excitation::DIFF_GAUSSIAN ||
110+
type == Excitation::MOD_GAUSSIAN || type == Excitation::SMOOTH_STEP)
114111
{
115112
MFEM_VERIFY(data.pulse_tau > 0.0,
116113
"Excitation width is missing for transient simulation!");
117114
}
118-
const double delay =
119-
(type == config::TransientSolverData::ExcitationType::GAUSSIAN ||
120-
type == config::TransientSolverData::ExcitationType::DIFF_GAUSSIAN ||
121-
type == config::TransientSolverData::ExcitationType::MOD_GAUSSIAN)
122-
? 4.5 * data.pulse_tau
123-
: 0.0;
115+
const double delay = (type == Excitation::GAUSSIAN || type == Excitation::DIFF_GAUSSIAN ||
116+
type == Excitation::MOD_GAUSSIAN)
117+
? 4.5 * data.pulse_tau
118+
: 0.0;
124119
switch (type)
125120
{
126-
case config::TransientSolverData::ExcitationType::SINUSOIDAL:
121+
case Excitation::SINUSOIDAL:
127122
if (dot)
128123
{
129124
return F{[=](double t) { return dpulse_sinusoidal(t, data.pulse_f, delay); }};
@@ -133,7 +128,7 @@ std::function<double(double)> TransientSolver::GetTimeExcitation(bool dot) const
133128
return F{[=](double t) { return pulse_sinusoidal(t, data.pulse_f, delay); }};
134129
}
135130
break;
136-
case config::TransientSolverData::ExcitationType::GAUSSIAN:
131+
case Excitation::GAUSSIAN:
137132
if (dot)
138133
{
139134
return F{[=](double t) { return dpulse_gaussian(t, data.pulse_tau, delay); }};
@@ -143,7 +138,7 @@ std::function<double(double)> TransientSolver::GetTimeExcitation(bool dot) const
143138
return F{[=](double t) { return pulse_gaussian(t, data.pulse_tau, delay); }};
144139
}
145140
break;
146-
case config::TransientSolverData::ExcitationType::DIFF_GAUSSIAN:
141+
case Excitation::DIFF_GAUSSIAN:
147142
if (dot)
148143
{
149144
return F{[=](double t) { return dpulse_gaussian_diff(t, data.pulse_tau, delay); }};
@@ -153,7 +148,7 @@ std::function<double(double)> TransientSolver::GetTimeExcitation(bool dot) const
153148
return F{[=](double t) { return pulse_gaussian_diff(t, data.pulse_tau, delay); }};
154149
}
155150
break;
156-
case config::TransientSolverData::ExcitationType::MOD_GAUSSIAN:
151+
case Excitation::MOD_GAUSSIAN:
157152
if (dot)
158153
{
159154
return F{[=](double t)
@@ -165,7 +160,7 @@ std::function<double(double)> TransientSolver::GetTimeExcitation(bool dot) const
165160
{ return pulse_gaussian_mod(t, data.pulse_f, data.pulse_tau, delay); }};
166161
}
167162
break;
168-
case config::TransientSolverData::ExcitationType::RAMP_STEP:
163+
case Excitation::RAMP_STEP:
169164
if (dot)
170165
{
171166
return F{[=](double t) { return dpulse_ramp(t, data.pulse_tau, delay); }};
@@ -175,7 +170,7 @@ std::function<double(double)> TransientSolver::GetTimeExcitation(bool dot) const
175170
return F{[=](double t) { return pulse_ramp(t, data.pulse_tau, delay); }};
176171
}
177172
break;
178-
case config::TransientSolverData::ExcitationType::SMOOTH_STEP:
173+
case Excitation::SMOOTH_STEP:
179174
if (dot)
180175
{
181176
return F{[=](double t) { return dpulse_smootherstep(t, data.pulse_tau, delay); }};

0 commit comments

Comments
 (0)