27 "field variables name to set");
32 "field variables type");
37 "prescribe a specific time to set data");
42 "prescribe the probe point coordinate");
47 "prescribe the value to add to the probe point coordinate. If it is a scalar, set the value for first element and set zeros for the other two elements");
52 "The mode can be either findCell or findNearestCell");
54 #include "setRootCase.H"
55 #include "createTime.H"
56 #include "createMesh.H"
59 if (
args.optionFound(
"fieldName"))
61 fieldName = word(
args.optionLookup(
"fieldName")());
65 Info <<
"fieldName not set! Exit." << endl;
70 if (
args.optionFound(
"fieldType"))
72 fieldType = word(
args.optionLookup(
"fieldType")());
76 Info <<
"fieldType not set! Exit." << endl;
80 word
mode =
"findCell";
81 if (
args.optionFound(
"mode"))
83 mode = word(
args.optionLookup(
"mode")());
87 Info <<
"mode not set! Use the default findCell mode." << endl;
90 vector probeCoord = {0.0, 0.0, 0.0};
91 if (
args.readIfPresent(
"probeCoord", probeCoord))
93 Info <<
"The probeCoord is: " << probeCoord << endl;
97 Info <<
"probeCoord not set!" << endl;
100 vector value = {0.0, 0.0, 0.0};
101 if (
args.readIfPresent(
"value", value))
103 Info <<
"The value is: " << value << endl;
107 Info <<
"value not set!" << endl;
111 if (
args.optionFound(
"time"))
113 time = readScalar(
args.optionLookup(
"time")());
116 Info <<
"Extract latestTime" << endl;
120 Info <<
"Extract time = " << time << endl;
125 Info <<
"time not set! Extract all time instances." << endl;
128 Info <<
"Set field " << fieldName <<
" value at " << probeCoord <<
" with " << value << endl;
130 scalar endTime =
runTime.endTime().value();
131 scalar deltaT =
runTime.deltaT().value();
132 label nInstances = -1;
135 nInstances = round(endTime / deltaT);
142 for (label n = 1; n < nInstances + 1; n++)
151 else if (time == 9999)
155 t = timeDirs.last().value();
164 Info <<
"Working on time = " << t << endl;
166 if (fieldType ==
"scalar")
168 volScalarField fieldRead(
171 mesh.time().timeName(),
177 if (
mode ==
"findCell")
179 point coordPoint = {probeCoord[0], probeCoord[1], probeCoord[2]};
180 label probeCellI =
mesh.findCell(coordPoint);
183 Info <<
"Cell not found for coord: " << probeCoord << endl;
184 Info <<
"Exit!" << endl;
187 fieldRead[probeCellI] = value[0];
189 else if (
mode ==
"findNearestCell")
191 point coordPoint = {probeCoord[0], probeCoord[1], probeCoord[2]};
192 label probeCellI =
mesh.findNearestCell(coordPoint);
193 fieldRead[probeCellI] = value[0];
197 FatalErrorIn(
"mode not valid! Options are findCell or findNearestCell")
202 else if (fieldType ==
"vector")
204 volVectorField fieldRead(
207 mesh.time().timeName(),
213 if (
mode ==
"findCell")
215 point coordPoint = {probeCoord[0], probeCoord[1], probeCoord[2]};
216 label probeCellI =
mesh.findCell(coordPoint);
217 fieldRead[probeCellI] = value;
219 else if (
mode ==
"findNearestCell")
221 point coordPoint = {probeCoord[0], probeCoord[1], probeCoord[2]};
222 label probeCellI =
mesh.findNearestCell(coordPoint);
223 fieldRead[probeCellI] = value;
227 FatalErrorIn(
"mode not valid! Options are findCell or findNearestCell")
234 Info <<
"fieldName and type not supported!" << endl;
238 Info <<
"Finished!" << endl;