77//* Licensed under LGPL 2.1, please see LICENSE for details
88//* https://www.gnu.org/licenses/lgpl-2.1.html
99
10+ #include "MooseTypes.h"
11+ #include "IntegratedBCBase.h"
12+
1013#ifdef NEML2_ENABLED
1114
1215// MOOSE includes
@@ -35,6 +38,27 @@ NEML2CentralDifference::NEML2CentralDifference(const InputParameters & parameter
3538void
3639NEML2CentralDifference ::initialSetup ()
3740{
41+ // build boundary element list by iterating over all integrated BCs
42+ const auto & ibcs = _nl -> getIntegratedBCWarehouse ();
43+ std ::unordered_set < BoundaryID > bnds ;
44+ for (const auto & ibc : ibcs .getObjects ())
45+ bnds .insert (ibc - > boundaryIDs ().begin (), ibc - > boundaryIDs ().end ());
46+
47+ if (!bnds .empty ())
48+ {
49+ mooseInfo ("Dectected BCs on ", bnds .size (), " boundaries .");
50+
51+ // deduplicate elements that have multiple boundaries
52+ std ::unordered_set < const Elem * > unique_elems ;
53+ const auto end = _fe_problem .mesh ().bndElemsEnd ();
54+ for (auto it = _fe_problem .mesh ().bndElemsBegin (); it != end ; ++ it )
55+ if (bnds .find ((* it )-> _bnd_id ) != bnds .end ())
56+ unique_elems .insert ((* it )-> _elem );
57+
58+ _boundary_elems .assign (unique_elems .begin (), unique_elems .end ());
59+ mooseInfo ("Adding " , _boundary_elems .size (), " elements to the algebraic range." );
60+ }
61+
3862 ExplicitMixedOrder ::initialSetup ();
3963 _neml2_assembly = & _fe_problem .getUserObject < NEML2Assembly > ("assembly" , /*tid=*/ 0 );
4064 _fe = & _fe_problem .getUserObject < NEML2FEInterpolation > ("fe" , /*tid=*/ 0 );
@@ -52,8 +76,8 @@ NEML2CentralDifference::evaluateRHSResidual()
5276{
5377 if (_fe -> contextUpToDate () && _neml2_assembly -> upToDate ())
5478 {
55- libMesh ::ConstElemRange null_elem_range ( & _no_elem );
56- _fe_problem .setCurrentAlgebraicElementRange (& null_elem_range );
79+ libMesh ::ConstElemRange boundary_elem_range ( & _boundary_elems );
80+ _fe_problem .setCurrentAlgebraicElementRange (& boundary_elem_range );
5781
5882 libMesh ::ConstNodeRange null_node_range (& _no_node );
5983 _fe_problem .setCurrentAlgebraicNodeRange (& null_node_range );
0 commit comments