www.mooseframework.org
GeometryBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "GeometryBase.h"
11 #include "MooseMesh.h"
12 #include "libmesh/mesh_base.h"
13 
14 template <>
17 {
19  params.addClassDescription("Snap refined nodes on a given boundary to a given geometry");
20  params.addParam<std::vector<BoundaryName>>(
21  "boundary", "List of boundaries whose nodes are snapped to a given geometry");
22  return params;
23 }
24 
26  : GeneralUserObject(parameters),
27  _mesh(_subproblem.mesh()),
28  _boundary_ids(_mesh.getBoundaryIDs(getParam<std::vector<BoundaryName>>("boundary")))
29 {
30 }
31 
32 void
34 {
35 }
36 
37 void
39 {
40 }
41 
42 void
44 {
45 }
46 
47 void
49 {
50  auto & mesh = _mesh.getMesh();
51 
52  for (auto & boundary_id : _boundary_ids)
53  {
54  auto node_ids = _mesh.getNodeList(boundary_id);
55  for (auto & node_id : node_ids)
56  {
57  auto & node = mesh.node_ref(node_id);
58 
59  snapNode(node);
60  }
61  }
62 }
GeometryBase(const InputParameters &parameters)
Definition: GeometryBase.C:25
virtual void initialize() final
Called before execute() is ever called so that data can be cleared.
Definition: GeometryBase.C:33
virtual void execute() final
Execute method.
Definition: GeometryBase.C:38
const std::vector< BoundaryID > _boundary_ids
List of boundaries (or node sets) that will be snapped to a geometry.
Definition: GeometryBase.h:46
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralUserObject >()
InputParameters validParams< GeometryBase >()
Definition: GeometryBase.C:16
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2567
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:2594
virtual void finalize() final
Finalize.
Definition: GeometryBase.C:43
std::vector< libMesh::boundary_id_type > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown)
virtual void meshChanged() final
Called on this object when the mesh changes.
Definition: GeometryBase.C:48
MooseMesh & _mesh
Reference to the current simulation mesh.
Definition: GeometryBase.h:43
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
virtual void snapNode(Node &node)=0
Override this method in derived classes to implement a specific geometry.