Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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 "KokkosMaterial.h" 11 : 12 : namespace Moose::Kokkos 13 : { 14 : 15 : InputParameters 16 39308 : Material::validParams() 17 : { 18 39308 : InputParameters params = MaterialBase::validParams(); 19 39308 : params += MaterialPropertyInterface::validParams(); 20 117924 : params.addParamNamesToGroup("use_displaced_mesh", "Advanced"); 21 39308 : return params; 22 0 : } 23 : 24 2768 : Material::Material(const InputParameters & parameters) 25 : : MaterialBase(parameters), 26 : Coupleable(this, false), 27 : MaterialPropertyInterface(this, blockIDs(), boundaryIDs()), 28 1566 : _bnd(_material_data_type != Moose::BLOCK_MATERIAL_DATA), 29 1566 : _neighbor(_material_data_type == Moose::NEIGHBOR_MATERIAL_DATA), 30 1579 : _qrule(_bnd ? (_neighbor ? _subproblem.assembly(_tid, 0).qRuleNeighbor() 31 532 : : _subproblem.assembly(_tid, 0).qRuleFace()) 32 1566 : : _subproblem.assembly(_tid, 0).qRule()) 33 : { 34 3101 : for (auto coupled_var : getCoupledMooseVars()) 35 333 : addMooseVariableDependency(coupled_var); 36 2768 : } 37 : 38 87859 : Material::Material(const Material & object) 39 : : MaterialBase(object), 40 : Coupleable(object, {}), 41 : MaterialPropertyInterface(object, {}), 42 49327 : _bnd(object._bnd), 43 49327 : _neighbor(object._neighbor), 44 49327 : _qrule(object._qrule) 45 : { 46 87859 : } 47 : 48 : void 49 3208 : Material::initStatefulProperties(unsigned int) 50 : { 51 3208 : if ((!_bnd && !_neighbor) || _constant_option == PropertyConstantOption::SUBDOMAIN) 52 : { 53 1128 : if (!DispatcherRegistry::hasUserMethod<ElementInit>(type())) 54 685 : return; 55 : 56 443 : Policy policy(0, numKokkosElements()); 57 : 58 443 : if (!_init_dispatcher) 59 248 : _init_dispatcher = DispatcherRegistry::build<ElementInit>(this, type()); 60 : 61 443 : _init_dispatcher->parallelFor(policy); 62 443 : } 63 2080 : else if (_bnd && !_neighbor) 64 : { 65 1054 : if (!DispatcherRegistry::hasUserMethod<SideInit>(type())) 66 581 : return; 67 : 68 473 : Policy policy(0, numKokkosElementSides()); 69 : 70 473 : if (!_init_dispatcher) 71 263 : _init_dispatcher = DispatcherRegistry::build<SideInit>(this, type()); 72 : 73 473 : _init_dispatcher->parallelFor(policy); 74 473 : } 75 : else 76 : { 77 1026 : if (!DispatcherRegistry::hasUserMethod<NeighborInit>(type())) 78 583 : return; 79 : 80 443 : Policy policy(0, numKokkosElementSides()); 81 : 82 443 : if (!_init_dispatcher) 83 248 : _init_dispatcher = DispatcherRegistry::build<NeighborInit>(this, type()); 84 : 85 443 : _init_dispatcher->parallelFor(policy); 86 443 : } 87 : } 88 : 89 : void 90 84002 : Material::computeProperties() 91 : { 92 84002 : if ((!_bnd && !_neighbor) || _constant_option == PropertyConstantOption::SUBDOMAIN) 93 : { 94 28450 : Policy policy(0, numKokkosElements()); 95 : 96 28450 : if (!_compute_dispatcher) 97 634 : _compute_dispatcher = DispatcherRegistry::build<ElementCompute>(this, type()); 98 : 99 28450 : _compute_dispatcher->parallelFor(policy); 100 28450 : } 101 55552 : else if (_bnd && !_neighbor) 102 : { 103 28452 : Policy policy(0, numKokkosElementSides()); 104 : 105 28452 : if (!_compute_dispatcher) 106 561 : _compute_dispatcher = DispatcherRegistry::build<SideCompute>(this, type()); 107 : 108 28452 : _compute_dispatcher->parallelFor(policy); 109 28452 : } 110 : else 111 : { 112 27100 : Policy policy(0, numKokkosElementSides()); 113 : 114 27100 : if (!_compute_dispatcher) 115 544 : _compute_dispatcher = DispatcherRegistry::build<NeighborCompute>(this, type()); 116 : 117 27100 : _compute_dispatcher->parallelFor(policy); 118 27100 : } 119 84002 : } 120 : 121 : void 122 1085 : Material::getKokkosMaterialPropertyHook(const std::string & prop_name_in, const unsigned int state) 123 : { 124 482 : const auto prop_name = 125 603 : _get_suffix.empty() 126 603 : ? prop_name_in 127 603 : : MooseUtils::join(std::vector<std::string>({prop_name_in, _get_suffix}), "_"); 128 : 129 1085 : if (state == 0) 130 132 : _requested_props.insert(prop_name); 131 : 132 1085 : registerPropName(prop_name, true, state); 133 1085 : } 134 : 135 : } // namespace Moose::Kokkos