Skip to content
Permalink
Browse files

Merge pull request #13352 from permcody/div_zero

Division by zero due to the use of two PRNGs in one object.
  • Loading branch information...
rwcarlsen committed May 3, 2019
2 parents 4a4a25b + 4e813f1 commit 8f6ea7dcd909d35783bf14a33e6e04dd747ae719
@@ -40,8 +40,6 @@ class PolycrystalVoronoiVoidIC : public MultiSmoothCircleIC
const unsigned int _op_num;
const unsigned int _op_index;

const unsigned int _rand_seed;

const bool _columnar_3D;

const PolycrystalVoronoi & _poly_ic_uo;
@@ -69,4 +67,3 @@ class PolycrystalVoronoiVoidIC : public MultiSmoothCircleIC
bool operator()(const DistancePoint & a, const DistancePoint & b) { return a.d < b.d; }
} _customLess;
};

@@ -55,6 +55,7 @@ PolycrystalVoronoiVoidICAction::act()
poly_params.set<MooseEnum>("structure_type") = "grains";
poly_params.set<UserObjectName>("polycrystal_ic_uo") =
getParam<UserObjectName>("polycrystal_ic_uo");

// Add initial condition
_problem->addInitialCondition(
"PolycrystalVoronoiVoidIC", name() + "_" + Moose::stringify(op), poly_params);
@@ -23,8 +23,6 @@ PolycrystalVoronoiVoidIC::actionParameters()

params.addRequiredParam<unsigned int>("op_num", "Number of order parameters");

params.addParam<unsigned int>("rand_seed", 12444, "The random seed");

params.addParam<bool>(
"columnar_3D", false, "3D microstructure will be columnar in the z-direction?");

@@ -62,7 +60,6 @@ PolycrystalVoronoiVoidIC::PolycrystalVoronoiVoidIC(const InputParameters & param
_structure_type(getParam<MooseEnum>("structure_type")),
_op_num(getParam<unsigned int>("op_num")),
_op_index(getParam<unsigned int>("op_index")),
_rand_seed(getParam<unsigned int>("rand_seed")),
_columnar_3D(getParam<bool>("columnar_3D")),
_poly_ic_uo(getUserObject<PolycrystalVoronoi>("polycrystal_ic_uo")),
_file_name(getParam<FileName>("file_name"))
@@ -84,15 +81,6 @@ PolycrystalVoronoiVoidIC::initialSetup()
if (_op_num <= _op_index)
mooseError("op_index is too large in CircleGrainVoidIC");

MooseRandom::seed(getParam<unsigned int>("rand_seed"));
// Set up domain bounds with mesh tools
for (unsigned int i = 0; i < LIBMESH_DIM; i++)
{
_bottom_left(i) = _mesh.getMinInDimension(i);
_top_right(i) = _mesh.getMaxInDimension(i);
}
_range = _top_right - _bottom_left;

// Obtain total number and centerpoints of the grains
_grain_num = _poly_ic_uo.getNumGrains();
_centerpoints = _poly_ic_uo.getGrainCenters();
@@ -125,7 +113,7 @@ PolycrystalVoronoiVoidIC::computeCircleCenters()
Point rand_point;

for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
rand_point(i) = _bottom_left(i) + _range(i) * MooseRandom::rand();
rand_point(i) = _bottom_left(i) + _range(i) * _random.rand(_tid);

// Allow the vectors to be sorted based on their distance from the
// rand_point
@@ -157,9 +145,10 @@ PolycrystalVoronoiVoidIC::computeCircleCenters()
Real lambda = 0;
Point mid_rand_vector = _mesh.minPeriodicVector(_var.number(), midpoint, rand_point);

Real slope_dot = slope * slope;
mooseAssert(slope_dot > 0, "The dot product of slope with itself is zero");
for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
lambda += (mid_rand_vector(i) * slope(i)) /
(slope(0) * slope(0) + slope(1) * slope(1) + slope(2) * slope(2));
lambda += (mid_rand_vector(i) * slope(i)) / slope_dot;

// Assigning points to vector
_centers[vp] = slope * lambda + midpoint;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 8f6ea7d

Please sign in to comment.
You can’t perform that action at this time.