MRMD 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
Kokkos_grow.hpp
Go to the documentation of this file.
1// Copyright 2024 Sebastian Eibl
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <Kokkos_Core.hpp>
18#include <cassert>
19
20namespace mrmd
21{
22namespace util
23{
24template <class T, class... P>
25void grow(Kokkos::View<T, P...>& view, idx_t size, real_t safetyMargin = 1.1_r)
26{
27 assert(size >= 0);
28
29 if (view.extent(0) <= static_cast<unsigned long>(size))
30 {
31 Kokkos::resize(view, idx_c(real_c(size) * safetyMargin));
32 }
33
34 assert(view.extent(0) >= static_cast<unsigned long>(size));
35}
36} // namespace util
37} // namespace mrmd
void grow(Kokkos::View< T, P... > &view, idx_t size, real_t safetyMargin=1.1_r)
Definition Kokkos_grow.hpp:25
Definition BerendsenBarostat.cpp:18
KOKKOS_INLINE_FUNCTION constexpr idx_t idx_c(const T &val)
Definition datatypes.hpp:93
int64_t idx_t
Definition datatypes.hpp:91
double real_t
Definition datatypes.hpp:99
KOKKOS_INLINE_FUNCTION constexpr real_t real_c(T t)
Definition datatypes.hpp:114