www.mooseframework.org
IsolatedBoundingBoxIC.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 "IsolatedBoundingBoxIC.h"
11 #include "MooseMesh.h"
12 
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<SmoothMultiBoundingBoxBaseIC>();
20  params.addClassDescription(
21  "Specify variable values inside and outside a list of isolated boxes shaped "
22  "axis-aligned regions defined by pairs of opposing corners");
23  params.addParam<Real>("outside", 0.0, "The value of the variable outside the boxes");
24  return params;
25 }
26 
27 IsolatedBoundingBoxIC::IsolatedBoundingBoxIC(const InputParameters & parameters)
28  : SmoothMultiBoundingBoxBaseIC(parameters), _outside(getParam<Real>("outside"))
29 {
30 }
31 
32 Real
34 {
36 
37  if (_int_width != 0.0)
38  {
39  for (unsigned int b = 0; b < _nbox; ++b)
40  {
41  for (unsigned int i = 0; i < _dim; ++i)
42  {
43  if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) - _int_width &&
44  p(i) <= _c2[b](i) + _int_width)
45  {
46  if (i != _dim - 1)
47  continue;
48  for (unsigned int n = b + 1; n < _nbox; ++n)
49  {
50  for (unsigned int j = 0; j < _dim; ++j)
51  {
52  if (p(j) >= _c1[n](j) - _int_width && p(j) <= _c2[n](j) + _int_width)
53  mooseError("Partially overlapping boxes are not allowed. Note that this "
54  "includes the overlapping diffused interfaces. For nested boxes, "
55  "use NestedBoundingBoxIC.C.");
56  }
57  }
58  Real f_in = 1.0;
59  for (unsigned int j = 0; j < _dim; ++j)
60  f_in *= 0.5 * (std::tanh(2.0 * libMesh::pi * (p(j) - _c1[b](j)) / _int_width) -
61  std::tanh(2.0 * libMesh::pi * (p(j) - _c2[b](j)) / _int_width));
62  value = _outside + (_inside[b] - _outside) * f_in;
63  }
64  else if (_c1[b](i) >= _c2[b](i))
65  mooseError("The coordinates of the smaller_coordinate_corners are equal to or larger "
66  "than that of "
67  "the larger_coordinate_corners.");
68  else
69  break;
70  }
71  }
72  }
73  return value;
74 }
SmoothMultiBoundingBoxBaseIC::value
Real value(const Point &p)
Definition: SmoothMultiBoundingBoxBaseIC.C:50
IsolatedBoundingBoxIC::value
Real value(const Point &p)
Definition: IsolatedBoundingBoxIC.C:33
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", IsolatedBoundingBoxIC)
validParams< IsolatedBoundingBoxIC >
InputParameters validParams< IsolatedBoundingBoxIC >()
Definition: IsolatedBoundingBoxIC.C:17
IsolatedBoundingBoxIC::_outside
const Real _outside
values outside all the boxes
Definition: IsolatedBoundingBoxIC.h:34
IsolatedBoundingBoxIC.h
SmoothMultiBoundingBoxBaseIC::_inside
std::vector< Real > _inside
values inside the boxes
Definition: SmoothMultiBoundingBoxBaseIC.h:50
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
IsolatedBoundingBoxIC::IsolatedBoundingBoxIC
IsolatedBoundingBoxIC(const InputParameters &parameters)
Definition: IsolatedBoundingBoxIC.C:27
SmoothMultiBoundingBoxBaseIC
SmoothMultiBoundingBoxBaseIC is the base class for IsolatedBoundingBoxIC and NestedBoundingBoxIC.
Definition: SmoothMultiBoundingBoxBaseIC.h:24
SmoothMultiBoundingBoxBaseIC::_c2
const std::vector< Point > _c2
Definition: SmoothMultiBoundingBoxBaseIC.h:37
IsolatedBoundingBoxIC
IsolatedBoundingBoxIC creates several isolated boxes defined by their coordinates in the domain.
Definition: IsolatedBoundingBoxIC.h:25