20 InputParameters params = validParams<SolutionUserObject>();
21 params.addClassDescription(
"Process an XYZ file of atomic coordinates and filter atoms via "
22 "threshold or map variable values.");
23 params.addRequiredParam<FileName>(
"xyz_input",
"XYZ input file.");
24 params.addRequiredParam<FileName>(
"xyz_output",
"XYZ output file.");
25 params.addRequiredParam<std::string>(
26 "variable",
"Variable from the mesh file to use for mapping to or filtering of the atoms.");
27 MooseEnum modeEnum(
"MAP FILTER",
"MAP");
28 params.addParam<MooseEnum>(
"raster_mode", modeEnum,
"Rasterization mode (MAP|FILTER).");
29 params.addParam<Real>(
"threshold",
30 "Accept atoms with a variable value above this threshold in FILTER mode.");
35 : SolutionUserObject(parameters),
36 _xyz_input(getParam<FileName>(
"xyz_input")),
37 _xyz_output(getParam<FileName>(
"xyz_output")),
38 _variable(getParam<std::string>(
"variable")),
39 _raster_mode(getParam<MooseEnum>(
"raster_mode")),
44 if (!isParamValid(
"threshold"))
45 mooseError(
"Please specify 'threshold' parameter for raster_mode = FILTER");
58 SolutionUserObject::initialSetup();
66 std::string line, dummy;
68 unsigned int current_line = 0;
69 unsigned int nfilter = 0, len0 = 0;
70 while (std::getline(stream_in, line))
75 stream_out << line <<
'\n';
79 if (current_line == 0)
84 std::istringstream iss(line);
86 if (iss >> dummy >> x >> y >> z)
90 stream_out << line <<
' ' << pointValue(0.0, Point(x, y, z),
_variable) <<
'\n';
95 stream_out << line <<
'\n';
112 std::ostringstream oss;
114 std::string newline0 = oss.str();
117 if (newline0.size() > len0)
119 mooseWarning(
"SolutionRasterizer could not update XYZ atom count in header.");
124 while (newline0.size() < len0)
128 std::ofstream stream_fix(
_xyz_output.c_str(), std::ios::binary | std::ios::in | std::ios::out);
129 stream_fix << newline0;