https://mooseframework.inl.gov
Loading...
Searching...
No Matches
StoreVariableByElemIDSideUserObject.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#include "THMUtils.h"
12
14
17{
19
20 params.addRequiredCoupledVar("variable", "Variable to store");
22 "Stores variable values at each quadrature point on a side by element ID.");
23
24 return params;
25}
26
28 const InputParameters & parameters)
29 : SideUserObject(parameters),
30
31 _u(adCoupledValue("variable"))
32{
33}
34
35void
40
41void
43{
44 unsigned int n_qp = _qrule->n_points();
45 const auto elem_id = _current_elem->id();
46
47 _elem_id_to_var_values[elem_id].resize(n_qp);
48 for (unsigned int qp = 0; qp < n_qp; qp++)
49 _elem_id_to_var_values[elem_id][qp] = _u[qp];
50}
51
52void
54{
55 const auto & other_uo = static_cast<const StoreVariableByElemIDSideUserObject &>(uo);
56 const auto other_map = other_uo._elem_id_to_var_values;
57 for (auto & it : other_map)
58 _elem_id_to_var_values[it.first] = it.second;
59}
60
61void
66
67const std::vector<ADReal> &
69{
70 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
71
72 auto it = _elem_id_to_var_values.find(elem_id);
73 if (it != _elem_id_to_var_values.end())
74 return it->second;
75 else
77 name(), ": The variable values for element ", elem_id, " were requested but not stored.");
78}
registerMooseObject("ThermalHydraulicsApp", StoreVariableByElemIDSideUserObject)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::string & name() const
void mooseError(Args &&... args) const
static InputParameters validParams()
const QBase *const & _qrule
const Elem *const & _current_elem
Stores variable values at each quadrature point on a side by element ID.
std::map< dof_id_type, std::vector< ADReal > > _elem_id_to_var_values
Map of element ID to variable values at each side quadrature point.
const std::vector< ADReal > & getVariableValues(dof_id_type elem_id) const
Gets the variable values at each quadrature point on the provided element.
virtual void threadJoin(const UserObject &y) override
StoreVariableByElemIDSideUserObject(const InputParameters &parameters)
const Parallel::Communicator & comm() const
void allGatherADVectorMap(const Parallel::Communicator &comm, std::map< dof_id_type, std::vector< ADReal > > &this_map)
Parallel gather of a map of DoF ID to AD vector.
Definition THMUtils.C:47