https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SmoothMultiBoundingBoxBaseIC.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11#include "MooseMesh.h"
12#include "FEProblemBase.h"
13
16{
18 params.addRequiredParam<Real>("outside", "Outside value");
19 params.addRequiredParam<std::vector<Point>>(
20 "smaller_coordinate_corners",
21 "For 1D, these are the left points; for 2D, these are the bottom left corners; for 3D, these "
22 "are the back bottom left corners. The format is (corner1_x corner1_y corner1_z corner2_x "
23 "corner2_y corner2_z ...)");
24 params.addRequiredParam<std::vector<Point>>(
25 "larger_coordinate_corners",
26 "For 1D, these are the right points; for 2D, these are the top right corners; for 3D, these "
27 "are the front top right corners. The format is (corner1_x corner1_y corner1_z corner2_x "
28 "corner2_y corner2_z ...)");
29 params.addRequiredParam<Real>("int_width", "The value of the interfacial width between boxes");
30 params.addRequiredParam<std::vector<Real>>("inside",
31 "The value of the variable inside each box "
32 "(one value per box or a single value for "
33 "all boxes)");
34 return params;
35}
36
38 : InitialCondition(parameters),
39 _outside(getParam<Real>("outside")),
40 _c1(getParam<std::vector<Point>>("smaller_coordinate_corners")),
41 _c2(getParam<std::vector<Point>>("larger_coordinate_corners")),
42 _nbox(_c1.size()),
43 _int_width(getParam<Real>("int_width")),
44 _dim(_fe_problem.mesh().dimension()),
45 _inside(getParam<std::vector<Real>>("inside"))
46{
47}
48
49Real
51{
52 Real value = _outside;
53
54 // if "inside" vector only has size 1, all the boxes have the same inside value
55 if (_inside.size() == 1)
56 {
57 _inside.assign(_nbox, _inside[0]);
58 }
59
60 // make sure inputs are the same length
61 if (_c2.size() != _nbox || _inside.size() != _nbox)
62 paramError("vector inputs must all be the same size");
63
64 if (_int_width < 0.0)
65 paramError("'int_width' should be non-negative");
66
67 if (_int_width == 0.0)
68 {
69 for (unsigned int b = 0; b < _nbox; ++b)
70 {
71 for (unsigned int i = 0; i < _dim; ++i)
72 if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) && p(i) <= _c2[b](i))
73 {
74 if (i != _dim - 1)
75 continue;
76 value = _inside[b];
77 break;
78 }
79 else
80 break;
81 }
82 }
83 return value;
84}
const Real p
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
const Real _int_width
value of interfacial width
const unsigned int _nbox
number of boxes
const unsigned int _dim
dimensionality of the mesh
SmoothMultiBoundingBoxBaseIC(const InputParameters &parameters)
std::vector< Real > _inside
values inside the boxes
const std::vector< Point > _c1
lists of opposite corners
MeshBase & mesh