Exemple #1
0
  void BoundingSphere::transform() {
    Float3::affineTransformPos(transformed_center_, mat_hierarchy_, center_);

    // Figure out the transformed radius.  The following WONT work if there is
    // sqew.  It's a bit of a hack...
    jtil::math::Float3 rad_vec(radius_, 0, 0);
    Float3::affineTransformVec(transformed_rad_vec_, mat_hierarchy_, rad_vec);
    transformed_radius_ = transformed_rad_vec_.length();
    float rad_sq_ = Float3::dot(transformed_rad_vec_, transformed_rad_vec_);

    rad_vec.set(0, radius_, 0);
    Float3::affineTransformVec(transformed_rad_vec_, mat_hierarchy_, rad_vec);
    rad_sq_ = std::max<float>(Float3::dot(transformed_rad_vec_,
      transformed_rad_vec_), rad_sq_);

    rad_vec.set(0, 0, radius_);
    Float3::affineTransformVec(transformed_rad_vec_, mat_hierarchy_, rad_vec);
    rad_sq_ = std::max<float>(Float3::dot(transformed_rad_vec_,
      transformed_rad_vec_), rad_sq_);
    transformed_radius_ = sqrtf(rad_sq_);
  }
Exemple #2
0
void
GapConductance::computeGapRadii(const GapConductance::GAP_GEOMETRY gap_geometry_type,
                                const Point & current_point,
                                const Point & p1,
                                const Point & p2,
                                const Real & gap_distance,
                                const Point & current_normal,
                                Real & r1,
                                Real & r2,
                                Real & radius)
{
  if (gap_geometry_type == GapConductance::CYLINDER)
  {
    // The vector _p1 + t*(_p2-_p1) defines the cylindrical axis.  The point along this
    // axis closest to current_point is found by the following for t:
    const Point p2p1(p2 - p1);
    const Point p1pc(p1 - current_point);
    const Real t = -(p1pc * p2p1) / p2p1.norm_sq();

    // The nearest point on the cylindrical axis to current_point is p.
    const Point p(p1 + t * p2p1);
    Point rad_vec(current_point - p);
    Real rad = rad_vec.norm();
    rad_vec /= rad;
    Real rad_dot_norm = rad_vec * current_normal;

    if (rad_dot_norm > 0)
    {
      r1 = rad;
      r2 = rad - gap_distance; // note, gap_distance is negative
      radius = r1;
    }
    else if (rad_dot_norm < 0)
    {
      r1 = rad + gap_distance;
      r2 = rad;
      radius = r2;
    }
    else
      mooseError("Issue with cylindrical flux calc. normals.\n");

  }
  else if (gap_geometry_type == GapConductance::SPHERE)
  {
    const Point origin_to_curr_point(current_point - p1);
    const Real normal_dot = origin_to_curr_point * current_normal;
    const Real curr_point_radius = origin_to_curr_point.norm();
    if (normal_dot > 0) // on inside surface
    {
      r1 = curr_point_radius;
      r2 = curr_point_radius - gap_distance; // gap_distance is negative
      radius = r1;
    }
    else if (normal_dot < 0) // on outside surface
    {
      r1 = curr_point_radius + gap_distance; // gap_distance is negative
      r2 = curr_point_radius;
      radius = r2;
    }
    else
      mooseError("Issue with spherical flux calc. normals. \n");
  }
  else
  {
    r2 = -gap_distance;
    r1 = 0;
    radius = 0;
  }
}