https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComputeGrainCenterUserObject.C
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
11
12#include "libmesh/quadrature.h"
13
16{
18 params.addClassDescription("Userobject for calculating the grain volumes and grain centers");
19 params.addRequiredCoupledVarWithAutoBuild("etas", "var_name_base", "op_num", "order parameters");
20 return params;
21}
22
24 : ElementUserObject(parameters),
25 _ncrys(coupledComponents("etas")), // determine number of grains from the number of names passed
26 // in. Note this is the actual number -1
27 _vals(coupledValues("etas")),
28 _ncomp(4 * _ncrys),
29 _grain_data(_ncomp),
30 _grain_volumes(_ncrys),
31 _grain_centers(_ncrys)
32{
33}
34
35void
37{
38 for (unsigned int i = 0; i < _ncomp; ++i)
39 _grain_data[i] = 0;
40}
41
42void
44{
45 for (unsigned int i = 0; i < _ncrys; ++i)
46 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
47 {
48 _grain_data[4 * i + 0] += _JxW[_qp] * _coord[_qp] * (*_vals[i])[_qp];
49 _grain_data[4 * i + 1] += _JxW[_qp] * _coord[_qp] * _q_point[_qp](0) * (*_vals[i])[_qp];
50 _grain_data[4 * i + 2] += _JxW[_qp] * _coord[_qp] * _q_point[_qp](1) * (*_vals[i])[_qp];
51 _grain_data[4 * i + 3] += _JxW[_qp] * _coord[_qp] * _q_point[_qp](2) * (*_vals[i])[_qp];
52 }
53}
54
55void
57{
59
60 for (unsigned int i = 0; i < _ncrys; ++i)
61 {
62 _grain_volumes[i] = _grain_data[4 * i + 0];
63 _grain_centers[i](0) = _grain_data[4 * i + 1] / _grain_volumes[i];
64 _grain_centers[i](1) = _grain_data[4 * i + 2] / _grain_volumes[i];
65 _grain_centers[i](2) = _grain_data[4 * i + 3] / _grain_volumes[i];
66 }
67}
68
69void
71{
72 const auto & pps = static_cast<const ComputeGrainCenterUserObject &>(y);
73 for (unsigned int i = 0; i < _ncomp; ++i)
74 _grain_data[i] += pps._grain_data[i];
75}
76
77const std::vector<Real> &
82
83const std::vector<Point> &
const std::vector< double > y
This UserObject computes a volumes and centers of grains.
ComputeGrainCenterUserObject(const InputParameters &parameters)
virtual void threadJoin(const UserObject &y)
const std::vector< Real > & getGrainVolumes() const
const std::vector< Point > & getGrainCenters() const
std::vector< Real > _grain_data
storing volumes and centers of all the grains
const std::vector< const VariableValue * > _vals
static InputParameters validParams()
const QBase *const & _qrule
const MooseArray< Real > & _coord
const MooseArray< Real > & _JxW
const MooseArray< Point > & _q_point
void addClassDescription(const std::string &doc_string)
void addRequiredCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
void gatherSum(T &value)