41 { inputFormatType::PLAIN,
"plain" },
42 { inputFormatType::DICTIONARY,
"dictionary" },
57 const char comment =
'#' 65 while ((line.empty() || line[0] == comment) && is.
good());
74 void Foam::lumpedPointState::calcRotations()
const 78 auto rotIter = rotationPtr_->begin();
90 void Foam::lumpedPointState::readDict
92 const dictionary&
dict,
109 rotationPtr_.reset(
nullptr);
121 rotationPtr_(nullptr)
127 points_(rhs.points_),
128 angles_(rhs.angles_),
130 degrees_(rhs.degrees_),
131 rotationPtr_(nullptr)
147 rotationPtr_(nullptr)
149 if (points_.
size() != angles_.
size())
153 <<
"Have " << points_.
size() <<
" points but " 154 << angles_.
size() <<
" angles" <<
nl 158 <<
"Have " << points_.
size() <<
" points but " 159 << angles_.
size() <<
" angles, resizing angles to match" <<
nl;
175 angles_(points_.size(),
Zero),
178 rotationPtr_(nullptr)
190 angles_(points_.size(),
Zero),
193 rotationPtr_(nullptr)
208 rotationPtr_(nullptr)
210 readDict(
dict, rotOrder, degrees);
218 points_ = rhs.points_;
219 angles_ = rhs.angles_;
221 degrees_ = rhs.degrees_;
223 rotationPtr_.reset(
nullptr);
240 points_ *= scaleFactor;
248 const lumpedPointState& prev
251 points_ = prev.points_ +
alpha*(points_ - prev.points_);
253 scalar convert = 1.0;
254 if (degrees_ != prev.degrees_)
268 angles_ = convert*prev.angles_ +
alpha*(angles_ - convert*prev.angles_);
270 rotationPtr_.reset(
nullptr);
284 string line = getLineNoComment(iss);
292 points_.resize(
count);
293 angles_.resize(
count);
299 IStringStream isstr(line);
308 points_.resize(
count);
309 angles_.resize(
count);
310 order_ = quaternion::eulerOrder::ZXZ;
313 rotationPtr_.reset(
nullptr);
327 readDict(
dict, rotOrder, degrees);
329 return points_.size();
344 if (order_ != quaternion::eulerOrder::ZXZ)
357 os <<
"# input for OpenFOAM\n" 358 <<
"# N, points, angles\n" 359 << points_.size() <<
"\n";
365 os <<
p.x() <<
' ' <<
p.y() <<
' ' <<
p.z();
367 if (i < angles_.size())
369 os <<
' ' << angles_[i].x()
370 <<
' ' << angles_[i].y()
371 <<
' ' << angles_[i].z() <<
'\n';
383 const inputFormatType fmt,
384 const fileName& file,
394 if (fmt == inputFormatType::PLAIN)
396 ok = this->readPlain(is, rotOrder, degrees);
400 ok = this->readData(is, rotOrder, degrees);
417 rotationPtr_.reset(
nullptr);
void size(const label n)
Older name for setAddressableSize.
static scalar visLength
The length for visualization triangles.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
inputFormatType
Input format types.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void writeDict(Ostream &os) const
Output as dictionary content.
void writePlain(Ostream &os) const
Output as plain content.
Unit conversion functions.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
static bool & parRun() noexcept
Test if this a parallel run.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
void operator=(const lumpedPointState &rhs)
Assignment operator.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static const Enum< eulerOrder > eulerOrderNames
The names for Euler-angle and Tait-Bryan angles, including "rollPitchYaw" and "yawPitchRoll" aliases...
bool writeData(Ostream &os) const
Output as dictionary content.
#define forAll(list, i)
Loop across all elements in list.
static bool visUnused
Enable/disable visualization of unused points.
bool readPlain(Istream &is, const quaternion::eulerOrder rotOrder=quaternion::eulerOrder::ZXZ, const bool degrees=false)
Read input as plain content.
static const Enum< inputFormatType > formatNames
Names for the input format types.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
vectorField pointField
pointField is a vectorField.
void operator+=(const point &origin)
Shift points by specified origin.
const vectorField & angles() const
The orientation of the points (mass centres)
Quaternion class used to perform rotations in 3D space.
eulerOrder
Euler-angle rotation order.
lumpedPointState()
Default construct.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
void scalePoints(const scalar scaleFactor)
Scale points by given factor.
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all processes in communicator.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Generic input stream using a standard (STL) stream.
#define WarningInFunction
Report a warning using Foam::Warning.
static tensor rotation(const vector &angles, bool degrees=false)
Rotation tensor calculated for the intrinsic Euler angles in z-x-z order.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
constexpr scalar radToDeg(const scalar rad) noexcept
Conversion from radians to degrees.
void relax(const scalar alpha, const lumpedPointState &prev)
Relax the state.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
bool good() const noexcept
True if next operation might succeed.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
A class for managing temporary objects.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
bool readData(Istream &is, const quaternion::eulerOrder rotOrder=quaternion::eulerOrder::ZXZ, const bool degrees=false)
Read input as dictionary content.
EnumType getOrDefault(const word &key, const dictionary &dict, const EnumType deflt, const bool failsafe=false) const
Find the key in the dictionary and return the corresponding enumeration element based on its name...
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
A class for handling character strings derived from std::string.
The state of lumped points corresponds to positions and rotations.
static constexpr const zero Zero
Global zero (0)