11 #include "MooseMesh.h"
19 sizeVector(std::vector<Real> v, std::size_t size)
22 return std::vector<Real>(size, v[0]);
32 InputParameters params = validParams<InitialCondition>();
33 params.addClassDescription(
"Specify variable values inside and outside a list of box shaped "
34 "axis-aligned regions defined by pairs of opposing corners");
35 params.addRequiredParam<std::vector<Point>>(
"corners",
"The corner coordinates boxes");
36 params.addRequiredParam<std::vector<Point>>(
37 "opposite_corners",
"The coordinates of the opposite corners of the boxes");
38 params.addRequiredParam<std::vector<Real>>(
"inside",
39 "The value of the variable inside each box "
40 "(one value per box or a single value for "
42 params.addParam<Real>(
"outside", 0.0,
"The value of the variable outside the box");
44 params.addClassDescription(
"Allows setting the initial condition of a value of a field inside "
45 "and outside multiple bounding boxes.");
50 : InitialCondition(parameters),
51 _c1(getParam<std::vector<Point>>(
"corners")),
52 _c2(getParam<std::vector<Point>>(
"opposite_corners")),
54 _dim(_fe_problem.mesh().dimension()),
55 _inside(sizeVector(getParam<std::vector<Real>>(
"inside"), _nbox)),
56 _outside(getParam<Real>(
"outside"))
60 mooseError(
"vector inputs must all be the same size");
68 for (
unsigned int b = 0; b <
_nbox; ++b)
70 if ((
_c1[b](0) <
_c2[b](0) && p(0) >=
_c1[b](0) && p(0) <=
_c2[b](0)) ||
71 (
_c1[b](0) >=
_c2[b](0) && p(0) <=
_c1[b](0) && p(0) >=
_c2[b](0)))
72 if (
_dim <= 1 || (
_c1[b](1) <
_c2[b](1) && p(1) >=
_c1[b](1) && p(1) <=
_c2[b](1)) ||
73 (
_c1[b](1) >=
_c2[b](1) && p(1) <=
_c1[b](1) && p(1) >=
_c2[b](1)))
74 if (
_dim <= 2 || (
_c1[b](2) <
_c2[b](2) && p(2) >=
_c1[b](2) && p(2) <=
_c2[b](2)) ||
75 (
_c1[b](2) >=
_c2[b](2) && p(2) <=
_c1[b](2) && p(2) >=
_c2[b](2)))