https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CutMeshByPlaneGenerator.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
12// C++ includes
13#include <cmath>
14
16
19{
21
22 params.addRequiredParam<Point>("plane_point", "A point on the plane.");
23 params.addRequiredParam<Point>("plane_normal", "The normal vector of the plane.");
24
26 "This CutMeshByPlaneGenerator object is designed to trim the input mesh by removing all the "
27 "elements on one side of a given plane with special processing on the elements crossed by "
28 "the cutting plane to ensure a smooth cross-section. The output mesh only consists of TET4 "
29 "elements.");
30
31 return params;
32}
33
36 _plane_point(getParam<Point>("plane_point")),
37 _plane_normal(getParam<Point>("plane_normal").unit())
38{
39 // Translate the plane point and plane normal to the form of the level set function
40 _func_level_set = std::make_shared<SymFunction>();
41 // set FParser internal feature flags
43 // The plane is (x - x0) * n_x + (y - y0) * n_y + (z - z0) * n_z = 0
44 std::stringstream level_set_ss;
45 // Let's be conservative about precision here
46 level_set_ss << std::fixed << std::setprecision(15) << _plane_normal(0) << "*(x-"
47 << _plane_point(0) << ") + " << _plane_normal(1) << "*(y-" << _plane_point(1)
48 << ") + " << _plane_normal(2) << "*(z-" << _plane_point(2) << ")";
49
50 // VERY unlikely to reach this point because we know what we are doing
51 // But just in case
52 if (_func_level_set->Parse(level_set_ss.str(), "x,y,z") >= 0)
53 mooseError("The given plane_point and plane_normal lead to invalid level set.\n",
55 "\nin CutMeshByPlaneGenerator ",
56 name(),
57 ".\n",
58 _func_level_set->ErrorMsg());
59 _func_params.resize(3);
60}
registerMooseObject("MooseApp", CutMeshByPlaneGenerator)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
This CutMeshByLevelSetGeneratorBase object is designed to be the base class of mesh generator that cu...
SymFunctionPtr _func_level_set
function parser object describing the level set
This CutMeshByPlaneGenerator object is designed to trim the input mesh by removing all the elements o...
CutMeshByPlaneGenerator(const InputParameters &parameters)
static InputParameters validParams()
const Point _plane_point
A point on the cutting plane.
const Point _plane_normal
A normal vector of the cutting plane.
std::vector< GenericReal< is_ad > > _func_params
Array to stage the parameters passed to the functions when calling Eval.
void setParserFeatureFlags(SymFunctionPtr &) const
apply input parameters to internal feature flags of the parser object
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
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.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103