Line data Source code
1 : //
2 : // This BC defines boundary conditions that are constant with respect to space.
3 : // However they may change in time using the :ref:`Numeric::Interpolator::Linear` method.
4 : //
5 : // In 2D, BCs are prescribed for each edge (4) and corner (4) on the boundary, for a total of 8 possible regions.
6 : // In 3D, BCs are prescribed for each face (6), each edge (12), and each corner (8), for a total of 26 possible regions.
7 : // Care must be taken to define BCs for edges/corners consistently with the faces/edges, or you will get poor
8 : // convergence and inaccurate behavior.
9 : // (See :ref:`BC::Operator::Elastic::TensionTest` for a reduced BC with streamlined load options.)
10 : //
11 : // To define a boundary condition, you must define both a "type" and a "value" in each direction.
12 : // The type can be "displacement", "disp", "neumann", "traction", "trac".
13 : // The value is the corresponding value.
14 : // All BCs are, by default, dirichlet (displacement) with a value of zero.
15 : //
16 :
17 : #ifndef BC_OPERATOR_ELASTIC_CONSTANT_H
18 : #define BC_OPERATOR_ELASTIC_CONSTANT_H
19 :
20 : // #include "Operator/Elastic.H"
21 : #include "IO/ParmParse.H"
22 : #include "Numeric/Interpolator/Linear.H"
23 : #include "BC/Operator/Elastic/Elastic.H"
24 :
25 : namespace BC
26 : {
27 : namespace Operator
28 : {
29 : namespace Elastic
30 : {
31 : class Constant : public Elastic
32 : {
33 : public:
34 : static constexpr const char* name = "constant";
35 :
36 18 : Constant()
37 18 : {
38 : // By default, all boundary conditions are displacement
39 216 : for (int face = 0; face < m_nfaces; face++)
40 672 : for (int direction = 0; direction < AMREX_SPACEDIM; direction++)
41 : {
42 474 : m_bc_type[face][direction] = Type::Displacement;
43 474 : m_bc_val [face][direction] = 0.0;
44 : }
45 18 : };
46 :
47 10 : Constant(IO::ParmParse &pp, std::string name): Constant()
48 10 : { pp_queryclass(name,*this); }
49 :
50 0 : ~Constant() {};
51 :
52 :
53 : void
54 : Set(const Face face,
55 : const Direction direction,
56 : const Type type,
57 : const Set::Scalar value)
58 : {
59 : m_bc_type[face][direction] = type;
60 : m_bc_val [face][direction] = value;
61 : }
62 :
63 : void
64 : Set(const Face /*face*/,
65 : const Direction /*direction*/,
66 : const Type /*type*/,
67 : const Set::Scalar /*value*/,
68 : amrex::Vector<amrex::MultiFab *> &/*a_rhs*/,
69 : const amrex::Vector<amrex::Geometry> &/*a_geom*/)
70 : {
71 : Util::Abort(INFO,"This has been depricated");
72 : }
73 :
74 : void
75 : Set(const Face face,
76 : const Direction direction,
77 : const Type type,
78 : const Set::Scalar value,
79 : amrex::Vector<amrex::MultiFab> &a_rhs,
80 : const amrex::Vector<amrex::Geometry> &a_geom)
81 : {
82 : amrex::Vector<amrex::MultiFab *> pa_rhs = amrex::GetVecOfPtrs(a_rhs);
83 : Set(face,direction,type,value,pa_rhs,a_geom);
84 : }
85 :
86 : void
87 : Set(const Face face,
88 : const Direction direction,
89 : const Type type,
90 : const Set::Scalar value,
91 : amrex::Vector<std::unique_ptr<amrex::MultiFab> > &a_rhs,
92 : const amrex::Vector<amrex::Geometry> &a_geom)
93 : {
94 : amrex::Vector<amrex::MultiFab *> pa_rhs = amrex::GetVecOfPtrs(a_rhs);
95 : Set(face,direction,type,value,pa_rhs,a_geom);
96 : }
97 :
98 : //using Elastic::Init;
99 :
100 : virtual void
101 470 : Init(amrex::FabArray<amrex::BaseFab<Set::Vector>> *a_rhs,
102 : const amrex::Geometry &a_geom,
103 : bool a_homogeneous = false) const
104 : {
105 470 : amrex::Box domain(a_geom.Domain());
106 940 : domain.convert(amrex::IntVect::TheNodeVector());
107 470 : const amrex::Dim3 lo= amrex::lbound(domain), hi = amrex::ubound(domain);
108 1073 : for (amrex::MFIter mfi(*a_rhs, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
109 : {
110 603 : amrex::Box bx = mfi.tilebox();
111 603 : bx.grow(2);
112 603 : bx = bx & domain;
113 603 : amrex::Array4<Set::Vector> const& rhs = a_rhs->array(mfi);
114 603 : amrex::ParallelFor (bx,[=] AMREX_GPU_DEVICE(int i, int j, int k) {
115 :
116 597537 : for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
117 : {
118 410858 : Face face = Face::INT;
119 :
120 : #if AMREX_SPACEDIM == 2
121 :
122 298358 : if (i==lo.x && j==lo.y) face = Face::XLO_YLO;
123 298090 : else if (i==lo.x && j==hi.y) face = Face::XLO_YHI;
124 297822 : else if (i==hi.x && j==lo.y) face = Face::XHI_YLO;
125 297554 : else if (i==hi.x && j==hi.y) face = Face::XHI_YHI;
126 :
127 297284 : else if (i==lo.x) face = Face::XLO;
128 294928 : else if (i==hi.x) face = Face::XHI;
129 292512 : else if (j==lo.y) face = Face::YLO;
130 290028 : else if (j==hi.y) face = Face::YHI;
131 :
132 : #elif AMREX_SPACEDIM == 3
133 :
134 112500 : if (i==lo.x && j==lo.y && k==lo.z) face = Face::XLO_YLO_ZLO;
135 111600 : else if (i==lo.x && j==lo.y && k==hi.z) face = Face::XLO_YLO_ZHI;
136 110700 : else if (i==lo.x && j==hi.y && k==lo.z) face = Face::XLO_YHI_ZLO;
137 109800 : else if (i==lo.x && j==hi.y && k==hi.z) face = Face::XLO_YHI_ZHI;
138 108900 : else if (i==hi.x && j==lo.y && k==lo.z) face = Face::XHI_YLO_ZLO;
139 108000 : else if (i==hi.x && j==lo.y && k==hi.z) face = Face::XHI_YLO_ZHI;
140 107100 : else if (i==hi.x && j==hi.y && k==lo.z) face = Face::XHI_YHI_ZLO;
141 106200 : else if (i==hi.x && j==hi.y && k==hi.z) face = Face::XHI_YHI_ZHI;
142 :
143 105300 : else if (j==lo.y && k==lo.z) face = Face::YLO_ZLO;
144 102600 : else if (j==lo.y && k==hi.z) face = Face::YLO_ZHI;
145 99900 : else if (j==hi.y && k==lo.z) face = Face::YHI_ZLO;
146 97200 : else if (j==hi.y && k==hi.z) face = Face::YHI_ZHI;
147 94500 : else if (k==lo.z && i==lo.x) face = Face::ZLO_XLO;
148 91800 : else if (k==lo.z && i==hi.x) face = Face::ZLO_XHI;
149 89100 : else if (k==hi.z && i==lo.x) face = Face::ZHI_XLO;
150 86400 : else if (k==hi.z && i==hi.x) face = Face::ZHI_XHI;
151 83700 : else if (i==lo.x && j==lo.y) face = Face::XLO_YLO;
152 81000 : else if (i==lo.x && j==hi.y) face = Face::XLO_YHI;
153 78300 : else if (i==hi.x && j==lo.y) face = Face::XHI_YLO;
154 75600 : else if (i==hi.x && j==hi.y) face = Face::XHI_YHI;
155 :
156 72900 : else if (i==lo.x) face = Face::XLO;
157 64800 : else if (i==hi.x) face = Face::XHI;
158 56700 : else if (j==lo.y) face = Face::YLO;
159 48600 : else if (j==hi.y) face = Face::YHI;
160 40500 : else if (k==lo.z) face = Face::ZLO;
161 32400 : else if (k==hi.z) face = Face::ZHI;
162 :
163 : #endif
164 :
165 410858 : if (!(face == Face::INT))
166 : {
167 99074 : if (a_homogeneous && m_bc_type[face][dir] == Type::Displacement)
168 0 : rhs(i,j,k)(dir) = 0.0;
169 : else
170 198148 : rhs(i,j,k)(dir) = m_bc_val[face][dir](m_time);
171 : }
172 : }
173 186679 : });
174 : }
175 470 : }
176 :
177 : using Elastic::Init;
178 : virtual void
179 0 : Init(amrex::MultiFab * a_rhs,
180 : const amrex::Geometry &a_geom,
181 : bool a_homogeneous = false) const
182 : {
183 0 : amrex::Box domain(a_geom.Domain());
184 0 : domain.convert(amrex::IntVect::TheNodeVector());
185 0 : const amrex::Dim3 lo= amrex::lbound(domain), hi = amrex::ubound(domain);
186 0 : for (amrex::MFIter mfi(*a_rhs, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
187 : {
188 0 : amrex::Box bx = mfi.tilebox();
189 0 : bx.grow(2);
190 0 : bx = bx & domain;
191 0 : amrex::Array4<amrex::Real> const& rhs = a_rhs->array(mfi);
192 0 : amrex::ParallelFor (bx,[=] AMREX_GPU_DEVICE(int i, int j, int k) {
193 :
194 0 : for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
195 : {
196 0 : Face face = Face::INT;
197 :
198 : #if AMREX_SPACEDIM == 2
199 :
200 0 : if (i==lo.x && j==lo.y) face = Face::XLO_YLO;
201 0 : else if (i==lo.x && j==hi.y) face = Face::XLO_YHI;
202 0 : else if (i==hi.x && j==lo.y) face = Face::XHI_YLO;
203 0 : else if (i==hi.x && j==hi.y) face = Face::XHI_YHI;
204 :
205 0 : else if (i==lo.x) face = Face::XLO;
206 0 : else if (i==hi.x) face = Face::XHI;
207 0 : else if (j==lo.y) face = Face::YLO;
208 0 : else if (j==hi.y) face = Face::YHI;
209 :
210 : #elif AMREX_SPACEDIM == 3
211 :
212 0 : if (i==lo.x && j==lo.y && k==lo.z) face = Face::XLO_YLO_ZLO;
213 0 : else if (i==lo.x && j==lo.y && k==hi.z) face = Face::XLO_YLO_ZHI;
214 0 : else if (i==lo.x && j==hi.y && k==lo.z) face = Face::XLO_YHI_ZLO;
215 0 : else if (i==lo.x && j==hi.y && k==hi.z) face = Face::XLO_YHI_ZHI;
216 0 : else if (i==hi.x && j==lo.y && k==lo.z) face = Face::XHI_YLO_ZLO;
217 0 : else if (i==hi.x && j==lo.y && k==hi.z) face = Face::XHI_YLO_ZHI;
218 0 : else if (i==hi.x && j==hi.y && k==lo.z) face = Face::XHI_YHI_ZLO;
219 0 : else if (i==hi.x && j==hi.y && k==hi.z) face = Face::XHI_YHI_ZHI;
220 :
221 0 : else if (j==lo.y && k==lo.z) face = Face::YLO_ZLO;
222 0 : else if (j==lo.y && k==hi.z) face = Face::YLO_ZHI;
223 0 : else if (j==hi.y && k==lo.z) face = Face::YHI_ZLO;
224 0 : else if (j==hi.y && k==hi.z) face = Face::YHI_ZHI;
225 0 : else if (k==lo.z && i==lo.x) face = Face::ZLO_XLO;
226 0 : else if (k==lo.z && i==hi.x) face = Face::ZLO_XHI;
227 0 : else if (k==hi.z && i==lo.x) face = Face::ZHI_XLO;
228 0 : else if (k==hi.z && i==hi.x) face = Face::ZHI_XHI;
229 0 : else if (i==lo.x && j==lo.y) face = Face::XLO_YLO;
230 0 : else if (i==lo.x && j==hi.y) face = Face::XLO_YHI;
231 0 : else if (i==hi.x && j==lo.y) face = Face::XHI_YLO;
232 0 : else if (i==hi.x && j==hi.y) face = Face::XHI_YHI;
233 :
234 0 : else if (i==lo.x) face = Face::XLO;
235 0 : else if (i==hi.x) face = Face::XHI;
236 0 : else if (j==lo.y) face = Face::YLO;
237 0 : else if (j==hi.y) face = Face::YHI;
238 0 : else if (k==lo.z) face = Face::ZLO;
239 0 : else if (k==hi.z) face = Face::ZHI;
240 :
241 : #endif
242 :
243 0 : if (!(face == Face::INT))
244 : {
245 0 : if (a_homogeneous && m_bc_type[face][dir] == Type::Displacement)
246 0 : rhs(i,j,k,dir) = 0.0;
247 : else
248 0 : rhs(i,j,k,dir) = m_bc_val[face][dir](m_time);
249 : }
250 : }
251 0 : });
252 : }
253 0 : }
254 :
255 : virtual
256 0 : std::array<Type,AMREX_SPACEDIM> getType (
257 : const int &i, const int &j, [[maybe_unused]] const int &k,
258 : const amrex::Box &domain)
259 : {
260 0 : amrex::IntVect m(AMREX_D_DECL(i,j,k));
261 : const amrex::Dim3 lo = amrex::lbound(domain), hi = amrex::ubound(domain);
262 :
263 : // Corners
264 : #if AMREX_SPACEDIM == 2
265 0 : if (m[0] == lo.x && m[1] == lo.y) return m_bc_type[Face::XLO_YLO];
266 0 : if (m[0] == lo.x && m[1] == hi.y) return m_bc_type[Face::XLO_YHI];
267 0 : if (m[0] == hi.x && m[1] == lo.y) return m_bc_type[Face::XHI_YLO];
268 0 : if (m[0] == hi.x && m[1] == hi.y) return m_bc_type[Face::XHI_YHI];
269 0 : if (m[0] == lo.x) return m_bc_type[Face::XLO];
270 0 : if (m[0] == hi.x) return m_bc_type[Face::XHI];
271 0 : if (m[1] == lo.y) return m_bc_type[Face::YLO];
272 0 : if (m[1] == hi.y) return m_bc_type[Face::YHI];
273 :
274 : #elif AMREX_SPACEDIM == 3
275 :
276 0 : if (m[0] == lo.x && m[1] == lo.y && m[2] == lo.z) return m_bc_type[Face::XLO_YLO_ZLO];
277 0 : if (m[0] == lo.x && m[1] == lo.y && m[2] == hi.z) return m_bc_type[Face::XLO_YLO_ZHI];
278 0 : if (m[0] == lo.x && m[1] == hi.y && m[2] == lo.z) return m_bc_type[Face::XLO_YHI_ZLO];
279 0 : if (m[0] == lo.x && m[1] == hi.y && m[2] == hi.z) return m_bc_type[Face::XLO_YHI_ZHI];
280 0 : if (m[0] == hi.x && m[1] == lo.y && m[2] == lo.z) return m_bc_type[Face::XHI_YLO_ZLO];
281 0 : if (m[0] == hi.x && m[1] == lo.y && m[2] == hi.z) return m_bc_type[Face::XHI_YLO_ZHI];
282 0 : if (m[0] == hi.x && m[1] == hi.y && m[2] == lo.z) return m_bc_type[Face::XHI_YHI_ZLO];
283 0 : if (m[0] == hi.x && m[1] == hi.y && m[2] == hi.z) return m_bc_type[Face::XHI_YHI_ZHI];
284 :
285 0 : if (m[1] == lo.y && m[2] == lo.z) return m_bc_type[Face::YLO_ZLO];
286 0 : if (m[1] == lo.y && m[2] == hi.z) return m_bc_type[Face::YLO_ZHI];
287 0 : if (m[1] == hi.y && m[2] == lo.z) return m_bc_type[Face::YHI_ZLO];
288 0 : if (m[1] == hi.y && m[2] == hi.z) return m_bc_type[Face::YHI_ZHI];
289 0 : if (m[2] == lo.z && m[0] == lo.x) return m_bc_type[Face::ZLO_XLO];
290 0 : if (m[2] == lo.z && m[0] == hi.x) return m_bc_type[Face::ZLO_XHI];
291 0 : if (m[2] == hi.z && m[0] == lo.x) return m_bc_type[Face::ZHI_XLO];
292 0 : if (m[2] == hi.z && m[0] == hi.x) return m_bc_type[Face::ZHI_XHI];
293 0 : if (m[0] == lo.x && m[1] == lo.y) return m_bc_type[Face::XLO_YLO];
294 0 : if (m[0] == lo.x && m[1] == hi.y) return m_bc_type[Face::XLO_YHI];
295 0 : if (m[0] == hi.x && m[1] == lo.y) return m_bc_type[Face::XHI_YLO];
296 0 : if (m[0] == hi.x && m[1] == hi.y) return m_bc_type[Face::XHI_YHI];
297 :
298 0 : if (m[0] == lo.x) return m_bc_type[Face::XLO];
299 0 : if (m[0] == hi.x) return m_bc_type[Face::XHI];
300 0 : if (m[1] == lo.y) return m_bc_type[Face::YLO];
301 0 : if (m[1] == hi.y) return m_bc_type[Face::YHI];
302 0 : if (m[2] == lo.z) return m_bc_type[Face::ZLO];
303 0 : if (m[2] == hi.z) return m_bc_type[Face::ZHI];
304 :
305 : #endif
306 :
307 0 : return {AMREX_D_DECL(Type::None,Type::None,Type::None)};
308 : }
309 :
310 :
311 : AMREX_FORCE_INLINE
312 11831360 : Set::Vector operator () (const Set::Vector &u,
313 : const Set::Matrix &gradu,
314 : const Set::Matrix &sigma,
315 : const int &i, const int &j, const int &k,
316 : const amrex::Box &domain)
317 : {
318 : (void)i; (void)j; (void)k; // Suppress "unused variable" warnings
319 : //Set::Vector f;
320 :
321 : const amrex::Dim3 lo= amrex::lbound(domain), hi = amrex::ubound(domain);
322 :
323 11831360 : amrex::IntVect m(AMREX_D_DECL(i,j,k));
324 :
325 : // Corners
326 : #if AMREX_SPACEDIM == 2
327 :
328 3214870 : if (m[0] == lo.x && m[1] == lo.y) return set(m_bc_type[Face::XLO_YLO], u, gradu, sigma, Set::Vector(-SQRT2INV, -SQRT2INV));
329 2854280 : if (m[0] == lo.x && m[1] == hi.y) return set(m_bc_type[Face::XLO_YHI], u, gradu, sigma, Set::Vector(-SQRT2INV, +SQRT2INV));
330 2854310 : if (m[0] == hi.x && m[1] == lo.y) return set(m_bc_type[Face::XHI_YLO], u, gradu, sigma, Set::Vector(+SQRT2INV, -SQRT2INV));
331 2493720 : if (m[0] == hi.x && m[1] == hi.y) return set(m_bc_type[Face::XHI_YHI], u, gradu, sigma, Set::Vector(+SQRT2INV, +SQRT2INV));
332 :
333 1952810 : if (m[0] == lo.x) return set(m_bc_type[Face::XLO], u, gradu, sigma, Set::Vector(-1, 0));
334 1572800 : if (m[0] == hi.x) return set(m_bc_type[Face::XHI], u, gradu, sigma, Set::Vector(+1, 0));
335 1218980 : if (m[1] == lo.y) return set(m_bc_type[Face::YLO], u, gradu, sigma, Set::Vector( 0,-1));
336 812694 : if (m[1] == hi.y) return set(m_bc_type[Face::YHI], u, gradu, sigma, Set::Vector( 0,+1));
337 :
338 : #elif AMREX_SPACEDIM == 3
339 :
340 13248800 : if (m[0] == lo.x && m[1] == lo.y && m[2] == lo.z) return set(m_bc_type[Face::XLO_YLO_ZLO], u, gradu, sigma, Set::Vector(-SQRT3INV,-SQRT3INV,-SQRT3INV));
341 12636300 : if (m[0] == lo.x && m[1] == lo.y && m[2] == hi.z) return set(m_bc_type[Face::XLO_YLO_ZHI], u, gradu, sigma, Set::Vector(-SQRT3INV,-SQRT3INV,+SQRT3INV));
342 12432200 : if (m[0] == lo.x && m[1] == hi.y && m[2] == lo.z) return set(m_bc_type[Face::XLO_YHI_ZLO], u, gradu, sigma, Set::Vector(-SQRT3INV,+SQRT3INV,-SQRT3INV));
343 11819700 : if (m[0] == lo.x && m[1] == hi.y && m[2] == hi.z) return set(m_bc_type[Face::XLO_YHI_ZHI], u, gradu, sigma, Set::Vector(-SQRT3INV,+SQRT3INV,+SQRT3INV));
344 12432200 : if (m[0] == hi.x && m[1] == lo.y && m[2] == lo.z) return set(m_bc_type[Face::XHI_YLO_ZLO], u, gradu, sigma, Set::Vector(+SQRT3INV,-SQRT3INV,-SQRT3INV));
345 11819700 : if (m[0] == hi.x && m[1] == lo.y && m[2] == hi.z) return set(m_bc_type[Face::XHI_YLO_ZHI], u, gradu, sigma, Set::Vector(+SQRT3INV,-SQRT3INV,+SQRT3INV));
346 11615500 : if (m[0] == hi.x && m[1] == hi.y && m[2] == lo.z) return set(m_bc_type[Face::XHI_YHI_ZLO], u, gradu, sigma, Set::Vector(+SQRT3INV,+SQRT3INV,-SQRT3INV));
347 11003100 : if (m[0] == hi.x && m[1] == hi.y && m[2] == hi.z) return set(m_bc_type[Face::XHI_YHI_ZHI], u, gradu, sigma, Set::Vector(+SQRT3INV,+SQRT3INV,+SQRT3INV));
348 :
349 10186400 : if (m[1] == lo.y && m[2] == lo.z) return set(m_bc_type[Face::YLO_ZLO], u, gradu, sigma, Set::Vector(0, -SQRT2INV,-SQRT2INV));
350 9543140 : if (m[1] == lo.y && m[2] == hi.z) return set(m_bc_type[Face::YLO_ZHI], u, gradu, sigma, Set::Vector(0, -SQRT2INV,+SQRT2INV));
351 9543140 : if (m[1] == hi.y && m[2] == lo.z) return set(m_bc_type[Face::YHI_ZLO], u, gradu, sigma, Set::Vector(0, +SQRT2INV,-SQRT2INV));
352 8899860 : if (m[1] == hi.y && m[2] == hi.z) return set(m_bc_type[Face::YHI_ZHI], u, gradu, sigma, Set::Vector(0, +SQRT2INV,+SQRT2INV));
353 8256580 : if (m[2] == lo.z && m[0] == lo.x) return set(m_bc_type[Face::ZLO_XLO], u, gradu, sigma, Set::Vector(-SQRT2INV, 0, -SQRT2INV));
354 7613300 : if (m[2] == lo.z && m[0] == hi.x) return set(m_bc_type[Face::ZLO_XHI], u, gradu, sigma, Set::Vector(+SQRT2INV, 0, -SQRT2INV));
355 7613300 : if (m[2] == hi.z && m[0] == lo.x) return set(m_bc_type[Face::ZHI_XLO], u, gradu, sigma, Set::Vector(-SQRT2INV, 0, +SQRT2INV));
356 6970030 : if (m[2] == hi.z && m[0] == hi.x) return set(m_bc_type[Face::ZHI_XHI], u, gradu, sigma, Set::Vector(+SQRT2INV, 0, +SQRT2INV));
357 6970030 : if (m[0] == lo.x && m[1] == lo.y) return set(m_bc_type[Face::XLO_YLO], u, gradu, sigma, Set::Vector(-SQRT2INV, -SQRT2INV,0 ));
358 6326750 : if (m[0] == lo.x && m[1] == hi.y) return set(m_bc_type[Face::XLO_YHI], u, gradu, sigma, Set::Vector(-SQRT2INV, +SQRT2INV,0 ));
359 6326750 : if (m[0] == hi.x && m[1] == lo.y) return set(m_bc_type[Face::XHI_YLO], u, gradu, sigma, Set::Vector(+SQRT2INV, -SQRT2INV,0 ));
360 5683470 : if (m[0] == hi.x && m[1] == hi.y) return set(m_bc_type[Face::XHI_YHI], u, gradu, sigma, Set::Vector(+SQRT2INV, +SQRT2INV,0 ));
361 :
362 4718550 : if (m[0] == lo.x) return set(m_bc_type[Face::XLO], u, gradu, sigma, Set::Vector(-1, 0, 0));
363 4044470 : if (m[0] == hi.x) return set(m_bc_type[Face::XHI], u, gradu, sigma, Set::Vector(+1, 0, 0));
364 3370400 : if (m[1] == lo.y) return set(m_bc_type[Face::YLO], u, gradu, sigma, Set::Vector( 0,-1, 0));
365 2696320 : if (m[1] == hi.y) return set(m_bc_type[Face::YHI], u, gradu, sigma, Set::Vector( 0,+1, 0));
366 2022240 : if (m[2] == lo.z) return set(m_bc_type[Face::ZLO], u, gradu, sigma, Set::Vector( 0, 0,-1));
367 1348160 : if (m[2] == hi.z) return set(m_bc_type[Face::ZHI], u, gradu, sigma, Set::Vector( 0, 0,+1));
368 :
369 : #endif
370 :
371 0 : Util::Abort(INFO,"Boundary condition error");
372 0 : return Set::Vector::Zero();
373 : }
374 :
375 : AMREX_FORCE_INLINE
376 : Set::Vector set(std::array<Type,AMREX_SPACEDIM> &bc_type,
377 : const Set::Vector &u, const Set::Matrix &gradu, const Set::Matrix &sigma, Set::Vector n) const
378 : {
379 11831360 : Set::Vector f = Set::Vector::Zero();
380 45031550 : for (int i = 0; i < AMREX_SPACEDIM; i++)
381 : {
382 33200100 : if (bc_type[i] == Type::Displacement)
383 13554260 : f(i) = u(i);
384 19645940 : else if (bc_type[i] == Type::Traction)
385 19645940 : f(i) = (sigma*n)(i);
386 0 : else if (bc_type[i] == Type::Neumann)
387 0 : f(i) = (gradu*n)(i);
388 0 : else if (bc_type[i] == Periodic)
389 0 : continue;
390 : }
391 11831360 : return f;
392 : }
393 :
394 : protected:
395 :
396 : #if AMREX_SPACEDIM==2
397 : static const int m_nfaces = 8;
398 : #elif AMREX_SPACEDIM==3
399 : static const int m_nfaces = 26;
400 : #endif
401 :
402 : std::array<std::array<Type, AMREX_SPACEDIM>, m_nfaces> m_bc_type;
403 : std::array<std::array<Numeric::Interpolator::Linear<Set::Scalar>,AMREX_SPACEDIM>, m_nfaces> m_bc_val;
404 :
405 : public:
406 10 : static void Parse(Constant & value, IO::ParmParse & pp)
407 : {
408 20 : std::map<std::string, Type> bcmap;
409 10 : bcmap["displacement"] = Type::Displacement;
410 10 : bcmap["disp"] = Type::Displacement;
411 10 : bcmap["neumann"] = Type::Neumann;
412 10 : bcmap["traction"] = Type::Traction;
413 10 : bcmap["trac"] = Type::Traction;
414 10 : bcmap["periodic"] = Type::Periodic;
415 :
416 20 : std::vector<std::string> str;
417 :
418 : // TYPES
419 :
420 : #if AMREX_SPACEDIM==3
421 0 : if (pp.contains("type.xloylozlo")) {
422 0 : pp_queryarr("type.xloylozlo",str); // 3D Corner
423 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XLO_YLO_ZLO][i] = bcmap[str[i]]; }
424 0 : if (pp.contains("type.xloylozhi")) {
425 0 : pp_queryarr("type.xloylozhi",str); // 3D Corner
426 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XLO_YLO_ZHI][i] = bcmap[str[i]]; }
427 0 : if (pp.contains("type.xloyhizlo")) {
428 0 : pp_queryarr("type.xloyhizlo",str); // 3D Corner
429 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XLO_YHI_ZLO][i] = bcmap[str[i]]; }
430 0 : if (pp.contains("type.xloyhizhi")) {
431 0 : pp_queryarr("type.xloyhizhi",str); // 3D Corner
432 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XLO_YHI_ZHI][i] = bcmap[str[i]]; }
433 0 : if (pp.contains("type.xhiylozlo")) {
434 0 : pp_queryarr("type.xhiylozlo",str); // 3D Corner
435 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XHI_YLO_ZLO][i] = bcmap[str[i]]; }
436 0 : if (pp.contains("type.xhiylozhi")) {
437 0 : pp_queryarr("type.xhiylozhi",str); // 3D Corner
438 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XHI_YLO_ZHI][i] = bcmap[str[i]]; }
439 0 : if (pp.contains("type.xhiyhizlo")) {
440 0 : pp_queryarr("type.xhiyhizlo",str); // 3D Corner
441 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XHI_YHI_ZLO][i] = bcmap[str[i]]; }
442 0 : if (pp.contains("type.xhiyhizhi")) {
443 0 : pp_queryarr("type.xhiyhizhi",str); // 3D Corner
444 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XHI_YHI_ZHI][i] = bcmap[str[i]]; }
445 : #else // ignore unused inputs
446 10 : pp.ignore("type.xloylozlo"); pp.ignore("type.xloylozhi"); pp.ignore("type.xloyhizlo"); pp.ignore("type.xloyhizhi");
447 10 : pp.ignore("type.xhiylozlo"); pp.ignore("type.xhiylozhi"); pp.ignore("type.xhiyhizlo"); pp.ignore("type.xhiyhizhi");
448 : #endif
449 :
450 : #if AMREX_SPACEDIM==3
451 0 : if (pp.contains("type.ylozlo")) {
452 0 : pp_queryarr("type.ylozlo",str); // 3D Edge
453 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::YLO_ZLO][i] = bcmap[str[i]]; }
454 0 : if (pp.contains("type.ylozhi")) {
455 0 : pp_queryarr("type.ylozhi",str); // 3D Edge
456 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::YLO_ZHI][i] = bcmap[str[i]]; }
457 0 : if (pp.contains("type.yhizlo")) {
458 0 : pp_queryarr("type.yhizlo",str); // 3D Edge
459 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::YHI_ZLO][i] = bcmap[str[i]]; }
460 0 : if (pp.contains("type.yhizhi")) {
461 0 : pp_queryarr("type.yhizhi",str); // 3D Edge
462 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::YHI_ZHI][i] = bcmap[str[i]]; }
463 0 : if (pp.contains("type.zloxlo")) {
464 0 : pp_queryarr("type.zloxlo",str); // 3D Edge
465 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::ZLO_XLO][i] = bcmap[str[i]]; }
466 0 : if (pp.contains("type.zloxhi")) {
467 0 : pp_queryarr("type.zloxhi",str); // 3D Edge
468 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::ZLO_XHI][i] = bcmap[str[i]]; }
469 0 : if (pp.contains("type.zhixlo")) {
470 0 : pp_queryarr("type.zhixlo",str); // 3D Edge
471 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::ZHI_XLO][i] = bcmap[str[i]]; }
472 0 : if (pp.contains("type.zhixhi")) {
473 0 : pp_queryarr("type.zhixhi",str); // 3D Edge
474 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::ZHI_XHI][i] = bcmap[str[i]]; }
475 : #else
476 10 : pp.ignore("type.ylozlo"); pp.ignore("type.ylozhi"); pp.ignore("type.yhizlo"); pp.ignore("type.yhizhi");
477 10 : pp.ignore("type.zloxlo"); pp.ignore("type.zloxhi"); pp.ignore("type.zhixlo"); pp.ignore("type.zhixhi");
478 : #endif
479 :
480 10 : if (pp.contains("type.xloylo")) {
481 4 : pp_queryarr("type.xloylo",str); // 3D Edge / 2D Corner
482 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XLO_YLO][i] = bcmap[str[i]]; }
483 10 : if (pp.contains("type.xloyhi")) {
484 4 : pp_queryarr("type.xloyhi",str); // 3D Edge / 2D Corner
485 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XLO_YHI][i] = bcmap[str[i]]; }
486 10 : if (pp.contains("type.xhiylo")) {
487 4 : pp_queryarr("type.xhiylo",str); // 3D Edge / 2D Corner
488 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XHI_YLO][i] = bcmap[str[i]]; }
489 10 : if (pp.contains("type.xhiyhi")) {
490 4 : pp_queryarr("type.xhiyhi",str); // 3D Edge / 2D Corner
491 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XHI_YHI][i] = bcmap[str[i]]; }
492 :
493 10 : if (pp.contains("type.xlo")) {
494 4 : pp_queryarr("type.xlo",str); // 3D Face / 2D Edge
495 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XLO][i] = bcmap[str[i]]; }
496 10 : if (pp.contains("type.xhi")) {
497 4 : pp_queryarr("type.xhi",str); // 3D Face / 2D Edge
498 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::XHI][i] = bcmap[str[i]]; }
499 10 : if (pp.contains("type.ylo")) {
500 4 : pp_queryarr("type.ylo",str); // 3D Face / 2D Edge
501 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::YLO][i] = bcmap[str[i]]; }
502 10 : if (pp.contains("type.yhi")) {
503 4 : pp_queryarr("type.yhi",str); // 3D Face / 2D Edge
504 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::YHI][i] = bcmap[str[i]]; }
505 : #if AMREX_SPACEDIM==3
506 0 : if (pp.contains("type.zlo")) {
507 0 : pp_queryarr("type.zlo",str); // 3D Face
508 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::ZLO][i] = bcmap[str[i]]; }
509 0 : if (pp.contains("type.zhi")) {
510 0 : pp_queryarr("type.zhi",str); // 3D Face
511 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_type[Face::ZHI][i] = bcmap[str[i]]; }
512 : #else
513 10 : pp.ignore("type.zlo"); pp.ignore("type.zhi");
514 : #endif
515 :
516 : // VALS
517 : //std::vector<Set::Scalar> val;
518 10 : std::vector<std::string> val;
519 :
520 : #if AMREX_SPACEDIM==3
521 0 : if (pp.contains("val.xloylozlo")) {
522 0 : pp_queryarr("val.xloylozlo",val); // 3D Corner
523 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XLO_YLO_ZLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
524 0 : if (pp.contains("val.xloylozhi")) {
525 0 : pp_queryarr("val.xloylozhi",val); // 3D Corner
526 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XLO_YLO_ZHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
527 0 : if (pp.contains("val.xloyhizlo")) {
528 0 : pp_queryarr("val.xloyhizlo",val); // 3D Corner
529 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XLO_YHI_ZLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
530 0 : if (pp.contains("val.xloyhizhi")) {
531 0 : pp_queryarr("val.xloyhizhi",val); // 3D Corner
532 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XLO_YHI_ZHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
533 0 : if (pp.contains("val.xhiylozlo")) {
534 0 : pp_queryarr("val.xhiylozlo",val); // 3D Corner
535 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XHI_YLO_ZLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
536 0 : if (pp.contains("val.xhiylozhi")) {
537 0 : pp_queryarr("val.xhiylozhi",val); // 3D Corner
538 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XHI_YLO_ZHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
539 0 : if (pp.contains("val.xhiyhizlo")) {
540 0 : pp_queryarr("val.xhiyhizlo",val); // 3D Corner
541 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XHI_YHI_ZLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
542 0 : if (pp.contains("val.xhiyhizhi")) {
543 0 : pp_queryarr("val.xhiyhizhi",val); // 3D Corner
544 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XHI_YHI_ZHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
545 : #else
546 10 : pp.ignore("val.xloylozlo"); pp.ignore("val.xloylozhi"); pp.ignore("val.xloyhizlo"); pp.ignore("val.xloyhizhi");
547 10 : pp.ignore("val.xhiylozlo"); pp.ignore("val.xhiylozhi"); pp.ignore("val.xhiyhizlo"); pp.ignore("val.xhiyhizhi");
548 : #endif
549 :
550 : #if AMREX_SPACEDIM==3
551 0 : if (pp.contains("val.ylozlo")) {
552 0 : pp_queryarr("val.ylozlo",val); // 3D Edge
553 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::YLO_ZLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
554 0 : if (pp.contains("val.ylozhi")) {
555 0 : pp_queryarr("val.ylozhi",val); // 3D Edge
556 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::YLO_ZHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
557 0 : if (pp.contains("val.yhizlo")) {
558 0 : pp_queryarr("val.yhizlo",val); // 3D Edge
559 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::YHI_ZLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
560 0 : if (pp.contains("val.yhizhi")) {
561 0 : pp_queryarr("val.yhizhi",val); // 3D Edge
562 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::YHI_ZHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
563 0 : if (pp.contains("val.zloxlo")) {
564 0 : pp_queryarr("val.zloxlo",val); // 3D Edge
565 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::ZLO_XLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
566 0 : if (pp.contains("val.zloxhi")) {
567 0 : pp_queryarr("val.zloxhi",val); // 3D Edge
568 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::ZLO_XHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
569 0 : if (pp.contains("val.zhixlo")) {
570 0 : pp_queryarr("val.zhixlo",val); // 3D Edge
571 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::ZHI_XLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
572 0 : if (pp.contains("val.zhixhi")) {
573 0 : pp_queryarr("val.zhixhi",val); // 3D Edge
574 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::ZHI_XHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
575 : #else
576 10 : pp.ignore("val.ylozlo"); pp.ignore("val.ylozhi"); pp.ignore("val.yhizlo"); pp.ignore("val.yhizhi");
577 10 : pp.ignore("val.zloxlo"); pp.ignore("val.zloxhi"); pp.ignore("val.zhixlo"); pp.ignore("val.zhixhi");
578 : #endif
579 10 : if (pp.contains("val.xloylo")) {
580 0 : pp_queryarr("val.xloylo",val); // 3D Edge / 2D Corner
581 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XLO_YLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
582 10 : if (pp.contains("val.xloyhi")) {
583 0 : pp_queryarr("val.xloyhi",val); // 3D Edge / 2D Corner
584 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XLO_YHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
585 10 : if (pp.contains("val.xhiylo")) {
586 3 : pp_queryarr("val.xhiylo",val); // 3D Edge / 2D Corner
587 9 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XHI_YLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
588 10 : if (pp.contains("val.xhiyhi")) {
589 3 : pp_queryarr("val.xhiyhi",val); // 3D Edge / 2D Corner
590 9 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XHI_YHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
591 :
592 10 : if (pp.contains("val.xlo")) {
593 0 : pp_queryarr("val.xlo",val); // 3D Face / 2D Edge
594 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
595 10 : if (pp.contains("val.xhi")) {
596 4 : pp_queryarr("val.xhi",val); // 3D Face / 2D Edge
597 12 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::XHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
598 10 : if (pp.contains("val.ylo")) {
599 0 : pp_queryarr("val.ylo",val); // 3D Face / 2D Edge
600 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::YLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
601 10 : if (pp.contains("val.yhi")) {
602 0 : pp_queryarr("val.yhi",val); // 3D Face / 2D Edge
603 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::YHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
604 : #if AMREX_SPACEDIM==3
605 0 : if (pp.contains("val.zlo")) {
606 0 : pp_queryarr("val.zlo",val); // 3D Face
607 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::ZLO][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
608 0 : if (pp.contains("val.zhi")) {
609 0 : pp_queryarr("val.zhi",val); // 3D Face
610 0 : for (int i = 0; i < AMREX_SPACEDIM; i++) value.m_bc_val[Face::ZHI][i] = Numeric::Interpolator::Linear<Set::Scalar>(val[i]); }
611 : #else
612 10 : pp.ignore("val.zlo"); pp.ignore("val.zhi");
613 : #endif
614 :
615 10 : }
616 : };
617 : }
618 : }
619 : }
620 : #endif
|