Skip to content

Commit

Permalink
Merge pull request #287 from awslabs/hughcars/waveport-configuration-dev
Browse files Browse the repository at this point in the history
Expose WavePort configuration options
  • Loading branch information
hughcars authored Oct 16, 2024
2 parents c168aea + c9f9934 commit 13ecb3a
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ The format of this changelog is based on
match the mesh on the boundaries specified by the donor and receiver attributes. This is
only possible the mesh on the donor and receiver match exactly, non-matching meshes are
not supported.
- Exposed configuration linear solver and eigen solver options for the wave port
subproblem. These can now be specified as part of the `config["Boundaries"]["WavePort"]`
configuration. The defaults align with the previously hardcoded values.

## [0.13.0] - 2024-05-20

Expand Down
16 changes: 15 additions & 1 deletion docs/src/config/boundaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ corresponding coordinate system.
"Active": <bool>,
"Mode": <int>,
"Offset": <float>,
"SolverType": <string>
"SolverType": <string>,
"MaxIts": <int>,
"KSPTol": <float>,
"EigenTol": <float>,
"Verbose": <int>
},
...
]
Expand Down Expand Up @@ -378,6 +382,16 @@ port boundary, specified in mesh length units.
the boundary mode for this wave port. See
[`config["Solver"]["Eigenmode"]["Type"]`](solver.md#solver%5B%22Eigenmode%22%5D).

`"MaxIts" [30]` : Specifies the maximum number of iterations to be used in the GMRES
solver.

`"KSPTol" [1e-8]` : Specifies the tolerance to be used in the linear solver.

`"EigenTol" [1e-6]` : Specifies the tolerance to be used in the eigenvalue solver.

`"Verbose" [0]` : Specifies the verbosity level to be used in the linear and eigensolver
for the wave port problem.

## `boundaries["WavePortPEC"]`

```json
Expand Down
24 changes: 20 additions & 4 deletions examples/cpw/cpw_wave_uniform.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,41 @@
"Attributes": [4],
"Mode": 1,
"Offset": 0.0,
"Excitation": true
"Excitation": true,
"MaxIts": 30,
"KSPTol": 1e-8,
"EigenTol": 1e-6,
"Verbose": 0
},
{
"Index": 2,
"Attributes": [5],
"Mode": 1,
"Offset": 0.0
"Offset": 0.0,
"MaxIts": 30,
"KSPTol": 1e-8,
"EigenTol": 1e-6,
"Verbose": 0
},
{
"Index": 3,
"Attributes": [6],
"Mode": 1,
"Offset": 0.0
"Offset": 0.0,
"MaxIts": 30,
"KSPTol": 1e-8,
"EigenTol": 1e-6,
"Verbose": 0
},
{
"Index": 4,
"Attributes": [7],
"Mode": 1,
"Offset": 0.0
"Offset": 0.0,
"MaxIts": 30,
"KSPTol": 1e-8,
"EigenTol": 1e-6,
"Verbose": 0
}
],
"Postprocessing":
Expand Down
21 changes: 9 additions & 12 deletions palace/models/waveportoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,14 +645,11 @@ WavePortData::WavePortData(const config::WavePortData &data,
{
// Define the linear solver to be used for solving systems associated with the
// generalized eigenvalue problem.
constexpr int ksp_print = 0;
constexpr double ksp_tol = 1.0e-8;
constexpr double ksp_max_it = 30;
auto gmres = std::make_unique<GmresSolver<ComplexOperator>>(port_comm, ksp_print);
auto gmres = std::make_unique<GmresSolver<ComplexOperator>>(port_comm, data.verbose);
gmres->SetInitialGuess(false);
gmres->SetRelTol(ksp_tol);
gmres->SetMaxIter(ksp_max_it);
gmres->SetRestartDim(ksp_max_it);
gmres->SetRelTol(data.ksp_tol);
gmres->SetMaxIter(data.ksp_max_its);
gmres->SetRestartDim(data.ksp_max_its);
// gmres->SetPrecSide(GmresSolverBase::PrecSide::RIGHT);

config::LinearSolverData::Type pc_type = solver.linear.type;
Expand Down Expand Up @@ -698,7 +695,7 @@ WavePortData::WavePortData(const config::WavePortData &data,
#if defined(MFEM_USE_SUPERLU)
auto slu = std::make_unique<SuperLUSolver>(
port_comm, config::LinearSolverData::SymFactType::DEFAULT, false,
ksp_print - 1);
data.verbose - 1);
// slu->GetSolver().SetColumnPermutation(mfem::superlu::MMD_AT_PLUS_A);
return slu;
#endif
Expand All @@ -708,7 +705,8 @@ WavePortData::WavePortData(const config::WavePortData &data,
#if defined(MFEM_USE_STRUMPACK)
auto strumpack = std::make_unique<StrumpackSolver>(
port_comm, config::LinearSolverData::SymFactType::DEFAULT,
config::LinearSolverData::CompressionType::NONE, 0.0, 0, 0, ksp_print - 1);
config::LinearSolverData::CompressionType::NONE, 0.0, 0, 0,
data.verbose - 1);
// strumpack->SetReorderingStrategy(strumpack::ReorderingStrategy::AMD);
return strumpack;
#endif
Expand All @@ -718,7 +716,7 @@ WavePortData::WavePortData(const config::WavePortData &data,
#if defined(MFEM_USE_MUMPS)
auto mumps = std::make_unique<MumpsSolver>(
port_comm, mfem::MUMPSSolver::UNSYMMETRIC,
config::LinearSolverData::SymFactType::DEFAULT, 0.0, ksp_print - 1);
config::LinearSolverData::SymFactType::DEFAULT, 0.0, data.verbose - 1);
// mumps->SetReorderingStrategy(mfem::MUMPSSolver::AMD);
return mumps;
#endif
Expand Down Expand Up @@ -770,9 +768,8 @@ WavePortData::WavePortData(const config::WavePortData &data,
eigen = std::move(slepc);
#endif
}
constexpr double tol = 1.0e-6;
eigen->SetNumModes(mode_idx, std::max(2 * mode_idx + 1, 5));
eigen->SetTol(tol);
eigen->SetTol(data.eig_tol);
eigen->SetLinearSolver(*ksp);

// We want to ignore evanescent modes (kₙ with large imaginary component). The
Expand Down
12 changes: 12 additions & 0 deletions palace/utils/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,10 @@ void WavePortBoundaryData::SetUp(json &boundaries)
data.eigen_type = it->value("SolverType", data.eigen_type);
data.excitation = it->value("Excitation", data.excitation);
data.active = it->value("Active", data.active);
data.ksp_max_its = it->value("MaxIts", data.ksp_max_its);
data.ksp_tol = it->value("KSPTol", data.ksp_tol);
data.eig_tol = it->value("EigenTol", data.eig_tol);
data.verbose = it->value("Verbose", data.verbose);

// Cleanup
it->erase("Index");
Expand All @@ -1123,6 +1127,10 @@ void WavePortBoundaryData::SetUp(json &boundaries)
it->erase("SolverType");
it->erase("Excitation");
it->erase("Active");
it->erase("MaxIts");
it->erase("KSPTol");
it->erase("EigenTol");
it->erase("Verbose");
MFEM_VERIFY(it->empty(),
"Found an unsupported configuration file keyword under \"WavePort\"!\n"
<< it->dump(2));
Expand All @@ -1137,6 +1145,10 @@ void WavePortBoundaryData::SetUp(json &boundaries)
std::cout << "SolverType: " << data.eigen_type << '\n';
std::cout << "Excitation: " << data.excitation << '\n';
std::cout << "Active: " << data.active << '\n';
std::cout << "MaxIts: " << data.ksp_max_its << '\n';
std::cout << "KSPTol: " << data.ksp_tol << '\n';
std::cout << "EigenTol: " << data.eig_tol << '\n';
std::cout << "Verbose: " << data.verbose << '\n';
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion palace/utils/configfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,18 @@ struct WavePortData

// List of boundary attributes for this wave port.
std::vector<int> attributes = {};

// Maximum number of iterations in linear solver.
int ksp_max_its = 45;

// Tolerance for linear solver.
double ksp_tol = 1e-8;

// Tolerance for eigenvalue solver.
double eig_tol = 1e-6;

// Print level for linear and eigenvalue solvers.
int verbose = 0;
};

struct WavePortBoundaryData : public internal::DataMap<WavePortData>
Expand Down Expand Up @@ -674,7 +686,7 @@ struct EigenSolverData
// Maximum iterations for eigenvalue solver.
int max_it = -1;

// Eigensolver subspace dimension or maximum dimension before restart.
// Eigenvalue solver subspace dimension or maximum dimension before restart.
int max_size = -1;

// Desired number of eigenmodes.
Expand Down
6 changes: 5 additions & 1 deletion scripts/schema/config/boundaries.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@
"Offset": { "type": "number", "minimum": 0.0 },
"SolverType": { "type": "string" },
"Excitation": { "type": "boolean" },
"Active": { "type": "boolean" }
"Active": { "type": "boolean" },
"MaxIts": { "type": "integer", "exclusiveMinimum": 0 },
"KSPTol": { "type": "number", "exclusiveMinimum": 0.0 },
"EigenTol": { "type": "number", "exclusiveMinimum": 0.0 },
"Verbose": { "type": "integer", "minimum": 0.0 }
}
}
},
Expand Down

0 comments on commit 13ecb3a

Please sign in to comment.