https://mooseframework.inl.gov
NestedBoundingBoxIC.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 
10 #include "NestedBoundingBoxIC.h"
11 #include "MooseMesh.h"
12 
14 
17 {
19  params.addClassDescription("Specify variable values inside a list of nested boxes shaped "
20  "axis-aligned regions defined by pairs of opposing corners");
21  params.addParam<Real>("outside", 0.0, "The value of the variable outside the largest boxes");
22  return params;
23 }
24 
26  : SmoothMultiBoundingBoxBaseIC(parameters), _outside(getParam<Real>("outside"))
27 {
28 }
29 
30 Real
32 {
34 
35  if (_int_width != 0.0)
36  {
37  for (unsigned int b = 0; b < _nbox; ++b)
38  {
39  for (unsigned int i = 0; i < _dim; ++i)
40  {
41  if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) - _int_width &&
42  p(i) <= _c2[b](i) + _int_width)
43  {
44  if (i != _dim - 1)
45  continue;
46  Real f_in = 1.0;
47  for (unsigned int j = 0; j < _dim; ++j)
48  f_in *= 0.5 * (std::tanh(2.0 * libMesh::pi * (p(j) - _c1[b](j)) / _int_width) -
49  std::tanh(2.0 * libMesh::pi * (p(j) - _c2[b](j)) / _int_width));
50  if (b == _nbox - 1)
51  value = _outside + (_inside[b] - _outside) * f_in;
52  else
53  value = _inside[b + 1] + (_inside[b] - _inside[b + 1]) * f_in;
54  goto label;
55  }
56  else if (_c1[b](i) >= _c2[b](i))
57  mooseError("The coordinates of the smaller_coordinate_corners are equal to or larger "
58  "than that of "
59  "the larger_coordinate_corners.");
60  else
61  break;
62  }
63  }
64  }
65 label:
66  return value;
67 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const unsigned int _dim
dimensionality of the mesh
registerMooseObject("PhaseFieldApp", NestedBoundingBoxIC)
NestedBoundingBoxIC creates several nested boxes defined by their coordinates in the domain...
std::vector< Real > _inside
values inside the boxes
const unsigned int _nbox
number of boxes
const Real _int_width
value of interfacial width
NestedBoundingBoxIC(const InputParameters &parameters)
const std::vector< Point > _c1
lists of opposite corners
static InputParameters validParams()
SmoothMultiBoundingBoxBaseIC is the base class for IsolatedBoundingBoxIC and NestedBoundingBoxIC.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real value(const Point &p)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const Real _outside
values outside all the boxes
const Real pi