https://mooseframework.inl.gov
XFEMCutMeshOutput.C
Go to the documentation of this file.
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"
12 
14 
17 {
19  params.addClassDescription("Outputs XFEM MeshCut2DUserObjectBase cutter mesh in Exodus format.");
20  params.addRequiredParam<UserObjectName>("xfem_cutter_uo",
21  "The MeshCut2DUserObject to get cutter mesh from");
22  return params;
23 }
24 
26  : FileOutput(params),
27  UserObjectInterface(this),
28  _cutter_uo(getUserObject<MeshCut2DUserObjectBase>("xfem_cutter_uo"))
29 {
30 }
31 
32 std::string
34 {
35  // Append the .e extension to the base file name
36  std::ostringstream output;
37  output << _file_base << "_XFEMCutMeshOutput.e";
38 
39  // Add the _000x extension to the file
40  if (_file_num > 1)
41  output << "-s" << std::setw(_padding) << std::setprecision(0) << std::setfill('0') << std::right
42  << _file_num;
43 
44  // Return the filename
45  return output.str();
46 }
47 
48 void
50 {
51  // exodus_num is always one because we are always assuming the mesh changes between outputs
52  int exodus_num = 1;
53  ++_file_num;
54  _es = std::make_unique<EquationSystems>(_cutter_uo.getCutterMesh());
55  _exodus_io = std::make_unique<libMesh::ExodusII_IO>(_es->get_mesh());
56  // Default to non-HDF5 output for wider compatibility
57  _exodus_io->set_hdf5_writing(false);
58  _exodus_io->write_timestep(
59  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  _es->clear();
65  _es = nullptr;
66 }
static InputParameters validParams()
std::unique_ptr< libMesh::ExodusII_IO > _exodus_io
Exodus for outputting points and values.
const MeshCut2DUserObjectBase & _cutter_uo
The mesh cutting user object.
virtual void output() override
std::string _file_base
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned int _padding
Outputs the cutting mesh used by XFEM to an Exodus file.
std::unique_ptr< libMesh::EquationSystems > _es
The EquationSystems.
MeshCut2DUserObjectBase: (1) reads in a mesh describing the crack surface, (2) Fills xfem cut element...
static InputParameters validParams()
virtual std::string filename() override
MooseApp & _app
XFEMCutMeshOutput(const InputParameters &parameters)
void addClassDescription(const std::string &doc_string)
unsigned int & _file_num
Real getGlobalTimeOffset() const
registerMooseObject("XFEMApp", XFEMCutMeshOutput)
virtual Real getOutputTime()