Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
field_types.hpp
Go to the documentation of this file.
1 // Copyright Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
13 #pragma once
14 
17 
18 namespace smith {
19 
21 constexpr int SHAPE_ORDER = 1;
22 
25 
28 
31 
34 
37 
40 
43 template <typename T>
44 auto getFieldPointers(std::vector<std::shared_ptr<T>>& states, std::vector<std::shared_ptr<T>>& params)
45 {
46  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
47  "Type must be either FiniteElementState or FiniteElementDual");
48  std::vector<T*> pointers;
49  for (auto& t : states) {
50  pointers.push_back(t.get());
51  }
52  for (auto& t : params) {
53  pointers.push_back(t.get());
54  }
55  return pointers;
56 }
57 
60 template <typename T>
61 auto getFieldPointers(std::vector<std::shared_ptr<T>>& states)
62 {
63  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
64  "Type must be either FiniteElementState or FiniteElementDual");
65  std::vector<T*> pointers;
66  for (auto& t : states) {
67  pointers.push_back(t.get());
68  }
69  return pointers;
70 }
71 
73 template <typename T>
74 auto getFieldPointers(std::vector<T>& states, std::vector<T>& params)
75 {
76  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
77  "Type must be either FiniteElementState or FiniteElementDual");
78  std::vector<T*> pointers;
79  for (auto& t : states) {
80  pointers.push_back(&t);
81  }
82  for (auto& t : params) {
83  pointers.push_back(&t);
84  }
85  return pointers;
86 }
87 
89 template <typename T>
90 auto getFieldPointers(std::vector<T>& states)
91 {
92  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
93  "Type must be either FiniteElementState or FiniteElementDual");
94  std::vector<T*> pointers;
95  for (auto& t : states) {
96  pointers.push_back(&t);
97  }
98  return pointers;
99 }
100 
103 template <typename T>
104 auto getFieldPointers(std::shared_ptr<T>& state)
105 {
106  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
107  "Type must be either FiniteElementState or FiniteElementDual");
108  return std::vector<T*>{state.get()};
109 }
110 
112 template <typename T>
113 auto getFieldPointers(T& state)
114 {
115  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
116  "Type must be either FiniteElementState or FiniteElementDual");
117  return std::vector<T*>{&state};
118 }
119 
122 template <typename T>
123 auto getConstFieldPointers(const std::vector<std::shared_ptr<T>>& states,
124  const std::vector<std::shared_ptr<T>>& params = {})
125 {
126  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
127  "Type must be either FiniteElementState or FiniteElementDual");
128  std::vector<T const*> pointers;
129  for (auto& t : states) {
130  pointers.push_back(t.get());
131  }
132  for (auto& t : params) {
133  pointers.push_back(t.get());
134  }
135  return pointers;
136 }
137 
140 template <typename T>
141 auto getConstFieldPointers(const std::vector<T*>& states, const std::vector<T*>& params = {})
142 {
143  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
144  "Type must be either FiniteElementState or FiniteElementDual");
145  std::vector<T const*> pointers;
146  for (auto& t : states) {
147  pointers.push_back(t);
148  }
149  for (auto& t : params) {
150  pointers.push_back(t);
151  }
152  return pointers;
153 }
154 
156 template <typename T>
157 auto getConstFieldPointers(const std::vector<T>& states, const std::vector<T>& params = {})
158 {
159  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
160  "Type must be either FiniteElementState or FiniteElementDual");
161  std::vector<T const*> pointers;
162  for (auto& t : states) {
163  pointers.push_back(&t);
164  }
165  for (auto& t : params) {
166  pointers.push_back(&t);
167  }
168  return pointers;
169 }
170 
173 template <typename T>
174 auto getConstFieldPointers(const std::shared_ptr<T>& state)
175 {
176  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
177  "Type must be either FiniteElementState or FiniteElementDual");
178  return std::vector<T const*>{state.get()};
179 }
180 
182 template <typename T>
183 auto getConstFieldPointers(const T& state)
184 {
185  static_assert(std::is_same_v<T, FiniteElementState> || std::is_same_v<T, FiniteElementDual>,
186  "Type must be either FiniteElementState or FiniteElementDual");
187  return std::vector<T const*>{&state};
188 }
189 
190 } // namespace smith
Class for encapsulating the dual vector space of a finite element space (i.e. the space of linear for...
Class for encapsulating the critical MFEM components of a primal finite element field.
This contains a class that represents the dual of a finite element vector space, i....
This file contains the declaration of structure that manages the MFEM objects that make up the state ...
Accelerator functionality.
Definition: smith.cpp:36
constexpr H1< SHAPE_ORDER, 3 > SHAPE_DIM_3
Function space for shape displacement on dimension 2 meshes.
Definition: field_types.hpp:27
constexpr int SHAPE_ORDER
Polynomial order used to discretize the shape displacement field.
Definition: field_types.hpp:21
auto getConstFieldPointers(const std::vector< std::shared_ptr< T >> &states, const std::vector< std::shared_ptr< T >> &params={})
Get a vector of ConstFieldPtr or ConstDualFieldPtr from a vector of shared_pointers to FiniteElementS...
constexpr H1< SHAPE_ORDER, 2 > SHAPE_DIM_2
Function space for shape displacement on dimension 2 meshes.
Definition: field_types.hpp:24
auto getFieldPointers(std::vector< std::shared_ptr< T >> &states, std::vector< std::shared_ptr< T >> &params)
Get a vector of FieldPtr or DualFieldPtr from a vector of shared_pointers to FiniteElementState or Fi...
Definition: field_types.hpp:44
FiniteElementDual const * ConstDualFieldPtr
using
Definition: field_types.hpp:39
FiniteElementState const * ConstFieldPtr
using
Definition: field_types.hpp:36
H1 elements of order p.