Line data Source code
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 : 10 : #include "XFEMCutMeshOutput.h" 11 : #include "MeshCutUserObjectBase.h" 12 : 13 : registerMooseObject("XFEMApp", XFEMCutMeshOutput); 14 : 15 : InputParameters 16 41 : XFEMCutMeshOutput::validParams() 17 : { 18 41 : InputParameters params = FileOutput::validParams(); 19 41 : params.addClassDescription("Outputs XFEM MeshCutUserObjectBase cutter mesh in Exodus format."); 20 82 : params.addRequiredParam<UserObjectName>("xfem_cutter_uo", 21 : "The MeshCutUserObject to get cutter mesh from"); 22 41 : return params; 23 0 : } 24 : 25 20 : XFEMCutMeshOutput::XFEMCutMeshOutput(const InputParameters & params) 26 : : FileOutput(params), 27 : UserObjectInterface(this), 28 20 : _cutter_uo(getUserObject<MeshCutUserObjectBase>("xfem_cutter_uo")) 29 : { 30 20 : } 31 : 32 : std::string 33 100 : XFEMCutMeshOutput::filename() 34 : { 35 : // Append the .e extension to the base file name 36 100 : std::ostringstream output; 37 100 : output << _file_base << "_XFEMCutMeshOutput.e"; 38 : 39 : // Add the _000x extension to the file 40 100 : if (_file_num > 1) 41 60 : output << "-s" << std::setw(_padding) << std::setprecision(0) << std::setfill('0') << std::right 42 60 : << _file_num; 43 : 44 : // Return the filename 45 100 : return output.str(); 46 100 : } 47 : 48 : void 49 80 : XFEMCutMeshOutput::output() 50 : { 51 : // exodus_num is always one because we are always assuming the mesh changes between outputs 52 : int exodus_num = 1; 53 80 : ++_file_num; 54 160 : _es = std::make_unique<EquationSystems>(_cutter_uo.getCutterMesh()); 55 160 : _exodus_io = std::make_unique<libMesh::ExodusII_IO>(_es->get_mesh()); 56 : // Default to non-HDF5 output for wider compatibility 57 80 : _exodus_io->set_hdf5_writing(false); 58 80 : _exodus_io->write_timestep( 59 160 : filename(), *_es, exodus_num, getOutputTime() + _app.getGlobalTimeOffset()); 60 : 61 : // Done with these 62 : // We don't necessarily need to create a new mesh every time, but it's easier than 63 : // checking if the cutter mesh has changed from last time we built a mesh 64 80 : _es->clear(); 65 : _es = nullptr; 66 80 : }