Commit Graph

26249 Commits

Author SHA1 Message Date
Mark OLESEN
c66993e288 Revert "Merge branch 'primitiveMeshOptimization' into 'develop'"
This reverts merge request !596
2023-03-03 16:34:40 +00:00
alonzameret
61d610574c ENH: improved point-cell and cell-point topology methods (#2715)
- for OpenFOAM-v2212 and earlier cellPoints() were constructed
  from pointCells(), but this is slower than constructing
  pointCells() from cellPoints().

  Some of the slowness is due to allocations associated with
  cells::labels(), but a large amount of slowness is the duplicate
  point avoidance. Since this is being done for many points/cells
  at once, using a bitSet for managing the duplicates amortizes
  quickly

- now construct cellPoints() from cached pointCells(), otherwise
  construct manually (using bitSet/DynamicList for bookkeeping)

- construct pointCells() from cached cellPoints(), or cached
  pointFaces(), otherwise manually.

Code Contribution: Alon Zameret

Co-authored-by: Mark Olesen
2023-03-03 16:23:42 +01:00
Mark Olesen
820f93c3b4 ENH: simplify box mesh construction (PDRblockMesh)
ENH: construct or reset boundBox from zero_one for a 0-1 unit cube

ENH: add some testing timings (for !596 and #2715)
2023-03-03 16:23:42 +01:00
Mark Olesen
4dff2bfad1 STYLE: PtrList emplace_set for symmetry with HashPtrTable method naming 2023-03-03 12:17:25 +01:00
Mark Olesen
d5c0852de1 ENH: improve diagnostic fields for checkFaMesh -write-vtk
ENH: support VTK output of procIDs for point data for some writers

TUT: areaWrite for drippingChair
2023-03-02 20:50:52 +01:00
Mark Olesen
4284d02c99 CONFIG: accept -decompose-dict=xyz for Run functions and mpirunDebug
- interpret as '-decomposeParDict xyz' for simpler scripting:
  A empty value ("") as well as "none" or "false" values are ignored.

  Eg,
      unset decompDict
      if some_condition; then decompDict=decomposeParDict-12; fi

      runParallel -decompose-dict=$decompDict ...

ENH: more generous when scanning decomposeParDict for numberOfSubdomains

- assume file is in system/ directory if not otherwise found
2023-03-02 20:50:52 +01:00
Mark Olesen
82c0b360c6 ENH: support run-time PstreamBuffers algorithm selection (advanced option)
- this helps isolate selection of PEX vs NBX, for potential migration
  to a hybrid PEX
2023-03-02 20:50:48 +01:00
Mark Olesen
99bf27cbee STYLE: use PstreamBuffers allProcs() addressing in zoneDistribute
STYLE: more generous handling of procIDs on non-master (globalIndex)
2023-03-02 15:31:50 +01:00
Mark Olesen
d3867a2d34 SUBMODULE: minor updates for external-solver 2023-03-02 12:37:06 +01:00
Mark Olesen
f75af788c1 ENH: add factory method readContents to IO containers
- useful when regular contents are to be read via an IOobject and
  returned.

  Eg,  dictionary propsDict(IOdictionary::readContents(dictIO));
  vs.  dictionary propsDict(static_cast<dictionary&&>(IOdictionary(dictIO)));

  Commonly these would have simply been constructed directly as the
  IO container:

  eg,  IOdictionary propsDict(dictIO);

  However, that style may not ensure proper move semantics for return
  types.

  Now,
  =====
      labelList decomp(labelIOList::readContents(io));
      ... something
      return decomp;
  =====

  Previously,
  =====
      labelIOList decomp(io);

      // Hope for the best...
      return decomp;

      // Or be explicit and ensure elision occurs...
      return labelList(std::move(static_cast<labelList&>(decomp)));
  =====

  Note:
       labelList list(labelIOList(io));

       looks like a good idea, but generally fails to compile
2023-02-28 15:43:26 +01:00
Mark Olesen
790a5c26f9 ENH: range-for and updated accessors in primitiveMesh
STYLE: split off primitiveMesh::calcCellPoints internal

- for easier reworking (#2715)
2023-02-28 09:48:52 +01:00
Mark Olesen
9729617ae3 ENH: PtrList iterate over non-null entries (#2702)
- the iterator/const_iterator now skip any nullptr entries,
  which enables the following code to work even if the PtrList
  contains nullptr:

  for (const auto& intf : interfaces)
  {
      // Do something
      ...
  }

- this is a change in behaviour compared to OpenFOAM-v2212 and earlier,
  but is non-breaking:
  * Lists without null entries will traverse exactly as before.
  * Lists with null entries will now traverse correctly without
    provoking a FatalError.
2023-02-27 20:03:02 +01:00
Mark Olesen
afee861af9 DEFEATURE: remove PtrList random access iterators (#2702)
- random access was unused.
  Retaining it would impede reimplementing iterators to only iterate
  across non-null items.
2023-02-27 20:03:02 +01:00
Mark Olesen
72d2ff8249 ENH: PtrList detail level iteration of null/non-null entries (#2702)
- naming as per bitSet (ie, find_first, find_next) that work with list
  indices.
- relocate bounds checked access into detail. Add at() accessor
2023-02-27 20:03:02 +01:00
Mark Olesen
0ab0ecb541 ENH: change refCount (internal) from count() to use_count()
- allows unambiguous of count() for other classes.
  Naming as per std::shared_ptr.

STYLE: qualify use_count() and unique() methods with the refCount base

- clearer/consistent meaning
2023-02-27 20:03:02 +01:00
Mark Olesen
00f499d714 ENH: more noexcept methods for edge, avoid some intermediates
STYLE: document edge parameters as 'vertex' (not point)

- edge is also used for graph edges or connection edges etc.
2023-02-27 20:03:02 +01:00
Mark Olesen
0fc2c817e1 STYLE: emplace_back/push_back instead of append in tree algorithms 2023-02-27 20:03:02 +01:00
Mark Olesen
117173aaba ENH: use min/max instead of first/last for int/slice ranges
- consistent with MinMax tuple etc.
- cull unused before(), after() methods
2023-02-27 15:41:25 +01:00
Mark Olesen
b33b26ad34 STYLE: replace zero::null usage with zero
- the null output adapter was previously used for the HashTables API
  when HashSet actually stored key/value. Now that the node only
  contains the key, having suppressed output is redundant, as is the
  zero::null class (reduces clutter)

STYLE: replace one::minus dispatch in extendedEdgeMesh

GIT: remove Foam::nil typedef (deprecated since May-2017)
2023-02-27 15:41:25 +01:00
Mark Olesen
cdcbd05587 COMP: resolve clamp() float/double ambiguity (SPDP compilation)
- pass by value instead of reference, add functional casts in some
  places. Can still rely on integer promotions though.

  OK:   clamp(value, 2, 20)   ==> (float, int, int)
  OK:   clamp(value, scalar(2), scalar(20))  ==> (float, float, float)
  NOK:  clamp(value, 2.0, 20) ==> (float, double, int)
2023-02-27 15:41:25 +01:00
Mark Olesen
28b492bd54 ENH: unroll loops for complexVector functions
STYLE: prefer STL naming real(), imag() instead of Re(), Im()
2023-02-27 15:41:25 +01:00
Mark Olesen
f0a196a908 STYLE: include primitivePatch.H (instead of PrimitivePatch.H)
- further de-clutter in the future

ENH: PrimitivePatchInterpolation with unique_ptr for memory management
2023-02-27 15:41:25 +01:00
Mark Olesen
d51aa5a74d STYLE: merge EdgeMap definition into edgeHashes.H
STYLE: combine some list typedefs, add documentation comments

GIT: relocate some compat includes
2023-02-27 15:41:25 +01:00
Mark Olesen
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
Mark Olesen
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
Mark Olesen
f3d447579a ENH: provide explicit literal/regex for dictionary findEntry 2023-02-27 15:41:25 +01:00
Mark Olesen
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
Mark Olesen
8a2cd2edfb STYLE: use nProcs check on PstreamBuffers 2023-02-27 15:41:25 +01:00
Mark Olesen
9938a13b2a ENH: simplify generic patch field code 2023-02-27 15:41:22 +01:00
Mark Olesen
899d59686c CONFIG: increment API level to 2301 2023-02-21 14:28:19 +01:00
Mark Olesen
0b7c0844f4 TUT: replace calc with eval for wallMountedHump (faster!) 2023-02-21 14:27:33 +01:00
Mark Olesen
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
Mark Olesen
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
Mark Olesen
68bbd8f3a8 Merge remote-tracking branch 'origin/master' into develop 2023-02-21 10:21:31 +01:00
Andrew Heather
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
Mark Olesen
f180740b03 STYLE: lerp and emplace_back to simplify streamline coding 2023-02-21 10:10:43 +01:00
Mark Olesen
1cc72ea7e3 STYLE: use clamp/clamp_range instead of min(max(..., upper), lower) 2023-02-21 10:10:43 +01:00
Mark Olesen
ba6667a344 STYLE: use clamp/clamp_range instead of max(min(..., upper), lower) 2023-02-21 10:10:43 +01:00
Mark Olesen
4d45cfd5a9 ENH: lerp for patch/neighbour weights 2023-02-21 10:10:43 +01:00
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
a7d77391fa BUG: selfComm had 0 instead of parent rank for UPstream::procID (#2706) 2023-02-21 09:29:44 +01:00
Mark Olesen
2569405383 ENH: implement NBX with recovery of sizes and non-blocking receives 2023-02-20 19:00:31 +01:00
Mark Olesen
fb2bf77e8e TUT: update keyword coordinateRotation -> rotation 2023-02-20 19:00:31 +01:00
Mark Olesen
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