https://mooseframework.inl.gov
TestFaceToCellReconstruction.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 // MOOSE includes
13 #include "MooseMesh.h"
14 #include "Assembly.h"
15 
17 
20 {
22  params.addClassDescription("Computes reconstruction error for face centered functor.");
23  return params;
24 }
25 
27  : GeneralPostprocessor(parameters),
28  _reconstruction_error(0.0),
29  _face_values(_subproblem.mesh(), _subproblem.mesh().meshSubdomains(), "face_values")
30 {
31 }
32 
33 void
35 {
36  const auto state = determineState();
37 
38  for (auto & fi : _fe_problem.mesh().faceInfo())
39  {
40  const auto & face_center = fi->faceCentroid();
41  RealVectorValue face_value(
42  -sin(face_center(0)) * cos(face_center(1)), cos(face_center(0)) * sin(face_center(1)), 0);
43  _face_values[fi->id()] = face_value;
44  }
45 
46  // Loop over the local elements if we have distributed tests
47  for (const Elem * elem : _fe_problem.mesh().getMesh().active_local_element_ptr_range())
48  {
49  const auto elem_arg = makeElemArg(elem);
50  const Point & elem_centroid = _fe_problem.mesh().elemInfo(elem->id()).centroid();
51  const Real elem_volume = this->_assembly.elementVolume(elem);
52 
53  RealVectorValue exact_value(-sin(elem_centroid(0)) * cos(elem_centroid(1)),
54  cos(elem_centroid(0)) * sin(elem_centroid(1)),
55  0);
56 
57  RealVectorValue diff = exact_value - _face_values(elem_arg, state);
58  _reconstruction_error += diff * diff * elem_volume;
59  }
60 
61  // We collect and sum the values across every process
63 
65 }
66 
69 {
70  return _reconstruction_error;
71 }
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
Moose::StateArg determineState() const
MeshBase & mesh
registerMooseObject("NavierStokesTestApp", TestFaceToCellReconstruction)
Number exact_value(const Point &p, const Parameters &parameters, const std::string &, const std::string &)
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
static InputParameters validParams()
const std::vector< const FaceInfo *> & faceInfo() const
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
void gatherSum(T &value)
MeshBase & getMesh()
Real elementVolume(const Elem *elem) const
virtual PostprocessorValue getValue() const override final
TestFaceToCellReconstruction(const InputParameters &parameters)
Real PostprocessorValue
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _face_values
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
FEProblemBase & _fe_problem
virtual MooseMesh & mesh() override
void addClassDescription(const std::string &doc_string)
const ElemInfo & elemInfo(const dof_id_type id) const