Line data Source code
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 : 10 : #include "ShortestDistanceToSurface.h" 11 : #include "SBMUtils.h" 12 : 13 : registerMooseObject("ShiftedBoundaryMethodApp", ShortestDistanceToSurface); 14 : 15 : InputParameters 16 93 : ShortestDistanceToSurface::validParams() 17 : { 18 93 : InputParameters params = ThreadedGeneralUserObject::validParams(); 19 186 : params.addRequiredParam<std::vector<FunctionName>>( 20 : "surfaces", 21 : "Functions defining the surfaces to measure distance to; each must be a ParsedFunction " 22 : "level set or an UnsignedDistanceToSurfaceMesh."); 23 93 : params.addClassDescription( 24 : "Computes the shortest distance vector and true normal to one or more surfaces defined by " 25 : "parsed level-set functions and/or mesh-based distance functions."); 26 93 : return params; 27 0 : } 28 : 29 53 : ShortestDistanceToSurface::ShortestDistanceToSurface(const InputParameters & parameters) 30 53 : : ThreadedGeneralUserObject(parameters) 31 : { 32 106 : const auto function_names = getParam<std::vector<FunctionName>>("surfaces"); 33 53 : _distance_functions = SBMUtils::buildDistanceFunctions(function_names, *this); 34 51 : } 35 : 36 : RealVectorValue 37 1840448 : ShortestDistanceToSurface::distanceVector(const Point & pt) const 38 : { 39 1840448 : return SBMUtils::closestDistanceVector(_distance_functions, pt, _t); 40 : } 41 : 42 : RealVectorValue 43 1024 : ShortestDistanceToSurface::trueNormal(const Point & pt) const 44 : { 45 1024 : return SBMUtils::closestTrueNormalVector(_distance_functions, pt, _t); 46 : } 47 : 48 : RealVectorValue 49 1024 : ShortestDistanceToSurface::distanceVectorByIndex(unsigned int idx, const Point & pt) const 50 : { 51 1024 : const auto & func = _distance_functions.at(idx); 52 1024 : return SBMUtils::distanceVectorFromFunction(func, pt, _t); 53 : } 54 : 55 : RealVectorValue 56 1024 : ShortestDistanceToSurface::trueNormalByIndex(unsigned int idx, const Point & pt) const 57 : { 58 1024 : const auto & func = _distance_functions.at(idx); 59 1024 : return SBMUtils::trueNormalFromFunction(func, pt, _t); 60 : } 61 : 62 : RealVectorValue 63 2144 : ShortestDistanceToSurface::distanceVectorByFunc(const Point & pt, 64 : Real t, 65 : const Function * func) const 66 : { 67 2144 : return SBMUtils::distanceVectorFromFunction(func, pt, t); 68 : } 69 : 70 : RealVectorValue 71 2048 : ShortestDistanceToSurface::trueNormalByFunc(const Point & pt, Real t, const Function * func) const 72 : { 73 2048 : return SBMUtils::trueNormalFromFunction(func, pt, t); 74 : }