- the internal data are contiguous so can broadcast size and internals
directly without an intermediate stream.
ENH: split out broadcast time for profilingPstream information
STYLE: minor Pstream cleanup
- UPstream::commsType_ from protected to private, since it already has
inlined noexcept getters/setters that should be used.
- don't pass unused/unneed tag into low-level MPI reduction templates.
Document where tags are not needed
- had Pstream::broadcast instead of UPstream::broadcast in internals
- used Pstream::maxCommsSize (bytes) for the lower limit when sending.
This would have send more data on each iteration than expected based
on maxCommsSize and finish with a number of useless iterations.
Was generally not a serious bug since maxCommsSize (if used) was
likely still far away from the MPI limits and exchange() is primarily
harnessed by PstreamBuffers, which is sending character data
(ie, number of elements and number of bytes is identical).
- PstreamBuffers nProcs() and allProcs() methods to recover the rank
information consistent with the communicator used for construction
- allowClearRecv() methods for more control over buffer reuse
For example,
pBufs.allowClearRecv(false);
forAll(particles, particlei)
{
pBufs.clear();
fill...
read via IPstream(..., pBufs);
}
This preserves the receive buffers memory allocation between calls.
- finishedNeighbourSends() method as compact wrapper for
finishedSends() when send/recv ranks are identically
(eg, neighbours)
- hasSendData()/hasRecvData() methods for PstreamBuffers.
Can be useful for some situations to skip reading entirely.
For example,
pBufs.finishedNeighbourSends(neighProcs);
if (!returnReduce(pBufs.hasRecvData(), orOp<bool>()))
{
// Nothing to do
continue;
}
...
On an individual basis:
for (const int proci : pBufs.allProcs())
{
if (pBufs.hasRecvData(proci))
{
...
}
}
Also conceivable to do the following instead (nonBlocking only):
if (!returnReduce(pBufs.hasSendData(), orOp<bool>()))
{
// Nothing to do
pBufs.clear();
continue;
}
pBufs.finishedNeighbourSends(neighProcs);
...
- split off a Pstream::genericBroadcast() which uses UOPBstream during
serialization and UOPBstream during de-serialization.
This function will not normally be used directly by callers, but
provides a base layer for higher-level broadcast calls.
- low-level UPstream broadcast of string content.
Since std::string has length and contiguous content, it is possible
to handle directly by the following:
1. broadcast size
2. resize
3. broadcast content when size != 0
Although this is a similar amount of communication as the generic
streaming version (min 1, max 2 broadcasts) it is more efficient
by avoiding serialization/de-serialization overhead.
- handle broadcast of List content distinctly.
Allows an optimized path for contiguous data, similar to how
std::string is handled (broadcast size, resize container, broadcast
content when size != 0), but can revert to genericBroadcast (streamed)
for non-contiguous data.
- make various scatter variants simple aliases for broadcast, since
that is what they are doing behind the scenes anyhow:
* scatter()
* combineScatter()
* listCombineScatter()
* mapCombineScatter()
Except scatterList() which remains somewhat different.
Beyond the additional (size == nProcs) check, the only difference to
using broadcast(List<T>&) or a regular scatter(List<T>&) is that
processor-local data is skipped. So leave this variant as-is.
STYLE: rename/prefix implementation code with 'Pstream'
- better association with its purpose and provides a unique name
- The idea of broadcast streams is to replace multiple master to
subProcs communications with a single MPI_Bcast.
if (Pstream::master())
{
OPBstream toAll(Pstream::masterNo());
toAll << data;
}
else
{
IPBstream fromMaster(Pstream::masterNo());
fromMaster >> data;
}
// vs.
if (Pstream::master())
{
for (const int proci : Pstream::subProcs())
{
OPstream os(Pstream::commsTypes::scheduled, proci);
os << data;
}
}
else
{
IPstream is(Pstream::commsTypes::scheduled, Pstream::masterNo());
is >> data;
}
Can simply use UPstream::broadcast() directly for contiguous data
with known lengths.
Based on ideas from T.Aoyagi(RIST), A.Azami(RIST)
- native MPI min/max/sum reductions for float/double
irrespective of WM_PRECISION_OPTION
- native MPI min/max/sum reductions for (u)int32_t/(u)int64_t types,
irrespective of WM_LABEL_SIZE
- replace rarely used vector2D sum reduction with FixedList as a
indicator of its intent and also generalizes to different lengths.
OLD:
vector2D values; values.x() = ...; values.y() = ...;
reduce(values, sumOp<vector2D>());
NEW:
FixedList<scalar,2> values; values[0] = ...; values[1] = ...;
reduce(values, sumOp<scalar>());
- allow returnReduce() to use native reductions. Previous code (with
linear/tree selector) would have bypassed them inadvertently.
ENH: added support for MPI broadcast (for a memory span)
ENH: select communication schedule as a static method
- UPstream::whichCommunication(comm) to select linear/tree
communication instead of ternary or
if (Pstream::nProcs() < Pstream::nProcsSimpleSum) ...
STYLE: align nProcsSimpleSum static value with etc/controlDict override
ENH: provide fieldTypes::surface names (as per fieldTypes::volume)
ENH: reduce number of files for surface fields
- combine face and point field declarations/definitions,
simplify typeName definitions
- used low-level MPI gather, but the wrapping routine contains an
additional safety check for is_contiguous which is not defined for
various std::pair<..> combination.
So std::pair<label,vector> (which is actually contiguous, but not
declared as is_contiguous) would falsely trip the check.
Avoid by simply gathering unbundled values instead.
- do not need STRINGIFY macros in ragel code
- remove wordPairHashTable.H and use equivalent wordPairHashes.H instead
STYLE: replace addDictOption with explicit option
- the usage text is otherwise misleading
GIT: combine Pair/Tuple2 directories
- unused in regular OpenFOAM code
- POSIX version uses deprecated gethostbyname()
- Windows version never worked
COMP: localize, noexcept on internal OSspecific methods
STYLE: support fileName::Type SYMLINK and LINK as synonyms
- for contiguous data, added mpiGatherOp() to complement the
gatherOp() static method
- the gather ops (static methods) populate the globalIndex on the
master only (not needed on other procs) for reduced communication
- rename inplace gather methods to include 'inplace' in their name.
Regular gather methods return the gathered data directly, which
allows the following:
const scalarField mergedWeights(globalFaces().gather(wghtSum));
vs.
scalarField mergedWeights;
globalFaces().gather(wghtSum, mergedWeights());
or even:
scalarField mergedWeights;
List<scalarField> allWeights(Pstream::nProcs());
allWeights[Pstream::myProcNo()] = wghtSum;
Pstream::gatherList(allWeights);
if (Pstream::master())
{
mergedWeights =
ListListOps::combine<scalarField>
(
allWeights, accessOp<scalarField>()
);
}
- add parRun guards on various globalIndex gather methods
(simple copies or no-ops in serial) to simplify the effort for callers.
ENH: reduce code effort for clearing linked-lists
ENH: adjust linked-list method name
- complement linked-list append() method with prepend() method
instead of 'insert', which is not very descriptive
- similar idea to swak timelines/lookuptables but combined together
and based on Function1 for more flexibility.
Specified as 'functions<scalar>' or 'functions<vector>'.
For example,
functions<scalar>
{
intakeType table ((0 0) (10 1.2));
p_inlet
{
type sine;
frequency 3000;
scale 50;
level 101325;
}
}
These can be referenced in the expressions as a nullary function or a
unary function.
Within the parser, the names are prefixed with "fn:" (function).
It is thus possible to define "fn:sin()" that is different than
the builtin "sin()" function.
* A nullary call uses time value
- Eg, fn:p_inlet()
* A unary call acts as a remapper function.
- Eg, fn:intakeType(6.25)
- previously simply reused the scan token, which works fine for
non-nested tokenizations but becomes too fragile with nesting.
Now changed to use tagged unions that can be copied about
and still retain some rudimentary knowledge of their types,
which can be manually triggered with a destroy() call.
- provide an 'identifier' non-terminal as an additional catch
to avoid potential leakage on parsing failure.
- adjust lemon rules and infrastructure:
- use %token to predefine standard tokens.
Will reduce some noise on the generated headers by retaining the
order on the initial token names.
- Define BIT_NOT, internal token rename NOT -> LNOT
- handle non-terminal vector values.
Support vector::x, vector::y and vector::z constants
- permit fieldExpr access to time().
Probably not usable or useful for an '#eval' expression,
but useful for a Function1.
- provisioning for hooks into function calls. Establishes token
names for next commit(s).
- use `#word` to concatenate, expand content with the resulting string
being treated as a word token. Can be used in dictionary or
primitive context.
In dictionary context, it fills the gap for constructing dictionary
names on-the-fly. For example,
```
#word "some_prefix_solverInfo_${application}"
{
type solverInfo;
libs (utilityFunctionObjects);
...
}
```
The '#word' directive will automatically squeeze out non-word
characters. In the block content form, it will also strip out
comments. This means that this type of content should also work:
```
#word {
some_prefix_solverInfo
/* Appended with application name (if defined) */
${application:+_} // Use '_' separator
${application} // The application
}
{
type solverInfo;
libs (utilityFunctionObjects);
...
}
```
This is admittedly quite ugly, but illustrates its capabilities.
- use `#message` to report expanded string content to stderr.
For example,
```
T
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-10;
relTol 0;
#message "using solver: $solver"
}
```
Only reports on the master node.
- use FACE_DATA (was SURFACE_DATA) for similarity with polySurface
ENH: add expression value enumerations and traits
- simple enumeration of standard types (bool, label, scalar, vector)
that can be used as a value type-code for internal bookkeeping.
GIT: relocate pTraits into general traits/ directory
- releases ownership of the pointer. A no-op (and returns nullptr)
for references.
Naming consistent with unique_ptr and autoPtr.
DOC: adjust wording for memory-related classes
- add is_const() method for tmp, refPtr.
Drop (ununsed and confusing looking) isTmp method from refPtr
in favour of is_pointer() or movable() checks
ENH: noexcept for some pTraits methods, remove redundant 'inline'
- test for const first for tmp/refPtr (simpler logic)
- similar to -dry-run handling, can be interrogated from argList,
which makes it simpler to add into utilities.
- support multiple uses of -dry-run and -verbose to increase the
level. For example, could have
someApplication -verbose -verbose
and inside of the application:
if (args.verbose() > 2) ...
BUG: error with empty distributed roots specification (fixes#2196)
- previously used the size of distributed roots to transmit if the
case was running in distributed mode, but this behaves rather poorly
with bad input. Specifically, the following questionable setup:
distributed true;
roots ( /*none*/ );
Now transmit the ParRunControl distributed() value instead,
and also emit a gentle warning for the user:
WARNING: running distributed but did not specify roots!
- provide a plain stream() method on messageStream to reduce reliance
on casting operators and slightly opaque operator()() calls etc
- support alternative stream for messageStream serial output.
This can be used to support local redirection of output.
For example,
refPtr<OFstream> logging; // or autoPtr, unique_ptr etc
// Later...
Info.stream(logging.get())
<< "Detailed output ..." << endl;
This will use the stdout semantics in the normal case, or allow
redirection to an output file if a target output stream is defined,
but still effectively use /dev/null on non-master processes.
This is mostly the same as this ternary
(logging ? *logging : Info())
except that the ternary could be incorrect on sub-processes,
requires more typing etc.
ENH: use case-relative names of dictionary, IOstream for FatalIOError
- normally yields more easily understandable information
- UPstream::mpiGather (MPI_Gather) - used by Pstream::listGatherValues
- UPstream::mpiScatter (MPI_Scatter) - used by Pstream::listScatterValues
These are much simpler forms for gather/scatter of fixed-sized
contiguous types data types (eg, primitives, simple pairs etc).
In the gather form, creates a list of gathered values on the master
process. The subranks have a list size of zero.
Similarly, scatter will distribute a list of values to single values
on each process.
Instead of
labelList sendSizes(Pstream::nProcs());
sendSizes[Pstream::myProcNo()] = sendData.size();
Pstream::gatherList(sendSizes);
Can write
const labelList sendSizes
(
UPstream::listGatherValues<label>(sendData.size())
);
// Less code, lower overhead and list can be const.
For scattering an individual value only,
instead of
labelList someValues;
if (Pstream::master()) someValues = ...;
Pstream::gatherList(sendSizes);
const label localValue
(
someValues[Pstream::myProcNo()]
);
Can write
labelList someValues;
if (Pstream::master()) someValues = ...;
Pstream::gatherList(sendSizes);
const label localValue
(
UPstream::listScatterValues<label>(someValues)
);
Can of course also mix listGatherValues to assemble a list on master
and use Pstream::scatterList to distribute.
ENH: adjusted globalIndex gather methods
- added mpiGather() method [contiguous data only] using MPI_Gatherv
- respect localSize if gathering master data to ensure that a
request for 0 master elements is properly handled.
- the size of a List often requires adjustment prior to an operation,
but old values (if any) are not of interest and will be overwritten.
In these cases can use the _nocopy versions to avoid additional memory
overhead of the intermediate list and the copy/move overhead of
retaining the old values (that we will subsequently discard anyhow).
No equivalent for PtrList/UPtrList - this would be too fragile.
- add swap DynamicField with DynamicList
BUG: fixed Dynamic{Field,List} setCapacity corner case
- for the case when the newly requested capacity coincides with the
current addressable size, the resize of the underlying list would have
been bypassed - ie, the real capacity was not actually changed.
- remove (unused) PtrDynList setCapacity method as too fragile
- previously returned the range slice as a UList,
but this prevents convenient assignment.
Apply similar handling for Field/SubField
Allows the following
labelRange range(...);
fullList.slice(range) = identity(range.size());
and
fullList.slice(range) = UIndirectList<T>(other, addr);
ENH: create SubList from full FixedList (simplifies interface)
- allow default constructed SubList. Use shallowCopy to 'reset' later
- support simple mesh subsetting to vtu formats to enable debug output
for a subsection of an existing polyMesh
- rudimentary support for VTK from cellShapes is intended for handling
basic primitive cell shapes without a full blown polyMesh description.
For example,
// Create an empty polyMesh with points only
polyMesh debugMesh
(
io,
std::move(points),
faceList(), // faces
labelList(), // owner
labelList(), // neighbour
true // syncPar
);
// Establish the appropriate VTK sizing for the TET shapes
vtk::vtuCells vtuCells;
vtuCells.resetShapes(debugCutTets);
vtuCells.nPoints(debugMesh.nPoints());
NOTE
Since the vtk::internalMeshWriter only uses the polyMesh reference
for the points, it is also possible to create the vtuCells
description without a pointField (or from a different mesh
description) and write out the connectivity using the pointField
from a different mesh.
- allows reuse similar to refPtr for wrapping different content.
- additional control for when contents are copied back,
instead of waiting for the adaptor to go out of scope.
Eg,
if (adaptor.active())
{
adaptor.commit();
adaptor.clear();
}
- static ConstPrecisionAdaptor::get method renamed to 'select' as a
better description of its purpose and avoid confusion with
non-static 'get' method.
Was previously only used within GAMGPreconditioner, but even there
it is better just to use the ConstPrecisionAdaptor directly.
- Can specify
```
transform
{
origin (1 2 3);
rotation none;
}
```
instead of the longer form
```
transform
{
origin (1 2 3);
e1 (1 0 0);
e3 (0 0 1);
}
```
COMPAT: remove old (pre-1812) Euler and STARCD keywords
- use "angles", remove old compat name "rotation"
as clutter and possible confusion with "coordinate rotation"
STYLE: remove coordinate rotation move constructors
- an unnecessary holdover from older code.
- adjust commented-out evaluation to avoid warnings.
With code like this
```
#if 0
nxin #eval{ round($nxin / 5) };
#endif
```
The handling of the "#if 0 / #endif" clause uses the plain ISstream
parser to tokenize. This means that the "round(" is parsed as a word
with a mismatched closing ')', whereas the "#eval" parser will slurp
everything in until the closing brace and send it off as a string
to the expression parser.
- makes it easier to use for local or alternative storage.
Eg,
```
tmp<volScalarField> tfld;
tfld.cref(obj.cfindObject<volScalarField>("name"));
if (!tfld)
{
tfld = volScalarField::New("name", ...);
}
```
- refine definition of patch boundary faces to distinguish between
boundaryFaces() and uniqBoundaryFaces().
* boundaryFaces() for edge to face lookup on boundary edges.
* uniqBoundaryFaces() for accessing quantities such as face areas
or eroding an outer layer
ENH: LabelledItem container, replaces unused 'Keyed' container
- method names in alignment with objectHit, pointIndexHit etc.
Top-level name aligns with labelledTri.
- can now drop older Test-decomposePar for exploration purposes
and simply use -dry-run with the -domains and -method options.
- write VTK file instead of volScalarField in combination
with -dry-run and -cellDist.
Avoids adding any OpenFOAM fields and is usually faster to load.
Also easier to rename than a volScalarField would be when exploring
multiple decompositions.
- minor simplification of #if/#endif handling
ENH: improve input robustness with negative-prefixed expansions (#2095)
- especially in blockMeshDict it is useful to negate an value directly.
Eg,
```
xmax 100;
xmin -$xmax;
```
However, this fails since the dictionary expansion is a two-step
process of tokenization followed by expansion. After the expansion
the given input would now be the following:
```
xmax 100;
xmin - 100;
```
and retrieving a scalar value for 'xmin' fails.
Counteract this by being more generous on tokenized input when
attempting to retrieve a label or scalar value.
If a '-' is found where a number is expected, use it to negate the
subsequent value.
The previous solution was to invoke an 'eval':
```
xmax 100;
xmin #eval{-$xmax};
```
which adds additional clutter.
- return internalEdges() and boundaryEdges() sub lists directly
- calculate and return boundaryFaces() to identify faces attached to
boundary edges.
- minor code cleanup, and add PrimitivePatchBase class for
non-templated code.
STYLE: mark unused parameter in globalMeshData mergePoints
- this constructor was added for similarity with std::vector,
but continues to cause various annoyances.
The main problem is that the templated parameter tends to grab
anything that is not a perfect match for other constructors.
Typically seen with two integers (in 64-bit mode), but various other
cases as well.
If required, the ListOps::create() function provides a lengthier
alternative but one that can also incorporate transformations.
Eg,
pointField pts = ....;
List<scalar> mags
(
List<scalar>::create
(
pts.begin(),
pts.end(),
[](const vector& v){ return magSqr(v); }
);
- additional rcEdge(), rcEdges() methods for reverse order walk
- accept generic edge() method as alternative to faceEdge() for
single edge retrieval.
- edge() method with points -> returns the vector
- reduce the number of operations in edgeDirection methods
DEFEATURE: remove longestEdge global function
- deprecated and replaced by face::longestEdge() method (2017-04)
Step 1.
include "addAllRegionOptions.H"
Adds the -allRegions, -regions and -region options to argList.
Step 2.
include "getAllRegionOptions.H"
Processes the options with -allRegions selecting everything
from the regionProperties.
OR use -regions to specify multiple regions (from
regionProperties), and can also contain regular expressions
OR use the -region option
Specifying a single -regions NAME (not a regular expresssion)
is the same as -region NAME and doesn't use regionProperties
Creates a `wordList regionNames`
Step 3.
Do something with the region names.
Either directly, or quite commonly with the following
include "createNamedMeshes.H"
Creates a `PtrList<fvMesh> meshes`
STYLE: add description to some central include files
- make regionName an optional constructor parameter, which eliminates
a separate set of constructors and construction tables. Adjust
internals to treat a missing/empty regionName as a no-op.
- pass in fallback dictionary content via new IOdictionary constructor
with a pointer
ENH: further relax check for matching number of processor dirs
- if the "numberOfSubdomains" entry is missing (or even zero)
ignore checks of processor dirs as meaningless.
- additional debug information
- improve support for dictionary specification of constant, polynomial
and table entries. These previously only worked properly for
primitiveEntry, which causes confusion.
- extend table Function1 to include TableFile functionality.
Simplifies switching and modifying content.
- additional default construct
- add explicit zero-size constructor for ITstream.
For tagged dispatching, without ambiguity
- elminate mandatory name for parsing versions.
This makes it easier to use ITstream, IStringStream, UListStream
interchangeable.
- The keyType is primarily used within dictionary reading, whereas
wordRe and wordRes are used for selectors in code.
Unifying on wordRe and wordRes reduces the number matching options.
- additional dummy template parameter to assist with supporting
derived classes. Currently just used for string types, but can be
extended.
- provide hash specialization for various integer types.
Removes the need for any forwarding.
- change default hasher for HashSet/HashTable from 'string::hash'
to `Hash<Key>`. This avoids questionable hashing calls and/or
avoids compiler resolution problems.
For example,
HashSet<label>::hasher and labelHashSet::hasher now both properly
map to Hash<label> whereas previously HashSet<label> would have
persistently mapped to string::hash, which was incorrect.
- standardize internal hashing functors.
Functor name is 'hasher', as per STL set/map and the OpenFOAM
HashSet/HashTable definitions.
Older code had a local templated name, which added unnecessary
clutter and the template parameter was always defaulted.
For example,
Old: `FixedList<label, 3>::Hash<>()`
New: `FixedList<label, 3>::hasher()`
Unchanged: `labelHashSet::hasher()`
Existing `Hash<>` functor namings are still supported,
but deprecated.
- define hasher and Hash specialization for bitSet and PackedList
- add symmetric hasher for 'face'.
Starts with lowest vertex value and walks in the direction
of the next lowest value. This ensures that the hash code is
independent of face orientation and face rotation.
NB:
- some of keys for multiphase handling (eg, phasePairKey)
still use yet another function naming: `hash` and `symmHash`.
This will be targeted for alignment in the future.
- wrap command-line retrieval of fileName with an implicit validate.
Instead of this:
fileName input(args[1]);
fileName other(args["someopt"]);
Now use this:
auto input = args.get<fileName>(1);
auto other = args.get<fileName>("someopt");
which adds a fileName::validate on the inputs
Because of how it is implemented, it will automatically also apply
to argList getOrDefault<fileName>, readIfPresent<fileName> etc.
- adjust fileName::validate and clean to handle backslash conversion.
This makes it easier to ensure that path names arising from MS-Windows
are consistently handled internally.
- dictionarySearch: now check for initial '/' directly instead of
relying on fileName isAbsolute(), which now does more things
BREAKING: remove fileName::clean() const method
- relying on const/non-const to control the behaviour (inplace change
or return a copy) is too fragile and the const version was
almost never used.
Replace:
fileName sanitized = constPath.clean();
With:
fileName sanitized(constPath);
sanitized.clean());
STYLE: test empty() instead of comparing with fileName::null
- simplify compile/uncompile, reading, assignment
- implicit construct wordRe from keyType (was explicit) to simplify
future API changes.
- make Foam::isspace consistent with std::isspace (C-locale)
by including vertical tab and form feed
ENH: improve #ifeq float/label comparisons
- originally had tests for regex meta characters strewn across
regExp classes as well as wordRe, keyType, string.
And had special-purpose quotemeta static function within string
that relied on special naming convention for testing the meta
characters.
The regex meta character testing/handling now relegated entirely
to the regExp class(es).
Relocate quotemeta to stringOps, with a predicate.
- avoid code duplication. Reuse some regExpCxx methods in regExpPosix
For example,
```
entry #eval 10 { vector(rand(), 0, 0) };
```
ENH: be more generous and ignore trailing ';' in expressions
STYLE: adjust parse token name for tensor::I
- simplifies local toggling.
- centralize fileModification static variables into IOobject.
They were previously scattered between IOobject and regIOobject
- support selective enable/disable of the file banner.
ENH: improve code isolation for decomposedBlockData
- use readBlockEntry/writeBlockEntry to encapsulate the IO handling,
which ensures more consistency
- new decomposedBlockData::readHeader for chaining into the
block header information.
- remove unused constructors for decomposedBlockData
ENH: minor cleanup of collated fileOperations
- improves interface and data consistency.
Older signatures are still active (via the Foam_IOstream_extras
define).
- refine internals for IOstreamOption streamFormat, versionNumber
ENH: improve data alignment for IOstream and IOobject
- fit sizeof label/scalar into unsigned char
STYLE: remove dead code
- read/write lists of character data in binary only.
This is the only means of preserving data.
If character data are written as an ASCII list, there is no means of
determining if spaces or newlines are content or separators.
- handle binary/contiguous first as being the most obvious, followed
by increasing complexity of ascii.
Structure reading and writing routines similarly by introducing a
readList method to compliment the writeList method.
- for use when the is_contiguous check has already been done outside
the loop. Naming as per std::span.
STYLE: use data/cdata instead of begin
ENH: replace random_shuffle with shuffle, fix OSX int64 ambiguity
- direct check of punctuation.
For example,
while (!tok.isPunctuation(token::BEGIN_LIST)) ..
instead of
while (!(tok.isPunctuation() && tok.pToken() == token::BEGIN_LIST)) ..
Using direct comparison (tok != token::BEGIN_LIST) can be fragile
when comparing int values:
int c = readChar(is);
while (tok != c) .. // Danger, uses LABEL comparison!
- direct check of word.
For example,
if (tok.isWord("uniform")) ..
instead of
if (tok.isWord() && tok.wordToken() == "uniform") ..
- make token lineNumber() a setter method
ENH: adjust internal compound method empty() -> moved()
- support named compound tokens
STYLE: setter method for stream indentation
- centralises existing functions (erfInv, incGamma*, invIncGamma*).
Provides a location for additional functions in the future.
- adjusted existing models to use these functions
(e.g. distributionModels::normal)
- robuster matching behaviour when encountering paths that themselves
contain the word "processor" in them. For example,
"/path/processor0generation2/case1/processor10/system"
will now correctly match on processor10 instead of failing.
- use procRangeType for encapsulating the processor ranges
- provision for information of distributed vs non-distributed roots.
The information is currently available from the initial setup, but
can useful to access directly within fileOperation.
STYLE: modernize list iteration
- the NullObject singleton can also be cast to a bitSet
(sufficient size and bit-pattern). Useful for places that
need to hold a reference on construction
- change to a templated implementation instead of relying on
the container's writeList() method.
This inlines the generation while also adding the flexibility to
define different delimiters (at compile time) without the
performance penalty of passing run-time parameters.
- deprecate get(key, deflt) in favour of lookup(key, deflt).
Method name compatibility with HashTable.
- deprecate operator().
The meaning is too opaque and equally served by other means:
- use get(key) instead of operator()(key).
Const access whereas HashTable::operator()(key)
creates missing entry.
- lookup(key, deflt) - instead of operator()(key, deflt).
Const access whereas HashTable::operator()(key, deflt)
creates a missing entry.
- make Enum iterable to allow participation in range-for etc.
- For slow oscillations it can be more intuitive to specify the
period.
ENH: separate mark/space for Square
- makes it easier to tailor the desired intervals.
BUG: incorrect square wave fraction with negative phase shifts
ENH: additional cosine Function1
STYLE: avoid code duplication by inheriting Cosine/Square from Sine.
- deprecated Feb-2018, but not marked as such.
The set() method originally enforce an additional run-time check
(Fatal if pointer was already set), but this was rarely used.
In fact, the set() method was invariably used in constructors
where the pointer by definition was unset.
Can now mark as deprecated to catch the last of these.
We prefer reset() for similarity with std::unique_ptr
Eg,
FOAM_EXTRA_CXXFLAGS="-DFoam_autoPtr_deprecate_setMethod" wmake
ENH: support construction of zero-sized IndirectList
- useful when addressing is to be generated in-place after construction.
Eg,
indirectPrimitivePatch myPatches
(
IndirectList<face>(mesh.faces(), Zero),
mesh.points()
);
labelList& patchFaces = myPatches.addressing();
patchFaces.resize(...);
// populate patchFaces
STYLE: add noexcept for zero/one fields and remove old dependency files
COMP: correct typedefs for geometricOneField, geometricZeroField
- uses ocountstream for the output, which swallows all output.
Improves portability
ENH: improved efficiency in countstreambuf
- xsputn() instead of overflow
- more consistent seek* methods
- prefix FOAM_MPI and library directories with 'sys-' for system
versions for uniform identication.
WM_MPLIB | libdir (FOAM_MPI) | old naming |
SYSTEMMPI | sys-mpi | mpi |
SYSTEMOPENMPI | sys-openmpi | openmpi-system |
- prefix preferences with 'prefs.' to make them more easily
identifiable, and update bin/tools/create-mpi-config accordingly
Old name: config.{csh,sh}/openmpi
New name: config.{csh,sh}/prefs.openmpi
- additional mpi preferences now available:
* prefs.intelmpi
* prefs.mpich
...
CONFIG: added hook for EASYBUILDMPI (eb-mpi), somewhat like USERMPI
- EasyBuild uses mpicc when compiling, so no explicit wmake rules are
used
ENH: support different major versions for system openmpi
- for example, with
WM_MPLIB=SYSTEMOPENMPI2
defines FOAM_MPI=sys-openmpi2 and thus creates lib/sys-openmpi2
ENH: centralize handling of mpi as 'mpi-rules'
Before:
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
sinclude $(DEFAULT_RULES)/mplib$(WM_MPLIB)
ifeq (,$(FOAM_MPI_LIBBIN))
FOAM_MPI_LIBBIN := $(FOAM_LIBBIN)/$(FOAM_MPI)
endif
After:
include $(GENERAL_RULES)/mpi-rules
- also allows variants such as SYSTEMOPENMPI2 to be handled separately
- ensures that subsequent Allwmake scripts know about it.
ENH: add bin/tools/query-detect wrapper for wmake have_* scripts
CONFIG: use project/ThirdParty without additional sanity checks
- no need to test for Allwmake or platforms/ if ThirdParty is located
within the project directory itself.
COMP: add simple mpi test to 00-dummy
- for testing library linkage, etc.
- a sphere/spheroid can be specified as a single radius or three radii.
If all three values happen to be identical, they are collapsed to a
single value. Examples,
radius 2;
radius (2 2 2);
radius (2 3 4);
radius (2 2 4);
The search for nearest point on an ellipse or ellipsoid follows the
description given by Geometric Tools (David Eberly), which also
include some pseudo code. The content is CC-BY 4.0
In the search algorithm, symmetry is exploited and the searching is
confined to the first (+x,+y,+z) octant, and the radii are ordered
from largest to smallest.
Searching is optimized for sphere, prolate and oblate spheroids.
- code reduction, documentation, code stubs for spheroid (#1901)
- make searchableSurfaceCollection available as 'collection'
for consistency with other objects
ENH: add some scalar constants for .org compatibility (#1881)
Although it can very much be a moving target, it can prove partly
useful to have some compatibility constants/methods.
- The wholesale change of 'GREAT' -> 'great' etc (JAN-2018), makes
user coding for multiple versions problematic. When
COMPAT_OPENFOAM_ORG is defined, now define constants (aliases) named
as per the openfoam.org version. Values, however, remain identical.
- For type-safe dictionary value retrieval, we have the templated
get<> methods added around NOV-2018 and deprecated the lookupType
method.
The .org version followed suit in NOV-2019, but opted for renaming
the templated lookupType method as a templated 'lookup' method.
Using this is discouraged, but allowed when COMPAT_OPENFOAM_ORG is
defined.
- flips state while preserving the textual representation.
Eg, OFF <-> ON, YES <-> NO etc.
- fix test case to avoid triggering abort(), which we cannot try/catch
- provides a more direct means of generating a compound token without
an Istream
- add transferCompoundToken() without Istream reference
- mark more token methods as noexcept
- provides consistency with identity(label, label) and looks more
familiar than using labelRange::labels()
- relocates labelRange IO operators to IntRange
ENH: make sliceRange interators random access
STYLE: scalarRanges::match() instead of predicate operator
- returns a range of `int` values that can be iterated across.
For example,
for (const int proci : Pstream::subProcs()) { ... }
instead of
for
(
int proci = Pstream::firstSlave();
proci <= Pstream::lastSlave();
++proci
)
{
...
}
- returns a range of `int` values that can be iterated across.
For example,
for (const int proci : Pstream::allProcs()) { ... }
instead of
for (label proci = 0; proci < Pstream::nProcs(); ++proci) { ... }
- add reverse iterators and replace std::iterator
(deprecated in C++17) with full definitions
- simplify construction of iterators
- construct labelRange from a single single parameter.
This creates a (0,len) range.
- make basic constructors forms constexpr.
Remove unused size checks.
- Derive labelRange from new IntRange template class.
Allows reuse of base functionality with different integral sizes.
Deprecations:
- deprecate labelRange::valid() in favour of using
labelRange::empty() or the bool operator.
For example,
if (range) ... vs older if (range.valid()) ...
DEFEATURE: drop labelRange::null, scalarRange::null static variables
- turned out to be not particularly useful.
Can simply use constexpr contructor forms
DEFEATURE: drop labelRange::identity static method
- simply use the single-parameter constructor
- introduce WM_COMPILE_CONTROL variable to convey control information
into the build rules.
The convention (as per spack):
- '+' to select a feature
- '~' to deselect a feature
Eg, to select the gold linker, and disable openmp
(spaces are not required):
WM_COMPILE_CONTROL="+gold ~openmp"
CONFIG: accept FOAM_EXTRA_LDFLAGS for AMD, gold, Mingw linkers
CONFIG: generalize PROJECT_LIBS (-ldl used almost universally)
- makes it easier to use in combination with various 'New' selectors,
which mostly return an autoPtr.
ENH: add very simple FFT test
- basic sanity test that the library links properly
- previously hidden as Detail::[IO]FstreamAllocator, now exposed
directly as [io]fstreamPointer, which allows reuse for
std::ifstream, std::ofstream wrapping, without the additional
ISstream, OSstream layers.
These stream pointers have some characteristics similar to a
unique_ptr.
- restrict direct gzstream usage to two files (fstreamPointers.C,
gzstream.C) which improves localization and makes it simpler to
enable/disable with the `HAVE_LIBZ` define.
The HAVE_LIBZ define is currently simply hard-coded in the
Make/options.
If compiled WITHOUT libz support:
- reading gz files : FatalError
- writing gz files : emit warning and downgrade to uncompressed
- warn if compression is specified in the case controlDict
and downgrade to uncompressed
ENH: minor updates to gzstream interface for C++11
- support construct/open with std::string for the file names.
CONFIG: provisioning for have_libz detection as wmake/script
- naming similarity with autoPtr, unique_ptr and other containers.
For UPtrList derivatives, this is equivalent to the existing
operator(). The read-only variant is also equivalent to the
single-parameter 'set(label)' method.
With PtrList<T> list(...) :
const T* ptr = list.get(10);
if (ptr)
{
ptr->method();
}
vs.
if (list.set(10))
{
list[10].method();
}
For HashPtrTable there is only a read-only variant which is equivalent
to testing for existence and for value.
With HashPtrTable<T> hash(...) :
const T* ptr = list.get("key");
if (ptr)
{
ptr->method();
}
vs.
if (list.found("key"))
{
// Fails on null pointer!!
list["key"].method();
}
Use of get() is largely a matter of taste or local coding requirements
- forwarding like the emplace() method, but overwriting existing
entries as required
- propagate similar changes to HashPtrTable
For example, with HashPtrTable<labelList> table(...) :
With 'insert' semantics
table.emplace("list1", 1000);
vs
if (!table.found("list1"))
{
table.set("list1", new labelList(1000));
}
or
table.insert("list1", autoPtr<labelList>::New(1000));
Note that the last example invokes an unnecessary allocation/deletion
if the insertion is unsuccessful.
With 'set' semantics:
table.emplace_set("list1", 15);
vs
table.set("list1", new labelList(15));
The fakeError function object emits FatalError at different stages (or
does nothing), which is useful for testing purposes (issue #1779).
Can request errors from constructor, execute and write methods.
- with '&&' conditions, often better to check for non-null autoPtr
first (it is cheap)
- check as bool instead of valid() method for cleaner code, especially
when the wrapped item itself has a valid/empty or good.
Also when handling multiple checks.
Now
if (ptr && ptr->valid())
if (ptr1 || ptr2)
instead
if (ptr.valid() && ptr->valid())
if (ptr1.valid() || ptr2.valid())
- libs() singleton method for global library handling
- explicit handling of empty filename for dlLibraryTable open/close.
Largely worked before, but now be more explicit about its behaviour.
- add (key, dict) constructor and open() methods.
More similarity to dimensionedType, Enum etc, and there is no
ambiguity with the templated open().
- construct or open from initializer_list of names
- optional verbosity when opening with auxiliary table,
avoid duplicate messages or spurious messages for these.
- basename and fullname methods (migrated from dynamicCode).
- centralise low-level load/unload hooks
- adjust close to also dlclose() aliased library names.
- use simpler decomposeParDict in tutorials, several had old
'boilerplate' decomposeParDict
- use simpler libs () format
- update surface sampling to use dictionary format
1) Implementation of the compressibleIsoInterFOam solver
2) Implementation of a new PLIC interpolation scheme.
3) New tutorials associated with the solvers
This implementation was carried out by Henning Scheufler (DLR) and Johan
Roenby (DHI), following :
\verbatim
Henning Scheufler, Johan Roenby,
Accurate and efficient surface reconstruction from volume fraction data
on general meshes, Journal of Computational Physics, 2019, doi
10.1016/j.jcp.2019.01.009
\endverbatim
The integration of the code was carried out by Andy Heather and Sergio
Ferraris from OpenCFD Ltd.
ENH: add Test-EigenMatrix application
The new iterative eigen decomposition functionality is
derived from:
Passalacqua et al.'s OpenQBMM (openqbmm.org/),
which is mostly derived from JAMA (math.nist.gov/javanumerics/jama/).
- bundled of boolean values as a vector of 3 components with
element access using x(), y() and z() member functions.
It also has some methods similar to bitSet.
- Not derived from Vector or VectorSpace since it does not share very
many vector-like characteristics.
- support construct from initializer_list, which can help simplify
code with constant coefficients.
- add default constructor for polynomialFunction and Istream reading
to support resizable lists of polynomialFunction.
A default constructed polynomialFunction is simply equivalent to
a constant zero.
- no special IO handling for Polynomial required,
it is the same as VectorSpace anyhow.
- previously introduced `getOrDefault` as a dictionary _get_ method,
now complete the transition and use it everywhere instead of
`lookupOrDefault`. This avoids mixed usage of the two methods that
are identical in behaviour, makes for shorter names, and promotes
the distinction between "lookup" access (ie, return a token stream,
locate and return an entry) and "get" access (ie, the above with
conversion to concrete types such as scalar, label etc).
- Favour use of argList methods that are more similar to dictionary
method names with the aim of reducing the cognitive load.
* Silently deprecate two-parameter get() method in favour of the
more familiar getOrDefault.
* Silently deprecate opt() method in favour of get()
These may be verbosely deprecated in future versions.
- similar to the behaviour of std::ignore and consistent with the
no input / no output nature of nullObject. Similarly accept a
const reference for its Istream operator.
- make most nullObject methods constexpr
- mostly wraps std::chrono so can inline much of it, which is potentially
helpful when used for inner timings.
- add elapsedTime() method for direct cast to double and for
naming similarity with wall-clock method.
Potential breaking change (minor):
- clockValue construct with a bool parameter is now simply tagged
dispatch (value is ignored) and always queries the current clock
value. This avoids needless branching.
Since this constructor form has primarily been used internally (eg,
clockTime), breakages in user code are not expected.
- have printBuildInfo output to std::ostream
- removed extraneous include "stdFoam.H"
ENH: revert to pre-processor defines for hard-coded paths (#1712)
- redundant information, but more robust at run-time without relying
on initialization order
- less frequently used, but the information was previously inaccessible
under etcFiles.C.
Now exposed within the foamVersion namespace and defined under
<global.Cver> to improve configuration possibilities.
- simplified templating, which cleans up code and does not appear to
break any normal user coding.
ENH: unique_ptr instead of homegrown demand-driven handling.
- takes a search string and a replacement character.
The replacement character can also be a nul char ('\0'), which
simply removes the characters.
Possible uses:
* Replace reserved characters
str.replaceAny("<>:", '_');
* Remove shell meta-characters or reserved filesystem characters
str.replaceAny("*?<>{}[]:", '\0');
- adjustments to internal handling to improve run-time addition of
other formats (eg, with additional user library)
For example, to write a binary STL with a '.stl' extension:
$ surfaceMeshConvert input.obj -write-format stlb output.stl
Or in a sampler,
to specify the input type without ambiguity:
surf
{
type meshedSurface;
surface sampling.inp;
fileType starcd;
scale 0.001;
...
}
STYLE: regularize naming for input/output scaling
* -read-scale (compat: -scaleIn)
* -write-scale (compat: -scaleOut)
CONFIG: change edge/surface selection name for STARCD format
- now select as "starcd" instead of "inp" to avoid naming ambiguity
with abaqus
- face_type, point_type (similar to STL value_type, etc).
The naming avoids potential confusion with template parameters.
- rename private typedef from ParentType to MeshReference for more
consistency with polySurface etc.
- previously used a Pstream::exit() invoked from the argList
destructor to handle all MPI shutdown, but this has the unfortunate
side-effect of using a fixed return value for the program exit.
Instead use the Pstream::shutdown() method in the destructor and allow
the normal program exit codes as usual. This means that the
following code now works as expected.
```
argList args(...);
if (...)
{
InfoErr<< "some error\n";
return 1;
}
```
Style changes:
- use std algorithm for some stringOps internals
- pass SubStrings iterators by const reference
ENH: special nullptr handling for ISstream getLine
- pass through to istream::ignore to support read and discard
* Support default values for format/compress enum lookups.
- Avoids situations where the preferred default format is not ASCII.
For example, with dictionary input:
format binar;
The typing mistake would previously have caused formatEnum to
default to ASCII. We can now properly control its behaviour.
IOstream::formatEnum
(
dict.get<word>("format"), IOstream::BINARY
);
Allowing us to switch ascii/binary, using BINARY by default even in
the case of spelling mistakes. The mistakes are flagged, but the
return value can be non-ASCII.
* The format/compression lookup behave as pass-through if the lookup
string is empty.
- Allows the following to work without complaint
IOstream::formatEnum
(
dict.getOrDefault("format", word::null), IOstream::BINARY
);
- Or use constructor-like failsafe method
IOstream::formatEnum("format", dict, IOstream::BINARY);
- Apply the same behaviour with setting stream format/compression
from a word.
is.format("binar");
will emit a warning, but leave the stream format UNCHANGED
* Rationalize versionNumber construction
- constexpr constructors where possible.
Default construct is the "currentVersion"
- Construct from token to shift the burden to versionNumber.
Support token as argument to version().
Now:
is.version(headerDict.get<token>("version"));
or failsafe constructor method
is.version
(
IOstreamOption::versionNumber("version", headerDict)
);
Before (controlled input):
is.version
(
IOstreamOption::versionNumber
(
headerDict.get<float>("version")
)
);
Old, uncontrolled input - has been removed:
is.version(headerDict.lookup("version"));
* improve consistency, default behaviour for IOstreamOption construct
- constexpr constructors where possible
- add copy construct with change of format.
- construct IOstreamOption from streamFormat is now non-explicit.
This is a commonly expected result with no ill-effects
- renamed 'core/' -> 'base/' to avoid gitignore masking when re-adding
files
- rename 'nas/' to 'nastran/' for more clarity
- relocated OBJstream from surfMesh to fileFormats
STYLE: remove unused parseNASCoord. Was deprecated 2017-09
- `tensor` and `tensor2D` returns complex eigenvalues/vectors
- `symmTensor` and `symmTensor2D` returns real eigenvalues/vectors
- adds new test routines for eigendecompositions
- improves numerical stability by:
- using new robust algorithms,
- reordering the conditional branches in root-type selection
- ensures each Tensor-container operates for the following base types:
- floatScalar
- doubleScalar
- complex
- adds/improves test applications for each container and base type:
- constructors
- member functions
- global functions
- global operators
- misc:
- silently removes `invariantIII()` for `tensor2D` and `symmTensor2D`
since the 3rd invariant does not exist for 2x2 matrices
- fixes `invariantII()` algorithm for `tensor2D` and `symmTensor2D`
- adds `Cmpt` multiplication to `Vector2D` and `Vector`
- adds missing access funcs for symmetric containers
- improves func/header documentations
- provides an indirect access to a sub-section of a list that is
somewhat less efficient than a Foam::SubList, but supports the
following:
* adjustment of its addressing range after construction
* recovery of the original, underlying list at any time
This can be more convenient for some coding cases.
For example,
template<class Addr>
void renumberFaces(IndirectListBase<face, Addr>& faces, ...);
which can be called for
* Specific faces:
UIndirectList<face>(mesh.faces(), facesToChange)
* A sub-range of faces:
IndirectSubList<face>(mesh.faces(), pp.range())
* All faces:
IndirectSubList<face>(mesh.faces())
CONFIG: added IndirectListsFwd.H with some common forwarding
- now use debug 2 for scanner and debug 4 for parser.
Provided better feedback about what is being parsed (debug mode)
- relocate debug application to applications/tools/foamExprParserInfo
- follows the principle of least surprise if the expansion behaviour
for #eval and expressions (eg, exprFixedValue) are the same. This
is possible now that we harness the regular stringOps::expand()
within exprString::expand()
- reuse more of stringOps expansions to reduce code and improve the
syntax flexiblity.
We can now embed "pre-calculated" values into an expression.
For example,
angle 35;
valueExpr "vector(${{cos(degToRad($angle))}}, 2, 3)";
and the ${{..}} will be evaluated with the regular string evaluation
and used to build the entire expression for boundary condition
evaluation.
Could also use for fairly wild indirect referencing:
axis1 (1 0 0);
axis2 (0 1 0);
axis3 (0 0 1);
index 100;
expr "$[(vector) axis${{ ($index % 3) +1 }}] / ${{max(1,$index)}}";
QRMatrix (i.e. QR decomposition, QR factorisation or orthogonal-triangular
decomposition) decomposes a scalar/complex matrix \c A into the following
matrix product:
\verbatim
A = Q*R,
\endverbatim
where
\c Q is a unitary similarity matrix,
\c R is an upper triangular matrix.
Usage
Input types:
- \c A can be a \c SquareMatrix<Type> or \c RectangularMatrix<Type>
Output types:
- \c Q is always of the type of the matrix \c A
- \c R is always of the type of the matrix \c A
Options for the output forms of \c QRMatrix (for an (m-by-n) input matrix
\c A with k = min(m, n)):
- outputTypes::FULL_R: computes only \c R (m-by-n)
- outputTypes::FULL_QR: computes both \c R and \c Q (m-by-m)
- outputTypes::REDUCED_R: computes only reduced \c R (k-by-n)
Options where to store \c R:
- storeMethods::IN_PLACE: replaces input matrix content with \c R
- storeMethods::OUT_OF_PLACE: creates new object of \c R
Options for the computation of column pivoting:
- colPivoting::FALSE: switches off column pivoting
- colPivoting::TRUE: switches on column pivoting
Direct solution of linear systems A x = b is possible by solve() alongside
the following limitations:
- \c A = a scalar square matrix
- output type = outputTypes::FULL_QR
- store method = storeMethods::IN_PLACE
Notes
- QR decomposition is not unique if \c R is not positive diagonal \c R.
- The option combination:
- outputTypes::REDUCED_R
- storeMethods::IN_PLACE
will not modify the rows of input matrix \c A after its nth row.
- Both FULL_R and REDUCED_R QR decompositions execute the same number of
operations. Yet REDUCED_R QR decomposition returns only the first n rows
of \c R if m > n for an input m-by-n matrix \c A.
- For m <= n, FULL_R and REDUCED_R will produce the same matrices
COMP: delay evaluation of fieldToken enumeration types
- lazy evaluation at runTime instead of compile-time to make the code
independent of initialization order.
Otherwise triggers problems on gcc-4.8.5 on some systems where
glibc is the same age, or older.
- replace stringOps::toScalar with a more generic stringOps::evaluate
method that handles scalars, vectors etc.
- improve #eval to handle various mathematical operations.
Previously only handled scalars. Now produce vectors, tensors etc
for the entries. These tokens are streamed directly into the entry.
- ITstream append() would previously have used the append from the
underlying tokenList, which leaves the tokenIndex untouched and
renders the freshly appended tokens effectively invisible if
interspersed with primitiveEntry::read() that itself uses tokenIndex
when building the list.
The new append() method makes this hidden ITstream bi-directionality
easier to manage. For efficiency, we only append lists
(not individual tokens) and support a 'lazy' resizing that allows
the final resizing to occur later when all tokens have been appended.
- The new ITstream seek() method provides a conveniently means to move
to the end of the list or reposition to the middle.
Using rewind() and using seek(0) are identical.
ENH: added OTstream to output directly to a list of tokens
---
BUG: List::newElem resized incorrectly
- had a simple doubling of the List size without checking that this
would indeed be sufficient for the requested index.
Bug was not triggered since primitiveEntry was the only class using
this call, and it added the tokens sequentially.
- allows use of Enum in more situations where a tiny Map/HashTable
replacement is desirable. The new methods can be combined with
null constructed for to have a simple low-weight caching system
for words/integers instead of fitting in a HashTable.
- silently deprecate 'startsWith', 'endsWith' methods
(added in 2016: 2b14360662), in favour of
'starts_with', 'ends_with' methods, corresponding to C++20 and
allowing us to cull then in a few years.
- handle single character versions of starts_with, ends_with.
- add single character version of removeEnd and silently deprecate
removeTrailing which did the same thing.
- drop the const versions of removeRepeated, removeTrailing.
Unused and with potential confusion.
STYLE: use shrink_to_fit(), erase()
- Now accept '/' when reading variables without requiring
a surrounding '{}'
- fix some degenerate parsing cases when the first character is
already bad.
Eg, $"abc" would have previously parsed as a <$"> variable, even
although a double quote is not a valid variable character.
Now emits a warning and parses as a '$' token and a string token.
- add toScalar evaluation, embedded as "${{EXPR}}".
For example,
"repeat ${{5 * 7}} times or ${{ pow(3, 10) }}"
- use direct string concatenation if primitive entry is only a string
type. This prevents spurious quotes from appearing in the expansion.
radius "(2+4)";
angle "3*15";
#eval "$radius*sin(degToRad($angle))";
We want to have
'(2+4)*sin(degToRad(3*15))'
and not
'"(2+4)"*sin(degToRad("3*15"))'
ENH: code refactoring
- refactored expansion code with low-level service routines now
belonging to file-scope. All expansion routines use a common
multi-parameter backend to handle with/without dictionary etc.
This removes a large amount of code duplication.
- add floor/ceil/round methods
- support evaluation of sub-strings
STYLE: add blockMeshDict1.calc, blockMeshDict1.eval test dictionaries
- useful for testing and simple demonstration of equivalence
- SubField and SubList assign from zero
- SubField +=, -=, *=, /= operators
- SubList construct from UList (as per SubField)
Note: constructing an anonymous SubField or SubList with a single
parameter should use '{} instead of '()' to avoid compiler
ambiguities.
- the #eval directive is similar to the #calc directive, but for evaluating
string expressions into scalar values. It uses an internal parser for
the evaluation instead of dynamic code compilation. This can make it
more suitable for 'quick' evaluations.
The evaluation supports the following:
- operations: - + * /
- functions: exp, log, log10, pow, sqrt, cbrt, sqr, mag, magSqr
- trigonometric: sin, cos, tan, asin, acos, atan, atan2, hypot
- hyperbolic: sinh, cosh, tanh
- conversions: degToRad, radToDeg
- constants: pi()
- misc: rand(), rand(seed)
- this largely reverts 3f0f218d88 and 4ee65d12c4.
Consistent addressing with support for wrapped pointer types (eg,
autoPtr, std::unique_ptr) has proven to be less robust than desired.
Thus rescind HashTable iterator '->' dereferencing (from APR-2019).
- relax casting rules
* down-cast of labelToken to boolToken
* up-cast of wordToken to stringToken.
Can use isStringType() test for word or string types
- simplify constructors, move construct etc.
- expose reset() method as public, which resets to UNDEFINED and
clears allocated storage etc.
DEFEATURE: remove assign from word or string pointer.
- This was deprecated 2017-11 and now removed.
For this type of content transfer, move assignment should be used
instead of stealing pointers.
- change contiguous from a series of global functions to separate
templated traits classes:
- is_contiguous
- is_contiguous_label
- is_contiguous_scalar
The static constexpr 'value' and a constexpr conversion operator
allow use in template expressions. The change also makes it much
easier to define general traits and to inherit from them.
The is_contiguous_label and is_contiguous_scalar are special traits
for handling data of homogeneous components of the respective types.
- this is principally for cases where reduced indentation is desired,
such as when streaming to a memory location. If the indentation size
is zero or one, only a single space will be used to separate the
key/value.
This change does not affect the stream allocation size, since the
extra data falls within the padding.
ENH: relocate label/scalar sizes from Istream to IOstream.
- could allow future use for output streams as well?
Due to padding, reorganization has no effect on allocated size
of output streams.
STYLE: add read/write name qualifier to beginRaw, endRaw
- removes ambiguity for bi-directional streams
STYLE: fix inconsistent 'const' qualifier on std::streamsize
- base Ostream was without const, some derived streams with const
- allows full recovery of allocated space, not just addressable range.
This can be particularly useful for code patterns that repeatedly
reuse the same buffer space. For example,
DynamicList<char> buf(1024);
// some loop
{
OListStream os(std::move(buf));
os << ...
os.swap(buf);
}
Can read back from this buffer as a second operation:
{
UIListStream is(buf);
is >> ...
}
- the behaviour of std::rename with overwriting an existing file is
implementation dependent:
- POSIX: it overwrites.
- Windows: it does not overwrite.
- for Windows need to use the ::MoveFileEx() routine for overwriting.
More investigation is needed for proper handling of very long names.
- unfriend HashSet, HashTable IO operators
- global min(), max(), minMax() functions taking a labelHashSet and an
optional limit. For example,
labelHashSet set = ...;
Info<< "min is " << min(set) << nl;
Info<< "max (non-negative) " << max(set, 0) << nl;
- make HashTable iterator '->' dereferencing more consistent by also
supporting non-pointer types as well.
- read HashTable values in-situ to avoid copying
ENH: define addition/subtraction operations for scalar and complex
- required since construct complex from scalar is explicit
- additional tests in Test-complex
- forces c++DBUG='-DFULLDEBUG -g -O0' for the compilation, to allow
localized debugging during development without file editing and
while retaining the WM_COMPILE_OPTION (eg, Opt)
Note that switching between 'wmake' and 'wmake -debug' will not
cause existing targets to be rebuilt. As before, these are driven by
the dependencies. An intermediate wclean may thus be required.
- generalize identity matrix constructors for non-scalar types
- add constructors using labelPair for the row/column sizing information.
For a SquareMatrix, this provides an unambiguous parameter resolution.
- reuse assignment operators
STYLE: adjust matrix comments