https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DistributionInterface.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#include "InputParameters.h"
13#include "ParallelUniqueId.h"
14#include "MooseObject.h"
15
16// Forward declarations
17class Distribution;
18class FEProblemBase;
19
26{
27public:
29
30 DistributionInterface(const MooseObject * moose_object);
31
32#ifdef MOOSE_KOKKOS_ENABLED
37 const Moose::Kokkos::FunctorCopy & key);
38#endif
39
41
46 const Distribution & getDistribution(const std::string & name) const;
47
48 template <typename T>
49 const T & getDistribution(const std::string & name) const;
51
53
58 const Distribution & getDistributionByName(const DistributionName & name) const;
59
60 template <typename T>
61 const T & getDistributionByName(const std::string & name) const;
63
64private:
67
70
73};
74
75template <typename T>
76const T &
77DistributionInterface::getDistribution(const std::string & name) const
78{
79 try
80 {
81 const T & dist = dynamic_cast<const T &>(getDistribution(name));
82 return dist;
83 }
84 catch (std::bad_cast & exception)
85 {
86 DistributionName dist_name = _dni_params.get<DistributionName>(name);
87 mooseError("The '",
89 "' object failed to retrieve '",
90 dist_name,
91 "' distribution with the desired type.");
92 }
93}
94
95template <typename T>
96const T &
97DistributionInterface::getDistributionByName(const std::string & name) const
98{
99 try
100 {
101 const T & dist = dynamic_cast<const T &>(getDistribution(name));
102 return dist;
103 }
104 catch (std::bad_cast & exception)
105 {
106 mooseError("The '",
108 "' object failed to retrieve '",
109 name,
110 "' distribution with the desired type.");
111 }
112}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Interface for objects that need to use distributions.
const MooseObject *const _dni_moose_object_ptr
Pointer to the MooseObject.
const Distribution & getDistribution(const std::string &name) const
Get a distribution with a given name.
const InputParameters & _dni_params
Parameters of the object with this interface.
FEProblemBase & _dni_feproblem
Reference to FEProblemBase instance.
static InputParameters validParams()
const Distribution & getDistributionByName(const DistributionName &name) const
Get a distribution with a given name.
All Distributions should inherit from this class.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31