27 "probe point coordinates");
32 "name of the variable to get time-series from");
37 "type of the variable, can be either scalar or vector");
42 "name of the output file (optional)");
47 "Use user-prescribed deltaT to extract time series, otherwise, use the deltaT in controlDict");
49 #include "setRootCase.H"
50 #include "createTime.H"
51 #include "createMesh.H"
53 word outputName =
"VarTimeSeries";
54 if (
args.optionFound(
"outputName"))
56 outputName = word(
args.optionLookup(
"outputName")());
60 if (
args.optionFound(
"coords"))
62 coords = scalarList(
args.optionLookup(
"coords")());
66 Info <<
"Error: coords not set! Exit." << endl;
69 point coordPoint = {coords[0], coords[1], coords[2]};
70 label probeCellI =
mesh.findCell(coordPoint);
73 if (
args.optionFound(
"varName"))
75 varName = word(
args.optionLookup(
"varName")());
79 Info <<
"Error: varName not set! Exit." << endl;
84 if (
args.optionFound(
"varType"))
86 varType = word(
args.optionLookup(
"varType")());
90 Info <<
"Error: varType not set! Exit." << endl;
96 Info <<
"Error: coords " << coords <<
" are not within a cell! Exit." << endl;
100 if (varType !=
"scalar" && varType !=
"vector")
102 Info <<
"Error: varType = " << varType <<
" is not supported. The options are either scalar or vector " << endl;
105 OFstream f(outputName +
".txt");
107 scalar endTime =
runTime.endTime().value();
108 scalar deltaT =
runTime.deltaT().value();
110 if (
args.optionFound(
"deltaT"))
112 deltaT = readScalar(
args.optionLookup(
"deltaT")());
114 Info <<
"Extracting " << varName <<
" time series" << endl;
116 label nSteps = round(endTime / deltaT);
118 for (label i = 0; i < nSteps; i++)
120 word timeName = Foam::name(i * deltaT);
122 if (varType ==
"vector")
133 f << var[probeCellI][0] <<
" " << var[probeCellI][1] <<
" " << var[probeCellI][2] << endl;
135 else if (varType ==
"scalar")
146 f << var[probeCellI] << endl;
150 Info <<
"Done! " << endl;