https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TorchScript1DProfileFunctorMaterial.h
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
10#pragma once
11
12#ifdef MOOSE_LIBTORCH_ENABLED
13
14#include "FunctorMaterial.h"
15#include "LinearInterpolation.h"
17
18#include <memory>
19#include <set>
20#include <vector>
21
44{
45public:
47
49
50 virtual void initialSetup() override;
51 virtual void timestepSetup() override;
52
53protected:
59 void updateProfiles();
60
64 torch::Tensor buildInputTensor() const;
65
69 Real sampleProfile(unsigned int profile_index, const Point & point) const;
70
73
75 const std::vector<PostprocessorName> _input_names;
76
78 const std::vector<Real> _input_values;
79
81 std::vector<const PostprocessorValue *> _postprocessor_inputs;
82
84 const std::vector<MooseFunctorName> _profile_names;
85
87 const std::vector<Real> _profile_coordinates;
88
90 const Point _profile_origin;
91
93 RealVectorValue _profile_direction;
94
97
100
103
107 const std::set<ExecFlagType> _profile_update_schedule;
108
110 std::vector<std::unique_ptr<LinearInterpolation>> _profiles;
111};
112
113#endif
const InputParameters & parameters() const
Evaluates a TorchScript model on the schedule given by the execute_on parameter (default: once,...
const std::vector< PostprocessorName > _input_names
Postprocessor-based model inputs.
void updateProfiles()
Evaluate the TorchScript model once and (re)build every profile interpolator in _profiles.
const TorchScriptUserObject & _torch_script_userobject
Existing MOOSE object that owns and evaluates the TorchScript module.
const std::vector< Real > _profile_coordinates
Coordinates at which the model output values are defined.
const std::vector< MooseFunctorName > _profile_names
Names assigned to the output profile functors.
RealVectorValue _profile_direction
Unit direction of increasing profile coordinate.
const Point _profile_origin
Physical origin of the one-dimensional profile coordinate.
std::vector< const PostprocessorValue * > _postprocessor_inputs
References to postprocessor values, populated when input_names is used.
const std::set< ExecFlagType > _profile_update_schedule
Execute flags on which updateProfiles() re-runs inference.
const MooseEnum _out_of_range_behavior
error, clamp, or extrapolate
Real sampleProfile(unsigned int profile_index, const Point &point) const
Evaluate a cached profile at a physical point.
const Real _coordinate_scale
Physical distance corresponding to one profile-coordinate unit.
torch::Tensor buildInputTensor() const
Construct the model input tensor.
const std::vector< Real > _input_values
Direct constant model inputs.
std::vector< std::unique_ptr< LinearInterpolation > > _profiles
Cached interpolator for each model output channel.