https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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 MeshCutUserObjectBase cutter mesh in Exodus format.");
20 params.addRequiredParam<UserObjectName>("xfem_cutter_uo",
21 "The MeshCutUserObject to get cutter mesh from");
22 return params;
23}
24
26 : FileOutput(params),
28 _cutter_uo(getUserObject<MeshCutUserObjectBase>("xfem_cutter_uo"))
29{
30}
31
32std::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
48void
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}
registerMooseObject("XFEMApp", XFEMCutMeshOutput)
unsigned int _padding
static InputParameters validParams()
std::string _file_base
unsigned int & _file_num
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Simple base class for XFEM cutting objects that use a mesh to cut.
MeshBase & getCutterMesh() const
Get a reference to the cutter mesh.
Real getGlobalTimeOffset() const
MooseApp & _app
virtual Real getOutputTime()
Outputs the cutting mesh used by XFEM to an Exodus file.
virtual std::string filename() override
const MeshCutUserObjectBase & _cutter_uo
The mesh cutting user object.
static InputParameters validParams()
std::unique_ptr< libMesh::EquationSystems > _es
The EquationSystems.
std::unique_ptr< libMesh::ExodusII_IO > _exodus_io
Exodus for outputting points and values.
virtual void output() override
XFEMCutMeshOutput(const InputParameters &parameters)