Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some clang-tidy fixes #414

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions Source/BaseState.H
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ struct BaseStateArray {
constexpr BaseStateArray(BaseStateArray<T> const& rhs) noexcept
: dptr(rhs.dptr), nlev(rhs.nlev), len(rhs.len), nvar(rhs.nvar) {}

/// destructor
AMREX_GPU_HOST_DEVICE
~BaseStateArray() = default;

// no copy assignment
AMREX_GPU_HOST_DEVICE
BaseStateArray& operator= (const BaseStateArray<T>& other) = delete;

// no move constructor
AMREX_GPU_HOST_DEVICE
BaseStateArray(BaseStateArray<T>&& other) = delete;

// no move assignment
AMREX_GPU_HOST_DEVICE
BaseStateArray& operator= (BaseStateArray<T>&& other) = delete;

/// initialize from pointer
AMREX_GPU_HOST_DEVICE
constexpr BaseStateArray(T* ptr, const int num_levs = 1,
Expand Down Expand Up @@ -83,8 +99,8 @@ struct BaseStateArray {
return dptr[i];
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T* ptr(int lev, int i = 0,
int n = 0) const noexcept {
AMREX_GPU_HOST_DEVICE [[nodiscard]] AMREX_FORCE_INLINE T* ptr(int lev, int i = 0,
int n = 0) const noexcept {
return dptr + (lev * len + i) * nvar + n;
}

Expand All @@ -93,17 +109,17 @@ struct BaseStateArray {
}

/// number of levels in base
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nLevels() const noexcept {
AMREX_GPU_HOST_DEVICE [[nodiscard]] AMREX_FORCE_INLINE int nLevels() const noexcept {
return nlev;
}

/// number of cells in base
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int length() const noexcept {
AMREX_GPU_HOST_DEVICE [[nodiscard]] AMREX_FORCE_INLINE int length() const noexcept {
return len;
}

/// number of components
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nComp() const noexcept {
AMREX_GPU_HOST_DEVICE [[nodiscard]] AMREX_FORCE_INLINE int nComp() const noexcept {
return nvar;
}
};
Expand Down Expand Up @@ -140,7 +156,7 @@ class BaseState {

/// return a BaseStateArray object to allow for accessing
/// the underlying data
AMREX_FORCE_INLINE
[[nodiscard]] AMREX_FORCE_INLINE
BaseStateArray<T const> array() const noexcept {
return makeBaseStateArray<T const>(base_data.dataPtr(), nlev, len,
nvar);
Expand All @@ -153,7 +169,7 @@ class BaseState {
return makeBaseStateArray<T>(base_data.dataPtr(), nlev, len, nvar);
}

AMREX_FORCE_INLINE
[[nodiscard]] AMREX_FORCE_INLINE
BaseStateArray<const T> const_array() const noexcept {
return makeBaseStateArray<const T>(base_data.dataPtr(), nlev, len,
nvar);
Expand Down Expand Up @@ -181,17 +197,17 @@ class BaseState {
void setVal(const int comp, const T& val);

/// number of levels in base
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nLevels() const noexcept {
AMREX_GPU_HOST_DEVICE [[nodiscard]] AMREX_FORCE_INLINE int nLevels() const noexcept {
return nlev;
};

/// number of cells in base
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int length() const noexcept {
AMREX_GPU_HOST_DEVICE [[nodiscard]] AMREX_FORCE_INLINE int length() const noexcept {
return len;
};

/// number of components
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nComp() const noexcept {
AMREX_GPU_HOST_DEVICE [[nodiscard]] AMREX_FORCE_INLINE int nComp() const noexcept {
return nvar;
};

Expand All @@ -209,7 +225,7 @@ class BaseState {

T* dataPtr() noexcept { return base_data.dataPtr(); };

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T* dataPtr() const noexcept {
AMREX_GPU_HOST_DEVICE [[nodiscard]] AMREX_FORCE_INLINE T* dataPtr() const noexcept {
return this->dptr;
}

Expand Down Expand Up @@ -359,7 +375,7 @@ void BaseState<T>::define(const int num_levs, const int length, const int ncomp,
template <class T>
void BaseState<T>::resize(const int num_levs, const int length, const int ncomp,
const T val) {
if (base_data.size() > 0) {
if (! base_data.empty()) {
base_data.resize(0);
amrex::Gpu::streamSynchronize();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Maestro.H
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ amrex::Real QuadInterp(const amrex::Real x, const amrex::Real x0,
const amrex::Real y2, const bool limit = true);

/// hard code a maximum level limit
#define MAESTRO_MAX_LEVELS 15
constexpr int MAESTRO_MAX_LEVELS{15};

class Maestro : public amrex::AmrCore {
public:
Expand Down
3 changes: 1 addition & 2 deletions Util/simple_log/SimpleLog.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class SimpleLog {
public:
SimpleLog() {
log_data.resize(MAX_LINES);
log_lines = 0;
};

void Log(const std::string& str, const amrex::Real d);
Expand All @@ -33,7 +32,7 @@ class SimpleLog {
private:
static constexpr int MAX_LINES = 128;

int log_lines;
int log_lines{0};

std::vector<std::string> log_data;
};
Expand Down
Loading