https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BlockOrientationFromUserObject.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#include "MooseMesh.h"
12#include "Assembly.h"
13#include "MooseVariable.h"
14#include "SystemBase.h"
15#include "libmesh/quadrature.h"
16#include "EulerAngles.h"
17
19
22{
24
25 params.addRequiredParam<UserObjectName>(
26 "block_orientation_uo",
27 "Name of ComputeBlockOrientation user object for updated block orientation.");
28
29 params.addParam<bool>(
30 "degree_to_radian",
31 false,
32 "Whether to convert euler angles from degree to radian. The default is to use degrees.");
33
35 "Output the Euler angle for each block computed from average of quaternions.");
36 return params;
37}
38
40 : GeneralVectorPostprocessor(parameters),
41 _mesh(_subproblem.mesh()),
42 _uo_name(getParam<UserObjectName>("block_orientation_uo")),
43 _num_cols(4), // add one colum for the subdomain ID
44 _num_rows(_mesh.meshSubdomains().size())
45{
47
48 for (const auto j : make_range(_num_cols))
49 {
50 if (j == 0)
51 _output_vector[j] = &declareVector("subdomain_id");
52 else
53 _output_vector[j] = &declareVector("euler_angle_" + std::to_string(j)); // can change
54 }
55
56 _uo = &getUserObjectByName<ComputeBlockOrientationBase>(_uo_name);
57}
58
59void
61{
62 for (const auto j : make_range(_num_cols))
63 {
64 _output_vector[j]->clear();
65 _output_vector[j]->resize(_num_rows, 0.0);
66 }
67}
68
69void
71{
72 // parallel communication
73 for (const auto row : make_range(_num_rows))
74 for (const auto col : make_range(_num_cols))
75 _communicator.max((*_output_vector[col])[row]);
76}
77
78void
80{
81 int row = 0;
82 for (const auto sid : _mesh.meshSubdomains())
83 {
84 // get Euler angle for each subdomain
86
87 // convert EulerAngles to RealVectorValue
88 RealVectorValue euler_angle = (RealVectorValue)ea;
89
90 if (getParam<bool>("degree_to_radian"))
91 euler_angle *= pi / 180.0;
92
93 for (const auto col : make_range(_num_cols))
94 {
95 if (col == 0)
96 (*_output_vector[col])[row] = sid;
97 else
98 (*_output_vector[col])[row] = euler_angle(col - 1);
99 }
100 row++;
101 }
102}
registerMooseObject("SolidMechanicsApp", BlockOrientationFromUserObject)
int _num_rows
Number of rows, representing the number of data entries in the VectorPostprocessor.
const UserObjectName & _uo_name
User object to grab average value from.
MooseMesh & _mesh
Reference to the mesh.
BlockOrientationFromUserObject(const InputParameters &parameters)
const ComputeBlockOrientationBase * _uo
std::vector< VectorPostprocessorValue * > _output_vector
Vector of outputs, where each entry is the vector of average values for single variable in each block...
int _num_cols
Number of columns, representing the number of features in the VectorPostprocessor.
virtual EulerAngles getBlockOrientation(SubdomainID block) const
Given a block ID return the block orientation of that block.
Euler angle triplet.
Definition EulerAngles.h:25
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::set< SubdomainID > & meshSubdomains() const
void max(const T &r, T &o, Request &req) const
VectorPostprocessorValue & declareVector(const std::string &vector_name)
const Parallel::Communicator & _communicator
MeshBase & mesh