https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Functions
TheWarehouse.C File Reference

Go to the source code of this file.

Classes

class  WarehouseStorage
 
class  VecStore
 

Functions

bool operator== (const std::unique_ptr< Attribute > &lhs, const std::unique_ptr< Attribute > &rhs)
 TheWarehouse uses this operator function for indexing and caching queries.
 
void isValid (MooseObject *obj)
 
void checkCoupledScalarVariableBlocks (ScalarKernelBase &scalar_kernel)
 Check the scalar variables coupled into a scalar kernel.
 

Function Documentation

◆ checkCoupledScalarVariableBlocks()

void checkCoupledScalarVariableBlocks ( ScalarKernelBase &  scalar_kernel)

Check the scalar variables coupled into a scalar kernel.

The kernel assembles the matrix entries pairing its own variable's dofs with the coupled variable's dofs, and those entries are preallocated only on the elements where both variables exist. A scalar kernel carries no block restriction of its own to compare against, so the condition is a relation between the two variables: they must share at least one block.

Definition at line 307 of file TheWarehouse.C.

308{
309 const auto & var = scalar_kernel.variable();
310 const auto & subdomains = var.activeSubdomains();
311
312 // An empty set of active subdomains means the variable lives on the whole mesh
313 if (subdomains.empty())
314 return;
315
316 for (const MooseVariableScalar * const coupled_var : scalar_kernel.getCoupledMooseScalarVars())
317 {
318 const auto & coupled_subdomains = coupled_var->activeSubdomains();
319 if (coupled_subdomains.empty())
320 continue;
321
322 std::set<SubdomainID> shared_subdomains;
323 std::set_intersection(subdomains.begin(),
324 subdomains.end(),
325 coupled_subdomains.begin(),
326 coupled_subdomains.end(),
327 std::inserter(shared_subdomains, shared_subdomains.begin()));
328
329 if (shared_subdomains.empty())
330 mooseError("The 'block' parameter of the scalar variable '",
331 coupled_var->name(),
332 "' coupled into the object '",
333 scalar_kernel.name(),
334 "' must overlap the 'block' parameter of the variable '",
335 var.name(),
336 "' that the object acts on:\n Variable '",
337 var.name(),
338 "': ",
339 Moose::stringify(subdomains, ", "),
340 "\n Variable '",
341 coupled_var->name(),
342 "': ",
343 Moose::stringify(coupled_subdomains, ", "));
344 }
345}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
const std::set< SubdomainID > & activeSubdomains() const
The subdomains the variable is active on.
Class for scalar variables (they are different).
virtual const MooseVariableScalar & variable() const override
The variable that this kernel operates on.
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:65

Referenced by isValid().

◆ isValid()

void isValid ( MooseObject *  obj)

Definition at line 348 of file TheWarehouse.C.

349{
350 auto blk = dynamic_cast<BlockRestrictable *>(obj);
351 if (!blk)
352 {
353 // Scalar kernels are not block restrictable, so their coupled scalar variables are checked
354 // against the variable the kernel acts on
355 if (auto scalar_kernel = dynamic_cast<ScalarKernelBase *>(obj))
356 checkCoupledScalarVariableBlocks(*scalar_kernel);
357 return;
358 }
359
360 // Check variables
361 auto c_ptr = dynamic_cast<Coupleable *>(obj);
362 if (c_ptr)
363 for (MooseVariableFEBase * var : c_ptr->getCoupledMooseVars())
364 blk->checkVariable(*var);
365
366 // Check scalar variables
367 auto sc_ptr = dynamic_cast<ScalarCoupleable *>(obj);
368 if (sc_ptr)
369 for (MooseVariableScalar * var : sc_ptr->getCoupledMooseScalarVars())
370 blk->checkVariable(*var);
371
372 const InputParameters & parameters = obj->parameters();
373
374 SubProblem & problem = *parameters.get<SubProblem *>("_subproblem");
375
376 THREAD_ID tid = parameters.get<THREAD_ID>("_tid");
377
378 if (parameters.isParamValid("variable"))
379 {
380 // Try the scalar version first
381 std::string variable_name = parameters.getMooseType("variable");
382 if (variable_name == "")
383 // When using vector variables, we are only going to use the first one in the list at the
384 // interface level...
385 variable_name = parameters.getVecMooseType("variable")[0];
386
387 blk->checkVariable(problem.getVariable(
389 }
390}
unsigned int THREAD_ID
Definition MooseTypes.h:237
void checkCoupledScalarVariableBlocks(ScalarKernelBase &scalar_kernel)
Check the scalar variables coupled into a scalar kernel.
An interface that restricts an object to subdomains via the 'blocks' input parameter.
Interface for objects that needs coupling capabilities.
Definition Coupleable.h:53
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class.
std::vector< std::string > getVecMooseType(const std::string &name) const
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
This class provides an interface for common operations on field variables of both FE and FV types wit...
Interface for objects that needs scalar coupling capabilities.
Base class shared by AD and non-AD scalar kernels.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
void checkVariable(const Variable &var, bool expect_vector, const std::string &wrapper_name)
@ VAR_FIELD_ANY
Definition MooseTypes.h:781
@ VAR_ANY
Definition MooseTypes.h:772

Referenced by TheWarehouse::add().

◆ operator==()

bool operator== ( const std::unique_ptr< Attribute > &  lhs,
const std::unique_ptr< Attribute > &  rhs 
)

TheWarehouse uses this operator function for indexing and caching queries.

So this is important even though you don't see it being called (directly) anywhere - it IS being used.

Definition at line 37 of file TheWarehouse.C.

38{
39 return (*lhs) == (*rhs);
40}