https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"),
40 Moose::VarKindType::VAR_SOLVER,
41 Moose::VarFieldType::VAR_FIELD_STANDARD)),
42 _mesh(_fe_problem.mesh().getMesh()),
43 _subdomain_id(_fe_problem.mesh().getSubdomainID(getParam<SubdomainName>("subdomain"))),
44 _tolerance(getParam<Real>("tolerance"))
45{
46}
47
48void
53
54void
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}
registerMooseObject("ContactApp", ContactDOFSetSize)
Real PostprocessorValue
const ConsoleStream _console
virtual void initialize() override
const MooseVariableFieldBase & _var
MOOSE variable we compute the contact set from.
virtual void execute() override
ContactDOFSetSize(const InputParameters &parameters)
virtual PostprocessorValue getValue() const override
const SubdomainID _subdomain_id
The subdomain over which to query degrees of freedom.
const MeshBase & _mesh
The libmesh mesh.
unsigned int _count
Represents the number of values in contact.
const Real _tolerance
The tolerance used to decide whether the variable indicates contact.
static InputParameters validParams()
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::string & name() const
unsigned int number() const
NumericVector< Number > & solution()
void gatherSum(T &value)
FEProblemBase & _fe_problem
MeshBase & mesh