https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TorchCentralDifference.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#ifdef MOOSE_LIBTORCH_ENABLED
11
12#include "MooseTypes.h"
13#include "IntegratedBCBase.h"
14
15// MOOSE includes
17
19
22{
25 "Central difference time integrator using batched libtorch finite-element kernels (and "
26 "optionally NEML2 material models for the constitutive update).");
27 params.addRequiredParam<UserObjectName>(
28 "assembly", "The TorchAssembly object to use to provide assembly information");
29 params.addRequiredParam<UserObjectName>(
30 "fe", "The TorchFEInterpolation object to use to couple variables");
31 return params;
32}
33
38
39void
41{
42 if (!_nl)
43 return;
44
45 _boundary_elems.clear();
46
47 // build boundary element list by iterating over all integrated BCs
48 const auto & ibcs = _nl->getIntegratedBCWarehouse();
49 std::unordered_set<BoundaryID> bnds;
50 for (const auto & ibc : ibcs.getObjects())
51 bnds.insert(ibc->boundaryIDs().begin(), ibc->boundaryIDs().end());
52
53 if (!bnds.empty())
54 {
55 mooseInfo("Dectected BCs on ", bnds.size(), " boundaries.");
56
57 // deduplicate elements that have multiple boundaries
58 std::unordered_set<const Elem *> unique_elems;
59 const auto end = _fe_problem.mesh().bndElemsEnd();
60 for (auto it = _fe_problem.mesh().bndElemsBegin(); it != end; ++it)
61 if (bnds.find((*it)->_bnd_id) != bnds.end())
62 unique_elems.insert((*it)->_elem);
63
64 _boundary_elems.assign(unique_elems.begin(), unique_elems.end());
65 mooseInfo("Adding ", _boundary_elems.size(), " elements to the algebraic range.");
66 }
67
69}
70
71void
79
80void
86
87void
93
94void
115
116#endif // MOOSE_LIBTORCH_ENABLED
registerMooseObject("SolidMechanicsApp", TorchCentralDifference)
Implements a form of the central difference time integrator that calculates acceleration directly fro...
virtual void postSolve() override
virtual void meshChanged() override
virtual void evaluateRHSResidual()
Evaluate the RHS residual.
static InputParameters validParams()
virtual void initialSetup() override
T & getUserObject(const std::string &name, unsigned int tid=0) const
void setCurrentAlgebraicNodeRange(libMesh::ConstNodeRange *range)
void setCurrentAlgebraicElementRange(libMesh::ConstElemRange *range)
virtual MooseMesh & mesh() override
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseInfo(Args &&... args) const
virtual bnd_elem_iterator bndElemsBegin()
virtual bnd_elem_iterator bndElemsEnd()
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse()
NonlinearSystemBase * _nl
FEProblemBase & _fe_problem
bool upToDate() const
TorchAssembly * _assembly
The assembly object with cached assembly information.
void evaluateRHSResidual() override
Evaluate the RHS residual.
TorchFEInterpolation * _fe
The FE interface for getting variable values/gradients interpolated onto the finite element space.
static InputParameters validParams()
std::vector< const Node * > _no_node
Empty node vector to help zero out the algebraic range.
TorchCentralDifference(const InputParameters &parameters)
bool _boundary_elems_dirty
Whether the cached boundary element list needs rebuilding.
std::vector< const Elem * > _boundary_elems
Empty element vector to help zero out the algebraic range.
void invalidateInterpolations()
bool contextUpToDate() const