https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MoveNodesToGeometryModifierBase.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 "MooseMesh.h"
12#include "libmesh/mesh_base.h"
13
16{
19 "Snap refined nodes on a given boundary or block to a given geometry.");
20 params.addParam<std::vector<BoundaryName>>(
21 "boundary", {}, "List of boundaries whose nodes are snapped to a given geometry");
22 params.addParam<std::vector<SubdomainName>>(
23 "block", {}, "List of blocks whose nodes are snapped to a given geometry");
24
25 // By default don't execute
26 params.set<ExecFlagEnum>("execute_on") = "NONE";
27
28 return params;
29}
30
32 : GeneralUserObject(parameters),
33 _mesh(_subproblem.mesh()),
34 _boundary_ids(_mesh.getBoundaryIDs(getParam<std::vector<BoundaryName>>("boundary"))),
35 _subdomain_ids(_mesh.getSubdomainIDs(getParam<std::vector<SubdomainName>>("block")))
36{
37}
38
39void
43
44void
49
50void
54
55void
60
61void
63{
64 auto & mesh = _mesh.getMesh();
65
66 // go over boundaries
67 for (auto & boundary_id : _boundary_ids)
68 {
69 auto node_ids = _mesh.getNodeList(boundary_id);
70 for (auto & node_id : node_ids)
71 {
72 auto & node = mesh.node_ref(node_id);
73
74 snapNode(node);
75 }
76 }
77
78 // go over blocks
79 MeshBase::node_iterator node = mesh.active_nodes_begin();
80 MeshBase::node_iterator node_end = mesh.active_nodes_end();
81 for (; node != node_end; ++node)
82 {
83 // check if node is part of any of the selected blocks
84 const auto & node_blocks = _mesh.getNodeBlockIds(**node);
85 for (const auto subdomain_id : _subdomain_ids)
86 if (node_blocks.count(subdomain_id))
87 {
88 snapNode(**node);
89 break;
90 }
91 }
92}
A MultiMooseEnum object to hold "execute_on" flags.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3549
const std::vector< dof_id_type > & getNodeList(boundary_id_type nodeset_id) const
Return a writable reference to a vector of node IDs that belong to nodeset_id.
Definition MooseMesh.C:3571
const std::set< SubdomainID > & getNodeBlockIds(const Node &node) const
Return list of blocks to which the given node belongs.
Definition MooseMesh.C:1489
virtual void snapNode(Node &node)=0
Override this method in derived classes to implement a specific geometry.
MooseMesh & _mesh
Reference to the current simulation mesh.
const std::vector< BoundaryID > _boundary_ids
List of boundaries (or node sets) from which nodes will be snapped to a geometry.
virtual void initialize() final
Called before execute() is ever called so that data can be cleared.
virtual void meshChanged() final
Called on this object when the mesh changes.
const std::vector< SubdomainID > _subdomain_ids
List of blocks (likely lower D blocks) from which nodes will be snapped to a geometry.
void snapNodes()
Snap all nodes from the specified block or boundary restriction to the derived-class-defined geometry...
MoveNodesToGeometryModifierBase(const InputParameters &parameters)
virtual void execute() final
Execute method.
MeshBase & mesh