https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VariableSizeMaterialPropertiesInterface.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#include "MaterialWarehouse.h"
12
13std::size_t
15 const MaterialPropertyName & prop_name) const
16{
17 mooseError("getVectorPropertySize() is not implemented for the material declaring property '",
18 prop_name,
19 "'");
20}
21
22std::pair<std::size_t, std::size_t>
24 const MaterialPropertyName & prop_name) const
25{
26 mooseError("getMatrixPropertySize() is not implemented for the material declaring property '",
27 prop_name,
28 "'");
29}
30
31void
33 const MaterialWarehouse & warehouse,
34 const std::set<SubdomainID> & blocks,
35 const std::string & param_name,
36 const std::size_t count,
37 const bool is_matrix)
38{
39 const auto & prop_name = object.getParam<MaterialPropertyName>(param_name);
40 for (const auto id : blocks)
41 {
42 if (!warehouse.hasActiveBlockObjects(id))
43 continue;
44 for (const auto & mat : warehouse.getActiveBlockObjects(id))
45 {
46 if (!mat->getSuppliedItems().count(prop_name))
47 continue;
48 const auto * const vsmi =
49 dynamic_cast<const VariableSizeMaterialPropertiesInterface *>(mat.get());
50 if (!vsmi)
51 continue;
52
53 if (is_matrix)
54 {
55 const auto [rows, cols] = vsmi->getMatrixPropertySize(prop_name);
56 if (rows != count || cols != count)
57 object.paramError(param_name,
58 "The size (",
59 rows,
60 "x",
61 cols,
62 ") of material property '",
63 prop_name,
64 "' declared by material '",
65 mat->name(),
66 "' is inconsistent with the number of components of the array "
67 "variable (",
68 count,
69 ")");
70 }
71 else
72 {
73 const auto size = vsmi->getVectorPropertySize(prop_name);
74 if (size != count)
75 object.paramError(param_name,
76 "The size (",
77 size,
78 ") of material property '",
79 prop_name,
80 "' declared by material '",
81 mat->name(),
82 "' is inconsistent with the number of components of the array "
83 "variable (",
84 count,
85 ")");
86 }
87 }
88 }
89}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int count
Definition MortarUtils.C:53
char ** blocks
MaterialBase objects are special in that they have additional objects created automatically (see FEPr...
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
bool hasActiveBlockObjects(THREAD_ID tid=0) const
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
Interface class to return the size of material properties that do not have a fixed size.
virtual std::size_t getVectorPropertySize(const MaterialPropertyName &prop_name) const
Return the size of the variable size vector material property that the material defines.
virtual std::pair< std::size_t, std::size_t > getMatrixPropertySize(const MaterialPropertyName &prop_name) const
Return the number of rows and columns of the variable size matrix material property that the material...
void checkArrayMaterialPropertySize(const MooseObject &object, const MaterialWarehouse &warehouse, const std::set< SubdomainID > &blocks, const std::string &param_name, std::size_t count, bool is_matrix)
Check during setup that an array material property used as a coefficient has one entry per component ...