Commit Graph

26833 Commits

Author SHA1 Message Date
c65fac192e REGRESSION: incorrect fill range for ensight writeString
- introduced by b76595df42, only affects recent develop
2023-10-13 14:42:37 +02:00
c423ebecc1 BUG: ConeInjection - corrected parallel restart. Fixes #2998 2023-10-12 11:37:02 +01:00
fc9fb5c150 Merge branch 'update-stringIO-and-containers' into 'develop'
updates for resizing containers, reduced overhead for std::string output etc

See merge request Development/openfoam!632
2023-10-11 18:12:09 +00:00
0fb2c8eb1c STYLE: update applications/tests to use SpanStream/CharStream 2023-10-11 18:11:37 +00:00
3693d61e6c ENH: refine SpanStream and CharStream methods
- support std::string_view (c++17) or span view (older c++) of stream
  buffer contents. This simplifies formatting + reparsing.

  Example,

      OCharStream os;
      os << ...;

      ISpanStream is(os.view());
      is >> ...;

- additional release() method for ICharStream, OCharStream
  that returns the contents as a DynamicList<char> and resets the stream.

- provide a str() method for API compatibility with older
  std::ostringstream etc.
2023-10-11 18:11:37 +00:00
1ddcad820f ENH: multi-parameter IOobject::scopedName 2023-10-11 18:11:37 +00:00
722c528316 ENH: add string::length static methods
- simplifies writing of code that should accept either
  C strings (forwards to strlen) or
  C++ strings (forwards to std::string::length)
2023-10-11 18:11:37 +00:00
b76595df42 ENH: improve stream output of std::string etc.
- change write(const string&) to write(const std::string&).
  This allows output of std::string without an intermediate copy.

- additional writeQuoted method to handle range of char data:

     writeQuoted(const char* str, std::streamsize len, bool)

  This helps with supporting string_view and span<char>

- add operator<< for stdFoam::span<char> and std::string_view (c++17)

- avoid duplicate code in OBJstream

STYLE: add override keyword for IO stream methods
2023-10-11 18:11:37 +00:00
d9727fad1c ENH: use updated HashTable methods 2023-10-11 18:11:37 +00:00
5dcced7b86 ENH: use capacity=0 for HashTable/HashSet/Map default constructors
- default construct is now identical to HashTable(Foam::zero).
  It performs no allocation and is also noexcept.

  The previously used default capacity (128) was a holdover from
  much older versions where set/insert did not properly handle
  insertion into a table with zero capacity (number of buckets).
2023-10-11 18:11:37 +00:00
89d3687278 ENH: HashTable sizing improvements
- earlier deletion of unpopulated HashTable on resizing:

  If the table is already clear (ie, has no entries),
  can immediately remove the old internal table before reallocating
  the newly sized table, which may avoid a needless memory spike.

- reserve() method:

  Naming and general behaviour as per std::unordered_map.
  It behaves similarly to the resize() method but is supplied the
  number of elements instead of the capacity, which can be a more
  natural way of specifying the storage requirements.
  Additionally, reserve() will only increase the table capacity for
  behaviour similar to DynamicList and std::vector, std::string etc.

  Old:
     labelHashSet set;
     set.resize(2*nElems);

  Now:
     labelHashSet set;
     set.reserve(nElems);

- remove unused HashTable(Istream&, label) constructor

STYLE: static_cast of (nullptr) and std::fill_n for filling table
2023-10-11 18:11:37 +00:00
58bd255a73 ENH: handle List<char> I/O in base class
- previously used a template specialization, but now recombined into
  regular readList/writeList methods to consolidate the code logic
2023-10-11 18:11:37 +00:00
96c9bf8615 ENH: add List::resize_unsafe(label)
- changes the addressed list size without affecting list allocation.
  Can be useful for the following type of coding pattern:

  - pre-allocate a List with some max content length
  - populate with some content (likely not the entire pre-allocated size)
  - truncate the list to the length of valid content
  - process the List
  - discard the List

  Since the List is being discarded, using resize_unsafe() instead of
  resize() avoids an additional allocation with the new size and
  copying/moving of the elements.

  This programming pattern can also be used when the List is being
  returned from a subroutine, and carrying about a bit of unused memory
  is less important than avoiding reallocation + copy/move.

  If used improperly, it can obviously result in addressing into
  unmanaged memory regions (ie, 'unsafe').
2023-10-11 18:11:37 +00:00
0f53871fd3 ENH: make various List/Field move constructors noexcept 2023-10-11 18:11:37 +00:00
ce1260cf70 ENH: improve DynamicList shrink and swapping
- shrink_to_fit()
  corresponds to std::vector naming.
  For DynamicList it is a *binding* request.

- shrink_unsafe()
  simply adjusts the capacity() to match the
  current size() without forcing a re-allocation.

  Useful when collapsing to a non-dynamic list to avoid reallocation
  and copying contents. The memory cleanup will still occur properly
  at a later stage.

- DynamicList::swap(List&)
  simple recovery of content into a non-dynamic List that also
  ensures that the capacity is correctly updated.

STYLE: promote List::capacity() to public visibility (like std::vector)

STYLE: remove unused expandStorage() method

- simply a wrapper for resize(capacity())
2023-10-11 18:11:37 +00:00
1d43e45fdd ENH: add test application for fileHander writing
COMP: update applications/test
2023-10-11 18:11:37 +00:00
1af40e7dfe STYLE: remove unused (transitional) methods from CircularBuffer
- old methods (and class) were not widely used
2023-10-11 18:11:37 +00:00
524c953af3 STYLE: use List clear() instead of setSize(0), resize(0)
- adds some consistency
2023-10-11 18:11:37 +00:00
9ac0f03963 ENH: pisoFoam: allow runTimeModifiable. Fixes #2997. 2023-10-11 15:54:30 +01:00
dfb08af3de BUG: ThermoSurfaceFilm: reintroduce energy to film sources (fixes #2996) 2023-10-11 11:23:08 +01:00
3458cea49e FIX: avoid bad copy (foamCloneCase) when time dir is missing (fixes #2975) 2023-10-08 17:58:53 +02:00
a811e25556 DOC: StandardWallInteraction: correct restitution coeff (fixes #2676) 2023-10-04 17:06:43 +01:00
f7dfb02d12 DEFEATURE: remove unused (and partly-broken) SubDimensionedField 2023-09-27 19:37:18 +02:00
a252677618 BUG: Lambda2: reverse the sign of the governing equation (fixes #2731) 2023-09-27 17:09:13 +01:00
99f5d9a7db BUG: overset: correct sizing. Fixes #2985. 2023-09-18 18:12:37 +01:00
133149a1dd ENH: snappyHexMesh: mutliple inside points. Fixes #2981 2023-09-14 16:12:53 +01:00
6396256522 BUG: cyclicAMI: operate on copy. Fixes #2980
also
- steal nbr value
- do not copy nbr value if different internalfield
2023-09-14 15:10:15 +01:00
8fe025cb8e BUG: snappyHexMesh: correct oppositeness checking. Fixes #2971 2023-09-07 11:55:57 +01:00
5d98eec6af ENH: re-toggle warnings in functionObjectList execution (#2973)
- when running with "errors warn;" it will reset the warnings counter
  (if any) when it returns to a good state.
  This re-enables un-suppressed warnings for the next cycle.
  Also reset the warnings counter on end().

ENH: add short-circuit in HashTable::erase(key)

- skip and return false if the table is empty or the key is not found.
  This makes for faster no-op behaviour.
2023-09-06 10:19:38 +02:00
2d76514b5b Merge branch 'issue-2966-errorhandling' into 'develop'
ENH: add error handling for empty surfaces in surfaceFieldValue (#2966)

See merge request Development/openfoam!627
2023-09-05 15:37:33 +00:00
2e3f0811a0 ENH: error handling for empty surfaces in surfaceFieldValue (#2966)
- for workflows with appearing/disappearing patches (for example)
  can specify that empty surfaces should be ignored or warned about
  instead of raising a FatalError.

  Note that this handling is additional to the regular top-level
  "errors" specification. So specifying 'strict' will only actually
  result in a FatalError if the "errors" does not trap errors.

- "ignore" : any empty surfaces are simply ignored and no
  file output (besides the header).

- "warn" : empty surfaces are warned about a few times (10)
  and the file output contains a NaN entry

- "strict" : corresponds to the default behaviour.
  Throws a FatalError if the surface is empty.
  This error may still be caught by the top-level "errors" handling.
2023-09-05 15:36:53 +00:00
ff2abdf1f0 ENH: relocate functionObjectList errorHandling types to error (#2966)
- was previously private within functionObjectList, now exposed from
  error as 'handlerTypes' and 'handlerNames' enumeration.
2023-09-05 15:36:53 +00:00
f49403969e Merge branch 'extend-list-functionality' into 'develop'
Add SubList re-slicing, find within a List sub-section, uniformity enumeration

See merge request Development/openfoam!626
2023-09-05 15:36:17 +00:00
2e8e259217 CONFIG: increment API level to 2307 2023-09-05 10:15:57 +02:00
0250a1b0bb ENH: support List sub-slice searching, use std::find()
- support UList shallowCopy with pointer/size
  (eg, for slicing into or from span)

ENH: add SubList::reset() functionality

- allows modification of a SubList after construction.
  Previously a SubList had an immutable location after construction
  and there was no way to shift or change its location.

BUG: missed special handling for DynamicList<char>::readList (fixes #2974)

- equivalent to List<char>::readList, in which the stream is
  temporarily toggled from ASCII to BINARY when reading in a List of
  char data.
  This specialization was missed when DynamicList<T>::readList() was
  fully implemented.
2023-09-05 10:15:17 +02:00
aa1b6d9cbd ENH: add ListPolicy uniformity enumeration and algorithm
- defines values for EMPTY, UNIFORM, NONUNIFORM and MIXED
  that allow bitwise OR reduction and provide an algorithm
  for calculating uniformity

ENH: consolidate more efficient uniformity checks in PackedList

ENH: improve linebreak handling when outputting small matrices
2023-09-04 14:40:33 +02:00
df6de6ed33 CONFIG: runParallel with --oversubscribe for openmpi
- not always required, but useful when running some tutorials locally
2023-09-04 14:24:13 +02:00
f800ccc3d9 Merge branch 'update-memory-streams' into 'develop'
update and enhancements for memory-based streams

See merge request Development/openfoam!624
2023-09-01 14:44:56 +00:00
459aaad0f9 ENH: improve robustness of raw reading, file size checks
- use ignore instead of seekg/tellg to swallow input (robuster)

- check for bad gcount() values

- wrap Foam::fileSize() compressed/uncompressed handling into IFstream.

- improve handling of compressed files in masterUncollatedFileOperation.
  Previously read into a string via stream iterators.
  Now read chunk-wise into a List of char for fewer reallocations.
2023-09-01 14:44:49 +00:00
a341d09afc ENH: update and enhancement of memory-streams
- soft renames (ie, old names still available via typedefs) for more
  reasonable names and more coverage with std stream variants.

  The old names could be a bit cryptic.
  For example, uiliststream (== an unallocated/external list storage),
  which is written as std::ispanstream for C++23.

  Could similarly argue that IListStream is better named as
  ICharStream, since it is an input stream of characters and the
  internal storage mechanism (List or something else) is mostly
  irrelevant.

  Extending the coverage to include all std stream variants, and
  simply rewrap them for OpenFOAM IOstream types. This simplifies the
  inheritance patterns and allows reuse of icharstream/ocharstream as
  a drop-in replace for istringstream/ostringstream in other wrappers.

  Classes:
    * icharstream / ICharStream   [old: none / IListStream]
    * ocharstream / OCharStream   [old: none / OListStream]
    * ispanstream / ISpanStream   [old: uiliststream / UIListStream]
    * ospanstream / OSpanStream   [old: none / UOListStream]

  Possible new uses : read file contents into a buffer, broadcast
  buffer contents to other ranks and then transfer into an icharstream
  to be read from. This avoid the multiple intermediate copies that
  would be associated when using an istringstream.

- Use size doubling instead of block-wise incremental for ocharstream
  (OCharStream). This corresponds to the sizing behaviour as per
  std::stringstream (according to gcc-11 includes)

STYLE: drop Foam_IOstream_extras constructors for memory streams

- transitional/legacy constructors but not used in any code
2023-09-01 14:44:49 +00:00
6d7e67408e BUG: snappyHexMesh: correct oppositeness checking. Fixes #2971 2023-08-31 14:06:02 +01:00
313b1f71f1 BUG: mapFields: incorrect patches. Fixes #2944. 2023-08-31 09:45:12 +02:00
61cd298928 COMP: missing compilation of hostUncollated (fixes #2934) 2023-08-31 09:45:12 +02:00
d8f5714d1b Merge branch 'feature-nonblocking-cyclicAMI' into 'develop'
Support non-blocking construction of cyclic AMI

See merge request Development/openfoam!623
2023-08-30 15:52:01 +00:00
69169c5abe ENH: add non-blocking handling for cyclicAMI (#2963)
Co-authored-by: Mark Olesen <>
2023-08-30 13:39:16 +00:00
539d538d5a ENH: mapDistribute consistency improvements
- nonBlocking: receive before send

- nonBlocking: wait for receive requests, process and then wait for
  other requests. Can be extended to use polling...

- the 'fake' send (to self) now send copies into recv buffers instead
  of send buffers.
  This provides a clear separation of send and receive fields

- avoid unnecessary reallocations with PtrList of send/recv buffers

- remove outer looping for accessAndFlip and pass target field
  as parameter for inner looping instead

ENH: refine mapDistribute send/recv requests handling

- separate send/recv requests for finer control
- receive does not need access to PtrList of sendBuffers, since the
  send-to-self now uses the recvBuffers
2023-08-30 13:39:16 +00:00
c09acbb781 ENH: avoid list resizing when reindexing AMIInterpolation::append (#2933)
- create reindexing values as interleaved identity maps directly into
  the remapping lookup.
2023-08-30 13:39:16 +00:00
b931772369 ENH: mapDistribute subMapTotalSize(), constructMapTotalSize()
- the sum of the respective list sizes

COMP: add noexcept to trivial mapDistribute constructors
2023-08-30 13:39:16 +00:00
750d9084d4 ENH: improve addressing into labelRanges (#2933)
- totalSize() returns retrieve the linear (total) size
  (naming as per globalIndex)
- operator[] retrieves the referenced value (linear indexing)
- labels() returns a flattened labelList (as per labelRange itself)
2023-08-30 13:39:16 +00:00
6defeddbff BUG: mapFields: incorrect patches. Fixes #2944. 2023-08-30 11:46:25 +01:00