MRMD 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
IsInSymmetricSlab.hpp
Go to the documentation of this file.
1// Copyright 2024 Sebastian Eibl
2// Copyright 2026 Julian Friedrich Hille
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// https://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#pragma once
17
18#include "datatypes.hpp"
19
20namespace mrmd
21{
22namespace util
23{
25{
26private:
27 const real_t center_;
28 const real_t slabMin_;
29 const real_t slabMax_;
30 const AXIS axis_;
31 const real_t tolerance_;
32
33public:
34 KOKKOS_INLINE_FUNCTION
35 bool operator()(const real_t& x, const real_t& y, const real_t& z) const
36 {
37 auto dx = Point3D{x, y, z}[to_underlying(axis_)] - center_;
38 auto absDx = std::abs(dx);
39
40 return (absDx >= slabMin_ - tolerance_ && absDx <= slabMax_ + tolerance_);
41 }
42
43 KOKKOS_INLINE_FUNCTION
44 bool operator()(const real_t& coord) const
45 {
46 auto dx = coord - center_;
47 auto absDx = std::abs(dx);
48
49 return (absDx >= slabMin_ - tolerance_ && absDx <= slabMax_ + tolerance_);
50 }
51
53 const real_t slabMin,
54 const real_t slabMax,
55 const AXIS axis = AXIS::X,
56 const real_t tolerance = 0_r)
57 : center_(center[to_underlying(axis)]),
58 slabMin_(slabMin),
59 slabMax_(slabMax),
60 axis_(axis),
61 tolerance_(tolerance)
62 {
63 }
64};
65} // namespace util
66} // namespace mrmd
Definition IsInSymmetricSlab.hpp:25
KOKKOS_INLINE_FUNCTION bool operator()(const real_t &x, const real_t &y, const real_t &z) const
Definition IsInSymmetricSlab.hpp:35
KOKKOS_INLINE_FUNCTION bool operator()(const real_t &coord) const
Definition IsInSymmetricSlab.hpp:44
IsInSymmetricSlab(const Point3D &center, const real_t slabMin, const real_t slabMax, const AXIS axis=AXIS::X, const real_t tolerance=0_r)
Definition IsInSymmetricSlab.hpp:52
Definition BerendsenBarostat.cpp:18
Kokkos::Array< real_t, 3 > Point3D
Definition datatypes.hpp:100
AXIS
Definition datatypes.hpp:141
@ X
index of the x coordinate in vector views
double real_t
Definition datatypes.hpp:99
KOKKOS_INLINE_FUNCTION constexpr std::underlying_type_t< Enum > to_underlying(Enum e) noexcept
Definition datatypes.hpp:148