... | ... | @@ -4,32 +4,20 @@ |
|
|
|
|
|
## User Input / Interaction
|
|
|
|
|
|
### Environment
|
|
|
|
|
|
Since OpenFOAM-v1612, `FOAM_INST_DIR` and `foamInstDir` no longer have any
|
|
|
special meanings when sourcing the `bashrc` or `cshrc` files.
|
|
|
|
|
|
The outdated use of `foamInstDir` and `FOAM_INST_DIR` has been largely removed.
|
|
|
If you have environments that used these values, they may require
|
|
|
adjustment.
|
|
|
|
|
|
|
|
|
### Dictionary input compatibility
|
|
|
|
|
|
Removed deprecated support for `compressed/uncompressed` as selector
|
|
|
names for the `writeCompression` type.
|
|
|
|
|
|
These were deprecated DEC-2009 and now finally removed.
|
|
|
|
|
|
If these are encountered, a warning will be emitted
|
|
|
|
|
|
Unknown compression specifier 'compressed', assuming no compression
|
|
|
|
|
|
```
|
|
|
Unknown compression specifier 'compressed', assuming no compression
|
|
|
```
|
|
|
Update your dictionaries to use a normal switch value:
|
|
|
|
|
|
writeCompression on;
|
|
|
writeCompression off;
|
|
|
|
|
|
```
|
|
|
writeCompression on;
|
|
|
writeCompression off;
|
|
|
```
|
|
|
|
|
|
## Source code incompatibilities
|
|
|
|
... | ... | @@ -41,10 +29,11 @@ code. |
|
|
### Compiler define for the API level
|
|
|
|
|
|
The compiler define for the API level is simplified:
|
|
|
|
|
|
##if OPENFOAM < 1806
|
|
|
... old code
|
|
|
##endif
|
|
|
```
|
|
|
#if OPENFOAM < 1806
|
|
|
... old code
|
|
|
#endif
|
|
|
```
|
|
|
|
|
|
The older `OPENFOAM_PLUS` define is provided (in stdFoam.H)
|
|
|
for existing code.
|
... | ... | @@ -76,22 +65,22 @@ Previously it was possible to implicitly create a string from a single |
|
|
character, which could lead to very curious situations.
|
|
|
|
|
|
Both of these would have previously worked:
|
|
|
|
|
|
str.replace('(', '_'); // Sure
|
|
|
str.replace('(', true); // Compiled, but a bad idea
|
|
|
|
|
|
```
|
|
|
str.replace('(', '_'); // Sure
|
|
|
str.replace('(', true); // Compiled, but a bad idea
|
|
|
```
|
|
|
This constructor is now marked as being explicit, to avoid dubious
|
|
|
automatic conversions. This means that some existing code will not
|
|
|
compile.
|
|
|
|
|
|
For example, the following
|
|
|
|
|
|
str.replace('(', '_'); // Sure
|
|
|
|
|
|
```
|
|
|
str.replace('(', '_'); // Sure
|
|
|
```
|
|
|
should be changed to this
|
|
|
|
|
|
str.replace("(", "_");
|
|
|
|
|
|
```
|
|
|
str.replace("(", "_");
|
|
|
```
|
|
|
|
|
|
### regExp
|
|
|
|
... | ... | @@ -111,16 +100,16 @@ possible due to incomplete coverage with various compilers. |
|
|
The `regExp::results_type` now behaves similarly to the C++11 `std::smatch`
|
|
|
type.
|
|
|
|
|
|
Old:
|
|
|
|
|
|
List<std::string> mat;
|
|
|
if (re.match(text, mat)) Info<< "group 1: " << mat[0] << nl;
|
|
|
|
|
|
New:
|
|
|
|
|
|
regExp::results_type mat;
|
|
|
if (re.match(text, mat)) Info<< "group 1: " << mat.str(1) << nl;
|
|
|
|
|
|
- Old:
|
|
|
```
|
|
|
List<std::string> mat;
|
|
|
if (re.match(text, mat)) Info<< "group 1: " << mat[0] << nl;
|
|
|
```
|
|
|
- New:
|
|
|
```
|
|
|
regExp::results_type mat;
|
|
|
if (re.match(text, mat)) Info<< "group 1: " << mat.str(1) << nl;
|
|
|
```
|
|
|
|
|
|
### Foam::name
|
|
|
|
... | ... | @@ -130,8 +119,9 @@ replaced by `word::printf()` to avoid ambiguity and clarify the expected |
|
|
output and behaviour.
|
|
|
|
|
|
For example,
|
|
|
|
|
|
word::prinf("index_%05d", idx);
|
|
|
```
|
|
|
word::prinf("index_%05d", idx);
|
|
|
```
|
|
|
|
|
|
|
|
|
### HashTable, HashSet, string::hash
|
... | ... | @@ -141,9 +131,10 @@ operates on `std::string` directly, to further eliminate inadvertent |
|
|
automatic conversions.
|
|
|
|
|
|
This means that the following type of code will no longer compile:
|
|
|
|
|
|
HashSet<label> set;
|
|
|
HashTable<scalar, label> table;
|
|
|
```
|
|
|
HashSet<label> set;
|
|
|
HashTable<scalar, label> table;
|
|
|
```
|
|
|
|
|
|
since there is correct way to use a string hash function on a label.
|
|
|
This did compile in previous versions (through the automatic
|
... | ... | @@ -152,9 +143,10 @@ hash tables. |
|
|
|
|
|
The easy correction is to use a container with the suitable
|
|
|
hasher, e.g.,
|
|
|
|
|
|
labelHashSet set;
|
|
|
Map<scalar> table;
|
|
|
```
|
|
|
labelHashSet set;
|
|
|
Map<scalar> table;
|
|
|
```
|
|
|
|
|
|
|
|
|
### HashPtrTable, PtrMap
|
... | ... | @@ -179,27 +171,30 @@ Similar to potential memory leakage with `HashPtrTable`. |
|
|
|
|
|
Removed direct use of C-string or string, which was previously
|
|
|
implicitly converted to a `regExp`:
|
|
|
|
|
|
findStrings()
|
|
|
subsetStrings()
|
|
|
subsetStrings()
|
|
|
inplaceSubsetStrings()
|
|
|
```
|
|
|
findStrings()
|
|
|
subsetStrings()
|
|
|
subsetStrings()
|
|
|
inplaceSubsetStrings()
|
|
|
```
|
|
|
|
|
|
For most cases, this conversion would be largely unintentional
|
|
|
and also less efficient. If the regex is desirable, the caller
|
|
|
should invoke it explicitly.
|
|
|
|
|
|
For example,
|
|
|
|
|
|
findStrings(regExp(str), listOfStrings);
|
|
|
```
|
|
|
findStrings(regExp(str), listOfStrings);
|
|
|
```
|
|
|
|
|
|
Or use one of the more standard `keyType`, `wordRe`, `wordRes` variants
|
|
|
instead.
|
|
|
|
|
|
If string is to be used as a plain (non-regex) matcher, the
|
|
|
`ListOps` function should be used:
|
|
|
|
|
|
findIndices(listOfStrings, str);
|
|
|
```
|
|
|
findIndices(listOfStrings, str);
|
|
|
```
|
|
|
|
|
|
|
|
|
### ListOps namespace change
|
... | ... | @@ -221,18 +216,20 @@ possible and parameter options than previously. |
|
|
### ListOps functions removed
|
|
|
|
|
|
Removed deprecated and unused `ListOps` functions which were deprecated MAR-2017.
|
|
|
|
|
|
subset(const UList<T>& select, const T& value, const ListType&);
|
|
|
inplaceSubset(const UList<T>& select, const T& value, ListType&);
|
|
|
```
|
|
|
subset(const UList<T>& select, const T& value, const ListType&);
|
|
|
inplaceSubset(const UList<T>& select, const T& value, ListType&);
|
|
|
```
|
|
|
|
|
|
The `subsetList`/`inplaceSubsetList` variants with a unary predicate
|
|
|
provide more flexible and robuster solutions.
|
|
|
|
|
|
|
|
|
Removed the deprecated (deprecated MAR-2017) `initList` methods
|
|
|
|
|
|
initList(const T[mRows]);
|
|
|
initListList(const T[mRows][nColumns]);
|
|
|
```
|
|
|
initList(const T[mRows]);
|
|
|
initListList(const T[mRows][nColumns]);
|
|
|
```
|
|
|
|
|
|
These have be replaced by `List` constructors and
|
|
|
`std::initializer_list`
|
... | ... | @@ -284,35 +281,36 @@ In some cases this automatic behaviour was convenient, in other cases |
|
|
it could be used inadvertently and cause subtle bugs.
|
|
|
|
|
|
|
|
|
Old code:
|
|
|
|
|
|
PackedBoolList items(10);
|
|
|
|
|
|
items[20] = true; // OK. auto vivifies a new element
|
|
|
items.get(30); // OK. lazy evaluation (out-of-bounds) = false
|
|
|
items.set(40); // OK. auto vivifies a new element
|
|
|
if (items[50]) ... // OK. lazy evaluation (out-of-bounds) = false
|
|
|
- Old code:
|
|
|
```
|
|
|
PackedBoolList items(10);
|
|
|
|
|
|
items[20] = true; // OK. auto vivifies a new element
|
|
|
items.get(30); // OK. lazy evaluation (out-of-bounds) = false
|
|
|
items.set(40); // OK. auto vivifies a new element
|
|
|
if (items[50]) ... // OK. lazy evaluation (out-of-bounds) = false
|
|
|
```
|
|
|
|
|
|
New code:
|
|
|
- New code:
|
|
|
```
|
|
|
bitSet items(10);
|
|
|
|
|
|
bitSet items(10);
|
|
|
|
|
|
items[20] = true; // Error. Out of bounds.
|
|
|
items.get(30); // OK. lazy evaluation (out-of-bounds) = false
|
|
|
items.set(40); // OK. auto vivifies a new element
|
|
|
if (items[50]) ... // Error. Out of bounds.
|
|
|
if (items.test(50))... // OK. lazy evaluation (out-of-bounds) = false
|
|
|
items[20] = true; // Error. Out of bounds.
|
|
|
items.get(30); // OK. lazy evaluation (out-of-bounds) = false
|
|
|
items.set(40); // OK. auto vivifies a new element
|
|
|
if (items[50]) ... // Error. Out of bounds.
|
|
|
if (items.test(50))... // OK. lazy evaluation (out-of-bounds) = false
|
|
|
```
|
|
|
|
|
|
|
|
|
For read-only (const) access, the behaviour is similar to previously.
|
|
|
```
|
|
|
bitSet items(10);
|
|
|
|
|
|
bitSet items(10);
|
|
|
|
|
|
items.get(30); // OK. lazy evaluation (out-of-bounds) = false
|
|
|
if (items[50]) ... // OK. lazy evaluation (out-of-bounds) = false
|
|
|
if (items.test(50))... // OK. lazy evaluation (out-of-bounds) = false
|
|
|
|
|
|
items.get(30); // OK. lazy evaluation (out-of-bounds) = false
|
|
|
if (items[50]) ... // OK. lazy evaluation (out-of-bounds) = false
|
|
|
if (items.test(50))... // OK. lazy evaluation (out-of-bounds) = false
|
|
|
```
|
|
|
|
|
|
##### Iterators
|
|
|
|
... | ... | @@ -327,35 +325,37 @@ The `bitSet const_iterator` has changed behaviour. It now only iterates |
|
|
over values that are true, skipping intermediate values.
|
|
|
Dereferencing the iterator returns the location.
|
|
|
|
|
|
Old code:
|
|
|
|
|
|
PackedBoolList selected(...);
|
|
|
|
|
|
forAllConstIters(selected, iter)
|
|
|
{
|
|
|
if (*iter)
|
|
|
{
|
|
|
// Value is true, but where am I?
|
|
|
}
|
|
|
}
|
|
|
|
|
|
forAll(selected, celli)
|
|
|
{
|
|
|
if (selected[celli])
|
|
|
{
|
|
|
sumVol += mesh_.cellVolumes()[celli];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
New code:
|
|
|
|
|
|
bitSet selected(...);
|
|
|
|
|
|
for (const label celli : selected)
|
|
|
{
|
|
|
sumVol += mesh_.cellVolumes()[celli];
|
|
|
}
|
|
|
- Old code:
|
|
|
```
|
|
|
PackedBoolList selected(...);
|
|
|
|
|
|
forAllConstIters(selected, iter)
|
|
|
{
|
|
|
if (*iter)
|
|
|
{
|
|
|
// Value is true, but where am I?
|
|
|
}
|
|
|
}
|
|
|
|
|
|
forAll(selected, celli)
|
|
|
{
|
|
|
if (selected[celli])
|
|
|
{
|
|
|
sumVol += mesh_.cellVolumes()[celli];
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
|
|
|
- New code:
|
|
|
```
|
|
|
bitSet selected(...);
|
|
|
|
|
|
for (const label celli : selected)
|
|
|
{
|
|
|
sumVol += mesh_.cellVolumes()[celli];
|
|
|
}
|
|
|
```
|
|
|
|
|
|
|
|
|
This change increases usability and improves performance since the
|
... | ... | |