https://mooseframework.inl.gov
FVPointValueConstraint.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 "FVPointValueConstraint.h"
11 
12 #include "MooseVariableScalar.h"
13 #include "MooseVariableFV.h"
14 #include "Assembly.h"
15 
17 
20 {
22  params.addClassDescription("This class is used to enforce integral of phi = volume * phi_0 "
23  "with a Lagrange multiplier approach.");
24  params.setDocString("phi0", "What we want the point value of the primal variable to be.");
25  params.addRequiredParam<Point>(
26  "point", "The XYZ coordinates of the points where the value shall be enforced.");
27  return params;
28 }
29 
32  _point(getParam<Point>("point")),
33  _my_elem(nullptr)
34 {
35  setMyElem();
36 }
37 
38 void
40 {
41  // Find the element containing the point
43  _point_locator->enable_out_of_mesh_mode();
44 
45  // We only check in the restricted blocks, if needed
46  const Elem * elem =
47  blockRestricted() ? (*_point_locator)(_point, &blockIDs()) : (*_point_locator)(_point);
48 
49  // We communicate the results and if there is conflict between processes,
50  // the minimum cell ID is chosen
51  const dof_id_type elem_id = elem ? elem->id() : libMesh::DofObject::invalid_id;
52  dof_id_type min_elem_id = elem_id;
53  _mesh.comm().min(min_elem_id);
54 
55  if (min_elem_id == libMesh::DofObject::invalid_id)
56  mooseError("The specified point for the FVPointValueConstraint is not in the "
57  "domain! Try alleviating block restrictions or "
58  "using another point!");
59 
60  _my_elem = min_elem_id == elem_id ? elem : nullptr;
61 }
62 
63 ADReal
65 {
66  if (_current_elem == _my_elem)
68  else
69  return 0;
70 }
MooseMesh & _mesh
Reference to this Kernel&#39;s mesh object.
void setDocString(const std::string &name, const std::string &doc)
Set the doc string of a parameter.
ADReal computeQpResidual() override final
This is the primary function that must be implemented for flux kernel terms.
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
std::unique_ptr< libMesh::PointLocatorBase > _point_locator
We use a point locator in case the constraint is a point value.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Parallel::Communicator & comm() const
This Kernel implements the residuals that enforce the constraint.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
Base class for implementing constraints on finite volume variable elemental values using scalar Lagra...
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:46
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
Helper method to create an elemental argument for a functor that includes whether to perform skewness...
void min(const T &r, T &o, Request &req) const
const Elem *const & _current_elem
const Elem * _my_elem
Pointer to the element in case we have a point constraint.
static const dof_id_type invalid_id
registerMooseObject("MooseApp", FVPointValueConstraint)
const Point _point
The point where the constraint should be enforced.
FVPointValueConstraint(const InputParameters &parameters)
TREE_LOCAL_ELEMENTS
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
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...
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)
const PostprocessorValue & _phi0
The value that we want the average of the primal variable to be equal to.
uint8_t dof_id_type
MooseVariableFV< Real > & _var