https://mooseframework.inl.gov
IsolatedBoundingBoxIC.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 "IsolatedBoundingBoxIC.h"
11 #include "MooseMesh.h"
12 
14 
17 {
19  params.addClassDescription(
20  "Specify variable values inside and outside a list of isolated 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 boxes");
23  return params;
24 }
25 
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  for (unsigned int n = b + 1; n < _nbox; ++n)
48  {
49  for (unsigned int j = 0; j < _dim; ++j)
50  {
51  if (p(j) >= _c1[n](j) - _int_width && p(j) <= _c2[n](j) + _int_width)
52  mooseError("Partially overlapping boxes are not allowed. Note that this "
53  "includes the overlapping diffused interfaces. For nested boxes, "
54  "use NestedBoundingBoxIC.C.");
55  }
56  }
57  Real f_in = 1.0;
58  for (unsigned int j = 0; j < _dim; ++j)
59  f_in *= 0.5 * (std::tanh(2.0 * libMesh::pi * (p(j) - _c1[b](j)) / _int_width) -
60  std::tanh(2.0 * libMesh::pi * (p(j) - _c2[b](j)) / _int_width));
61  value = _outside + (_inside[b] - _outside) * f_in;
62  }
63  else if (_c1[b](i) >= _c2[b](i))
64  mooseError("The coordinates of the smaller_coordinate_corners are equal to or larger "
65  "than that of "
66  "the larger_coordinate_corners.");
67  else
68  break;
69  }
70  }
71  }
72  return value;
73 }
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
std::vector< Real > _inside
values inside the boxes
IsolatedBoundingBoxIC creates several isolated boxes defined by their coordinates in the domain...
const Real _outside
values outside all the boxes
const unsigned int _nbox
number of boxes
static InputParameters validParams()
const Real _int_width
value of interfacial width
const std::vector< Point > _c1
lists of opposite corners
SmoothMultiBoundingBoxBaseIC is the base class for IsolatedBoundingBoxIC and NestedBoundingBoxIC.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
IsolatedBoundingBoxIC(const InputParameters &parameters)
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const Real pi
registerMooseObject("PhaseFieldApp", IsolatedBoundingBoxIC)
Real value(const Point &p)