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 "MeshCut2DUserObjectBase.h" 12 : 13 : registerMooseObject("XFEMApp", XFEMCutMeshOutput); 14 : 15 : InputParameters 16 33 : XFEMCutMeshOutput::validParams() 17 : { 18 33 : InputParameters params = FileOutput::validParams(); 19 33 : params.addClassDescription("Outputs XFEM MeshCut2DUserObjectBase cutter mesh in Exodus format."); 20 66 : params.addRequiredParam<UserObjectName>("xfem_cutter_uo", 21 : "The MeshCut2DUserObject to get cutter mesh from"); 22 33 : return params; 23 0 : } 24 : 25 16 : XFEMCutMeshOutput::XFEMCutMeshOutput(const InputParameters & params) 26 : : FileOutput(params), 27 : UserObjectInterface(this), 28 16 : _cutter_uo(getUserObject<MeshCut2DUserObjectBase>("xfem_cutter_uo")) 29 : { 30 16 : } 31 : 32 : std::string 33 80 : XFEMCutMeshOutput::filename() 34 : { 35 : // Append the .e extension to the base file name 36 80 : std::ostringstream output; 37 80 : output << _file_base << "_XFEMCutMeshOutput.e"; 38 : 39 : // Add the _000x extension to the file 40 80 : if (_file_num > 1) 41 48 : output << "-s" << std::setw(_padding) << std::setprecision(0) << std::setfill('0') << std::right 42 48 : << _file_num; 43 : 44 : // Return the filename 45 80 : return output.str(); 46 80 : } 47 : 48 : void 49 64 : 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 64 : ++_file_num; 54 128 : _es = std::make_unique<EquationSystems>(_cutter_uo.getCutterMesh()); 55 128 : _exodus_io = std::make_unique<libMesh::ExodusII_IO>(_es->get_mesh()); 56 : // Default to non-HDF5 output for wider compatibility 57 64 : _exodus_io->set_hdf5_writing(false); 58 64 : _exodus_io->write_timestep( 59 128 : 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 64 : _es->clear(); 65 : _es = nullptr; 66 64 : }