Commit Graph

26226 Commits

Author SHA1 Message Date
e623e6a865 STYLE: favour include word.H instead of string.H
- in many places the string.H include is redundant anyhow.
  May wish to change to foamString.H (or equiv) in the future
2023-02-27 15:41:25 +01:00
d88272f031 ENH: relocate zero_one to pTraits, allows reuse for scalar clamping
ENH: add pTraits and IO for std::int8_t

STYLE: cull some implicitly available includes

- pTraits.H is included by label/scalar etc
- zero.H is included by UList

STYLE: cull redundant forward declarations for Istream/Ostream
2023-02-27 15:41:25 +01:00
f3d447579a ENH: provide explicit literal/regex for dictionary findEntry 2023-02-27 15:41:25 +01:00
7246b49eac ENH: downgrade finiteArea processor edge-length checks
- now simply warn (on FULLDEBUG) instead of Fatal.
  Avoids spurious errors on small edges.
2023-02-27 15:41:25 +01:00
8a2cd2edfb STYLE: use nProcs check on PstreamBuffers 2023-02-27 15:41:25 +01:00
9938a13b2a ENH: simplify generic patch field code 2023-02-27 15:41:22 +01:00
899d59686c CONFIG: increment API level to 2301 2023-02-21 14:28:19 +01:00
0b7c0844f4 TUT: replace calc with eval for wallMountedHump (faster!) 2023-02-21 14:27:33 +01:00
d006339c9a ENH: remove restricted precision for calc/eval (#2635)
- in earlier versions: used 'fixed' notation
  to force floating point numbers to be printed with at least
  some decimal digits. However, in the meantime we are more
  flexible with handling float/int input so remove this constraint.

- use ITstream::toString, which makes the string expansion of ${var}
  and the expression expansion of $[var] consistent.
2023-02-21 14:20:02 +01:00
74d65ed018 CONFIG: additional test for mpfr library in cgal config (#2664)
- other systems (eg, ARM64 linux with clang) do not have a separate
  mpfr library configured so also check for mpfr (gmp is assumed to be
  the same) and return corresponding cgal flavour (eg, header-no-mpfr)
2023-02-21 10:22:53 +01:00
68bbd8f3a8 Merge remote-tracking branch 'origin/master' into develop 2023-02-21 10:21:31 +01:00
40bdab1c1a Merge branch 'feature-field-functions-SIMD' into 'develop'
Field functions for lerp and clamp. Add clamping as Field methods

See merge request Development/openfoam!593
2023-02-21 09:17:57 +00:00
f180740b03 STYLE: lerp and emplace_back to simplify streamline coding 2023-02-21 10:10:43 +01:00
1cc72ea7e3 STYLE: use clamp/clamp_range instead of min(max(..., upper), lower) 2023-02-21 10:10:43 +01:00
ba6667a344 STYLE: use clamp/clamp_range instead of max(min(..., upper), lower) 2023-02-21 10:10:43 +01:00
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
c9081d5daf BUG: globalIndex gather/scatter fails with multi-world (fixes #2706)
- was using UPstream::procIDs(), which returns the sub-ranks with
  respect to the parent communicator. This is normally just an
  identity list (single-world) but with multi-world the indexing
  is incorrect.  Use UPstream::allProcs() instead.
2023-02-20 16:15:44 +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
a597c044c7 BUG: inconsistent faceArea on processor boundaries (fixes #2683)
- was missing evaluateCoupled on the initial faceAreaNormals field
  (related to #2507)

ENH: simplify/consistent geometry updating
2023-02-15 17:22:12 +01:00
d8c6b6b811 CONFIG: disable reporting of ensight type checks (unless in debug)
- avoids flooding the log file with warnings when reading in data
  sets that were not generated with OpenFOAM utilities
2023-02-15 14:07:25 +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