https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SubdomainElementModifier.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
11#include "SBMUtils.h"
12
13#include <vector>
14
15registerMooseObject("ShiftedBoundaryMethodApp", SubdomainElementModifier);
16
19{
21 params.addClassDescription("Assign subdomain ID based on geometric inclusion using per-subdomain "
22 "in-out checks provided by a subdomain_id_tester.");
23
24 params.addRequiredParam<UserObjectName>(
25 "subdomain_id_tester",
26 "The UserObject (PointInSubdomainCheckUO) for subdomain in/out tests.");
27
28 return params;
29}
30
33 _subdomain_id_tester(getUserObject<PointInSubdomainCheckUO>("subdomain_id_tester"))
34{
35}
36
39{
40 const Elem * elem = this->_current_elem;
41 if (!elem)
42 mooseError("SubdomainElementModifier: _current_elem is null!");
43
44 const auto & all_checkers = _subdomain_id_tester.subdomainCheckers();
45 if (all_checkers.empty())
46 mooseError("SubdomainElementModifier: subdomain checker collection is empty!");
47
48 // Compute the occupancy of the element with respect to each subdomain's in/out checker.
49 std::vector<SBMUtils::SubdomainOccupancy> candidate_occupancies;
50 candidate_occupancies.reserve(all_checkers.size());
51 for (const auto & [subdomain_id, checker_ptr] : all_checkers)
52 {
53 const auto * const checker = checker_ptr.get();
54 const auto is_in_domain = [checker](const Point & point)
55 { return checker->sideness(point) != SurfaceGeometry::SurfaceSide::OUTSIDE; };
56 candidate_occupancies.push_back(
57 {subdomain_id, SBMUtils::elementDomainOccupancy(*elem, _qrule_order, is_in_domain)});
58 }
59
60 // Select the subdomain ID based on the measured occupancies and the intercepted-subdomain policy.
61 const auto subdomain = SBMUtils::selectSubdomainFromOccupancies(
62 candidate_occupancies, _intercepted_subdomain_policy, _lambda);
63
64 // INVALID_BLOCK_ID tells ElementSubdomainModifier to retain the current subdomain.
65 return subdomain.value_or(Moose::INVALID_BLOCK_ID);
66}
subdomain_id_type SubdomainID
registerMooseObject("ShiftedBoundaryMethodApp", SubdomainElementModifier)
const Elem *const & _current_elem
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
Performs in-out testing and identifies the subdomain containing a point.
const std::map< subdomain_id_type, std::unique_ptr< const PointContainmentClassifier > > & subdomainCheckers() const
Read-only view of the per-subdomain checkers (subdomain id -> checker).
const SBMUtils::InterceptedSubdomainPolicy _intercepted_subdomain_policy
Policy for assigning partial elements to a dedicated intercepted subdomain.
const Order _qrule_order
Quadrature order used to estimate the retained-domain fraction.
const Real _lambda
Threshold applied to the fraction outside the retained domain for a partial element.
Common partial-element classification parameters for shifted boundary element modifiers.
Modifies element subdomains dynamically based on point-in-subdomain geometric checks provided by Poin...
SubdomainElementModifier(const InputParameters &parameters)
const PointInSubdomainCheckUO & _subdomain_id_tester
The user object containing subdomain-wise in/out checkers.
virtual SubdomainID computeSubdomainID() override
static InputParameters validParams()
const SubdomainID INVALID_BLOCK_ID
std::optional< SubdomainID > selectSubdomainFromOccupancies(const std::vector< SubdomainOccupancy > &candidate_occupancies, const InterceptedSubdomainPolicy &intercepted_policy, Real lambda)
Select a subdomain based on how multiple candidate domains occupy an element.
Definition SBMUtils.C:92
ElementDomainOccupancy elementDomainOccupancy(const Elem &elem, Order qrule_order, const std::function< bool(const libMesh::Point &)> &is_in_domain)
Test an element against the domain defined by is_in_domain.
Definition SBMUtils.C:51