Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiangrimberg committed Jan 29, 2024
1 parent 8ec1ad4 commit 1161062
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 34 deletions.
9 changes: 0 additions & 9 deletions palace/linalg/operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,6 @@ void ComplexWrapperOperator::AddMult(const ComplexVector &x, ComplexVector &y,
const Vector &xi = x.Imag();
Vector &yr = y.Real();
Vector &yi = y.Imag();
// MFEM_VERIFY(a.real() == 0.0 || a.imag() == 0.0,
// "ComplexWrapperOperator::AddMult does not support a general complex-valued
// " "coefficient!");
if (a.real() != 0.0 && a.imag() != 0.0)
{
ty.SetSize(height);
Expand Down Expand Up @@ -287,9 +284,6 @@ void ComplexWrapperOperator::AddMultTranspose(const ComplexVector &x, ComplexVec
const Vector &xi = x.Imag();
Vector &yr = y.Real();
Vector &yi = y.Imag();
// MFEM_VERIFY(a.real() == 0.0 || a.imag() == 0.0,
// "ComplexWrapperOperator::AddMultTranspose does not support a general "
// "complex-valued coefficient!");
if (a.real() != 0.0 && a.imag() != 0.0)
{
tx.SetSize(width);
Expand Down Expand Up @@ -358,9 +352,6 @@ void ComplexWrapperOperator::AddMultHermitianTranspose(const ComplexVector &x,
const Vector &xi = x.Imag();
Vector &yr = y.Real();
Vector &yi = y.Imag();
// MFEM_VERIFY(a.real() == 0.0 || a.imag() == 0.0,
// "ComplexWrapperOperator::AddMultHermitianTranspose does not support a "
// "general complex-valued coefficient!");
if (a.real() != 0.0 && a.imag() != 0.0)
{
tx.SetSize(width);
Expand Down
40 changes: 15 additions & 25 deletions palace/linalg/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ void MfemWrapperSolver<Operator>::SetOperator(const Operator &op)
const auto *PtAP = dynamic_cast<const ParOperator *>(&op);
MFEM_VERIFY(PtAP,
"MfemWrapperSolver must be able to construct a HypreParMatrix operator!");
pc->SetOperator(PtAP->ParallelAssemble());
if (!save_assembled)
{
PtAP->StealParallelAssemble();
}
pc->SetOperator(!save_assembled ? *PtAP->StealParallelAssemble()
: PtAP->ParallelAssemble());
}
this->height = op.Height();
this->width = op.Width();
Expand All @@ -34,31 +31,24 @@ void MfemWrapperSolver<Operator>::SetOperator(const Operator &op)
template <>
void MfemWrapperSolver<ComplexOperator>::SetOperator(const ComplexOperator &op)
{
// XX TODO: Test complex matrix assembly if coarse solve supports it
// Assemble the real and imaginary parts, then add.
const mfem::HypreParMatrix *hAr = nullptr, *hAi = nullptr;
// XX TODO: Test complex matrix assembly if coarse solve supports it
const mfem::HypreParMatrix *hAr = dynamic_cast<const mfem::HypreParMatrix *>(op.Real());
const mfem::HypreParMatrix *hAi = dynamic_cast<const mfem::HypreParMatrix *>(op.Imag());
const ParOperator *PtAPr = nullptr, *PtAPi = nullptr;
if (op.Real())
if (op.Real() && !hAr)
{
hAr = dynamic_cast<const mfem::HypreParMatrix *>(op.Real());
if (!hAr)
{
PtAPr = dynamic_cast<const ParOperator *>(op.Real());
MFEM_VERIFY(PtAPr,
"MfemWrapperSolver must be able to construct a HypreParMatrix operator!");
hAr = &PtAPr->ParallelAssemble();
}
PtAPr = dynamic_cast<const ParOperator *>(op.Real());
MFEM_VERIFY(PtAPr,
"MfemWrapperSolver must be able to construct a HypreParMatrix operator!");
hAr = &PtAPr->ParallelAssemble();
}
if (op.Imag())
if (op.Imag() && !hAi)
{
hAi = dynamic_cast<const mfem::HypreParMatrix *>(op.Imag());
if (!hAi)
{
PtAPi = dynamic_cast<const ParOperator *>(op.Imag());
MFEM_VERIFY(PtAPi,
"MfemWrapperSolver must be able to construct a HypreParMatrix operator!");
hAi = &PtAPi->ParallelAssemble();
}
PtAPi = dynamic_cast<const ParOperator *>(op.Imag());
MFEM_VERIFY(PtAPi,
"MfemWrapperSolver must be able to construct a HypreParMatrix operator!");
hAi = &PtAPi->ParallelAssemble();
}
if (hAr && hAi)
{
Expand Down

0 comments on commit 1161062

Please sign in to comment.