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

#include <PenetrationLocator.h>

Inheritance diagram for PenetrationLocator:
[legend]

Public Types

enum  NORMAL_SMOOTHING_METHOD { NSM_EDGE_BASED, NSM_NODAL_NORMAL_BASED }
 

Public Member Functions

 PenetrationLocator (SubProblem &subproblem, GeometricSearchData &geom_search_data, MooseMesh &mesh, const unsigned int master_id, const unsigned int slave_id, Order order, NearestNodeLocator &nearest_node)
 
 ~PenetrationLocator ()
 
void detectPenetration ()
 
void reinit ()
 Completely redo the search from scratch. More...
 
Real penetrationDistance (dof_id_type node_id)
 
RealVectorValue penetrationNormal (dof_id_type node_id)
 
Real normDistance (const Elem &elem, const Elem &side, const Node &p0, Point &closest_point, RealVectorValue &normal)
 
int intersect2D_Segments (Point S1P0, Point S1P1, Point S2P0, Point S2P1, Point *I0, Point *I1)
 
int inSegment (Point P, Point SP0, Point SP1)
 
void setCheckWhetherReasonable (bool state)
 
void setUpdate (bool update)
 
void setTangentialTolerance (Real tangential_tolerance)
 
void setNormalSmoothingDistance (Real normal_smoothing_distance)
 
void setNormalSmoothingMethod (std::string nsmString)
 
Real getTangentialTolerance ()
 

Public Attributes

SubProblem_subproblem
 
MooseMesh_mesh
 
BoundaryID _master_boundary
 
BoundaryID _slave_boundary
 
FEType _fe_type
 
std::vector< std::vector< FEBase * > > _fe
 
NearestNodeLocator_nearest_node
 
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
 Data structure of nodes and their associated penetration information. More...
 
std::set< dof_id_type > & _has_penetrated
 

Protected Attributes

bool _check_whether_reasonable
 Check whether found candidates are reasonable. More...
 
bool & _update_location
 
Real _tangential_tolerance
 
bool _do_normal_smoothing
 
Real _normal_smoothing_distance
 
NORMAL_SMOOTHING_METHOD _normal_smoothing_method
 

Private Member Functions

template<typename T >
T & declareRestartableData (std::string data_name)
 Declare a piece of data as "restartable". More...
 
template<typename T >
T & declareRestartableData (std::string data_name, const T &init_value)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T >
T & declareRestartableDataWithContext (std::string data_name, void *context)
 Declare a piece of data as "restartable". More...
 
template<typename T >
T & declareRestartableDataWithContext (std::string data_name, const T &init_value, void *context)
 Declare a piece of data as "restartable" and initialize it. More...
 

Detailed Description

Definition at line 32 of file PenetrationLocator.h.

Member Enumeration Documentation

Enumerator
NSM_EDGE_BASED 
NSM_NODAL_NORMAL_BASED 

Definition at line 54 of file PenetrationLocator.h.

Constructor & Destructor Documentation

PenetrationLocator::PenetrationLocator ( SubProblem subproblem,
GeometricSearchData geom_search_data,
MooseMesh mesh,
const unsigned int  master_id,
const unsigned int  slave_id,
Order  order,
NearestNodeLocator nearest_node 
)

Definition at line 26 of file PenetrationLocator.C.

33  : Restartable(Moose::stringify(master_id) + "to" + Moose::stringify(slave_id),
34  "PenetrationLocator",
35  subproblem,
36  0),
37  _subproblem(subproblem),
38  _mesh(mesh),
39  _master_boundary(master_id),
40  _slave_boundary(slave_id),
41  _fe_type(order),
42  _nearest_node(nearest_node),
43  _penetration_info(declareRestartableDataWithContext<std::map<dof_id_type, PenetrationInfo *>>(
44  "penetration_info", &_mesh)),
45  _has_penetrated(declareRestartableData<std::set<dof_id_type>>("has_penetrated")),
47  _update_location(declareRestartableData<bool>("update_location", true)),
49  _do_normal_smoothing(false),
52 {
53  // Preconstruct an FE object for each thread we're going to use and for each lower-dimensional
54  // element
55  // This is a time savings so that the thread objects don't do this themselves multiple times
56  _fe.resize(libMesh::n_threads());
57  for (unsigned int i = 0; i < libMesh::n_threads(); i++)
58  {
59  unsigned int n_dims = _mesh.dimension();
60  _fe[i].resize(n_dims + 1);
61  for (unsigned int dim = 0; dim <= n_dims; ++dim)
62  _fe[i][dim] = FEBase::build(dim, _fe_type).release();
63  }
64 
66  {
67  if (!((_subproblem.hasVariable("nodal_normal_x")) &&
68  (_subproblem.hasVariable("nodal_normal_y")) &&
69  (_subproblem.hasVariable("nodal_normal_z"))))
70  {
71  mooseError("To use nodal-normal-based smoothing, the nodal_normal_x, nodal_normal_y, and "
72  "nodal_normal_z variables must exist. Are you missing the [NodalNormals] block?");
73  }
74  }
75 }
virtual bool hasVariable(const std::string &var_name)=0
Restartable(const InputParameters &parameters, std::string system_name, SubProblem *subproblem=NULL)
Class constructor Populates the SubProblem and MooseMesh pointers.
Definition: Restartable.C:20
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimsension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh m...
Definition: MooseMesh.C:1945
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::vector< std::vector< FEBase * > > _fe
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
bool _check_whether_reasonable
Check whether found candidates are reasonable.
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:66
SubProblem & _subproblem
T & declareRestartableDataWithContext(std::string data_name, void *context)
Declare a piece of data as "restartable".
Definition: Restartable.h:238
std::set< dof_id_type > & _has_penetrated
NORMAL_SMOOTHING_METHOD _normal_smoothing_method
NearestNodeLocator & _nearest_node
T & declareRestartableData(std::string data_name)
Declare a piece of data as "restartable".
Definition: Restartable.h:224
PenetrationLocator::~PenetrationLocator ( )

Definition at line 77 of file PenetrationLocator.C.

78 {
79  for (unsigned int i = 0; i < libMesh::n_threads(); i++)
80  for (unsigned int dim = 0; dim < _fe[i].size(); dim++)
81  delete _fe[i][dim];
82 
83  for (auto & it : _penetration_info)
84  delete it.second;
85 }
std::vector< std::vector< FEBase * > > _fe
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.

Member Function Documentation

template<typename T >
T & Restartable::declareRestartableData ( std::string  data_name)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)

Definition at line 224 of file Restartable.h.

225 {
226  return declareRestartableDataWithContext<T>(data_name, NULL);
227 }
template<typename T >
T & Restartable::declareRestartableData ( std::string  data_name,
const T &  init_value 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
init_valueThe initial value of the data

Definition at line 231 of file Restartable.h.

232 {
233  return declareRestartableDataWithContext<T>(data_name, init_value, NULL);
234 }
template<typename T >
T & Restartable::declareRestartableDataWithContext ( std::string  data_name,
void *  context 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
contextContext pointer that will be passed to the load and store functions

Definition at line 238 of file Restartable.h.

239 {
241  mooseError("No valid SubProblem found for ", _restartable_system_name, "/", _restartable_name);
242 
243  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
244  RestartableData<T> * data_ptr = new RestartableData<T>(full_name, context);
245 
247 
248  return data_ptr->get();
249 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:202
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::string _restartable_name
The name of the object.
Definition: Restartable.h:196
void registerRestartableDataOnSubProblem(std::string name, RestartableDataValue *data, THREAD_ID tid)
Helper function so we don&#39;t have to include SubProblem in the header.
Definition: Restartable.C:49
Concrete definition of a parameter value for a specified type.
SubProblem * _restartable_subproblem
Pointer to the SubProblem class.
Definition: Restartable.h:208
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:205
template<typename T >
T & Restartable::declareRestartableDataWithContext ( std::string  data_name,
const T &  init_value,
void *  context 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
init_valueThe initial value of the data
contextContext pointer that will be passed to the load and store functions

Definition at line 253 of file Restartable.h.

256 {
258  mooseError("No valid SubProblem found for ", _restartable_system_name, "/", _restartable_name);
259 
260  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
261  RestartableData<T> * data_ptr = new RestartableData<T>(full_name, context);
262 
263  data_ptr->set() = init_value;
264 
266 
267  return data_ptr->get();
268 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:202
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::string _restartable_name
The name of the object.
Definition: Restartable.h:196
void registerRestartableDataOnSubProblem(std::string name, RestartableDataValue *data, THREAD_ID tid)
Helper function so we don&#39;t have to include SubProblem in the header.
Definition: Restartable.C:49
Concrete definition of a parameter value for a specified type.
SubProblem * _restartable_subproblem
Pointer to the SubProblem class.
Definition: Restartable.h:208
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:205
void PenetrationLocator::detectPenetration ( )

Definition at line 88 of file PenetrationLocator.C.

Referenced by reinit(), and GeometricSearchData::update().

89 {
90  Moose::perf_log.push("detectPenetration()", "Execution");
91 
92  // Data structures to hold the element boundary information
93  std::vector<dof_id_type> elem_list;
94  std::vector<unsigned short int> side_list;
95  std::vector<boundary_id_type> id_list;
96 
97  // Retrieve the Element Boundary data structures from the mesh
98  _mesh.buildSideList(elem_list, side_list, id_list);
99 
100  // Grab the slave nodes we need to worry about from the NearestNodeLocator
101  NodeIdRange & slave_node_range = _nearest_node.slaveNodeRange();
102 
104  _mesh,
114  _fe,
115  _fe_type,
118  elem_list,
119  side_list,
120  id_list);
121 
122  Threads::parallel_reduce(slave_node_range, pt);
123 
124  Moose::perf_log.pop("detectPenetration()", "Execution");
125 }
StoredRange< std::vector< dof_id_type >::iterator, dof_id_type > NodeIdRange
Definition: MooseTypes.h:81
std::vector< std::vector< FEBase * > > _fe
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
void buildSideList(std::vector< dof_id_type > &el, std::vector< unsigned short int > &sl, std::vector< boundary_id_type > &il)
Calls BoundaryInfo::build_side_list().
Definition: MooseMesh.C:1986
bool _check_whether_reasonable
Check whether found candidates are reasonable.
NodeIdRange & slaveNodeRange()
Returns the NodeIdRange of slave nodes to be used for calling threaded functions operating on the sla...
PerfLog perf_log
Perflog to be used by applications.
SubProblem & _subproblem
NORMAL_SMOOTHING_METHOD _normal_smoothing_method
NearestNodeLocator & _nearest_node
const std::map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected...
Definition: MooseMesh.C:642
Real PenetrationLocator::getTangentialTolerance ( )
inline

Definition at line 93 of file PenetrationLocator.h.

int PenetrationLocator::inSegment ( Point  P,
Point  SP0,
Point  SP1 
)
int PenetrationLocator::intersect2D_Segments ( Point  S1P0,
Point  S1P1,
Point  S2P0,
Point  S2P1,
Point *  I0,
Point *  I1 
)
Real PenetrationLocator::normDistance ( const Elem &  elem,
const Elem &  side,
const Node &  p0,
Point &  closest_point,
RealVectorValue &  normal 
)
Real PenetrationLocator::penetrationDistance ( dof_id_type  node_id)

Definition at line 143 of file PenetrationLocator.C.

144 {
145  PenetrationInfo * info = _penetration_info[node_id];
146 
147  if (info)
148  return info->_distance;
149  else
150  return 0;
151 }
Data structure used to hold penetration information.
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
RealVectorValue PenetrationLocator::penetrationNormal ( dof_id_type  node_id)

Definition at line 154 of file PenetrationLocator.C.

155 {
156  std::map<dof_id_type, PenetrationInfo *>::const_iterator found_it =
157  _penetration_info.find(node_id);
158 
159  if (found_it != _penetration_info.end())
160  return found_it->second->_normal;
161  else
162  return RealVectorValue(0, 0, 0);
163 }
VectorValue< Real > RealVectorValue
Definition: Assembly.h:40
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
void PenetrationLocator::reinit ( )

Completely redo the search from scratch.

This is probably getting called because of mesh adaptivity.

Definition at line 128 of file PenetrationLocator.C.

Referenced by GeometricSearchData::reinit().

129 {
130  // Delete the PenetrationInfo objects we own before clearing the
131  // map, or we have a memory leak.
132  for (auto & it : _penetration_info)
133  delete it.second;
134 
135  _penetration_info.clear();
136 
137  _has_penetrated.clear();
138 
140 }
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
std::set< dof_id_type > & _has_penetrated
void PenetrationLocator::setCheckWhetherReasonable ( bool  state)

Definition at line 166 of file PenetrationLocator.C.

167 {
169 }
bool _check_whether_reasonable
Check whether found candidates are reasonable.
void PenetrationLocator::setNormalSmoothingDistance ( Real  normal_smoothing_distance)

Definition at line 184 of file PenetrationLocator.C.

Referenced by GapValueAux::GapValueAux(), NodeFaceConstraint::NodeFaceConstraint(), and PenetrationAux::PenetrationAux().

185 {
186  _normal_smoothing_distance = normal_smoothing_distance;
187  if (_normal_smoothing_distance > 0.0)
188  _do_normal_smoothing = true;
189 }
void PenetrationLocator::setNormalSmoothingMethod ( std::string  nsmString)

Definition at line 192 of file PenetrationLocator.C.

Referenced by GapValueAux::GapValueAux(), NodeFaceConstraint::NodeFaceConstraint(), and PenetrationAux::PenetrationAux().

193 {
194  if (nsmString == "edge_based")
196  else if (nsmString == "nodal_normal_based")
198  else
199  mooseError("Invalid normal_smoothing_method: ", nsmString);
200  _do_normal_smoothing = true;
201 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
NORMAL_SMOOTHING_METHOD _normal_smoothing_method
void PenetrationLocator::setTangentialTolerance ( Real  tangential_tolerance)

Definition at line 178 of file PenetrationLocator.C.

Referenced by GapValueAux::GapValueAux(), NodeFaceConstraint::NodeFaceConstraint(), and PenetrationAux::PenetrationAux().

179 {
180  _tangential_tolerance = tangential_tolerance;
181 }
void PenetrationLocator::setUpdate ( bool  update)

Definition at line 172 of file PenetrationLocator.C.

173 {
174  _update_location = update;
175 }

Member Data Documentation

bool PenetrationLocator::_check_whether_reasonable
protected

Check whether found candidates are reasonable.

Definition at line 97 of file PenetrationLocator.h.

Referenced by detectPenetration(), and setCheckWhetherReasonable().

bool PenetrationLocator::_do_normal_smoothing
protected
std::vector<std::vector<FEBase *> > PenetrationLocator::_fe

Definition at line 78 of file PenetrationLocator.h.

Referenced by detectPenetration(), PenetrationLocator(), and ~PenetrationLocator().

FEType PenetrationLocator::_fe_type

Definition at line 75 of file PenetrationLocator.h.

Referenced by detectPenetration(), and PenetrationLocator().

std::set<dof_id_type>& PenetrationLocator::_has_penetrated

Definition at line 86 of file PenetrationLocator.h.

Referenced by reinit().

BoundaryID PenetrationLocator::_master_boundary

Definition at line 72 of file PenetrationLocator.h.

Referenced by detectPenetration().

MooseMesh& PenetrationLocator::_mesh

Definition at line 71 of file PenetrationLocator.h.

Referenced by detectPenetration(), and PenetrationLocator().

NearestNodeLocator& PenetrationLocator::_nearest_node
Real PenetrationLocator::_normal_smoothing_distance
protected

Definition at line 102 of file PenetrationLocator.h.

Referenced by detectPenetration(), and setNormalSmoothingDistance().

NORMAL_SMOOTHING_METHOD PenetrationLocator::_normal_smoothing_method
protected
std::map<dof_id_type, PenetrationInfo *>& PenetrationLocator::_penetration_info
BoundaryID PenetrationLocator::_slave_boundary
SubProblem& PenetrationLocator::_subproblem

Definition at line 60 of file PenetrationLocator.h.

Referenced by detectPenetration(), and PenetrationLocator().

Real PenetrationLocator::_tangential_tolerance
protected
bool& PenetrationLocator::_update_location
protected

Definition at line 98 of file PenetrationLocator.h.

Referenced by detectPenetration(), and setUpdate().


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