https://mooseframework.inl.gov
NEML2CentralDifference.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 "MooseTypes.h"
11 #include "IntegratedBCBase.h"
12 
13 #ifdef NEML2_ENABLED
14 
15 // MOOSE includes
16 #include "NEML2CentralDifference.h"
17 
18 registerMooseObject("SolidMechanicsApp", NEML2CentralDifference);
19 
22 {
24  params.addClassDescription(
25  "Central difference time integrator using NEML2 material models and kernels.");
26  params.addRequiredParam<UserObjectName>(
27  "assembly", "The NEML2Assembly object to use to provide assembly information");
28  params.addRequiredParam<UserObjectName>(
29  "fe", "The NEML2FEInterpolation object to use to couple variables");
30  return params;
31 }
32 
34  : ExplicitMixedOrder(parameters)
35 {
36 }
37 
38 void
40 {
41  if (!_nl)
42  return;
43 
44  _boundary_elems.clear();
45 
46  // build boundary element list by iterating over all integrated BCs
47  const auto & ibcs = _nl->getIntegratedBCWarehouse();
48  std::unordered_set<BoundaryID> bnds;
49  for (const auto & ibc : ibcs.getObjects())
50  bnds.insert(ibc->boundaryIDs().begin(), ibc->boundaryIDs().end());
51 
52  if (!bnds.empty())
53  {
54  mooseInfo("Dectected BCs on ", bnds.size(), " boundaries.");
55 
56  // deduplicate elements that have multiple boundaries
57  std::unordered_set<const Elem *> unique_elems;
58  const auto end = _fe_problem.mesh().bndElemsEnd();
59  for (auto it = _fe_problem.mesh().bndElemsBegin(); it != end; ++it)
60  if (bnds.find((*it)->_bnd_id) != bnds.end())
61  unique_elems.insert((*it)->_elem);
62 
63  _boundary_elems.assign(unique_elems.begin(), unique_elems.end());
64  mooseInfo("Adding ", _boundary_elems.size(), " elements to the algebraic range.");
65  }
66 
67  _boundary_elems_dirty = false;
68 }
69 
70 void
72 {
74  _neml2_assembly = &_fe_problem.getUserObject<NEML2Assembly>("assembly", /*tid=*/0);
77 }
78 
79 void
81 {
83  _boundary_elems_dirty = true;
84 }
85 
86 void
88 {
91 }
92 
93 void
95 {
98 
100  {
101  libMesh::ConstElemRange boundary_elem_range(&_boundary_elems);
102  _fe_problem.setCurrentAlgebraicElementRange(&boundary_elem_range);
103 
104  libMesh::ConstNodeRange null_node_range(&_no_node);
105  _fe_problem.setCurrentAlgebraicNodeRange(&null_node_range);
106  }
107 
109 
110  // Reset the algebraic ranges
113 }
114 
115 #endif // NEML2_ENABLED
virtual bnd_elem_iterator bndElemsEnd()
void setCurrentAlgebraicElementRange(libMesh::ConstElemRange *range)
void mooseInfo(Args &&... args) const
std::vector< const Elem * > _boundary_elems
Empty element vector to help zero out the algebraic range.
T & getUserObject(const std::string &name, unsigned int tid=0) const
std::vector< const Node * > _no_node
Empty node vector to help zero out the algebraic range.
void setCurrentAlgebraicNodeRange(libMesh::ConstNodeRange *range)
virtual void initialSetup() override
FEProblemBase & _fe_problem
bool upToDate() const
NEML2Assembly * _neml2_assembly
The assembly object with cached assembly information.
NonlinearSystemBase * _nl
virtual void postSolve() override
virtual bnd_elem_iterator bndElemsBegin()
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse()
Implements a form of the central difference time integrator that calculates acceleration directly fro...
bool _boundary_elems_dirty
Whether the cached boundary element list needs rebuilding.
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
void invalidateInterpolations()
static InputParameters validParams()
NEML2FEInterpolation * _fe
The FE interface for getting variable values/gradients interpolated onto the finite element space...
bool contextUpToDate() const
NEML2CentralDifference(const InputParameters &parameters)
virtual void meshChanged() override
registerMooseObject("SolidMechanicsApp", NEML2CentralDifference)
virtual MooseMesh & mesh() override
void addClassDescription(const std::string &doc_string)
virtual void evaluateRHSResidual()
Evaluate the RHS residual.
void evaluateRHSResidual() override
Evaluate the RHS residual.