Commit Graph

26177 Commits

Author SHA1 Message Date
fb69a54bc3 ENH: avoid prior communication when using mapDistribute
- in most cases can simply construct mapDistribute with the sendMap
  and have it take care of communication and addressing for the
  corresponding constructMap.

  This removes code duplication, which in some cases was also using
  much less efficient mechanisms (eg, combineReduce on list of
  lists, or an allGatherList on the send sizes etc) and also
  reduces the number of places where Pstream::exchange/exchangeSizes
  is being called.

ENH: reduce communication in turbulentDFSEMInlet

- was doing an allGatherList to populate a mapDistribute.
  Now simply use PstreamBuffers mechanisms directly.
2023-02-14 23:22:55 +01:00
1ce7a62209 ENH: Pstream::exchange with Map<Container> data
- dynamic sparse data exchange using Map to hold data and sizes.

  Still uses the personalised exchange paradigm, but with non-blocking
  consensus exchange to obtain the sizes and regular point-to-point
  for the data exchange itself. This avoids an all-to-all but still
  keeps the point-to-point for overlapping communication, data
  chunking etc.
2023-02-14 23:22:55 +01:00
b6af124b80 ENH: add Pstream chunked transfer detail
- to service both List and Map exchanges with limited message sizes
  (termed 'data chunking' here) add a PstreamDetail for walking and
  dispatching.  Like other Detail components, the API is subject
  to (possibly breaking) changes in the future at any time.

  The regular exchangeBuf detail has this type of signature:

  PstreamDetail::exchangeBuf
  (
      const UList<std::pair<int, stdFoam::span<const Type>>>& sends,
      const UList<std::pair<int, stdFoam::span<Type>>>& recvs,
      ...
  )

    Where [rank, span] is the tuple pack.

  The basic idea is to pre-process the send/receive buffers and
  marshall them into a flat list of [rank, span] tuples.

  The originating buffers could be any type of container (List or Map)
  which is then marshalled into this given sequence that can be
  processed in source-agnostic fashion.

  If data chunking is required (when UPstream::maxCommsSize > 0)
  it is possible to make a cheap copy of the rank/address information
  and then walk different slices or views.

ENH: replace private static methods with PstreamDetail functions

- simpler to update locally.
2023-02-14 23:22:55 +01:00
83740ad408 ENH: avoid clearStorage for persistent PstreamBuffers
- added persistent buffer for zoneDistribute
- additional handling for clearing buffers
2023-02-14 23:22:55 +01:00
a16f09b10c ENH: refine resizing of zero-sized DynamicList/DynamicField
- since List is being used to manage the storage content for
  DynamicList, it needs to free old memory for zero-sized lists first.

  Consider this case (slightly exaggerated):

      line 0:  DynamicList<label> list;
      line 1:  list.reserve(100000);
      line 2:  list.reserve(200000);

  After line 0:
     - list has size=0, capacity=0 and data=nullptr

  After line 1:
     - list has size=0, capacity=1e+5 and data != nullptr

  After line 2:
     - list has size=0, capacity=2e+5 and data != nullptr

  ---

  The internal resizing associated with line 1 corresponds to what the
  List resize would naturally do. Namely allocate new storage, copy/move
  any overlapping elements (in this case none) before freeing the old
  storage and replacing with new storage.

  Applying the same resizing logic for line 2 means, however, that the
  old memory (1e5) and new memory (2e5) are temporarily both
  accessible - leading to an unnecessary memory peak.

  Now: if there is no overlap, just remove old memory first.
2023-02-14 23:22:55 +01:00
702225c249 ENH: add stdFoam::span container
- basic functionality similar to std::span (C++20).
  Holds pointer and size: for lightweight handling of address ranges.

- implements cdata_bytes() and data_bytes() methods for similarity
  with UList. For span, however, both container accesses are const
  but the data_bytes() method is only available when the
  underlying pointer is non-const.

  No specializations of std::as_bytes() or std::as_writeable_bytes()
  as free functions, since std::byte etc are not available anyhow.
2023-02-13 21:41:14 +01:00
375a4792f9 ENH: HashSet, HashTable, HashPtrTable merge() method
- name and functionality similar to std::unordered_map (C++17).
  Formalizes what had been previously been implemented in IOobjectList
  but now manages without pointer deletion/creation.
2023-02-13 21:22:20 +01:00
aafcd0b9e0 TUT: use slash-scoped dictionary references 2023-02-13 21:18:57 +01:00
27a7ae2d1d ENH: use simpler lookupPatchField form 2023-02-13 20:08:48 +01:00
35dae3fc3b STYLE: simpler mass-flow/volume-flow dimension check
* (dimMass/dimTime)    instead of  (dimDensity*dimVelocity*dimArea)
* (dimVolume/dimTime)  instead of  (dimVelocity*dimArea)
2023-02-13 20:08:48 +01:00
2db3e2b64f STYLE: simplify ensightMeshReader with emplace_back/push_back
STYLE: emplace for mesh zones
2023-02-11 09:21:43 +01:00
1ab9dca2ab ENH: reduce all-to-all communication in mesh wave algorithms
- use persistent PstreamBuffers between iterations, restrict size
  information exchange to the processor neighbours (which is what the
  algorithm is handling there anyhow).
2023-02-10 19:43:43 +01:00
74fd94dff3 REGRESSION: overly aggressive handling of MPI groups
- attempted reduction in bookkeeping (commit: 068ab8ccc7) meant that
  the worldComm didn't have a group from which sub-communicators could
  be spun off.

- do not force reset of PstreamBuffers positions

STYLE: UPstream::globalComm instead of '0'
2023-02-10 19:43:43 +01:00
1dbb54c391 ENH: refine definition of PtrList emplace() and HashPtrTable emplace_set()
- like emplace_back(), return a reference to the new element
2023-02-10 19:43:43 +01:00
d597b3f959 STYLE: check iterator validity with good() instead of found()
- aligns better with other container checks
2023-02-10 17:12:48 +01:00
750381bd99 ENH: HashTable/HashSet contains(key) method
- functionality provided as 'found(key)' in OpenFOAM naming, since
  there was no stl equivalent at the time. Now support contains(),
  which is the equivalent for C++20 maps/sets.

STYLE: general contains() method for containers

STYLE: treat Enum and Switch similarly as hash-like objects
2023-02-10 17:11:15 +01:00
ed39ee6afe Merge branch 'update-pstream' into 'develop'
Pstream improvements for more flexibility. Non-blocking consensus exchange

See merge request Development/openfoam!592
2023-02-09 12:33:58 +00:00
422654a9ea ENH: added UPstream::waitAnyRequest(UList<UPstream::Request>&)
- waits for completion of any of the listed requests and returns the
  corresponding index into the list.
  This allows, for example, dispatching of data when the receive is
  completed.
2023-02-09 11:11:36 +01:00
add61ca273 ENH: support UOPstream and UIPstream as formatters with an external buffer
- can split serialise/de-serialise and send/recv actions
2023-02-09 10:44:42 +01:00
70d310329c ENH: PstreamBuffers consistency improvements
- make nProcs() independent of internal storage mechanism.
- reset receive positions with finished sends

- use size of received buffers to manage validity instead of
  an separate additional gather operation.
2023-02-08 14:22:29 +01:00
4ec75d538f ENH: clear Map entries, but not Map itself for NBX exchange
- clearing the receive 'slots' is preferrable to clearing out the map
  itself since this can potentially preserve allocated space (eg
  DynamicList entries) between calls.

BUG: remove stray MPI barrier in exchange code
2023-02-08 10:24:58 +01:00
df61104ef5 ENH: add Pstream non-blocking consensus exchange infrastructure
- can be beneficial with increasing number of ranks
2023-02-07 23:02:02 +01:00
068ab8ccc7 ENH: add separate tracking of MPI_Comm_free, MPI_Group_free pending
- permits distinction between communicators/groups that were
  user-created (eg, MPI_Comm_create) versus those queried from MPI.
  Previously simply relied on non-null values, but that is too fragile

ENH: support List<Request> version of UPstream::finishedRequests

- allows more independent algorithms

ENH: added UPstream::probeMessage(...). Blocking or non-blocking
2023-02-07 22:39:00 +01:00
ab4c5f25ac ENH: add PstreamBuffers access routines for friend classes
- allows the possibility of using demand-driven internal buffers
  and/or different storage mechanisms.

  Changes:

    * old: sendBuf_[proci]    -> accessSendBuffer(proci)
    * old: recvBuf_[proci]    -> accessRecvBuffer(proci)
    * old: recvBufPos_[proci] -> accessRecvPosition(proci)

  only affects internals of UIPstreamBase and UOPstreamBase

BUG: reduceOr in PstreamBuffers uses world communicator

- should respect the value of the communicator defined within
  PstreamBuffers
2023-02-07 22:39:00 +01:00
173c9ac163 ENH: reduce storage and startup communication for processorTopology
- previously built the entire adjacency table (full communication!)
  but this is only strictly needed when using 'scheduled' as the
  default communication mode. For blocking/nonBlocking modes this
  information is not necessary at that point.

  The processorTopology::New now generally creates a smaller amount of
  data at startup: the processor->patch mapping and the patchSchedule.

  If the default communication mode is 'scheduled', the behaviour is
  almost identical to previously.

- Use Map<label> for the processor->patch mapping for a smaller memory
  footprint on large (ie, sparsely connected) cases. It also
  simplifies coding and allows recovery of the list of procNeighbours
  on demand.

- Setup the processor initEvaluate/evaluate states with fewer loops
  over the patches.

========
BREAKING: procNeighbours() method changed definition

- this was previously the entire adjacency table, but is now only the
  processor-local neighbours. Now use procAdjacency() to create or
  recover the entire adjacency table.

  The only known use is within Cloud<ParticleType>::move and there it
  was only used to obtain processor-local information.

  Old:
      const labelList& neighbourProcs =
          mesh.globalData().topology().procNeighbours()[Pstream::myProcNo()];

  New:
      const labelList& neighbourProcs =
          mesh.globalData().topology().procNeighbours();

      // If needed, the old definition (with communication!)
      const labelListList& connectivity =
          mesh.globalData().topology().procAdjacency();
2023-02-07 22:39:00 +01:00
3e024d622b STYLE: relocate hashing and IO for std::pair to Pair.H (from Tuple2.H)
- makes it more universally available
2023-02-07 22:39:00 +01:00
d2ab9e9abf Merge branch 'feature-wallDistAddressing' into 'develop'
ENH: wallDistAddressing: wall distance which stores addressing.

See merge request Development/openfoam!590
2023-02-06 14:39:41 +00:00
e790e1c4ba ENH: wallDistAddressing: wall distance which stores addressing. 2023-02-06 14:38:41 +00:00
f713f74855 ENH: overPotentialFoam: Make consistent. see #1749.
- createFields extends potentialFoam
- (so registers 'p' field, same as potentialFoam)
- writephi is optional as in potentialFoam
2023-02-02 10:34:47 +00:00
7c6232b8b3 BUG: FaceCellWave: support data with transformations. Fixes #2693
transformation support in-place modifies the data (e.g. to
add a transform). This might cause the neighbour side patch
to pick up owner side information.
2023-02-01 16:32:26 +00:00
56bf73d37d Merge branch 'feature-named-MeshObject' into 'develop'
ENH: MeshObject: specify name (instead of typeName)

See merge request Development/openfoam!589
2023-02-01 15:32:14 +00:00
c0e63a8de7 ENH: MeshObject: specify name (instead of typeName) 2023-02-01 15:32:14 +00:00
8b63f64503 STYLE: use std::ostringstream instead of std::to_string for complex
- std::to_string(double) is locale sensitive.
2023-01-31 15:55:21 +01:00
1471d292bf TUT: add dripping chair test 2023-01-31 15:29:26 +01:00
b93f038ea3 TUT: replace exprFixedValue with uniformFixedValue
- wish to deprecate and remove exprFixedValue in the future since the
  same functionality is possible using patch expressions with a
  uniformFixedValue condition.
2023-01-31 13:45:21 +01:00
a6b3a31b28 ENH: add patch expression support for face unit normal (#2691)
- make available as normal()
2023-01-31 13:13:16 +01:00
8ee7595a77 ENH: foamToVTK improvements for (-no-internal, -no-boundary)
- skip loading of fields with -no-internal, -no-boundary

- suppress reporting fields with -no-internal, -no-boundary

- cache loaded volume field for reuse with point interpolation.
  Trade off some memory overhead against reading twice.

  NOTE: this issue will not be evident with foamToEnsight since there
  it only handles cell data *or* point data (not both), so a field is
  only ever loaded/processed once.
2023-01-31 12:45:39 +01:00
72bfaa2be9 ENH: Field assign and construct from dictionary with readOption
- This simplifies definition of 'lazier' (READ_IF_PRESENT)
  construction or assignment.

  For construction:
    - For MUST_READ and key not found: FatalIOError.
    - For LAZY_READ and key not found: initialise field with Zero.
    - For NO_READ and key not found: simply size the field.

  For assignment:
    - If len == 0 : a no-op and return True.
    - For NO_READ : a no-op and return False.
    - For MUST_READ and key not found : FatalIOError
2023-01-31 12:45:39 +01:00
bebc6195a8 ENH: IOobjectOption isAnyRead() for checking against NO_READ
- encompasses isReadOptional or isReadRequired check

STYLE: allow LAZY_READ as a shorter synonym for READ_IF_PRESENT

- add helper for downgrading MUST_READ... to LAZY_READ
2023-01-31 12:45:38 +01:00
c8a2d82094 BUG: inconsistent faceArea on processor boundaries (fixes #2683)
- was missing evaluateCoupled on the initial faceAreaNormals field
  (related to #2507)
2023-01-31 12:45:38 +01:00
39cabfca9c ENH: use fvPatchFieldBase::readDict
- replaces getOrDefault/readIfPresent for "patchType"
2023-01-31 12:45:38 +01:00
0190fed56b ENH: support slicing for finiteArea fields 2023-01-31 12:45:38 +01:00
c206b12c80 ENH: patch boundarySlice() for extraction from a flat boundary list
- remove redundant raw patch slice and non-const patchSlice, which
  were only used internally by finiteArea.

STYLE: noexcept on more patch methods
2023-01-31 12:45:38 +01:00
911c28f17d STYLE: use vector::magSqr when checking size 2023-01-31 12:45:34 +01:00
2faf361354 BUG: faMesh geometryOrder=1 blocks in parallel
- with geometryOrder=1, edge normal calculation is done directly from
  the faces, whereas geometryOrder=2 they are calculated based on the
  point normals of each end.

  In both cases, the geometry calculation uses processor communication
  (with corresponding waitRequests etc).

  Since the final correction and the halo face normals also need
  collective communication, these routines must be triggered on all
  processors or they will block. Thus also include edgeAreaNormals()
  triggering in addition to pointAreaNormals() triggering.
2023-01-31 12:36:41 +01:00
312037d4ea ENH: simplify coding logic for calculating Le() vectors.
- handle lower geometryOrder values directly within edgeAreaNormals()
  and reuse the results within Le().

- direct nonBlocking recv/send of edge normals instead using the
  intermediate processorLduInterface buffers
2023-01-31 12:36:41 +01:00
5672bb296f ENH: use cmptMag, cmptMultiply instead of replacing field components 2023-01-31 12:36:41 +01:00
ea2bedf073 ENH: add coupledFaPatch::delta()
- symmetrical evaluation for processor patches, eliminates
  scalar/vector multiply followed by projection.

STYLE: use evaluateCoupled instead of local versions
2023-01-31 12:36:41 +01:00
eb8b51b475 ENH: use back(), pop_back() instead remove()
- adjust looping to resemble LIFO pattern

STYLE: adjust some string includes
2023-01-27 09:50:46 +01:00
7c60c80edd ENH: new/revised emplace_back() [for DynamicList/List/PtrDynList/PtrList]
- returns reference as per C++17 std::vector

STYLE: drop unused, redundant DynamicField remove() method
2023-01-27 09:50:45 +01:00