https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
38void
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
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("MooseApp", FVPointValueConstraint)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted,...
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
MooseVariableFV< Real > & _var
const Elem *const & _current_elem
This Kernel implements the residuals that enforce the constraint.
ADReal computeQpResidual() override final
This is the primary function that must be implemented for flux kernel terms.
std::unique_ptr< libMesh::PointLocatorBase > _point_locator
We use a point locator in case the constraint is a point value.
FVPointValueConstraint(const InputParameters &parameters)
const Point _point
The point where the constraint should be enforced.
static InputParameters validParams()
const Elem * _my_elem
Pointer to the element in case we have a point constraint.
Base class for implementing constraints on finite volume variable elemental values using scalar Lagra...
const PostprocessorValue & _phi0
The value that we want the average of the primal variable to be equal to.
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...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
void setDocString(const std::string &name, const std::string &doc)
Set the doc string of a parameter.
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.
MooseMesh & _mesh
Reference to this Kernel's mesh object.
void min(const T &r, T &o, Request &req) const
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
static constexpr dof_id_type invalid_id
const Parallel::Communicator & comm() const
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)
TREE_LOCAL_ELEMENTS