www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
LineSegmentLevelSetAux Class Reference

Calculate level set values for an interface that is defined by a set of line segments. More...

#include <LineSegmentLevelSetAux.h>

Inheritance diagram for LineSegmentLevelSetAux:
[legend]

Public Member Functions

 LineSegmentLevelSetAux (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeValue () override
 
virtual void compute () override
 
Real calculateSignedDistance (Point p)
 calculate the signed distance value for a given point. More...
 

Protected Attributes

const LineSegmentCutSetUserObject_linesegment_uo
 Pointer to the LineSegmentCutSetUserObject object. More...
 
std::vector< Real > _cut_data
 Store the cut locations. More...
 

Detailed Description

Calculate level set values for an interface that is defined by a set of line segments.

Definition at line 25 of file LineSegmentLevelSetAux.h.

Constructor & Destructor Documentation

◆ LineSegmentLevelSetAux()

LineSegmentLevelSetAux::LineSegmentLevelSetAux ( const InputParameters &  parameters)

Definition at line 29 of file LineSegmentLevelSetAux.C.

30  : AuxKernel(parameters)
31 {
32  if (!isNodal())
33  mooseError("LineSegmentLevelSetAux: Aux variable must be nodal variable.");
34 
35  FEProblemBase * fe_problem = dynamic_cast<FEProblemBase *>(&_subproblem);
36 
37  const UserObject * uo = &(
38  fe_problem->getUserObjectBase(getParam<UserObjectName>("line_segment_cut_set_user_object")));
39 
40  if (dynamic_cast<const LineSegmentCutSetUserObject *>(uo) == nullptr)
41  mooseError(
42  "Failed to cast UserObject to LineSegmentCutSetUserObject in LineSegmentLevelSetAux");
43 
44  _linesegment_uo = dynamic_cast<const LineSegmentCutSetUserObject *>(uo);
45 }
const LineSegmentCutSetUserObject * _linesegment_uo
Pointer to the LineSegmentCutSetUserObject object.

Member Function Documentation

◆ calculateSignedDistance()

Real LineSegmentLevelSetAux::calculateSignedDistance ( Point  p)
protected

calculate the signed distance value for a given point.

Parameters
pCoordinate of point
Returns
Signed distance

Definition at line 48 of file LineSegmentLevelSetAux.C.

Referenced by computeValue().

49 {
50  const int line_cut_data_len = 6;
51 
52  Real min_dist = std::numeric_limits<Real>::max();
53 
54  for (unsigned int i = 0; i < _cut_data.size() / line_cut_data_len; ++i)
55  {
56  Point a = Point(_cut_data[i * line_cut_data_len + 0], _cut_data[i * line_cut_data_len + 1], 0);
57  Point b = Point(_cut_data[i * line_cut_data_len + 2], _cut_data[i * line_cut_data_len + 3], 0);
58 
59  Point c = p - a;
60  Point v = (b - a) / (b - a).norm();
61  Real d = (b - a).norm();
62  Real t = v * c;
63 
64  Real dist;
65  Point nearest_point;
66 
67  if (t < 0)
68  {
69  dist = (p - a).norm();
70  nearest_point = a;
71  }
72  else if (t > d)
73  {
74  dist = (p - b).norm();
75  nearest_point = b;
76  }
77  else
78  {
79  v *= t;
80  dist = (p - a - v).norm();
81  nearest_point = (a + v);
82  }
83 
84  Point p_nearest_point = nearest_point - p;
85 
86  Point normal_ab = Point(-(b - a)(1), (b - a)(0), 0);
87 
88  if (normal_ab * p_nearest_point < 0)
89  dist = -dist;
90 
91  if (std::abs(dist) < std::abs(min_dist))
92  min_dist = dist;
93  }
94 
95  return min_dist;
96 }
std::vector< Real > _cut_data
Store the cut locations.

◆ compute()

void LineSegmentLevelSetAux::compute ( )
overrideprotectedvirtual

Definition at line 99 of file LineSegmentLevelSetAux.C.

100 {
102  AuxKernel::compute();
103 }
const LineSegmentCutSetUserObject * _linesegment_uo
Pointer to the LineSegmentCutSetUserObject object.
std::vector< Real > _cut_data
Store the cut locations.
virtual std::vector< Real > getCutData() const
Get the cut location information.

◆ computeValue()

Real LineSegmentLevelSetAux::computeValue ( )
overrideprotectedvirtual

Definition at line 106 of file LineSegmentLevelSetAux.C.

107 {
108  return calculateSignedDistance(*_current_node);
109 }
Real calculateSignedDistance(Point p)
calculate the signed distance value for a given point.

Member Data Documentation

◆ _cut_data

std::vector<Real> LineSegmentLevelSetAux::_cut_data
protected

Store the cut locations.

Definition at line 45 of file LineSegmentLevelSetAux.h.

Referenced by calculateSignedDistance(), and compute().

◆ _linesegment_uo

const LineSegmentCutSetUserObject* LineSegmentLevelSetAux::_linesegment_uo
protected

Pointer to the LineSegmentCutSetUserObject object.

Definition at line 42 of file LineSegmentLevelSetAux.h.

Referenced by compute(), and LineSegmentLevelSetAux().


The documentation for this class was generated from the following files: