https://mooseframework.inl.gov
NodalWaveSpeed.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 
10 #include "NodalWaveSpeed.h"
11 
12 // MOOSE includes
13 #include "MooseVariable.h"
14 #include "SystemBase.h"
15 
16 #include "libmesh/numeric_vector.h"
17 #include "libmesh/quadrature.h"
18 
19 registerMooseObject("ContactApp", NodalWaveSpeed);
20 
23 {
25  params.set<ExecFlagEnum>("execute_on") = EXEC_LINEAR;
26  params.addClassDescription("Compute the tributary wave speeds for nodes on a surface");
27  return params;
28 }
29 
31  : SideIntegralVariableUserObject(parameters),
32  _phi(_variable->phiFace()),
33  _system(_variable->sys()),
34  _aux_solution(_system.solution()),
35  _wave_speed(getMaterialProperty<Real>("wave_speed"))
36 {
37 }
38 
40 
41 void
43 {
44  const NodalWaveSpeed & na = dynamic_cast<const NodalWaveSpeed &>(fred);
45 
46  std::map<const Node *, Real>::const_iterator it = na._node_wave_speeds.begin();
47  const std::map<const Node *, Real>::const_iterator it_end = na._node_wave_speeds.end();
48  for (; it != it_end; ++it)
49  _node_wave_speeds[it->first] += it->second;
50 }
51 
52 void
54 {
55  _node_wave_speeds.clear();
56 }
57 
58 void
60 {
61  std::vector<Real> node_wave_speeds(_phi.size());
62  for (unsigned qp(0); qp < _qrule->n_points(); ++qp)
63  for (unsigned j(0); j < _phi.size(); ++j)
64  node_wave_speeds[j] += (_phi[j][qp] * _wave_speed[qp]);
65 
66  for (unsigned j(0); j < _phi.size(); ++j)
67  {
68  const Real wave_speed = node_wave_speeds[j];
69  if (wave_speed != 0)
70  _node_wave_speeds[_current_elem->node_ptr(j)] = wave_speed;
71  }
72 }
73 
74 void
76 {
77  const std::map<const Node *, Real>::iterator it_end = _node_wave_speeds.end();
78  for (std::map<const Node *, Real>::iterator it = _node_wave_speeds.begin(); it != it_end; ++it)
79  {
80  const Node * const node = it->first;
81  dof_id_type dof = node->dof_number(_system.number(), _variable->number(), 0);
82  _aux_solution.set(dof, it->second);
83  }
85 }
NumericVector< Number > & _aux_solution
unsigned int number() const
T & set(const std::string &name, bool quiet_mode=false)
virtual void threadJoin(const UserObject &uo)
NodalWaveSpeed(const InputParameters &parameters)
static InputParameters validParams()
const MaterialProperty< Real > & _wave_speed
std::map< const Node *, Real > _node_wave_speeds
unsigned int number() const
MooseVariableFE< Real > * _variable
const ExecFlagType EXEC_LINEAR
virtual void initialize()
SystemBase & _system
virtual void close()=0
virtual ~NodalWaveSpeed()
registerMooseObject("ContactApp", NodalWaveSpeed)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
virtual void set(const numeric_index_type i, const Number value)=0
const Elem *const & _current_elem
const VariablePhiValue & _phi
virtual void execute()
virtual void finalize()
static InputParameters validParams()
uint8_t dof_id_type