https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CheckFVBCAction.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 "CheckFVBCAction.h"
11#include "FEProblem.h"
12#include "NonlinearSystem.h"
13#include "FVFluxBC.h"
14#include "FVDirichletBCBase.h"
15
16registerMooseAction("MooseApp", CheckFVBCAction, "check_integrity");
17
20{
23 "Check that boundary conditions are defined correctly for finite volume problems.");
24 return params;
25}
26
28
29void
31{
32 if (_current_task == "check_integrity" && _problem->fvBCsIntegrityCheck())
33 {
34 // check that boundary conditions follow these rules:
35 // 1. One variable cannot define Dirichlet & Flux BCs
36 // on the same sideset
37 // 2. One variable cannot define more than one Dirichlet BCs
38 // on the same sideset
39 TheWarehouse & the_warehouse = _problem->theWarehouse();
40 for (const auto i : make_range(_problem->numNonlinearSystems()))
41 {
42 const std::vector<MooseVariableFEBase *> & variables =
43 _problem->getNonlinearSystemBase(i).getVariables(0);
44
45 for (auto & var : variables)
46 {
47 if (!var->isFV())
48 continue;
49
50 unsigned int var_num = var->number();
51 std::vector<FVFluxBC *> flux_bcs;
52 std::vector<FVDirichletBCBase *> dirichlet_bcs;
53 the_warehouse.query()
54 .template condition<AttribSystem>("FVFluxBC")
55 .template condition<AttribVar>(var_num)
56 .template condition<AttribThread>(0)
57 .template condition<AttribSysNum>(var->sys().number())
58 .queryInto(flux_bcs);
59
60 the_warehouse.query()
61 .template condition<AttribSystem>("FVDirichletBC")
62 .template condition<AttribVar>(var_num)
63 .template condition<AttribThread>(0)
64 .template condition<AttribSysNum>(var->sys().number())
65 .queryInto(dirichlet_bcs);
66
67 std::set<BoundaryID> all_flux_side_ids;
68 for (auto & fbc : flux_bcs)
69 {
70 const std::set<BoundaryID> & t = fbc->boundaryIDs();
71 all_flux_side_ids.insert(t.begin(), t.end());
72 }
73
74 std::set<BoundaryID> all_dirichlet_side_ids;
75 for (auto & dbc : dirichlet_bcs)
76 {
77 const std::set<BoundaryID> & temp = dbc->boundaryIDs();
78 // check rule #2
79 for (auto & t : temp)
80 if (all_dirichlet_side_ids.find(t) != all_dirichlet_side_ids.end())
82 "Sideset ", t, " defines at least two DirichletBCs for variable ", var->name());
83 all_dirichlet_side_ids.insert(temp.begin(), temp.end());
84 }
85
86 // check rule #1
87 for (auto & t : all_flux_side_ids)
88 if (all_dirichlet_side_ids.find(t) != all_dirichlet_side_ids.end())
90 "Sideset ", t, " defines a FluxBC and a DirichletBC for variable ", var->name());
91 }
92 }
93 }
94}
registerMooseAction("MooseApp", CheckFVBCAction, "check_integrity")
Base class for actions.
Definition Action.h:38
static InputParameters validParams()
Definition Action.C:26
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition Action.h:178
const std::string & _current_task
The current action (even though we have separate instances for each action)
Definition Action.h:172
CheckFVBCAction(const InputParameters &params)
static InputParameters validParams()
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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:271
std::vector< T * > & queryInto(std::vector< T * > &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
TheWarehouse is a container for MooseObjects that allows querying/filtering over various customizeabl...
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse.