Line data Source code
1 : /**********************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ 4 : /* */ 5 : /* Copyright 2017 Battelle Energy Alliance, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /**********************************************************************/ 8 : 9 : #include "MyTRIMMesh.h" 10 : #include "PointLocatorRegularOrthogonal.h" 11 : 12 : registerMooseObject("MagpieApp", MyTRIMMesh); 13 : 14 : InputParameters 15 246 : MyTRIMMesh::validParams() 16 : { 17 246 : InputParameters params = GeneratedMesh::validParams(); 18 246 : params.addClassDescription( 19 : "Regular orthogonal generated mesh with restrictions to simple elements."); 20 246 : params.suppressParameter<Real>("bias_x"); 21 246 : params.suppressParameter<Real>("bias_y"); 22 246 : params.suppressParameter<Real>("bias_z"); 23 246 : return params; 24 0 : } 25 : 26 126 : MyTRIMMesh::MyTRIMMesh(const InputParameters & parameters) 27 : : GeneratedMesh(parameters), 28 252 : _cell_count({_nx, _ny, _nz}), 29 126 : _min_corner(_xmin, _ymin, _zmin), 30 126 : _max_corner(_xmax, _ymax, _zmax) 31 : { 32 126 : _cell_count.resize(_dim); 33 : 34 252 : if (isParamValid("elem_type")) 35 : { 36 96 : MooseEnum elem_type_enum = getParam<MooseEnum>("elem_type"); 37 : 38 : // validate element type (only orthogonal stuff) 39 32 : switch (_dim) 40 : { 41 0 : case 1: 42 0 : if (elem_type_enum != "EDGE2") 43 0 : mooseError("1D simulations need to use EDGE2 elements"); 44 : break; 45 10 : case 2: 46 10 : if (elem_type_enum != "QUAD4") 47 2 : mooseError("2D simulations need to use QUAD4 elements"); 48 : break; 49 22 : case 3: 50 22 : if (elem_type_enum != "HEX8") 51 2 : mooseError("3D simulations need to use HEX8 elements"); 52 : } 53 28 : } 54 : 55 : // actually let's not allow 1D for now 56 122 : if (_dim == 1) 57 2 : mooseError("Only 2D and 3D simulations are currently supported."); 58 : 59 : // make sure no biasing snuck in 60 120 : if (_bias_x != 1.0 || _bias_y != 1.0 || _bias_z != 1.0) 61 0 : mooseError("Biased meshes are not supported."); 62 120 : } 63 : 64 0 : MyTRIMMesh::MyTRIMMesh(const MyTRIMMesh & other_mesh) 65 0 : : GeneratedMesh(other_mesh), _cell_count(other_mesh._cell_count) 66 : { 67 0 : } 68 : 69 : std::unique_ptr<MooseMesh> 70 0 : MyTRIMMesh::safeClone() const 71 : { 72 0 : return std::make_unique<MyTRIMMesh>(*this); 73 : } 74 : 75 : std::unique_ptr<PointLocatorBase> 76 482 : MyTRIMMesh::getPointLocator() const 77 : { 78 482 : if (_point_locator.get() == nullptr) 79 : { 80 101 : _point_locator.reset(new PointLocatorRegularOrthogonal(getMesh())); 81 101 : _point_locator->init(_cell_count, _min_corner, _max_corner); 82 : } 83 : return std::unique_ptr<PointLocatorBase>( 84 482 : new PointLocatorRegularOrthogonal(getMesh(), _point_locator.get())); 85 : } 86 : 87 : unsigned int 88 132 : MyTRIMMesh::getCellCountInDimension(unsigned int component) 89 : { 90 : mooseAssert(component < dimension(), 91 : "Querying invalid component in MyTRIMMesh::getCellCountInDimension"); 92 132 : return _cell_count[component]; 93 : }