Multi Resolution Molecular Dynamics 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{
26{
27private:
28 const real_t center_;
29 const real_t slabMin_;
30 const real_t slabMax_;
31 const AXIS axis_;
32 const real_t tolerance_;
33
34public:
35 KOKKOS_INLINE_FUNCTION
36 bool operator()(const real_t& x, const real_t& y, const real_t& z) const
37 {
38 auto dx = Point3D{x, y, z}[to_underlying(axis_)] - center_;
39 auto absDx = std::abs(dx);
40
41 return (absDx >= slabMin_ - tolerance_ && absDx <= slabMax_ + tolerance_);
42 }
43
44 KOKKOS_INLINE_FUNCTION
45 bool operator()(const real_t& coord) const
46 {
47 auto dx = coord - center_;
48 auto absDx = std::abs(dx);
49
50 return (absDx >= slabMin_ - tolerance_ && absDx <= slabMax_ + tolerance_);
51 }
52
54 const real_t slabMin,
55 const real_t slabMax,
56 const AXIS axis = AXIS::X,
57 const real_t tolerance = 0_r)
58 : center_(center[to_underlying(axis)]),
59 slabMin_(slabMin),
60 slabMax_(slabMax),
61 axis_(axis),
62 tolerance_(tolerance)
63 {
64 }
65};
66} // namespace util
67} // namespace mrmd
KOKKOS_INLINE_FUNCTION bool operator()(const real_t &x, const real_t &y, const real_t &z) const
Definition IsInSymmetricSlab.hpp:36
KOKKOS_INLINE_FUNCTION bool operator()(const real_t &coord) const
Definition IsInSymmetricSlab.hpp:45
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:53
Utility functions used throughout the library.
Top-level namespace of MRMD.
AXIS
Definition datatypes.hpp:141
@ X
index of the x coordinate in vector views
Definition datatypes.hpp:142
KOKKOS_INLINE_FUNCTION constexpr std::underlying_type_t< Enum > to_underlying(Enum e) noexcept
Definition datatypes.hpp:148
double real_t
Definition datatypes.hpp:99
Kokkos::Array< real_t, 3 > Point3D
Definition datatypes.hpp:100