https://mooseframework.inl.gov
Loading...
Searching...
No Matches
EulerAngleUpdateFromReporter.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://www.mooseframework.org
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
11
12#include <fstream>
13
15
18{
20 params.addClassDescription("Update Euler angle from reporter value.");
22 "euler_angle_0_name",
23 "reporter name for the first component of the Euler angles in degrees. This "
24 "parameter uses the reporter syntax <reporter>/<name>.");
26 "euler_angle_1_name",
27 "reporter name for the second component of the Euler angles in degrees. This "
28 "parameter uses the reporter syntax <reporter>/<name>.");
30 "euler_angle_2_name",
31 "reporter name for the third component of the Euler angles in degrees. This "
32 "parameter uses the reporter syntax <reporter>/<name>.");
33 params.addRequiredParam<ReporterName>("grain_id_name",
34 "reporter name for the grain IDs. This "
35 "parameter uses the reporter syntax <reporter>/<name>.");
36 return params;
37}
38
40 : EulerAngleFileReader(params),
41 _euler_angle_0(
42 getReporterValue<std::vector<Real>>("euler_angle_0_name", REPORTER_MODE_REPLICATED)),
43 _euler_angle_1(
44 getReporterValue<std::vector<Real>>("euler_angle_1_name", REPORTER_MODE_REPLICATED)),
45 _euler_angle_2(
46 getReporterValue<std::vector<Real>>("euler_angle_2_name", REPORTER_MODE_REPLICATED)),
47 _grain_id(getReporterValue<std::vector<Real>>("grain_id_name", REPORTER_MODE_REPLICATED)),
48 _first_time(true)
49{
50}
51
52void
54{
55 // only update Euler angles info from the reporter when the initial Euler angle has been read from
56 // file
57 if (_first_time)
58 {
59 _angles.clear();
61 _first_time = false;
62 }
63 else
65}
66
67void
69{
70 // check sizes of the containers
71 if (_grain_id.size() != _euler_angle_0.size() || _grain_id.size() != _euler_angle_1.size() ||
72 _grain_id.size() != _euler_angle_2.size())
73 paramError("grain_id_name", "Number of reporters' entries do not match.");
74
75 // Note here the size of the `_angles` and `_grain_id` can differ, as we resize the `_angles`
76 // container based on the largest grain ID. This can be improved by having `_angles` as a
77 // unordered_map which stores grain ID and EulerAngles pairs.
78
79 // zip the grain id with the euler angles
80 std::map<int, EulerAngles> ea_data;
81 for (const auto i : index_range(_grain_id))
82 {
83 unsigned int gid = (unsigned int)(_grain_id[i]);
85 }
86
87 // re-assign euler angles based on the new data
88 auto max_grain_id = ea_data.rbegin()->first;
89 _angles.clear();
90 _angles.resize(max_grain_id + 1); // make sure _angles[max_grain_id] is valid
91
92 for (const auto it : ea_data)
93 {
94 _angles[it.first] = it.second;
95 }
96}
registerMooseObject("SolidMechanicsApp", EulerAngleUpdateFromReporter)
const ReporterMode REPORTER_MODE_REPLICATED
void ErrorVector unsigned int
Read a set of Euler angles from a file.
static InputParameters validParams()
std::vector< EulerAngles > & _angles
Update Euler angle from reporter value.
const std::vector< Real > & _grain_id
Corresponding grain IDs - it is of Real type from reporter.
const std::vector< Real > & _euler_angle_2
const std::vector< Real > & _euler_angle_1
EulerAngleUpdateFromReporter(const InputParameters &parameters)
const std::vector< Real > & _euler_angle_0
Euler angles' components for every grain.
Euler angle triplet.
Definition EulerAngles.h:25
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const