https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LoadModelDataAction.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 "Action.h"
13#include "Attributes.h"
16
22template <typename T>
24{
25public:
27
28 LoadModelDataAction(const InputParameters & params) : Action(params) {}
29
30 virtual void act() override;
31
32private:
37 void load(const T & object);
38};
39
40template <typename T>
46
47template <typename T>
48void
50{
51 static_assert(std::is_base_of<RestartableModelInterface, T>::value,
52 "You must derive from RestartableModelInterface to use this action");
53
54 // We fetch the mapping objects and then load the necessary data
55 std::vector<T *> objects;
56 static const auto attribute_name = T::validParams().getSystemAttributeName();
57
58 _app.theWarehouse().query().template condition<AttribSystem>(attribute_name).queryInto(objects);
59 for (auto object_ptr : objects)
60 if (object_ptr->hasModelData())
61 load(*object_ptr);
62}
63
64template <typename T>
65void
67{
68 // Create the object that will load in data
70 _app, _app.getRestartableDataMap(object.modelMetaDataName()), _app.forceRestart());
72
73 // Read the supplied file
74 const std::string filename = object.getModelDataFileName();
75 try
76 {
77 reader.setInput(filename);
78 reader.restore();
79 }
80 catch (...)
81 {
82 paramError("filename", "The supplied file '", filename, "' failed to load.");
83 }
84}
const double T
static InputParameters validParams()
Action for loading the model data for the mapping objects.
virtual void act() override
static InputParameters validParams()
LoadModelDataAction(const InputParameters &params)
void load(const T &object)
Load the necessary information for the given model.
void setErrorOnLoadWithDifferentNumberOfProcessors(bool value)
void restore(const DataNames &filter_names={})
void setInput(std::unique_ptr< std::stringstream > header_stream, std::unique_ptr< std::stringstream > data_stream)