Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
components.hpp
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
13 #pragma once
14 
15 #include <bitset>
16 
17 namespace serac {
18 
20 enum class Component : size_t
21 {
22  X = 0b001,
23  Y = 0b010,
24  Z = 0b100,
25  ALL = 0b111
26 };
27 
29 class Components {
30  public:
32  Components(Component i) : flags_{size_t(i)} {};
33 
35  bool operator[](size_t i) const { return flags_[i]; };
36 
39 
42  {
43  flags_ |= size_t(i);
44  return *this;
45  };
46 
49 
50  private:
52  std::bitset<3> flags_;
53 };
54 
56 inline Components operator+(Component i, Component j) { return Components(i) + j; };
57 
59 inline Components operator+(Component i, Components c) { return c + i; }
60 
61 } // namespace serac
A set to flag components of a vector field.
Definition: components.hpp:29
Components(Component i)
Constructor.
Definition: components.hpp:32
bool operator[](size_t i) const
Indexing operator to check if a component is flagged.
Definition: components.hpp:35
friend Components operator+(Component i, Component j)
See docstring on function declaration.
Definition: components.hpp:56
Components operator+(Component i)
Flag an additional component using the plus operator.
Definition: components.hpp:41
Accelerator functionality.
Definition: serac.cpp:36
constexpr SERAC_HOST_DEVICE auto operator+(dual< gradient_type > a, double b)
addition of a dual number and a non-dual number
Definition: dual.hpp:59
Component
Type giving vector components meaningful names and restricting inputs to Components class to meaningf...
Definition: components.hpp:21