https://mooseframework.inl.gov
SideValueSampler.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 "SideValueSampler.h"
11 
12 // MOOSE includes
13 #include "MooseVariableFE.h"
14 
15 #include "libmesh/quadrature.h"
16 
18 
21 {
23  params += SamplerBase::validParams();
24  params.addClassDescription("Sample variable(s) along a sideset, internal or external.");
25  params.addRequiredCoupledVar(
26  "variable", "The names of the variables that this VectorPostprocessor operates on");
27 
28  return params;
29 }
30 
32  : SideVectorPostprocessor(parameters),
33  SamplerBase(parameters, this, _communicator),
34  _qp_sampling(true)
35 {
36  std::vector<std::string> var_names(_coupled_moose_vars.size());
37  _values.resize(_coupled_moose_vars.size());
38 
39  for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
40  {
41  var_names[i] = _coupled_moose_vars[i]->name();
43  }
44 
46  {
47  const auto num_fv_vars =
49  if (num_fv_vars != _coupled_moose_vars.size())
50  paramError(
51  "variable",
52  "This object cannot accept mixed FE and FV variables, please make "
53  "sure all the provided variables are either FE or FV by separating this vector "
54  "postprocessor "
55  "into two blocks, one for finite element and another for finite volume variables!");
56 
57  for (const auto var : _coupled_standard_fv_moose_vars)
58  _fv_vars.push_back(dynamic_cast<const MooseVariableField<Real> *>(var));
59  for (const auto var : _coupled_standard_linear_fv_moose_vars)
60  _fv_vars.push_back(dynamic_cast<const MooseVariableField<Real> *>(var));
61 
62  _qp_sampling = false;
63  }
64 
65  // Initialize the data structures in SamplerBase
66  SamplerBase::setupVariables(var_names);
67 }
68 
69 void
71 {
73 }
74 
75 void
77 {
78  if (_qp_sampling)
79  for (unsigned int _qp = 0; _qp < _qrule->n_points(); _qp++)
80  {
81  for (unsigned int i = 0; i < _coupled_moose_vars.size(); i++)
82  _values[i] = (dynamic_cast<MooseVariable *>(_coupled_moose_vars[i]))->sln()[_qp];
83 
85  }
86  else
87  {
88  getFaceInfos();
89 
90  const auto state = determineState();
91 
92  for (const auto & fi : _face_infos)
93  {
94  for (unsigned int i = 0; i < _fv_vars.size(); i++)
95  {
96  mooseAssert(_fv_vars[i]->hasFaceSide(*fi, true) || _fv_vars[i]->hasFaceSide(*fi, false),
97  "Variable " + _fv_vars[i]->name() +
98  " should be defined on one side of the face!");
99 
100  const auto * elem = _fv_vars[i]->hasFaceSide(*fi, true) ? fi->elemPtr() : fi->neighborPtr();
101 
102  const auto face_arg = Moose::FaceArg(
103  {fi, Moose::FV::LimiterType::CentralDifference, true, false, elem, nullptr});
104  _values[i] = MetaPhysicL::raw_value((*_fv_vars[i])(face_arg, state));
105  }
106 
107  SamplerBase::addSample(fi->faceCentroid(), _current_elem->id(), _values);
108  }
109  }
110 }
111 
112 void
114 {
116 }
117 
118 void
120 {
121  const auto & vpp = static_cast<const SideValueSampler &>(y);
122 
124 }
Base class for VectorPostprocessors that need to do "sampling" of values in the domain.
Definition: SamplerBase.h:37
virtual void initialize()
Initialize the datastructures.
Definition: SamplerBase.C:86
std::vector< MooseVariableFV< Real > * > _coupled_standard_fv_moose_vars
Vector of standard finite volume coupled variables.
Definition: Coupleable.h:1424
SideValueSampler(const InputParameters &parameters)
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
std::vector< Real > _values
So we don&#39;t have to create and destroy this vector over and over again.
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
const MooseArray< Point > & _q_point
virtual void finalize() override
Finalize the values.
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
std::vector< const FaceInfo * > _face_infos
Holds the FaceInfos to loop on to consider all active neighbors of an element on a given side...
void setupVariables(const std::vector< std::string > &variable_names)
You MUST call this in the constructor of the child class and pass down the name of the variables...
Definition: SamplerBase.C:60
A structure defining a "face" evaluation calling argument for Moose functors.
unsigned int _qp
virtual void threadJoin(const SamplerBase &y)
Join the values.
Definition: SamplerBase.C:225
void getFaceInfos()
Computes the local FaceInfo(s) to use in functor arguments and interpolations.
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
static InputParameters validParams()
Definition: SamplerBase.C:27
registerMooseObject("MooseApp", SideValueSampler)
std::vector< MooseVariableFieldBase * > _coupled_moose_vars
Vector of all coupled variables.
Definition: Coupleable.h:1412
virtual void finalize()
Finalize the values.
Definition: SamplerBase.C:159
virtual void addSample(const Point &p, const Real &id, const std::vector< Real > &values)
Call this with the value of every variable at each point you want to sample at.
Definition: SamplerBase.C:70
const QBase *const & _qrule
std::vector< MooseLinearVariableFV< Real > * > _coupled_standard_linear_fv_moose_vars
Vector of standard linear finite volume coupled variables.
Definition: Coupleable.h:1427
virtual void threadJoin(const UserObject &y) override
Must override.
virtual void execute() override
Execute method.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
bool _qp_sampling
Whether to sample over side quadrature points or FaceInfos.
const Elem *const & _current_elem
void checkForStandardFieldVariableType(const MooseVariableFieldBase *const var_ptr, const std::string &var_param_name="variable") const
Checks whether the passed variable pointer corresponds to a regular single-valued field variable...
Definition: SamplerBase.C:132
virtual void initialize() override
Initialize the datastructures.
std::vector< const MooseVariableField< Real > * > _fv_vars
Pointers to the FV variables to sample (if any)
Base class for user-specific data.
Definition: UserObject.h:40