41 { inputFormatType::PLAIN,
"plain" },
42 { inputFormatType::DICTIONARY,
"dictionary" },
57 const char comment =
'#'
65 while ((line.empty() || line[0] == comment) && is.
good());
74void Foam::lumpedPointState::calcRotations()
const
76 rotationPtr_.reset(
new tensorField(angles_.size()));
78 auto rotIter = rotationPtr_->begin();
90void Foam::lumpedPointState::readDict
109 rotationPtr_.reset(
nullptr);
121 rotationPtr_(nullptr)
127 points_(
rhs.points_),
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;
162 angles_.resize(points_.size(), Zero);
178 rotationPtr_(nullptr)
193 rotationPtr_(nullptr)
208 rotationPtr_(nullptr)
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);
302 >> points_[count].x() >> points_[count].y() >> points_[count].z()
303 >> angles_[count].x() >> angles_[count].y() >> angles_[count].z();
308 points_.resize(count);
309 angles_.resize(count);
313 rotationPtr_.reset(
nullptr);
329 return points_.size();
342 os.writeEntry(
"points", points_);
343 os.writeEntry(
"angles", angles_);
350 os.writeEntry(
"degrees",
"true");
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,
394 if (fmt == inputFormatType::PLAIN)
396 ok = this->readPlain(is, rotOrder, degrees);
400 ok = this->readData(is, rotOrder, degrees);
417 rotationPtr_.reset(
nullptr);
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
bool good() const noexcept
True if next operation might succeed.
Generic input stream using a standard (STL) stream.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static void broadcasts(const int communicator, Type &value, Args &&... values)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel.
void size(const label n)
Older name for setAddressableSize.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static tensor rotation(const vector &angles, bool degrees=false)
Rotation tensor calculated for the intrinsic Euler angles in z-x-z order.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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,...
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 handling file names.
The state of lumped points corresponds to positions and rotations.
lumpedPointState()
Default construct.
void writePlain(Ostream &os) const
Output as plain content.
inputFormatType
Input format types.
@ PLAIN
"plain" is a simple ASCII format
bool degrees() const
Rotation angles in degrees.
label size() const
The number of points.
bool writeData(Ostream &os) const
Output as dictionary content.
void relax(const scalar alpha, const lumpedPointState &prev)
Relax the state.
static bool visUnused
Enable/disable visualization of unused points.
static scalar visLength
The length for visualization triangles.
static const Enum< inputFormatType > formatNames
Names for the input format types.
bool readData(Istream &is, const quaternion::eulerOrder rotOrder=quaternion::eulerOrder::ZXZ, const bool degrees=false)
Read input as dictionary content.
void operator=(const lumpedPointState &rhs)
Assignment operator.
void writeDict(Ostream &os) const
Output as dictionary content.
bool readPlain(Istream &is, const quaternion::eulerOrder rotOrder=quaternion::eulerOrder::ZXZ, const bool degrees=false)
Read input as plain content.
void operator+=(const point &origin)
Shift points by specified origin.
void scalePoints(const scalar scaleFactor)
Scale points by given factor.
const vectorField & angles() const
The orientation of the points (mass centres).
Quaternion class used to perform rotations in 3D space.
static const Enum< eulerOrder > eulerOrderNames
The names for Euler-angle and Tait-Bryan angles, including "rollPitchYaw" and "yawPitchRoll" aliases.
eulerOrder
Euler-angle rotation order.
A class for handling character strings derived from std::string.
A class for managing temporary objects.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
constexpr scalar radToDeg() noexcept
Multiplication factor for radians to degrees conversion.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
static constexpr const zero Zero
Global zero (0).
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
vectorField pointField
pointField is a vectorField.
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.