51inline List<lumpedPointStateTuple> getResponseTable
68 const List<lumpedPointStateTuple>& tbl,
73 Info<<
"Using response table with " << tbl.
size() <<
" entries" <<
nl;
77 Info<<
"Increment input by " << span <<
nl;
82 Info<<
"Stopping after " << maxOut <<
" outputs" <<
nl;
89int main(
int argc,
char *argv[])
93 "Visualize lumpedPoint movements or provide a slave responder"
94 " for diagnostic purposes."
102 "Maximum number of outputs"
108 "Increment each input by N (default: 1)"
114 "Relaxation/scaling factor for movement (default: 1)"
120 "Visualization length for planes (visualized as triangles)"
124 "Test movement without a mesh"
129 "Remove lock-file on termination of slave"
134 "Invoke as a slave responder for testing"
140 const label maxOut =
Foam::max(0,
args.getOrDefault<label>(
"max", 0));
141 const label span =
Foam::max(1,
args.getOrDefault<label>(
"span", 1));
144 const bool dryrun =
args.dryRun();
145 const bool slave =
args.found(
"slave");
146 const bool removeLock =
args.found(
"removeLock");
148 const scalar
relax =
args.getOrDefault<scalar>(
"scale", 1);
160 Info<<
"Running as slave responder" <<
endl;
165 <<
"Running as slave responder is not permitted in parallel"
178 Info<<
"No valid movement found" <<
endl;
181 auto& movement = *movementPtr;
186 List<lumpedPointStateTuple> responseTable =
187 getResponseTable(responseFile, state0);
189 echoTableLimits(responseTable, span, maxOut);
193 Info<<
"dry-run: response table with " << responseTable.
size()
195 <<
"\nEnd\n" <<
endl;
203 label timei = 0, outputCount = 0;
204 timei < responseTable.
size();
208 Info<<
args.executable() <<
": waiting for master" <<
endl;
214 <<
": stopping status=done was detected" <<
endl;
225 movement.inputFormat()
233 os.writeEntry(
"time", responseTable[timei].first());
238 <<
": updated to state " << timei
239 <<
" - switch to master"
247 if (maxOut && outputCount >= maxOut)
250 <<
": stopping after " << maxOut <<
" outputs" <<
endl;
257 Info<<
args.executable() <<
": removing lock file" <<
endl;
261 Info<<
args.executable() <<
": finishing" <<
nl;
274 Info<<
"dry-run: creating states only" <<
nl;
284 Info<<
"No valid movement found" <<
endl;
287 auto& movement = *movementPtr;
292 List<lumpedPointStateTuple> responseTable =
293 getResponseTable(responseFile, state0);
295 echoTableLimits(responseTable, span, maxOut);
302 label timei = 0, outputCount = 0;
303 timei < responseTable.
size();
309 state += movement.origin();
313 Info<<
"output [" << timei <<
'/' << responseTable.
size() <<
']';
330 if (maxOut && outputCount >= maxOut)
332 Info<<
"Max output " << maxOut <<
" ... stopping" <<
endl;
339 if (stateSeries.
size())
341 Info<<
nl <<
"write state.vtp.series" <<
nl;
342 stateSeries.
write(
"state.vtp");
366 Info<<
"No valid movement found" <<
endl;
369 auto& movement = *movementPtr;
374 List<lumpedPointStateTuple> responseTable =
375 getResponseTable(responseFile, state0);
377 echoTableLimits(responseTable, span, maxOut);
384 Info<<
"No point patches with lumped movement found" <<
endl;
388 Info<<
"Lumped point patch controls set on "
399 movement.writeVTP(
"geom_init.vtp", state0,
mesh,
points0);
405 label timei = 0, outputCount = 0;
406 timei < responseTable.
size();
412 state += movement.origin();
416 Info<<
"output [" << timei <<
'/' << responseTable.
size() <<
']';
443 if (maxOut && outputCount >= maxOut)
445 Info<<
"Max output " << maxOut <<
" ... stopping" <<
endl;
453 if (geomSeries.
size())
455 Info<<
nl <<
"write geom.vtp.series" <<
nl;
456 geomSeries.
write(
"geom.vtp");
458 if (stateSeries.
size())
460 Info<<
nl <<
"write state.vtp.series" <<
nl;
461 stateSeries.
write(
"state.vtp");
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
void size(const label n)
Older name for setAddressableSize.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void addDryRunOption(const string &usage, bool advanced=false)
Enable a 'dry-run' bool option, with usage information.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Encapsulates the logic for coordinating between OpenFOAM and an external application.
enum Time::stopAtControls useSlave(const bool wait=false) const
Remove lock file to indicate that the external program is in charge.
enum Time::stopAtControls useMaster(const bool wait=false) const
Create lock file to indicate that OpenFOAM is in charge.
fileName resolveFile(const word &file) const
Return the file path in the communications directory.
enum Time::stopAtControls waitForMaster() const
Wait for master to complete.
A class for handling file names.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
static autoPtr< lumpedPointIOMovement > New(const objectRegistry &obr, label ownerId=-1)
Create a movement object in the registry by reading system dictionary.
The state of lumped points corresponds to positions and rotations.
void writePlain(Ostream &os) const
Output as plain content.
@ PLAIN
"plain" is a simple ASCII format
bool degrees() const
Rotation angles in degrees.
void relax(const scalar alpha, const lumpedPointState &prev)
Relax the state.
quaternion::eulerOrder rotationOrder() const
The Euler-angle rotation order.
static scalar visLength
The length for visualization triangles.
void writeDict(Ostream &os) const
Output as dictionary content.
void scalePoints(const scalar scaleFactor)
Scale points by given factor.
Provides a means of accumulating and generating VTK file series.
bool append(const fileNameInstant &inst)
Append the specified file instant.
static void write(const fileName &base, const UList< instant > &series, const char sep='_')
Write file series (JSON format) to disk, for specified instances.
label size() const noexcept
The number of data sets.
A class for handling words, derived from Foam::string.
static word printf(const char *fmt, const PrimitiveType &val)
Use a printf-style formatter for a primitive.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
word outputName("finiteArea-edges.obj")
OBJstream os(runTime.globalPath()/outputName)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
messageStream Info
Information stream (stdout output on master, null elsewhere).
vectorIOField pointIOField
pointIOField is a vectorIOField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))