Commit Graph

26199 Commits

Author SHA1 Message Date
4d45cfd5a9 ENH: lerp for patch/neighbour weights 2023-02-21 10:10:43 +01:00
128516b874 ENH: use lerp for valueFraction (mixed BCs) and field relaxation
Note:
  in some borderline cases (eg, PDRFoam) the multiplication order
  and rounding imposed by the lerp function may affect the
  results slightly.

  eg,  (valueFraction_ * this->patch().deltaCoeffs()*refValue_)
  vs.  (valueFraction_ * (this->patch().deltaCoeffs()*refValue_))
2023-02-21 10:10:36 +01:00
70d526cd82 ENH: neg(x) instead of '1 - pos0(x)' for less-than 0 check
- fewer operations

ENH: replace 'neg(x)*a + pos0(x)*b' with 'lerp(a, b, pos0(x))'

- uses pos0 as a 0-1 selector. Fewer operations.
2023-02-21 10:05:27 +01:00
e1a710014c ENH: define lerp field functions
- defined for lerp between two fields,
  either with a constant or a field of interpolation factors.

  * plain Field, DimensionedField, FieldField, GeometricFields

- using a field to lerp between two constants is not currently
  supported
2023-02-21 10:05:27 +01:00
ab10b4a05c EHN: add FieldFunction interface for 0/1 clamping
- enables clamp(field, zero_one{}) returning a tmp Field
2023-02-21 10:05:27 +01:00
6f68ce5239 ENH: update field function macros and 'reuse' field handling
- clearer, more consistent parameter naming, which helps when
  maintaining different field function types (eg, DimensionedFields,
  GeometricFields)

- provide reuseTmpGeometricField::New taking a reference (not a tmp),
  with forwarding. This helps centralise naming and acquisition etc

- split binary function macros into transform/interface
  for easier support of different transform loops.

- initial field macros for looping over ternaries
2023-02-21 10:05:26 +01:00
3d8a6a5433 ENH: use GeometricField clamp_min, clamp_max, clamp_range
- newer naming allows for less confusing code.
  Eg,
      max(lower)  ->  clamp_min(lower)
      min(upper)  ->  clamp_max(upper)

- prefer combined method, for few operations.
  Eg,
      max(lower) + min(upper) -> clamp_range(lower, upper)

  The updated naming also helps avoid some obvious coding errors.
  Eg,

     Re.min(1200.0);
     Re.max(18800.0);

  instead of
     Re.clamp_range(1200.0, 18800.0);

- can also use implicit conversion of zero_one to MinMax<Type> for
  this type of code:

      lambda_.clamp_range(zero_one{});
2023-02-21 10:05:26 +01:00
4d7180ae7c COMP: rename field methods clamp() -> clamp_range()
- this is slightly longer to write (but consistent with clamp_min
  etc). The main reason is that this allows easier use of the clamp()
  free function.

STYLE: skip checks for bad/invalid clamping ranges

- ranges are either already validated before calling, the caller logic
  has already made the branching decision.
2023-02-21 10:05:26 +01:00
a7d77391fa BUG: selfComm had 0 instead of parent rank for UPstream::procID (#2706) 2023-02-21 09:29:44 +01:00
2569405383 ENH: implement NBX with recovery of sizes and non-blocking receives 2023-02-20 19:00:31 +01:00
fb2bf77e8e TUT: update keyword coordinateRotation -> rotation 2023-02-20 19:00:31 +01:00
446aff1350 ENH: add DeprecatedInFunction macro
- run-time warning about deprecated features. For example,

  DeprecatedInFunction(2212)
     << "Prefer using xyz boundary condition. "
     << "This boundary condition will be removed in the future." << endl;

CONFIG: mark exprFixedValue as deprecated

- same functionality is possible with uniformFixedValue and an
  expression PatchFunction1, which can also be easily changed to any
  other PatchFunction1
2023-02-20 18:59:48 +01:00
c038a9447c STYLE: remove unneeded UPstream::listEq
- was only used in Pstream::combineReduce(...) with a full list,
  which should have been avoided in most cases anyhow.
  Much more efficient to simply gather the sizes directly
2023-02-20 11:34:29 +01:00
fdd7e4d87f STYLE: use push_back when walking cell queues
STYLE: use push_back for OTstream
2023-02-20 11:32:54 +01:00
0767e21d8c ENH: more consistent convenience macros for creating patchFields 2023-02-20 11:18:29 +01:00
fe4688c27f ENH: patch fields writeValueEntry method (frequently used)
- add base-level readValueEntry, readMixedEntries methods
  that allow optional or mandatory reading.

STYLE: wording for patch fields comments
2023-02-20 11:13:43 +01:00
b71a05a72f ENH: add Function1::NewIfPresent without a redirect type
- simplifies handling, consistent with PatchFunction1

STYLE: use Function1 NewIfPresent instead of separate found/New
2023-02-20 11:12:59 +01:00
aef990f8df SUBMODULE: update avalanche (compilation change only) 2023-02-17 13:24:29 +01:00
cbb153372e ENH: robuster finite-area least squares gradient
- avoid division by zero for small edges
2023-02-16 14:37:34 +01:00
58e4cfbc8a REGRESSION: PstreamBuffers gather was clearing 'send-to-self' on master 2023-02-16 13:26:52 +01:00
521bdf0f07 ENH: improve UPtrList sorting
- adjust nullptr checks to discourage flip-flop when confronted with
  multiple null values.

     Old:   (a && b) ? (*a < *b) : bool(a);
     New:   (a && b) ? (*a < *b) : !b;

  comparing (non-null < null) and (null < non-null) behaves
  identically, but comparing (null < null) now tests as true
  (ie, already sorted) whereas before it would have been false
  (ie, needs a swap)

- add UPtrList trimTrailingNull(), which reduces the effective
  (addressable) list size to ignore any trailing null pointers, but
  without reallocation. This is particularly useful when creating a
  UPtrList list view. For example,

     UPtrList<some_iterator> validValues(container.size());

     ...Loop to add valid entries, by some criteria...

     // Shorten list to hide null entries
     validValues.trimTrailingNull();

   This list view now only needs a single allocation, whereas using
   a resize (as was previously necessary) could invoke a second
   allocation, as well as recopying.
2023-02-15 11:05:12 +01:00
f215ad15d1 ENH: skip zero data sends via PstreamBuffers
- in several cases can use the PstreamBuffers recvDataCount(proci)
  on the receiving part of the logic
2023-02-14 23:32:58 +01:00
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