https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DomainUserObject.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 "DomainUserObject.h"
11#include "MooseVariableFE.h"
12#include "SubProblem.h"
13#include "Assembly.h"
14
17{
23 params.addParam<std::vector<BoundaryName>>(
24 "interface_boundaries", "The interface boundaries on which this object will execute");
25 // Need one layer of ghosting
26 params.addRelationshipManager("ElementSideNeighborLayers",
29 return params;
30}
31
33 : UserObject(parameters),
35 ThreeMaterialPropertyInterface(this, blockIDs(), Moose::EMPTY_BOUNDARY_IDS),
38 RandomInterface(parameters, _fe_problem, _tid, false),
40 _mesh(_subproblem.mesh()),
41 _current_elem(_assembly.elem()),
42 _current_elem_volume(_assembly.elemVolume()),
43 _current_side(_assembly.side()),
44 _current_side_elem(_assembly.sideElem()),
45 _current_side_volume(_assembly.sideElemVolume()),
46 _neighbor_elem(_assembly.neighbor()),
47 _current_neighbor_volume(_assembly.neighborVolume()),
48 _current_boundary_id(_assembly.currentBoundaryID()),
49 _normals(_assembly.normals()),
50 _q_point(_assembly.qPoints()),
51 _qrule(_assembly.qRule()),
52 _JxW(_assembly.JxW()),
53 _q_point_face(_assembly.qPointsFace()),
54 _qrule_face(_assembly.qRuleFace()),
55 _JxW_face(_assembly.JxWFace()),
56 _coord(_assembly.coordTransformation())
57{
58 if (isParamValid("interface_boundaries"))
59 {
60 const auto & interface_boundaries = getParam<std::vector<BoundaryName>>("interface_boundaries");
61 _interface_bnd_ids = MooseMeshUtils::getBoundaryIDSet(_mesh, interface_boundaries, false);
62
63 for (const auto interface_bnd_id : _interface_bnd_ids)
64 {
65 // check on which side the interface is connected with the subdomain of this domain user
66 // object
67 const auto & primary_connected_blocks = _mesh.getBoundaryConnectedBlocks(interface_bnd_id);
68 bool has_full_primary_connection = true;
69 for (const auto interface_connected_block : primary_connected_blocks)
70 if (!hasBlocks(interface_connected_block))
71 has_full_primary_connection = false;
72
73 const auto & secondary_connected_blocks =
75 bool has_full_secondary_connection = true;
76 for (const auto interface_connected_block : secondary_connected_blocks)
77 if (!hasBlocks(interface_connected_block))
78 has_full_secondary_connection = false;
79
80 // we push the subdomains on the other side for the interface
81 if (has_full_primary_connection)
82 _interface_connected_blocks[interface_bnd_id] = secondary_connected_blocks;
83 else if (has_full_secondary_connection)
84 _interface_connected_blocks[interface_bnd_id] = primary_connected_blocks;
85 else
86 paramError("interface_boundaries",
87 "Not all sides in the interface with ID ",
88 interface_bnd_id,
89 " is connected with the domain of the domain user object ",
90 name());
91 }
92 }
93}
94
96DomainUserObject::getInterfaceFieldVar(const std::string & var_name,
97 const unsigned int comp,
98 const std::set<BoundaryID> * interfaces)
99{
100 const auto * const field_var = getFieldVar(var_name, comp);
101 mooseAssert(field_var, "We should not be able to return a null variable");
102 if (interfaces)
103 _var_interfaces[field_var->name()] = *interfaces;
104 else
105 _var_interfaces[field_var->name()] = _interface_bnd_ids;
106 return field_var;
107}
108
109void
111{
112 auto it = _var_interfaces.find(variable.name());
113 if (it != _var_interfaces.end())
114 {
115 // we could have done this check in the constructor but to be consistent with other block
116 // restrictable checks, we'll do it here
117 auto & bnd_ids = it->second;
118 for (const auto bnd_id : bnd_ids)
119 {
120 const auto & connected_blocks = libmesh_map_find(_interface_connected_blocks, bnd_id);
121 for (const auto & bid : connected_blocks)
122 if (!variable.hasBlocks(bid))
123 mooseError("Variable '",
124 variable.name(),
125 "' is not defined on the interface connected block '",
127 "'");
128 }
129 }
130 else
132}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
An interface that restricts an object to subdomains via the 'blocks' input parameter.
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
virtual void checkVariable(const MooseVariableFieldBase &variable) const
Helper for checking that the ids for this object are in agreement with the variables on the supplied ...
static InputParameters validParams()
const MooseVariableFieldBase * getFieldVar(const std::string &var_name, unsigned int comp) const
Definition Coupleable.C:307
std::set< BoundaryID > _interface_bnd_ids
The set of boundary IDs on which this object should perform executeOnInterface.
std::map< VariableName, std::set< BoundaryID > > _var_interfaces
A map storing the set of boundaries where variables we wish to evaluate.
std::map< BoundaryID, std::set< SubdomainID > > _interface_connected_blocks
The set of blocks connected to our blocks through boundaries of the _interface_bnd_ids data member.
void checkVariable(const MooseVariableFieldBase &variable) const override
Helper for checking that the ids for this object are in agreement with the variables on the supplied ...
DomainUserObject(const InputParameters &parameters)
MooseMesh & _mesh
the Moose mesh
static InputParameters validParams()
const MooseVariableFieldBase * getInterfaceFieldVar(const std::string &var_name, unsigned int comp, const std::set< BoundaryID > *interfaces=nullptr)
Routes through to Coupleable::getFieldVar, but also inserts the return variable into a set of field v...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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 ...
Definition MooseBase.h:457
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
std::set< SubdomainID > getBoundaryConnectedSecondaryBlocks(const BoundaryID bid) const
Get the list of subdomains associated with the given boundary of its secondary side.
Definition MooseMesh.C:3633
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
Definition MooseMesh.C:1751
std::set< SubdomainID > getBoundaryConnectedBlocks(const BoundaryID bid) const
Get the list of subdomains associated with the given boundary.
Definition MooseMesh.C:3622
This class provides an interface for common operations on field variables of both FE and FV types wit...
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
Interface for objects that need parallel consistent random numbers without patterns over the course o...
static InputParameters validParams()
This interface is designed currently for DomainUserObject where material properties on element,...
Interface for objects that needs transient capabilities.
static InputParameters validParams()
Base class for user-specific data.
Definition UserObject.h:20
static InputParameters validParams()
Definition UserObject.C:14
MeshBase & mesh
std::set< BoundaryID > getBoundaryIDSet(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown)
Gets the boundary IDs into a set with their names.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...