Skip to content

Commit

Permalink
Style cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiangrimberg committed Jul 3, 2023
1 parent 2e71f76 commit 3b42a09
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
6 changes: 3 additions & 3 deletions fem/ceed/interface/operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Operator::Mult(const mfem::Vector &x, mfem::Vector &y) const
CeedScalar *y_ptr;
CeedMemType mem;
CeedGetPreferredMemType(mfem::internal::ceed, &mem);
if ( Device::Allows(Backend::DEVICE_MASK) && mem==CEED_MEM_DEVICE )
if (Device::Allows(Backend::DEVICE_MASK) && mem == CEED_MEM_DEVICE)
{
x_ptr = x.Read();
y_ptr = y.Write();
Expand Down Expand Up @@ -76,7 +76,7 @@ void Operator::AddMult(const mfem::Vector &x, mfem::Vector &y,
CeedScalar *y_ptr;
CeedMemType mem;
CeedGetPreferredMemType(mfem::internal::ceed, &mem);
if ( Device::Allows(Backend::DEVICE_MASK) && mem==CEED_MEM_DEVICE )
if (Device::Allows(Backend::DEVICE_MASK) && mem == CEED_MEM_DEVICE)
{
x_ptr = x.Read();
y_ptr = y.ReadWrite();
Expand Down Expand Up @@ -105,7 +105,7 @@ void Operator::GetDiagonal(mfem::Vector &diag) const
CeedScalar *d_ptr;
CeedMemType mem;
CeedGetPreferredMemType(mfem::internal::ceed, &mem);
if ( Device::Allows(Backend::DEVICE_MASK) && mem==CEED_MEM_DEVICE )
if (Device::Allows(Backend::DEVICE_MASK) && mem == CEED_MEM_DEVICE)
{
d_ptr = diag.ReadWrite();
}
Expand Down
3 changes: 2 additions & 1 deletion fem/ceed/interface/operator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ class Operator : public mfem::Operator
CeedVector &GetCeedVectorU() { return u; }
CeedVector &GetCeedVectorV() { return v; }
#endif

void Mult(const mfem::Vector &x, mfem::Vector &y) const override;
void AddMult(const mfem::Vector &x, mfem::Vector &y,
const double a = 1.0) const override;
void GetDiagonal(mfem::Vector &diag) const;
using mfem::Operator::SetupRAP;

virtual ~Operator()
{
#ifdef MFEM_USE_CEED
Expand Down
12 changes: 5 additions & 7 deletions fem/ceed/solvers/algebraic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ConstrainedOperator : public mfem::Operator
Array<int> ess_tdofs;
const mfem::Operator *P;
ceed::Operator *unconstrained_op;
mfem::ConstrainedOperator *constrained_op;
mfem::Operator *constrained_op;
};

ConstrainedOperator::ConstrainedOperator(
Expand All @@ -59,10 +59,8 @@ ConstrainedOperator::ConstrainedOperator(
: ess_tdofs(ess_tdofs_), P(P_)
{
unconstrained_op = new ceed::Operator(oper);
mfem::Operator *rap = unconstrained_op->SetupRAP(P, P);
height = width = rap->Height();
bool own_rap = (rap != unconstrained_op);
constrained_op = new mfem::ConstrainedOperator(rap, ess_tdofs, own_rap);
unconstrained_op->FormSystemOperator(ess_tdofs, constrained_op);
height = width = constrained_op->Height();
}

ConstrainedOperator::ConstrainedOperator(CeedOperator oper,
Expand Down Expand Up @@ -538,7 +536,7 @@ void AlgebraicInterpolation::Mult(const mfem::Vector& x, mfem::Vector& y) const
CeedScalar *out_ptr;
CeedMemType mem;
ierr = CeedGetPreferredMemType(internal::ceed, &mem); PCeedChk(ierr);
if ( Device::Allows(Backend::DEVICE_MASK) && mem==CEED_MEM_DEVICE )
if (Device::Allows(Backend::DEVICE_MASK) && mem == CEED_MEM_DEVICE)
{
in_ptr = x.Read();
out_ptr = y.ReadWrite();
Expand Down Expand Up @@ -571,7 +569,7 @@ void AlgebraicInterpolation::MultTranspose(const mfem::Vector& x,
ierr = CeedGetPreferredMemType(internal::ceed, &mem); PCeedChk(ierr);
const CeedScalar *in_ptr;
CeedScalar *out_ptr;
if ( Device::Allows(Backend::DEVICE_MASK) && mem==CEED_MEM_DEVICE )
if (Device::Allows(Backend::DEVICE_MASK) && mem == CEED_MEM_DEVICE)
{
in_ptr = x.Read();
out_ptr = y.ReadWrite();
Expand Down
24 changes: 13 additions & 11 deletions fem/ceed/solvers/algebraic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ class AlgebraicCoarseSpace : public FiniteElementSpace
public:
AlgebraicCoarseSpace(FiniteElementSpace &fine_fes, CeedElemRestriction fine_er,
int order, int dim, int order_reduction_);
~AlgebraicCoarseSpace();

int GetOrderReduction() const { return order_reduction; }
CeedElemRestriction GetCeedElemRestriction() const { return ceed_elem_restriction; }
CeedBasis GetCeedCoarseToFine() const { return coarse_to_fine; }
virtual const mfem::Operator *GetProlongationMatrix() const override { return NULL; }
virtual const SparseMatrix *GetRestrictionMatrix() const override { return NULL; }
~AlgebraicCoarseSpace();

protected:
int *dof_map;
Expand All @@ -64,11 +65,12 @@ class ParAlgebraicCoarseSpace : public AlgebraicCoarseSpace
int order_reduction_,
GroupCommunicator *gc_fine
);
~ParAlgebraicCoarseSpace();

virtual const mfem::Operator *GetProlongationMatrix() const override { return P; }
virtual const SparseMatrix *GetRestrictionMatrix() const override { return R_mat; }
GroupCommunicator *GetGroupCommunicator() const { return gc; }
HypreParMatrix *GetProlongationHypreParMatrix();
~ParAlgebraicCoarseSpace();

private:
SparseMatrix *R_mat;
Expand All @@ -92,14 +94,11 @@ class AlgebraicInterpolation : public mfem::Operator
Ceed ceed, CeedBasis basisctof,
CeedElemRestriction erestrictu_coarse,
CeedElemRestriction erestrictu_fine);

~AlgebraicInterpolation();

virtual void Mult(const mfem::Vector& x, mfem::Vector& y) const;

virtual void MultTranspose(const mfem::Vector& x, mfem::Vector& y) const;

using mfem::Operator::SetupRAP;
private:
int Initialize(Ceed ceed, CeedBasis basisctof,
CeedElemRestriction erestrictu_coarse,
Expand Down Expand Up @@ -127,11 +126,6 @@ class AlgebraicSpaceHierarchy : public FiniteElementSpaceHierarchy
The given space is a real (geometric) space, but the coarse spaces are
constructed semi-algebraically with no mesh information. */
AlgebraicSpaceHierarchy(FiniteElementSpace &fespace);
AlgebraicCoarseSpace& GetAlgebraicCoarseSpace(int level)
{
MFEM_ASSERT(level < GetNumLevels() - 1, "");
return static_cast<AlgebraicCoarseSpace&>(*fespaces[level]);
}
~AlgebraicSpaceHierarchy()
{
for (int i=0; i<R_tr.Size(); ++i)
Expand All @@ -144,6 +138,12 @@ class AlgebraicSpaceHierarchy : public FiniteElementSpaceHierarchy
}
}

AlgebraicCoarseSpace& GetAlgebraicCoarseSpace(int level)
{
MFEM_ASSERT(level < GetNumLevels() - 1, "");
return static_cast<AlgebraicCoarseSpace&>(*fespaces[level]);
}

private:
CeedElemRestriction fine_er;
Array<AlgebraicInterpolation*> ceed_interpolations;
Expand All @@ -168,9 +168,10 @@ class AlgebraicMultigrid : public GeometricMultigrid
BilinearForm &form,
const Array<int> &ess_tdofs
);
virtual void SetOperator(const mfem::Operator &op) override { }
~AlgebraicMultigrid();

virtual void SetOperator(const mfem::Operator &op) override {}

private:
OperatorHandle fine_operator;
Array<CeedOperator> ceed_operators;
Expand Down Expand Up @@ -200,6 +201,7 @@ class AlgebraicSolver : public Solver
*/
AlgebraicSolver(BilinearForm &form, const Array<int>& ess_tdofs);
~AlgebraicSolver();

void Mult(const Vector& x, Vector& y) const;
void SetOperator(const mfem::Operator& op);
};
Expand Down

0 comments on commit 3b42a09

Please sign in to comment.