- handles basic operations, references to other dictionary entries
(with '$name' syntax) and assorted mathematical functions:
pi(), degToRad, radToDeg, asin, acos, atan, sin, cos, tan, log,
log10, mag, atan2, pow
The basic syntax: #calc{ ... };
NOTE the trailing ';' is required for the primitiveEntry to be
properly defined.
- Rewrote globalPoints to use globalIndex class so now only transfers
single label instead of labelPair
- Added addressing in globalMeshData
- from coupled master points to slave points
- ,, edges ,, edges
- from coupled points (master or slave) to uncoupled boundary faces
- ,, ,, cells
- See test/globalMeshData for simple test
- Previously had just 'Warning' instead of '::Foam::Warning', which
meant that an identically named class method would inadvertently be
used - resulting in a compile failure.
- resize with factor 2 as per DynamicList
Old insertion speed:
1000000 in 0.61 s
2000000 in 2.24 s
3000000 in 3.97 s
4000000 in 5.76 s
5000000 in 7.54 s
6000000 in 9.41 s
7000000 in 11.5 s
New insertion speed:
1000000 in 0.01 s
2000000 in 0.02 s
3000000 in 0.01 s
4000000 in 0.02 s
5000000 in 0.01 s
6000000 in 0.01 s
7000000 in 0.01 s
- compatibility:
* 'polySpline' and 'simpleSpline' accepted
* detect and discard end tangent specifications
- a BSpline is also included (eg, for future support of NURBS), but is
not selectable from blockMesh since it really isn't as nice as the
Catmull-Rom (ie, doesn't *exactly* go through each point).
triangle, from:
http://en.wikipedia.org/wiki/Inertia_tensor_of_triangle
Adding the ability to calculate the inertia tensor of a polygon face
by summing the triangle inertias.
Added a test application to draw a test face with its principal
axes and moments of inertia.
- now that I re-examined the code, the note in commit 51fd6327a6
can be mostly ignored
PackedList isMaster(nPoints, 1u);
is not really inefficient at all, since the '1u' is packed into
32/64-bits before the subsequent assignment and doesn't involve
shifts/masking for each index
The same misinformation applies to the PackedList(size, 0u) form.
It isn't much slower at all.
Nonetheless, add bool specialization so that it is a simple assign.
- forgot to use readList in removeEntry, which caused the test failure.
- remaining problem:
it doesn't work as might be expected
This is the problem:
dict
{
foo xxx;
bar yyy;
}
dict
{
baz zzz;
#remove foo
}
This only removes 'foo' from the current scope (the second dict), since
it occurs before the dictionary merge does.
To remove from the final, merged dictionary, we'd need a new
deleteEntry type that would do the right thing on the merge before
self-destructing (ie, removing itself too).
- iterators store pointers instead of references to the HashTbl.
This lets us use the default bitwise copy/assignment
- add empty constructor for iterators. It returns the equivalent to end().
This lets us do this:
HashTbl<label>::iterator iter;
// some time later
iter = find(Value);
- erase(const HashTbl<AnyType, Key, AnyHash>&) is now more generous.
Only the Key type matters, not the hashing function.
Conflicts:
src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C
src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H
src/mesh/blockMesh/curvedEdges/BSpline.C
src/mesh/blockMesh/curvedEdges/spline.C
src/mesh/blockMesh/curvedEdges/spline.H
- Also adjusted chemistrySolver/EulerImplicit/EulerImplicit.C
to use simpleMatrix with initialized values
- following Andy's idea to return values as label whenever possible
eg, 1.2e6 -> 1200000
but left it commented out
- avoid buffer overflow in ISstream::read(word&).
Is the 'if (fail())' check itself actually in the correct place??
- other minor cosmetic changes
- allow construct with Xfer container for the addressing
- Replaced non-const addressing() method in BiIndirectList with
resetAddressing() method as per IndirectList
- could also move to utilities/miscellaneous
- the dictionary compare contents might be useful enough to move
into dictionary code.
- usage example (w/o -rewrite):
for i in $(find -name fvSolution)
do
fvSolutionCombine -case "${i%/system/fvSolution}"
done
- use shift-right instead of shift-left formulation to avoid wrong behaviour
with non-optimized compilation when the packed items fit exactly in the
available number of bits.
- use shift-right instead of shift-left formulation to avoid wrong behaviour
with non-optimized compilation when the packed items fit exactly in the
available number of bits.
- similar to the #include directive, but does not generate an error if the
file does not exist.
Note: opted for an explicit naming #includeIfPresent rather than #cinclude
Oriented somewhat on dictionary methods.
Return the argument string associated with the named option:
Info<< "-foo: " << args.option("foo") << nl;
Return true if the named option is found
if (args.optionFound("foo")) ...
Return an IStringStream to the named option
old: value = readScalar(IStringStream(args.options()["foo"])());
newer: value = readScalar(args.optionLookup("foo")());
also: List<scalar> lst(args.optionLookup("foo")());
Read a value from the named option
newest: value = args.optionRead<scalar>("foo");
Read a value from the named option if present.
old: if (args.options().found("foo"))
{
value = readScalar(IStringStream(args.options()["foo"])());
}
new: args.optionReadIfPresent("foo", value);
Read a List of values from the named option
patches = args.optionReadList<word>("patches");
Didn't bother adding optionReadListIfPresent<T>(const word&), since it
probably wouldn't be common anyhow.
- Read a bracket-delimited list, or handle a single value as list of size 1.
Mostly useful for handling command-line arguments.
eg,
if (args.options().found("patches"))
{
patches = readList<word>(IStringStream(args.options()["patches"])());
}
can handle both of these:
-patches patch0
-patches \( patch1 patch2 patch3 \)
- added constructor dictionary(const dictionary*) that also handles NULL
pointers and makes it convenient to construct from a possibly nonexistent
sub-dictionary:
eg,
dictionary dict2(dict1.subDictPtr("someDict"));
- make some of the turbulence Coeffs sub-dictionary optional.
Their contents are all 'lookupOrAddDefault' anyhow.
- in turbulentMixingLength BCs, skip namespace qualifier in template
(eg, <RASModel> vs. <compressible::RASModel>)
- change comments from 'turbulenceProperties' to RASProperties/LESProperties
- consistency between compressible/incompressible - no separate file for
'New' selector etc
- consistency in accessing the model coefficients.
Use method coeffDict() for const access.
Use protected data member coeffDict_ for read/write access.
- document model coefficients in etc/constant/RASProperties.
Need the same for LESProperties before we can prune these from the
tutorials.
- #inputMode error
now issues a FatalError on duplicate entries
- #inputMode warn
issues a warning on duplicate entries, corresponds to the
old behaviour of 'error'
- #inputMode protect
prevents overwriting existing entries
The 'protect' mode provides a simple mechanism for supplying default values.
eg,
in file1:
#inputMode protect
intensity 0.1;
mixingLength 0.005;
#inputMode merge
inlet
{
type turbulentIntensityKineticEnergyInlet;
intensity $intensity;
}
which is included from file2:
intensity 0.05;
#include "file1"
- objectRegistry gets a rename() that also adjusts the dbDir
- cloud reworked to use static variables subInstance and defaultName.
This avoids writing "lagrangian" everywhere
string fixes
- avoid masking of std::string::replace in string.H
- avoid old strstream in PV3FoamReader
- regIOobject: don't re-register an unregister object on rename/assignment
- Hasher: split-off HasherInt with uint32_t specializations
- IOobject: writeBanner/writeDivider return Stream for easier chaining.
... also dropped some namespace bracketing while I was at it.
- If the underlying type is contiguous, FixedList hashes its storage directly.
- Drop labelPairHash (non-commutative) from fvMeshDistribute since
FixedList::Hash does the right thing anyhow.
- Hash<edge> specialization is commutative, without multiplication.
- Hash<triFace> specialization kept multiplication (but now uLabel).
There's not much point optimizing it, since it's not used much anyhow.
Misc. changes
- added StaticAssert to NamedEnum.H
- label.H / uLabel.H : define FOAM_LABEL_MAX, FOAM_ULABEL_MAX with the
values finally used for the storage. These can be useful for pre-processor
checks elsewhere (although I stopped needing them in the meantime).
- not much speed difference between SuperFastHash and Jenkin's lookup3 but
both are 5-10% faster than what is currently implemented in Foam::string,
albeit inlining probably helps there.
- TODO: integration with existing infrastructure
- compare iteratorBase == iteratorBase by value, not position
thus this works
list[a] == list[b] ...
- compare iterator == iteratorBase and const_iterator == iteratorBase
by position, not value. The inheritance rules means that this works:
iter == list.end() ...
this will compare positions:
iter == list[5];
Of course, this will still compare values:
*iter == list[5];
- it was possible to create a PackedList::iterator from a
PackedList::const_iterator and violate const-ness
- added HashTable::printInfo for emitting some information
- changed default table sizes from 100 -> 128 in preparation for future
2^n table sizes
- much better performance on empty tables (4-6x speedup), neutral
performance change on filled tables. Since tableSize_ is non-zero when
nElmts_ is, there is no modulus zero problem.
- change system/controlDict to use functions {..} instead of functions (..);
* This is internally more efficient
- fixed formatting of system/controlDict functions entry
- pedantic change: use 'return 0' instead of 'return(0)' in the applications,
since return is a C/C++ keyword, not a function.
- this (now deprecated) idiom:
for (runTime++; !runTime.end(); runTime++) { ... }
has a few problems:
* stop-on-next-write will be off-by-one (ie, doesn't work)
* function objects are not executed on exit with runTime.end()
Fixing these problems is not really possible.
- this idiom
while (runTime.run())
{
runTime++;
...
}
works without the above problems.
- added class OSHA1stream for a stream-based calculation method
- dictionary gets digest() method
- dictionaryEntry tweak: avoid trailing space after dictionary keyword
- OSspecific: chmod() -> chMod(), even although it's not used anywhere
- ListOps get subset() and inplaceSubset() templated on BoolListType
- added UList<bool>::operator[](..) const specialization.
Returns false (actually pTraits<bool>::zero) for out-of-range elements.
This lets us use List<bool> with lazy evaluation and no noticeable
change in performance.
- use rcIndex() and fcIndex() wherever possible.
Could check if branching or modulus is faster for fcIndex().
- UList and FixedList get 'const T* cdata() const' and 'T* data()' members.
Similar to the STL front() and std::string::data() methods, they return a
pointer to the first element without needing to write '&myList[0]', recast
begin() or violate const-ness.
- moving back to original flat addressing in iterators means there is no
performance issue with using lazy evaluation
- set() method now has ~0 for a default value.
We can thus simply write 'set(i) to trun on all of the bits.
This means we can use it just like labelHashSet::set(i)
- added flip() method for inverting bits. I don't know where we might need
it, but the STL has it so we might as well too.
- dropped auto-vivification for now (performance issue), but reworked to
allow easy reinstatement
- derived both iterator and const_iterator from iteratorBase and use
iteratorBase as our proxy for non-const access to the list elements.
This allows properly chaining assignments:
list[1] = list[2];
list[1] = list[2] = 10;
- assigning iterators from iteratorBase or other iterators works:
iterator iter = list[20];
- made template parameter nBits=1 the default
- the bit counting is relatively fast:
under 0.2 seconds for 1M bits counted 1000 times
- trim()'ing the final zero elements tested for a few cases,
but might need more attention
- exists() = forward to OSspecific exists(...)
- isDir() = forward to OSspecific dir(...)
- isFile() = forward to OSspecific file(...)
- IOobjectComponents() - split into instance, local, name following rules
set out for IOobject.
- added IOobject(path, registry, ...) constructor that uses
fileName::IOobjectComponents(). This hides the complexity we otherwise need.
- added Mattijs' speed tests
- optimized resize() and assignment operators to avoid set() method
- add const_iterator and re-did the proxy handling.
Reading/writing by looping across iterators is still somewhat slow, but
might be acceptable.
- eliminated previous PackedBitRef class, the iterator does all of that and
can also be used to (forward) traverse the list
- no const_iterator yet
- Note that PackedList is also a bit like DynamicList in terms of storage
management and the append() method. Since the underlying storage in
integer, any auto-vivified elements will also flood-fill the gaps with
zero.
regExp:
- added optional ignoreCase for constructor.
- the compile() methods is now exposed as set(...) method with an optional
ignoreCase argument. Not currently much use for the other regex compile
flags though. The set() method can be used directly instead of the
operator=() assignment.
keyType + wordRe:
- it's not clear that any particular characters are valid/invalid (compared
to string or word), so just drop the valid(char) method for now
wordRe:
- a bool doesn't suffice, added enum compOption (compile-option)
- most constructors now have a compOption. In *all* cases it defaults to
LITERAL - ie, the same behaviour for std::string and Foam::string
- added set(...) methods that do much the same as operator=(...), but the
compOption can be specified. In all cases, it defaults to DETECT.
In Summary
By default the constructors will generally preserve the argument as
string literal and the assignment operators will use the wordRe::DETECT
compOption to scan the string for regular expression meta characters
and/or invalid word characters and react accordingly.
The exceptions are when constructing/assigning from another
Foam::wordRe (preserve the same type) or from a Foam::word (always
literal).