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 "KokkosVariable.h" 11 : 12 : #include "SystemBase.h" 13 : #include "FEProblemBase.h" 14 : 15 : namespace Moose::Kokkos 16 : { 17 : 18 : void 19 20010 : Variable::init(const MooseVariableFieldBase & variable, const TagName & tag_name) 20 : { 21 20010 : init(variable, variable.sys().feProblem().getVectorTagID(tag_name)); 22 20010 : } 23 : 24 : void 25 23631 : Variable::init(const MooseVariableFieldBase & variable, const TagID tag) 26 : { 27 23631 : _initialized = true; 28 23631 : _coupled = true; 29 23631 : _nodal = variable.isNodal(); 30 23631 : _components = variable.count(); 31 23631 : _tag = tag; 32 : 33 23631 : _moose_var.createHost(_components); 34 23631 : _var.create(_components); 35 23631 : _sys.create(_components); 36 : 37 47262 : for (unsigned int comp = 0; comp < _components; ++comp) 38 : { 39 23631 : _moose_var[comp] = &variable; 40 23631 : _var[comp] = variable.number() + comp; 41 23631 : _sys[comp] = variable.sys().number(); 42 : } 43 : 44 23631 : _var.copyToDevice(); 45 23631 : _sys.copyToDevice(); 46 : 47 23631 : const auto & problem = variable.sys().feProblem(); 48 : 49 23631 : if (problem.vectorTagExists(Moose::SOLUTION_DOT_TAG)) 50 11111 : _dot = tag == problem.getVectorTagID(Moose::SOLUTION_DOT_TAG); 51 : 52 23631 : if (problem.vectorTagExists(Moose::OLD_SOLUTION_TAG)) 53 11111 : _old = tag == problem.getVectorTagID(Moose::OLD_SOLUTION_TAG); 54 : 55 23631 : if (problem.vectorTagExists(Moose::OLDER_SOLUTION_TAG)) 56 204 : _old = _old || tag == problem.getVectorTagID(Moose::OLDER_SOLUTION_TAG); 57 23631 : } 58 : 59 : void 60 0 : Variable::init(const std::vector<MooseVariableFieldBase *> & variables, const TagName & tag_name) 61 : { 62 0 : init(std::vector<const MooseVariableFieldBase *>(variables.begin(), variables.end()), 63 0 : variables[0]->sys().feProblem().getVectorTagID(tag_name)); 64 0 : } 65 : 66 : void 67 0 : Variable::init(const std::vector<const MooseVariableFieldBase *> & variables, 68 : const TagName & tag_name) 69 : { 70 0 : init(variables, variables[0]->sys().feProblem().getVectorTagID(tag_name)); 71 0 : } 72 : 73 : void 74 0 : Variable::init(const std::vector<MooseVariableFieldBase *> & variables, const TagID tag) 75 : { 76 0 : init(std::vector<const MooseVariableFieldBase *>(variables.begin(), variables.end()), tag); 77 0 : } 78 : 79 : void 80 135 : Variable::init(const std::vector<const MooseVariableFieldBase *> & variables, const TagID tag) 81 : { 82 135 : _initialized = true; 83 135 : _coupled = true; 84 135 : _nodal = true; 85 135 : _components = variables.size(); 86 135 : _tag = tag; 87 : 88 135 : _moose_var.createHost(_components); 89 135 : _var.create(_components); 90 135 : _sys.create(_components); 91 : 92 353 : for (unsigned int comp = 0; comp < _components; ++comp) 93 : { 94 218 : _nodal = _nodal && variables[comp]->isNodal(); 95 : 96 218 : _moose_var[comp] = variables[comp]; 97 218 : _var[comp] = variables[comp]->number(); 98 218 : _sys[comp] = variables[comp]->sys().number(); 99 : } 100 : 101 135 : _var.copyToDevice(); 102 135 : _sys.copyToDevice(); 103 : 104 135 : const auto & problem = variables[0]->sys().feProblem(); 105 : 106 135 : if (problem.vectorTagExists(Moose::SOLUTION_DOT_TAG)) 107 0 : _dot = tag == problem.getVectorTagID(Moose::SOLUTION_DOT_TAG); 108 : 109 135 : if (problem.vectorTagExists(Moose::OLD_SOLUTION_TAG)) 110 0 : _old = tag == problem.getVectorTagID(Moose::OLD_SOLUTION_TAG); 111 : 112 135 : if (problem.vectorTagExists(Moose::OLDER_SOLUTION_TAG)) 113 0 : _old = _old || tag == problem.getVectorTagID(Moose::OLDER_SOLUTION_TAG); 114 135 : } 115 : 116 : void 117 398 : Variable::init(const std::vector<Real> & values, CoupleableKey) 118 : { 119 398 : _initialized = true; 120 398 : _coupled = false; 121 398 : _nodal = true; 122 398 : _components = values.size(); 123 : 124 398 : _default_value = values; 125 398 : } 126 : 127 : } // namespace Moose::Kokkos