Chi-Tech
FieldFunctionInterface.cc
Go to the documentation of this file.
2
4
5#include "chi_runtime.h"
6#include "chi_log.h"
7
8namespace chi_physics
9{
10
12{
14
15 params.AddRequiredParameterBlock("field_function",
16 "Field function handle or name.");
17 params.SetParameterTypeMismatchAllowed("field_function");
18
19 return params;
20}
21
23 const chi::InputParameters& params)
24 : field_function_param_(params.GetParam("field_function"))
25{
26}
27
29{
30 std::shared_ptr<chi_physics::FieldFunction> ref_ff_ptr = nullptr;
32 {
33 const auto name = field_function_param_.GetValue<std::string>();
34 for (const auto& ff_ptr : Chi::field_function_stack)
35 if (ff_ptr->TextName() == name) ref_ff_ptr = ff_ptr;
36
37 ChiInvalidArgumentIf(ref_ff_ptr == nullptr,
38 "Field function \"" + name + "\" not found.");
39 }
41 {
42 const auto handle = field_function_param_.GetValue<size_t>();
43 ref_ff_ptr = Chi::GetStackItemPtrAsType<chi_physics::FieldFunction>(
44 Chi::field_function_stack, handle, __FUNCTION__);
45 }
46 else
47 ChiInvalidArgument("Argument can only be STRING or INTEGER");
48
49 return &(*ref_ff_ptr);
50}
51
52} // namespace chi_physics
#define ChiInvalidArgumentIf(condition, message)
#define ChiInvalidArgument(message)
static std::vector< chi_physics::FieldFunctionPtr > field_function_stack
Definition: chi_runtime.h:92
void SetParameterTypeMismatchAllowed(const std::string &param_name)
Sets a tag for the given parameter that will allow its type to be mismatched upon assignment.
void AddRequiredParameterBlock(const std::string &name, const std::string &doc_string)
ParameterBlockType Type() const
FieldFunctionInterface(const chi::InputParameters &params)
static chi::InputParameters GetInputParameters()