Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the Geometry-UOs to MoveNodes meshmodifier #29001

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions framework/doc/content/source/meshmodifiers/MoveNodesToSphere.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# MoveNodesToSphere

!syntax description /UserObjects/MoveNodesToSphere

Moves all nodes from the supplied [!param](/UserObjects/MoveNodesToSphere/boundary) or [!param](/UserObjects/MoveNodesToSphere/block)
to the surface of the sphere specified by the [!param](/UserObjects/MoveNodesToSphere/center) and
[!param](/UserObjects/MoveNodesToSphere/radius) parameters.

This is performed by default during adaptivity to allow adaptive refinement of curved geometries.
It can also be performed using regular execution schedules specified by the [!param](/UserObjects/MoveNodesToSphere/execute_on)
parameter.

!syntax parameters /UserObjects/MoveNodesToSphere

!syntax inputs /UserObjects/MoveNodesToSphere

!syntax children /UserObjects/MoveNodesToSphere
13 changes: 0 additions & 13 deletions framework/doc/content/source/userobjects/GeometrySphere.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
#include "GeneralUserObject.h"

/**
* Base class for userobjects that snap nodes to a defined geometry when
* adaptivity happens.
* Base class for mesh modifiers that snap nodes to a defined geometry either when executed
* or when mesh adaptivity happens
*/
class GeometryBase : public GeneralUserObject
class MoveNodesToGeometryModifierBase : public GeneralUserObject
{
public:
static InputParameters validParams();

GeometryBase(const InputParameters & parameters);
MoveNodesToGeometryModifierBase(const InputParameters & parameters);

virtual void initialize() final;
virtual void execute() final;
Expand All @@ -29,6 +29,9 @@ class GeometryBase : public GeneralUserObject
virtual void meshChanged() final;

protected:
/// Snap all nodes from the specified block or boundary restriction to the derived-class-defined geometry
void snapNodes();

/**
* Override this method in derived classes to implement a specific geometry.
* The method takes a writable reference to a node. Set the position of the
Expand All @@ -39,9 +42,9 @@ class GeometryBase : public GeneralUserObject
/// Reference to the current simulation mesh
MooseMesh & _mesh;

/// List of boundaries (or node sets) that will be snapped to a geometry
/// List of boundaries (or node sets) from which nodes will be snapped to a geometry
const std::vector<BoundaryID> _boundary_ids;

/// List of blocks (likely lower D blocks) that will be snapped to a geometry
/// List of blocks (likely lower D blocks) from which nodes will be snapped to a geometry
const std::vector<SubdomainID> _subdomain_ids;
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@

#pragma once

#include "GeometryBase.h"
#include "MoveNodesToGeometryModifierBase.h"

/**
* Snaps the selected nodes to the surface of a sphere (or circular disk in 2D)
*/
class GeometrySphere : public GeometryBase
class MoveNodesToSphere : public MoveNodesToGeometryModifierBase
{
public:
static InputParameters validParams();

GeometrySphere(const InputParameters & parameters);
MoveNodesToSphere(const InputParameters & parameters);

protected:
virtual void snapNode(Node & node);
virtual void snapNode(Node & node) override;

/// Center of the sphere
const Point _center;
/// Radius of the sphere
const Real _radius;
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "GeometryBase.h"
#include "MoveNodesToGeometryModifierBase.h"
#include "MooseMesh.h"
#include "libmesh/mesh_base.h"

InputParameters
GeometryBase::validParams()
MoveNodesToGeometryModifierBase::validParams()
{
InputParameters params = GeneralUserObject::validParams();
params.addClassDescription(
Expand All @@ -21,10 +21,14 @@ GeometryBase::validParams()
"boundary", {}, "List of boundaries whose nodes are snapped to a given geometry");
params.addParam<std::vector<SubdomainName>>(
"block", {}, "List of blocks whose nodes are snapped to a given geometry");

// By default don't execute
params.set<ExecFlagEnum>("execute_on") = "NONE";

return params;
}

GeometryBase::GeometryBase(const InputParameters & parameters)
MoveNodesToGeometryModifierBase::MoveNodesToGeometryModifierBase(const InputParameters & parameters)
: GeneralUserObject(parameters),
_mesh(_subproblem.mesh()),
_boundary_ids(_mesh.getBoundaryIDs(getParam<std::vector<BoundaryName>>("boundary"))),
Expand All @@ -33,22 +37,29 @@ GeometryBase::GeometryBase(const InputParameters & parameters)
}

void
GeometryBase::initialize()
MoveNodesToGeometryModifierBase::initialize()
{
}

void
MoveNodesToGeometryModifierBase::execute()
{
snapNodes();
}

void
GeometryBase::execute()
MoveNodesToGeometryModifierBase::finalize()
{
}

void
GeometryBase::finalize()
MoveNodesToGeometryModifierBase::meshChanged()
{
snapNodes();
}

void
GeometryBase::meshChanged()
MoveNodesToGeometryModifierBase::snapNodes()
{
auto & mesh = _mesh.getMesh();

Expand Down
39 changes: 39 additions & 0 deletions framework/src/meshmodifiers/MoveNodesToSphere.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "MoveNodesToSphere.h"

registerMooseObject("MooseApp", MoveNodesToSphere);
registerMooseObjectRenamed("MooseApp", GeometrySphere, "06/30/2025 24:00", MoveNodesToSphere);

InputParameters
MoveNodesToSphere::validParams()
{
InputParameters params = MoveNodesToGeometryModifierBase::validParams();
params.addClassDescription(
"Snap nodes to the surface of a sphere either during adaptivity or on execution");
params.addParam<Point>("center", "Sphere center");
params.addParam<Real>("radius", "Sphere radius");
return params;
}

MoveNodesToSphere::MoveNodesToSphere(const InputParameters & parameters)
: MoveNodesToGeometryModifierBase(parameters),
_center(getParam<Point>("center")),
_radius(getParam<Real>("radius"))
{
}

void
MoveNodesToSphere::snapNode(Node & node)
{
const Point o = node - _center;
const Real r = o.norm();
node = o * _radius / r + _center;
}
35 changes: 0 additions & 35 deletions framework/src/userobjects/GeometrySphere.C

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Tests]
design = 'GeometrySphere.md'
design = 'MoveNodesToSphere.md'
[geometrysphere]
type = 'Exodiff'
input = 'geometrysphere.i'
Expand Down