https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SignedDistanceToSurfaceMesh.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
12#include "UserObjectBase.h"
13
15
18{
20
21 params.addRequiredParam<UserObjectName>("in_out_test", "The name of the in-out test user object");
22
24 "Returns signed distance to a surface mesh using KDTree nearest neighbor search. "
25 "The gradient returns the unit vector pointing from boundary to query point.");
26 return params;
27}
28
30 : UnsignedDistanceToSurfaceMesh(parameters), _in_out_test(nullptr)
31{
32}
33
34void
36{
37 // Lazy (Deferred) initialization
39 const UserObjectBase & base = getUserObjectBase("in_out_test");
40 _in_out_test = dynamic_cast<const PointInSurfaceCheckInterface *>(&base);
41 if (!_in_out_test)
42 paramError("in_out_test",
43 "'",
44 base.name(),
45 "' (type ",
46 base.type(),
47 ") does not implement the point-in-surface check interface.");
48}
49
50Real
51SignedDistanceToSurfaceMesh::value(Real t, const Point & p) const
52{
53 return UnsignedDistanceToSurfaceMesh::value(t, p) * (_in_out_test->contains(p) ? -1.0 : 1.0);
54}
55
56RealGradient
57SignedDistanceToSurfaceMesh::gradient(Real t, const Point & p) const
58{
60}
const Real p
registerMooseObject("ShiftedBoundaryMethodApp", SignedDistanceToSurfaceMesh)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::string & type() const
const std::string & name() const
void paramError(const std::string &param, Args... args) const
bool contains(const libMesh::Point &p) const
Computes the signed distance to a surface mesh using KDTree nearest neighbor lookup from SBMSurfaceMe...
Real value(Real t, const Point &p) const override
RealGradient gradient(Real t, const Point &p) const override
Return the spatial gradient of the signed distance function.
const PointInSurfaceCheckInterface * _in_out_test
user object for in-out test
SignedDistanceToSurfaceMesh(const InputParameters &parameters)
Computes the unsigned distance to a surface mesh using KDTree nearest neighbor lookup from SBMSurface...
Real value(Real t, const Point &p) const override
Return unsigned distance value.
RealGradient gradient(Real t, const Point &p) const override
Return the spatial gradient of the unsigned distance function.
const UserObjectBase & getUserObjectBase(const std::string &param_name, bool is_dependency=true) const