Skip to content

Commit

Permalink
MueLu: Add clang-format workflow and format using clang-format 8.0.1 …
Browse files Browse the repository at this point in the history
…with style file
  • Loading branch information
GrahamBenHarper committed Oct 29, 2023
1 parent 1e13a06 commit df350c8
Show file tree
Hide file tree
Showing 650 changed files with 68,901 additions and 71,577 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/muelu_clang_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check MueLu clang-format

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: DoozyX/[email protected]
with:
source: './packages/muelu/src'
exclude: './lib'
extensions: 'cpp,hpp'
clangFormatVersion: 8
style: file
inplace: False
13 changes: 13 additions & 0 deletions packages/muelu/src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Official Tool: clang-format version 8.0.1
#Kokkos options
BasedOnStyle: google
SortIncludes: false
AlignConsecutiveAssignments: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
#MueLu-specific options
ColumnLimit: 0
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeComma
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
Original file line number Diff line number Diff line change
Expand Up @@ -77,98 +77,96 @@

namespace MueLu {

template<class Scalar = DefaultScalar,
class LocalOrdinal = DefaultLocalOrdinal,
class GlobalOrdinal = DefaultGlobalOrdinal,
class Node = DefaultNode>
class BrickAggregationFactory : public SingleLevelFactoryBase {
template <class Scalar = DefaultScalar,
class LocalOrdinal = DefaultLocalOrdinal,
class GlobalOrdinal = DefaultGlobalOrdinal,
class Node = DefaultNode>
class BrickAggregationFactory : public SingleLevelFactoryBase {
#undef MUELU_BRICKAGGREGATIONFACTORY_SHORT
#include "MueLu_UseShortNames.hpp"
private:
typedef Teuchos::ScalarTraits<Scalar> STS;
private:
typedef Teuchos::ScalarTraits<Scalar> STS;

// Comparator for doubles
// Generally, the coordinates for coarser levels would come out of averaging of fine level coordinates
// It is possible that the result of the averaging differs slightly between clusters, as we might have
// 3x2 and 2x2 cluster which would result in averaging 6 and 4 y-coordinates respectively, leading to
// slightly different results.
// Therefore, we hardcode a constant so that close points are considered the same.
class compare {
public:
bool operator()(const Scalar& x, const Scalar& y) const {
if (STS::magnitude(x - y) < 1e-14)
return false;
return STS::real(x) < STS::real(y);
}
};
typedef std::map<Scalar,GlobalOrdinal,compare> container;
// Comparator for doubles
// Generally, the coordinates for coarser levels would come out of averaging of fine level coordinates
// It is possible that the result of the averaging differs slightly between clusters, as we might have
// 3x2 and 2x2 cluster which would result in averaging 6 and 4 y-coordinates respectively, leading to
// slightly different results.
// Therefore, we hardcode a constant so that close points are considered the same.
class compare {
public:
bool operator()(const Scalar& x, const Scalar& y) const {
if (STS::magnitude(x - y) < 1e-14)
return false;
return STS::real(x) < STS::real(y);
}
};
typedef std::map<Scalar, GlobalOrdinal, compare> container;

public:
//! @name Constructors/Destructors.
//@{
public:
//! @name Constructors/Destructors.
//@{

//! Constructor.
BrickAggregationFactory() : nDim_(-1), nx_(-1), ny_(-1), nz_(-1), bx_(-1), by_(-1), bz_(-1) { };
//! Constructor.
BrickAggregationFactory()
: nDim_(-1)
, nx_(-1)
, ny_(-1)
, nz_(-1)
, bx_(-1)
, by_(-1)
, bz_(-1){};

//! Destructor.
virtual ~BrickAggregationFactory() { }
//! Destructor.
virtual ~BrickAggregationFactory() {}

RCP<const ParameterList> GetValidParameterList() const;
RCP<const ParameterList> GetValidParameterList() const;

//@}
//@}

// Options shared by all aggregation algorithms
// Options shared by all aggregation algorithms

//! Input
//@{
//! Input
//@{

void DeclareInput(Level &currentLevel) const;
void DeclareInput(Level& currentLevel) const;

//@}
//@}

//! @name Build methods.
//@{
//! @name Build methods.
//@{

/*! @brief Build aggregates. */
void Build(Level &currentLevel) const;
/*! @brief Build aggregates. */
void Build(Level& currentLevel) const;

//@}
//@}

private:
void Setup(const RCP<const Teuchos::Comm<int> >& comm, const RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LO,GO,NO> >& coords, const RCP<const Map>& map) const;
RCP<container> Construct1DMap(const RCP<const Teuchos::Comm<int> >& comm, const ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& x) const;
private:
void Setup(const RCP<const Teuchos::Comm<int> >& comm, const RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType, LO, GO, NO> >& coords, const RCP<const Map>& map) const;
RCP<container> Construct1DMap(const RCP<const Teuchos::Comm<int> >& comm, const ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& x) const;

void BuildGraph(Level& currentLevel, const RCP<Matrix>& A) const;
void BuildGraph(Level& currentLevel, const RCP<Matrix>& A) const;

bool isDirichlet(LocalOrdinal LID) const;
bool isRoot(LocalOrdinal LID) const;
GlobalOrdinal getRoot(LocalOrdinal LID) const;
GlobalOrdinal getAggGID(LocalOrdinal LID) const;

bool isDirichlet(LocalOrdinal LID) const;
bool isRoot (LocalOrdinal LID) const;
GlobalOrdinal getRoot (LocalOrdinal LID) const;
GlobalOrdinal getAggGID(LocalOrdinal LID) const;
void getIJK(LocalOrdinal LID, int& i, int& j, int& k) const;
void getAggIJK(LocalOrdinal LID, int& i, int& j, int& k) const;

void getIJK(LocalOrdinal LID, int &i, int &j, int &k) const;
void getAggIJK(LocalOrdinal LID, int &i, int &j, int &k) const;
mutable int nDim_;
mutable RCP<container> xMap_, yMap_, zMap_;
mutable ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::magnitudeType> x_, y_, z_;
mutable int nx_, ny_, nz_;
mutable int bx_, by_, bz_;
mutable bool dirichletX_, dirichletY_, dirichletZ_;
mutable int naggx_, naggy_, naggz_;

mutable
int nDim_;
mutable
RCP<container> xMap_, yMap_, zMap_;
mutable
ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::magnitudeType> x_, y_, z_;
mutable
int nx_, ny_, nz_;
mutable
int bx_, by_, bz_;
mutable
bool dirichletX_,dirichletY_,dirichletZ_;
mutable
int naggx_, naggy_, naggz_;
mutable std::map<GlobalOrdinal, GlobalOrdinal> revMap_;
}; // class BrickAggregationFactory

mutable
std::map<GlobalOrdinal,GlobalOrdinal> revMap_;
}; // class BrickAggregationFactory

}
} // namespace MueLu

#define MUELU_BRICKAGGREGATIONFACTORY_SHORT
#endif /* MUELU_BRICKAGGREGATIONFACTORY_DECL_HPP_ */
Loading

0 comments on commit df350c8

Please sign in to comment.