https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TorchKernel.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 <torch/torch.h>
15
16// MOOSE includes
17#include "GeneralUserObject.h"
18#include "TorchAssembly.h"
20
37{
38public:
40
42
43 void initialize() override {}
44 void execute() override;
45 void finalize() override {}
46
47protected:
49 virtual void forward() = 0;
50
53
57
59 at::Tensor _output;
60};
61
62#endif // MOOSE_LIBTORCH_ENABLED
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
This user object caches assembly information (JxWxT) from MOOSE as a batched at::Tensor for the Torch...
This user object serves as the "interface" for interpolating MOOSE variable values and gradients from...
TorchKernel is a conceptual extension of a MOOSE kernel that operates on batched libtorch tensors.
Definition TorchKernel.h:37
TorchFEInterpolation & _fe
The FEM interface for getting variable values/gradients interpolated onto the finite element space.
Definition TorchKernel.h:56
void execute() override
Execute method.
Definition TorchKernel.C:36
void finalize() override
Finalize.
Definition TorchKernel.h:45
static InputParameters validParams()
Definition TorchKernel.C:16
at::Tensor _output
The output of the forward operator.
Definition TorchKernel.h:59
void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition TorchKernel.h:43
virtual void forward()=0
The forward operator of this kernel.
TorchAssembly & _assembly
The assembly object with cached assembly information.
Definition TorchKernel.h:52