https://mooseframework.inl.gov
ContactDOFSetSize.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 "ContactDOFSetSize.h"
11 
12 // MOOSE includes
13 #include "MooseVariable.h"
14 #include "FEProblemBase.h"
15 #include "NonlinearSystemBase.h"
16 #include "MooseMesh.h"
18 
19 #include "libmesh/mesh_base.h"
20 
22 
25 {
27  params.addRequiredParam<VariableName>("variable", "The name of the variable to test for contact");
28  params.addRequiredParam<SubdomainName>("subdomain", "The subdomain that the variable lives on");
29  params.addParam<Real>(
30  "tolerance", TOLERANCE, "The tolerance for accepting that the variable indicates contact");
31  params.addClassDescription("Outputs the number of dofs greater than a tolerance threshold "
32  "indicating mechanical contact");
33  return params;
34 }
35 
37  : GeneralPostprocessor(parameters),
38  _var(_fe_problem.getVariable(_tid,
39  getParam<VariableName>("variable"),
42  _mesh(_fe_problem.mesh().getMesh()),
43  _subdomain_id(_fe_problem.mesh().getSubdomainID(getParam<SubdomainName>("subdomain"))),
44  _tolerance(getParam<Real>("tolerance"))
45 {
46 }
47 
48 void
50 {
51  _count = 0;
52 }
53 
54 void
56 {
58 
59  // Get the element iterators corresponding to the subdomain id
60  auto elem_begin = _mesh.active_local_subdomain_elements_begin(_subdomain_id);
61  auto elem_end = _mesh.active_local_subdomain_elements_end(_subdomain_id);
62 
63  ConstElemRange range(elem_begin, elem_end);
64 
65  Threads::parallel_reduce(range, aldit);
66 
67  const auto & solution = _fe_problem.getNonlinearSystemBase(_sys.number()).solution();
68 
69  for (auto dof : aldit.getDofIndices())
70  if (solution(dof) > _tolerance)
71  ++_count;
72 
74  _console << std::endl << "The number of nodes in contact is " << _count << std::endl << std::endl;
75 }
76 
79 {
80  return _count;
81 }
VarFieldType
const MooseVariableFieldBase & _var
MOOSE variable we compute the contact set from.
VAR_SOLVER
T & getMesh(MooseMesh &mesh)
function to cast mesh
Definition: SCM.h:35
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
registerMooseObject("ContactApp", ContactDOFSetSize)
MeshBase & mesh
const std::string & name() const override
const Real _tolerance
The tolerance used to decide whether the variable indicates contact.
virtual PostprocessorValue getValue() const override
void addRequiredParam(const std::string &name, const std::string &doc_string)
SubdomainID getSubdomainID(const SubdomainName &subdomain_name, const MeshBase &mesh)
StoredRange< MeshBase::const_element_iterator, const Elem *> ConstElemRange
static InputParameters validParams()
static InputParameters validParams()
void gatherSum(T &value)
VarKindType
Real PostprocessorValue
const SubdomainID _subdomain_id
The subdomain over which to query degrees of freedom.
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
unsigned int number() const
virtual void execute() override
ContactDOFSetSize(const InputParameters &parameters)
virtual void initialize() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const MeshBase & _mesh
The libmesh mesh.
FEProblemBase & _fe_problem
unsigned int _count
Represents the number of values in contact.
void addClassDescription(const std::string &doc_string)
VAR_FIELD_STANDARD
const ConsoleStream _console