www.mooseframework.org
NestedBoundingBoxIC.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<SmoothMultiBoundingBoxBaseIC>();
20  params.addClassDescription("Specify variable values inside a list of nested boxes shaped "
21  "axis-aligned regions defined by pairs of opposing corners");
22  params.addParam<Real>("outside", 0.0, "The value of the variable outside the largest boxes");
23  return params;
24 }
25 
26 NestedBoundingBoxIC::NestedBoundingBoxIC(const InputParameters & parameters)
27  : SmoothMultiBoundingBoxBaseIC(parameters), _outside(getParam<Real>("outside"))
28 {
29 }
30 
31 Real
33 {
35 
36  if (_int_width != 0.0)
37  {
38  for (unsigned int b = 0; b < _nbox; ++b)
39  {
40  for (unsigned int i = 0; i < _dim; ++i)
41  {
42  if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) - _int_width &&
43  p(i) <= _c2[b](i) + _int_width)
44  {
45  if (i != _dim - 1)
46  continue;
47  Real f_in = 1.0;
48  for (unsigned int j = 0; j < _dim; ++j)
49  f_in *= 0.5 * (std::tanh(2.0 * libMesh::pi * (p(j) - _c1[b](j)) / _int_width) -
50  std::tanh(2.0 * libMesh::pi * (p(j) - _c2[b](j)) / _int_width));
51  if (b == _nbox - 1)
52  value = _outside + (_inside[b] - _outside) * f_in;
53  else
54  value = _inside[b + 1] + (_inside[b] - _inside[b + 1]) * f_in;
55  goto label;
56  }
57  else if (_c1[b](i) >= _c2[b](i))
58  mooseError("The coordinates of the smaller_coordinate_corners are equal to or larger "
59  "than that of "
60  "the larger_coordinate_corners.");
61  else
62  break;
63  }
64  }
65  }
66 label:
67  return value;
68 }
NestedBoundingBoxIC::value
Real value(const Point &p)
Definition: NestedBoundingBoxIC.C:32
SmoothMultiBoundingBoxBaseIC::value
Real value(const Point &p)
Definition: SmoothMultiBoundingBoxBaseIC.C:50
SmoothMultiBoundingBoxBaseIC::_c1
const std::vector< Point > _c1
lists of opposite corners
Definition: SmoothMultiBoundingBoxBaseIC.h:36
validParams< SmoothMultiBoundingBoxBaseIC >
InputParameters validParams< SmoothMultiBoundingBoxBaseIC >()
Definition: SmoothMultiBoundingBoxBaseIC.C:15
SmoothMultiBoundingBoxBaseIC::_dim
const unsigned int _dim
dimensionality of the mesh
Definition: SmoothMultiBoundingBoxBaseIC.h:47
registerMooseObject
registerMooseObject("PhaseFieldApp", NestedBoundingBoxIC)
NestedBoundingBoxIC::NestedBoundingBoxIC
NestedBoundingBoxIC(const InputParameters &parameters)
Definition: NestedBoundingBoxIC.C:26
NestedBoundingBoxIC.h
SmoothMultiBoundingBoxBaseIC::_inside
std::vector< Real > _inside
values inside the boxes
Definition: SmoothMultiBoundingBoxBaseIC.h:50
NestedBoundingBoxIC
NestedBoundingBoxIC creates several nested boxes defined by their coordinates in the domain.
Definition: NestedBoundingBoxIC.h:25
SmoothMultiBoundingBoxBaseIC::_int_width
const Real _int_width
value of interfacial width
Definition: SmoothMultiBoundingBoxBaseIC.h:44
SmoothMultiBoundingBoxBaseIC::_nbox
const unsigned int _nbox
number of boxes
Definition: SmoothMultiBoundingBoxBaseIC.h:41
validParams< NestedBoundingBoxIC >
InputParameters validParams< NestedBoundingBoxIC >()
Definition: NestedBoundingBoxIC.C:17
SmoothMultiBoundingBoxBaseIC
SmoothMultiBoundingBoxBaseIC is the base class for IsolatedBoundingBoxIC and NestedBoundingBoxIC.
Definition: SmoothMultiBoundingBoxBaseIC.h:24
NestedBoundingBoxIC::_outside
const Real _outside
values outside all the boxes
Definition: NestedBoundingBoxIC.h:34
SmoothMultiBoundingBoxBaseIC::_c2
const std::vector< Point > _c2
Definition: SmoothMultiBoundingBoxBaseIC.h:37