Commit Graph

7722 Commits

Author SHA1 Message Date
Mark Olesen
1d43e45fdd ENH: add test application for fileHander writing
COMP: update applications/test
2023-10-11 18:11:37 +00:00
Mark Olesen
1af40e7dfe STYLE: remove unused (transitional) methods from CircularBuffer
- old methods (and class) were not widely used
2023-10-11 18:11:37 +00:00
Mark Olesen
524c953af3 STYLE: use List clear() instead of setSize(0), resize(0)
- adds some consistency
2023-10-11 18:11:37 +00:00
mattijs
9ac0f03963 ENH: pisoFoam: allow runTimeModifiable. Fixes #2997. 2023-10-11 15:54:30 +01:00
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
9d291ab4cc ENH: add Pstream::broadcastList()
- broadcasts list contiguous content as a two-step process:
    1. broadcast the size, and resize for receiver list
    2. broadcast contiguous contents (if non-empty)

  This avoids serialization/de-serialization memory overhead but at
  the expense of an additional broadcast call.
  The trade-off of the extra broadcast of the size will be less
  important than avoiding a memory peak for large contiguous mesh data.

REVERT: unstable MPI_Mprobe/MPI_Mrecv on intelmpi + PMI-2 (#2796)

- partial revert of commit c6f528588b, for NBX implementation.
  Not yet flagged as causing errors here, but eliminated for
  consistency.
2023-08-29 11:24:16 +02:00
Mark Olesen
0e11f47f74 STYLE: prefer emplace_back() to append() + last() 2023-08-29 11:24:16 +02:00
Mark Olesen
698e05eeb3 STYLE: prefer push_uniq() to appendUniq
- more consistency with push_back etc.
2023-08-29 11:24:16 +02:00
Mark Olesen
2395e493d1 ENH: simplify add/remove patch/zone groups
STYLE: reuse polyBoundaryMesh patchSizes(), patchStarts()
2023-08-29 11:24:16 +02:00
Mark Olesen
886ba89ddb ENH: change internal dictionary separator to '/' (#1073)
- simplifies internal handling (like a fileName) and allows the
  dictionary name to be used with unambiguous addressing.
  The previous dot (.) separator is ambiguous (ie, as dictionary
  separator or as part of a keyword).

ENH: foamDictionary report -add/-set to stderr
2023-08-21 08:40:39 +02:00
Mark Olesen
778796853d CONFIG: enable use of stricter deprecation warnings
- selected with '+strict' in WM_COMPILE_CONTROL or 'wmake -strict', it
  enables the FOAM_DEPRECATED_STRICT() macro, which can be used to
  mark methods that are implicitly deprecated, but are not yet marked
  as full deprecated (eg, API modification is too recent, generates
  too many warnings).  Can be considered a developer option.
2023-08-21 08:39:36 +02:00
Mark Olesen
97668eab26 STYLE: update noexcept and default construct for signals
- eliminate ClassName in favour of simple debug

- include Apple-specific FPE handling after local definition
  to allow for more redefinitions

COMP: remove stray <csignal> includes
2023-08-18 15:42:18 +02:00
Mark Olesen
b620152191 ENH: add UPstream::msgType() setter method and UPstream::incrMsgType()
- like UPstream::parRun() etc, returns old value
2023-08-18 15:08:42 +02:00
Mark Olesen
03ca52b036 ENH: PtrList, PtrDynList, HashPtrTable try_emplace() method
- naming like std::map::try_emplace(), it behaves like emplace_set()
  if there is no element at the given location otherwise a no-op

ENH: reuse existing HashPtrTable 'slot' when setting pointers

- avoids extra HashTable operations
2023-08-18 13:55:32 +02:00
Mark Olesen
268de43afc ENH: provision for delayed reading of compound tokens (#2953)
- the construction of compound tokens is now split into two stages:
    - default construct
    - read contents
  This permits a larger variety of handling.

- the new token::readCompoundToken(..) method allows for simpler
  more failsafe invocations.

- forward resize(), read() methods for compound tokens to support
  separate read and population.
  Top-level refCompoundToken() method for modify access.

ENH: split off a private readCompoundToken() method within ISstream

- this allows overloading and alternative tokenisation handling for
  derived classes
2023-08-16 16:22:17 +02:00
Mark Olesen
43f8b477b7 ENH: additional ITstream access/manipulate methods
- simplifies iteration of ITstream using nRemainingTokens() and skip()
  methods or directly as a list of tokens.

  The currentToken() method returns const or non-const access to
  the token at the current tokenIndex.

  The peekToken(label) method provides failsafe read access to tokens
  at given locations.

ENH: add primitiveEntry construct with moving a single token
2023-08-16 16:22:17 +02:00
Mark Olesen
2422e6f061 ENH: use std algorithms for copy/move/compare within List containers
ENH: add List resize_fill variant. Fuses resize_nocopy + uniform fill

COMP: avoid cast ambiguity when assigning Foam::zero to UList<char>
2023-08-16 12:28:12 +02:00
Mark Olesen
eeb9d144e3 STYLE: qualify Swap with Foam:: prefix (visibility)
- drop unnecessary Foam::Swap specializations when MoveConstructible
  and MoveAssignable already apply. The explicit redirect to swap
  member functions was needed before proper move semantics where
  added.

  Removed specializations: autoPtr, refPtr, tmp, UList.
  Retained specialization: DynamicList, FixedList.

     Special handling for DynamicList is only to accommodate dissimilar
     sizing template parameters (which probably doesn't occur in
     practice).
     Special handling for FixedList to apply element-wise swapping.

- use std::swap for primitives. No need to mask with Foam::Swap wrapper
2023-08-16 12:28:09 +02:00
Mark Olesen
fabd3f4e0c ENH: eliminate reliance on SLList during reading
- fully implement DynamicList::readList() instead of simply
  redirecting to List::readList(). This also benefits DynamicField.
  Leverage DynamicList reading to simplify and improve CircularBuffer
  reading.

- bracket lists are now read chunk-wise instead of using a
  singly-linked list. For integral and vector-space types
  (eg, scalar, vector, etc) this avoids intermediate allocations
  for each element.

ENH: add CircularBuffer emplace_front/emplace_back

STYLE: isolate to-be-deprecated construct/assign forms

- still have construct/assign FixedList from a C-array.
  This is not really needed, can use std::initializer_list

- still have construct/assign List from SLList.
  Prefer to avoid these in the future.

DEFEATURE: remove construct/assign FixedList from SLList

- never used

DEFEATURE: remove move construct/assign List from SLList

- now unused. Retain copy construct/assign from SLList for transition
  purposes.
2023-08-16 12:27:04 +02:00
Mark Olesen
97a42df7ba ENH: add VectorSpace trait tests and evaluations
- is_vectorspace :
  test existence and non-zero value of the Type 'rank' static variable

- pTraits_rank :
  value of 'rank' static variable (if it exists), 0 otherwise

- pTraits_nComponents :
  value of 'nComponents' static variable (if it exists), 1 otherwise

- pTraits_has_zero :
  test for pTraits<T>::zero member, which probably means that it also
  has one, min, max members as well

Note that these traits are usable with any classes. For example,

  - is_vectorspace<std::string>::value  ==> false
  - pTraits_nComponents<std::string>::value  ==> 1
  - pTraits<std::string>::nComponents  ==> fails to compile

  Thus also allows testing pTraits_rank<...>::value with items
  for which pTraits<...>::rank fails to compile.

  Eg, cyclicAMIPolyPatch::interpolate called by FaceCellWave with a
  wallPoint.

     pTraits<wallPoint>::rank ==> fails to compile
     is_vectorspace<wallPoint>::value ==> false

GIT: relocate ListLoopM.H to src/OpenFOAM/fields/Fields (future isolation)
2023-08-10 10:38:39 +02:00
Mark Olesen
aad4c2222e ENH: subsetMesh -exclude-patches (#2947)
STYLE: use -exclude-patches instead of -excludePatch for other utilities

- avoids inconsistencies with utilities like foamToVTK etc.
2023-08-02 12:35:10 +02:00
Mark Olesen
14f7d44ca0 ENH: patch/zone indices with select/ignore combination
STYLE: prefer indices() to patchSet() with warn=false
2023-08-02 12:34:41 +02:00
Mark Olesen
db16d80840 ENH: use objectRegistry/IOobjectList sorted instead of lookupClass
- in most cases a parallel-consistent order is required.
  Even when the order is not important, it will generally require
  fewer allocations to create a UPtrList of entries instead of a
  HashTable or even a wordList.
2023-07-31 20:11:32 +02:00
Mark Olesen
dc95242cd2 ENH: use sorted order for fieldSelection::selectionNames() (#2819)
- return a sorted wordList instead of a wordHashSet to ensure that
  fields will be processed in consistent order in parallel
2023-07-31 20:11:32 +02:00
Mark Olesen
ed314b2740 ENH: use sorted order for patch IDs in fieldFunctionObjects (#2819)
- replaces labelHashSet with a sorted labelList to ensure that patches
  will be processed in consistent order in parallel
2023-07-31 20:11:32 +02:00
Mark Olesen
5397c9ac04 COMP: use csorted() instead of sorted() 2023-07-31 20:11:32 +02:00
Mark Olesen
129b738136 ENH: define IOobjectList::csorted(), deprecate some sorted() const methods
- prefer csorted() method for const access since it ensures that the
  return values are also const pointers (for example) even if
  the object itself can be accessed as a non-const.

- the csorted() method already existed for HashTable and
  objectRegistry, but now added to IOobjectList for method name
  consistency (even although the IOobjectList only has a const-access
  version)

ENH: objectRegistry with templated strict lookup

- for lookupClass and csorted/sorted. Allows isType restriction as a
  compile-time specification.
2023-07-31 20:11:32 +02:00
Mark Olesen
0eb4354ee0 ENH: use DynamicList for handling stored objects (ReadFields)
- DynamicList can be used as a LIFO with fewer allocations than a
  linked-list would have.

- support generic name matcher for readFields()
2023-07-31 20:11:32 +02:00
Mark Olesen
f18a29a742 ENH: subsetMesh suppress wildcard selection of processor patches (#2947) 2023-07-31 14:07:17 +02:00
Mark Olesen
945e3e41b1 ENH: more consistent use of good() or direct testing instead valid() 2023-07-27 16:52:03 +02:00
Mark Olesen
8117cde596 ENH: use emplace_set, emplace_back to simplify code
- eg, for cloud fields, tmp emplace when reading fields etc.
2023-07-27 16:52:03 +02:00
Mark Olesen
63258d0b33 ENH: refine PtrList emplace method, add emplace for autoPtr/refPtr...
* resize_null() methods for PtrList variants
  - for cases where an existing PtrList needs a specific size and
    but not retain any existing entries.

    Eg,
        ptrs.resize_null(100);

    vs.   ptrs.free();     ptr.resize(100);
    or    ptr.resize(100); ptrs.free();

* remove stored pointer before emplacing PtrList elements
  - may reduce memory peaks

* STYLE: static_cast of (nullptr) instead of reinterpret_cast of (0)

* COMP: implement emplace_set() for PtrDynList
  - previously missing, which meant it would have leaked through to the
    underlying PtrList definition

* emplace methods for autoPtr, refPtr, tmp
  - applies reset() with forwarding arguments.
    For example,

        tmp<GeoField> tfld = ...;

    later...

        tfld.emplace(io, mesh);

    vs.
        tfld.reset(new GeoField(io, mesh));
    or
        tfld.reset(tmp<GeoField>::New(io, mesh));

    The emplace() obviously has reduced typing, but also allows the
    existing stored pointer to be deleted *before* creating its
    replacement (reduces memory peaks).
2023-07-27 16:52:03 +02:00
Mark Olesen
32903d337e ENH: add slice/range support to UPstream::waitSomeRequests()
- this simplifies polling receives and allows separation from
  the sends

ENH: add UPstream::removeRequests(pos, len)

- cancel/free of outstanding requests and remove segment from the
  internal list of outstanding requests
2023-07-27 16:52:03 +02:00
Mark Olesen
779c3fe11e STYLE: use 'is_sorted()' instead of 'sorted()' for readers, Pair, ...
- avoids naming ambiguity between querying sorted state vs returning a
  sorted list (for example)

ENH: add 'good()' method to a few more classes
2023-07-19 14:10:31 +02:00
Mark Olesen
8562f4d7a4 STYLE: use UPtrList::test() instead of separate bounds checking 2023-07-19 14:10:31 +02:00
Mark Olesen
65cddb6120 ENH: specialise bitOr<unsigned char> reduction
STYLE: remove extraneous parRun check before Pstream::combineReduce

- already handled by Pstream::combineReduce itself

STYLE: remove deprecated globalMeshData::ListPlusEqOp

- deprecated/superseded by ListOps::appendEqOp (2020-09)

STYLE: qualify stream format with IOstreamOption (easier to find)
2023-07-19 14:06:23 +02:00
mattijs
ab0d4d95ff ENH: snappyHexMesh: write leak-closure faces 2023-07-19 12:55:02 +01:00
mattijs
a8df552998 ENH: checkMesh: use built-in merging 2023-07-18 12:03:58 +01:00
Mark Olesen
8ee4b52560 ENH: provide MPI native bitOrOp reduce with single/multiple values
- can be used, for example, to track global states:

      // Encode as 0:empty, 1:uniform, 2:nonuniform, 3:mixed
      PackedList<2> uniformity(fields.size());

      forAll(fields, i)
      {
          uniformity.set(i, fields[i].whichUniformity());
      }

      reduce
      (
          uniformity.data(),
          uniformity.size_data(),
          bitOrOp<unsigned>()
      );
2023-07-05 15:14:26 +02:00
Mark Olesen
a1e34bb251 ENH: use mapDistribute linear construct order in a few places
- simplifies code by avoiding code duplication:
  * parLagrangianDistributor
  * meshToMesh (processorLOD and AABBTree methods)

BUG: inconsistent mapping when using processorLOD boxes (fixes #2932)

- internally the processorLODs createMap() method used a 'localFirst'
  layout whereas a 'linear' order is what is actually expected for the
  meshToMesh mapping. This will cause of incorrect behaviour
  if using processorLOD instead of AABBTree.
  A dormant bug since processorLOD is not currently selectable.
2023-07-04 20:29:07 +02:00
Mark Olesen
5635e14f81 ENH: add low-level polymorphic/boxed exprValue
- primarily for handling expression results,
  but can also be used as a universal value holder.

  Has some characteristics suitable for type-less IO:
  eg, is_integral(), nComponents()

ENH: add is_pointer() check for expression scanToken
2023-07-04 17:25:26 +02:00
Mark Olesen
d5a0eaeeee STYLE: changes to Time and TimeState
- update TimeState access methods

- use writeTime() instead of old method name outputTime()

- use deltaTValue() instead of deltaT().value()
  to avoids pointless construct of intermediate
2023-07-04 17:25:25 +02:00
Andrew Heather
763bf4674d RELEASE: Updated headers to v2306 2023-06-28 16:35:48 +01:00
mattijs
2d145e070e COMP: chtMultiRegionTwoPhaseEulerFoam: compile local files only 2023-06-28 16:35:47 +01:00
mattijs
4d7c827bd7 ENH: checkMesh: report on processor patch if non-parallel. Fixes #698 2023-06-26 12:14:30 +01:00
Mark Olesen
642d8a9dfa COMP: guards around #define OMPI_SKIP_MPICXX (avoids compiler warnings) 2023-06-23 16:05:19 +02:00
mattijs
09edb23c1d BUG: collated fails with controlDict watch files
- files might have been set during token reading so only on
  known on master processor.
  Broadcast names to all processors (even alhough they are only
  checked on master) so that the watched states remain synchronised
2023-06-21 14:56:06 +02:00
Mark Olesen
fc86e52451 ENH: extrapolateInternal() method for patch fields
- provides a more succinct way of writing

      {fa,fv}PatchField<Type>::patchInternalField(*this)

  as well as a consistent naming that can be used for patches derived
  from valuePointPatchField

ENH: readGradientEntry helper method for fixedGradient conditions

- simplifies coding and logic.
- support different read construct modes for fixedGradient
2023-06-19 17:47:03 +02:00
Mark Olesen
f9d0895707 ENH: avoid spurious library loading for decomposePar, redistributePar
- individual processor Time databases are purely for internal logistics
  and should not be introducing any new library symbols: these will
  already have been loaded in the outer loop.
2023-06-19 17:05:45 +02:00
Mark Olesen
4412566c58 ENH: support command-line specification of MPI threads (#2791)
- MPI_THREAD_MULTIPLE is usually undesirable for performance reasons,
  but in some cases may be necessary if a linked library expects it.
  Provide a '-mpi-threads' option to explicitly request it.

ENH: consolidate some looping logic within argList
2023-06-19 17:05:45 +02:00
Mark Olesen
1cdba9b269 ENH: make checkMesh writing of bad edges optional (#2771)
- primarily relevant for finite-area meshes, in which case they can be
  considered to be an additional, detailed diagnositic that is
  normally not needed (clutters the file system).

  Writing can be enabled with the `-write-edges` option.
2023-06-13 20:41:53 +02:00
Andrew Heather
b87db82c05 ENH: particleTracks - reinstated label field output 2023-06-13 14:13:58 +01:00
Mark Olesen
1c9ea038d0 MISC: additional -repeat option for testing MPI_Comm leakage (#1598) 2023-06-12 13:59:47 +02:00
mattijs
adc38d55ac ENH: coupled: enforce consistency. See #2783 2023-06-01 08:14:42 +00:00
mattijs
fcbfa40b0b ENH: checkMesh: small message change 2023-05-30 10:41:15 +01:00
Mark Olesen
8d2bf3fc2e ENH: soft update of autoPtr<fileOperation> to refPtr<fileOperation>
Co-authored-by: mattijs <mattijs>
2023-05-23 15:03:23 +02:00
Mark Olesen
8a060e87cb ENH: fileHandler support for faMeshDistributor and field distributors
- fatten the interface to continue allowing write control with a bool
  or with a dedicated file handler. This may slim down in the future.

Co-authored-by: mattijs <mattijs>
2023-05-23 15:01:09 +02:00
Mark Olesen
d34dfbe0b7 ENH: dummy fileOperation: placeholder for interfaces taking a reference
STYLE: align readOnProc/writeOnProc naming within masterUncollated
2023-05-23 11:12:37 +02:00
Mark Olesen
a34262966b STYLE: use fileOperation nProcs() instead of setNProcs() 2023-05-22 18:04:21 +02:00
Mark Olesen
821d395259 ENH: use refPtr fileHandler in decomposeFaFields, faMeshReconstructor 2023-05-22 17:59:33 +02:00
Mark Olesen
06147dabe7 ENH: more flexible handling of FOAM_IORANKS
- accept plain lists (space or comma separated) as well as the
  traditional OpenFOAM lists. This simplifies argument handling
  with job scripts.

  For example,
     simpleFoam -ioRanks 0,4,8 ...
  vs
     simpleFoam -ioRanks '(0 4 8)'  ...

  It is also possible to select the IO ranks on a per-host basis:

     simpleFoam -ioRanks host  ...

- expose rank/subrank handling as static fileOperation methods
2023-05-22 17:59:30 +02:00
Mark Olesen
11742301f1 ENH: add support for file/directory broadcasting
Co-authored-by: mattijs <mattijs>
2023-05-22 17:48:09 +02:00
Mark Olesen
9cd14bc8b0 STYLE: remove unused isWriteProc() methods from distribute fields 2023-05-22 17:46:16 +02:00
Mark Olesen
5eebc75845 ENH: improved UPstream gather/scatter functionality
- added UPstream::allGatherValues() with a direct call to MPI_Allgather.
  This enables possible benefit from a variety of internal algorithms
  and simplifies the caller

    Old:
        labelList nPerProc
        (
            UPstream::listGatherValues<label>(patch_.size(), myComm)
        );
        Pstream::broadcast(nPerProc, myComm);

    New:

        const labelList nPerProc
        (
            UPstream::allGatherValues<label>(patch_.size(), myComm)
        );

- Pstream::allGatherList uses MPI_Allgather for contiguous values
  instead of the hand-rolled tree walking involved with
  gatherList/scatterList.

-
- simplified the calling parameters for mpiGather/mpiScatter.

  Since send/recv data types are identical, the send/recv count
  is also always identical. Eliminates the possibility of any
  discrepancies.

  Since this is a low-level call, it does not affect much code.
  Currently just Foam::profilingPstream and a UPstream internal.

BUG: call to MPI_Allgather had hard-coded MPI_BYTE (not the data type)

- a latent bug since it is currently only passed char data anyhow
2023-05-22 17:18:35 +02:00
Mark Olesen
302eb7b560 REGRESSION: createBaffles : incorrect dictionary lookup
- was introduced with f7a7f1c14c, only affected very recent develop
2023-05-20 18:59:20 +02:00
Mark Olesen
bc51caac32 ENH: remove sign from SHA1Digest cdata_bytes(), data_bytes()
- this refinement of commit 81807646ca makes these methods
  consistent with other objects/containers.

  The 'unsigned char' access is still available via cdata()
2023-05-19 15:54:23 +02:00
Mark Olesen
f41d1879b9 STYLE: prefer isHeaderClass<Type>() check instead of Type::typeName
- use typeHeaderOk<regIOobject>(false) for some generic file existence
  checks. Often had something like labelIOField as a placeholder, but
  that may be construed to have a particular something.
2023-05-19 00:48:14 +02:00
Mark Olesen
87cb811db2 COMP: fix library linkage (#2784), silence some unused variable warnings 2023-05-19 00:46:52 +02:00
Mark Olesen
a5d9ad3a5c STYLE: use noexcept creation of InfoProxy and dereference as '*iproxy'
- this removes the 'magic' use of the exposed t_ member in favour
  of a generic dereference
2023-05-18 18:23:46 +02:00
Mark Olesen
f7a7f1c14c ENH: reduced warnings about createBaffles on processor patches (#2781)
- coupled patches are treated distinctly and independently of
  internalFacesOnly, it makes little sense to report them with a
  warning about turning off boundary faces (which would not work
  anyhow).

STYLE: update code style for createBaffles
2023-05-17 11:46:57 +02:00
Mark Olesen
a581a8cb8d ENH: disallow implicit cast of autoPtr to non-const pointer
- permitting a cast to a non-const pointer adds uncertainty of
  ownership.

- adjust PtrDynList transfer. Remove the unused 'PtrDynList::remove()'
  method, which is better handled with pop().
2023-05-17 11:46:57 +02:00
Kutalmis Bercin
59b1cf080e ENH: Tensor/SymmTensor: add devSymm and devTwoSymm funcs to avoid intermediates 2023-05-15 17:05:10 +01:00
Mark Olesen
783934ccad ENH: add global topology check in checkMesh and makeFaMesh (#2771)
- detect when boundary patches are multiply connected across edges

STYLE: initialize some faMesh values
2023-05-09 19:30:58 +02:00
Mark Olesen
31600c96d4 ENH: output finiteArea patchID with foamToVTK -with-ids
- can be quite useful for debugging/orientation with complex
  geometries
2023-05-09 19:30:58 +02:00
Mark Olesen
f462a850ce ENH: added polyBoundaryMesh patchID(meshFacei) method
- this complements the whichPatch(meshFacei) method [binary search]
  and the list of patchID() by adding internal range checks.

  eg,
     Before
     ~~~~~~
     if (facei >= mesh.nInternalFaces() && facei < mesh.nFaces())
     {
         patchi = pbm.patchID()[facei - mesh.nInternalFaces()];
         ...
     }

     After
     ~~~~~
     patchi = pbm.patchID(facei);

     if (patchi >= 0)
     {
         ...
     }
2023-05-09 19:30:58 +02:00
Mark Olesen
8e32db2b5f STYLE: more explicit use of REGISTER when storing fields
ENH: add phaseScopedName convenience method

- unites IOobject::scopedName + phasePropertyName
2023-05-09 19:30:57 +02:00
Mark Olesen
16591012e9 ENH: add -verbose option to surface conversion, cleanup
- by default, reduce the amount of output

ENH: support default text description for -verbose option

- simplifies use in more places.
2023-05-09 19:30:57 +02:00
Mark Olesen
2eb1f5678d ENH: use Improbe/Mrecv for NBX size exchange
- retains the queried message without secondary polling.
  Purported to be slightly faster. Better thread-safety.
2023-05-09 14:51:43 +02:00
Mark Olesen
639b800049 ENH: clearer separation of MPI initialize/finalize stages (#2774)
ENH: support transfer from a wrapped MPI request to global list

- allows coding with a list UPstream::Request and subsequently either
  retain that list or transfer into the global list.
2023-05-09 14:51:43 +02:00
Mark Olesen
e967305ef2 STYLE: use calculatedType() and zeroGradientType() methods 2023-05-02 13:34:12 +02:00
Mark Olesen
ee39e3d276 STYLE: use explicit REGISTER option when storing fields 2023-04-25 13:45:08 +02:00
Mark Olesen
ce282dfbbf ENH: correct the selfComm procNo relative to world communicator
STYLE: qualify worldComm as UPstream instead Pstream

STYLE: PPCG::gSumMagProd() as static function
2023-04-24 15:46:04 +02:00
Mark Olesen
5042d1296f ENH: consistent UniformDimensionedField naming
- construct from components, or use word::null to ensure
  consistent avoid naming between IOobject vs dimensioned type.

- support construct with parameter ordering as per DimensionedField

ENH: instantiate a uniformDimensionedLabelField

- eg, for registering standalone integer counters
2023-04-24 15:46:04 +02:00
Mark Olesen
2b1061420c STYLE: remove trailing space, tabs 2023-04-24 15:37:33 +02:00
Mark Olesen
7bef18a274 STYLE: document const-ness of isA, refCast 2023-04-21 15:49:27 +02:00
Mark Olesen
80bc1db5b7 ENH: provide UPstream intra-host and inter-host communicators
- simplifies communication structuring with intra-host communication.
  Can be used for IO only, or for specialised communication.

  Demand-driven construction. Gathers the SHA1 of host names when
  determining the connectivity. Internally uses an MPI_Gather of the
  digests and a MPI_Bcast of the unique host indices.

  NOTE:
    does not use MPI_Comm_splt or MPI_Comm_splt_type since these
    return MPI_COMM_NULL on non-participating process which does not
    easily fit into the OpenFOAM framework.

    Additionally, if using the caching version of
    UPstream::commInterHost() and UPstream::commIntraHost()
    the topology is determined simultaneously
    (ie, equivalent or potentially lower communication).
2023-04-18 14:08:39 +02:00
Mark Olesen
9d3427e0b4 ENH: consolidate UPstream::commsStruct code
- make sizing of commsStruct List demand-driven as well
  for more robustness, fewer unneeded allocations.

- fix potential latent bug with allBelow/allNotBelow for proc 0
  (linear communication).

ENH: remove unused/unusable UPstream::communicator optional parameter

- had constructor option to avoid constructing the MPI backend,
  but this is not useful and inconsistent with what the reset or
  destructor expect.

STYLE: local use of UPstream::communicator

- automatically frees communicator when it leaves scope
2023-04-18 14:08:39 +02:00
Mark Olesen
b277b913cf ENH: add guards for partially populated communicators
- these are primarily when encountering sparse (eg, inter-host)
  communicators. Additional UPstream convenience methods:

  is_rank(comm)
    => True if process corresponds to a rank in the communicators.
       Can be a master rank or a sub-rank.

  is_parallel(comm)
    => True if parallel algorithm or exchange is used on the process.
       same as

           (parRun() && (nProcs(comm) > 1) && is_rank(comm))
2023-04-18 14:08:39 +02:00
Mark Olesen
a96dcf706b ENH: robuster handling of inv() of fields with singular tensors (#2724)
- replace the "one-size-fits-all" approach of tensor field inv()
  with individual 'failsafe' inverts.

  The inv() field function historically just checked the first entry
  to detect 2D cases and adjusted/readjusted *all* tensors accordingly
  (to avoid singularity tensors and/or noisy inversions).

  This seems to have worked reasonably well with 3D volume meshes, but
  breaks down for 2D area meshes, which can be axis-aligned
  differently on different sections of the mesh.
2023-04-18 13:59:09 +02:00
Mark Olesen
09dd913077 ENH: use primitive fields when calculating triSurface fields (#2758) 2023-04-13 20:54:50 +02:00
Mark Olesen
d826f9259f ENH: properly trap any sub-rank changes in allocatePstreamCommunicator
- not currently used, but it is possible that communicator allocation
  modifies the list of sub-ranks. Ensure that the correct size is used
  when (re)initialising the linear/tree structures.

STYLE: adjust MPI test applications

- remove some clutter and unneeded grouping.
  Some ideas for host-only communicators
2023-04-08 18:33:52 +02:00
Mark Olesen
475ed5cc32 STYLE: readOnProc/writeOnProc instead of 'valid' for IO 2023-04-04 15:04:26 +02:00
Mark Olesen
87eed5e3b8 ENH: place more patch field attributes under template invariant Base
- attributes such as assignable(), coupled() etc

- common patchField types: calculatedType(), zeroGradientType() etc.
  This simplifies reference to these types without actually needing a
  typed patchField version.

ENH: add some basic patchField types to fieldTypes namespace

- allows more general use of the names

ENH: set extrapolated/calculated from patchInternalField directly

- avoids intermediate tmp
2023-04-03 13:33:56 +02:00
Mark Olesen
4994456a28 ENH: add 2D det() / inv() methods for Tensor/SymmTensor (#2724)
- for cases where a 3D tensor is being used to represent 2D content,
  the determinant is zero. Can use inv2D(excludeDirection) to compensate
  and invert as if it were only 2D.

ENH: consistent definitions for magSqr of symmTensors, diagSqr() norm

COMP: return scalar not component type for magSqr

- had inconsistent definitions with SymmTensor returning the component
  type and Tensor returning scalar. Only evident with complex.
2023-03-23 10:31:54 +01:00
Mark Olesen
25bc7d65f7 STYLE: prefer REGISTER/NO_REGISTER instead of true/false for IOobject
- self-documenting
2023-03-10 14:16:32 +00:00
Mark Olesen
20566a87f5 ENH: provide getter/setter interface to standard communicators
- similar to UPstream::parRun(), the setter returns the previous value.

  The accessors are prefixed with 'comm':
  Eg, commGlobal(), commWarn(), commWorld(), commSelf().
  This distinguishes them from any existing variables (eg, worldComm)
  and arguably more similar to MPI_COMM_WORLD etc...

  If demand-driven communicators are added in the future, the function
  call syntax can help encapsulate that.

  Previously:

      const label oldWarnComm = UPstream::warnComm;
      const label oldWorldComm = UPstream::worldComm;
      UPstream::warnComm = myComm;
      UPstream::worldComm = myComm;
      ...

      UPstream::warnComm = oldWarnComm;
      UPstream::worldComm = oldWorldComm;

  Now:
      const label oldWarnComm = UPstream::commWarn(myComm);
      const label oldWorldComm = UPstream::commWorld(myComm);
      ...

      UPstream::commWarn(oldWarnComm);
      UPstream::commWorld(oldWorldComm);

STYLE: check (warnComm >= 0) instead of (warnComm != -1)
2023-03-09 16:01:04 +00:00
Mark Olesen
b17422ef1a ENH: use readValueEntry, readMixedEntries for simpler program control 2023-03-08 15:30:04 +00: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
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
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
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
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
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
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
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
68bbd8f3a8 Merge remote-tracking branch 'origin/master' into develop 2023-02-21 10:21:31 +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
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
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
0767e21d8c ENH: more consistent convenience macros for creating patchFields 2023-02-20 11:18:29 +01:00
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
27a7ae2d1d ENH: use simpler lookupPatchField form 2023-02-13 20:08:48 +01:00
Mark Olesen
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
Mark Olesen
2db3e2b64f STYLE: simplify ensightMeshReader with emplace_back/push_back
STYLE: emplace for mesh zones
2023-02-11 09:21:43 +01:00
Mark Olesen
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
Mark Olesen
d597b3f959 STYLE: check iterator validity with good() instead of found()
- aligns better with other container checks
2023-02-10 17:12:48 +01:00
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
Mark Olesen
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
mattijs
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
Mattijs Janssens
c0e63a8de7 ENH: MeshObject: specify name (instead of typeName) 2023-02-01 15:32:14 +00:00
Mark Olesen
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
Mark Olesen
0190fed56b ENH: support slicing for finiteArea fields 2023-01-31 12:45:38 +01:00
Mark Olesen
5672bb296f ENH: use cmptMag, cmptMultiply instead of replacing field components 2023-01-31 12:36:41 +01:00
Mark Olesen
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
Mark Olesen
988ec18ecc COMP: backslash instead of slash in Make/options 2023-01-30 11:55:35 +01:00
Mark Olesen
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
Mark Olesen
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
Mark Olesen
c1cdacc0b4 COMP: missing default parameters for UIPstream::read
ENH: support UIPstream::read, UOPstream::write with UList, SubList
2023-01-27 09:49:16 +01:00
Mark Olesen
94a79ef24f STYLE: explicit reference to mesh db for schemes, interfaceTracking etc 2023-01-23 15:05:04 +01:00
Mark Olesen
0c756cc676 ENH: define linear interpolations for scalar, complex, vector, tensor...
- vector, tensor versions are defined component-wise
  to avoid intermediates.

  The base version uses the form "(1-t)*a + t*b" without any bounds
  checking (ie, will also extrapolate).
2023-01-23 14:55:08 +01:00
Mark Olesen
ba153df8db ENH: improved handling for clamping
- proper component-wise clamping for MinMax clamp().

- construct clampOp from components

- propagate clamp() method from GeometricField to FieldField and Field

- clamp_min() and clamp_max() for one-sided clamping,
  as explicit alternative to min/max free functions which can
  be less intuitive and often involve additional field copies.

- top-level checks to skip applying invalid min/max ranges
  and bypass the internal checks of MinMax::clamp() etc.
2023-01-23 14:52:29 +01:00
Mark Olesen
3888bfa17f ENH: UList iterators at offset from begin
- simplifies addressing within sub-ranges.
  Clamps the access range directly
2023-01-23 14:52:29 +01:00
Mark Olesen
ecaa55295b ENH: add dimensionedLabel typedef
GIT: primitives/compat with compatibility includes
GIT: primitives/traits with pTraits, contiguous, zero, one etc.

COMP: relocate base equal(a,b) definition from scalar.H -> label.H
- make more universally available

STYLE: replace occasional use of notEqual(a,b) with !equal(a,b)
2023-01-23 11:38:54 +01:00
Mark Olesen
03ab6c1a9d COMP: remove commented Make/options item (#2668)
COMP: update include for CGAL-5.5 (#2665)

  old:  Robust_circumcenter_filtered_traits_3
  new:  Robust_weighted_circumcenter_filtered_traits_3

COMP: adjust CGAL rule for OSX (#2664)

- since CGAL is now header-only, the previous OSX-specific rules have
  become redundant
2023-01-23 09:39:30 +01:00
Mark Olesen
568ced68e2 ENH: support independent handling of MPI requests (#2674)
- UPstream::Request wrapping class provides an opaque wrapper for
  vendor MPI_Request values, independent of global lists.

ENH: support for MPI barrier (blocking or non-blocking)
ENH: support for MPI sync-send variants

STYLE: deprecate waitRequests() without a position parameter

- in many cases this can indicate a problem in the program logic since
  normally the startOfRequests should be tracked locally.
2023-01-12 21:19:12 +01:00
Andrew Heather
7e61f36c12 RELEASE: Updated headers to v2212 2022-12-21 16:16:18 +00:00
Mark Olesen
4cccd5f854 COMP: smoothSurfaceData was building into FOAM_USER_APPBIN 2022-12-21 16:16:17 +00:00
mattijs
fa7f0e1b67 ENH: pureZoneMixture: different mixture properties according to cellZone 2022-12-14 15:07:00 +00:00
Andrew Heather
48973bad83 ENH: chtMultiRegionFoam - add frozenFlow option
Also for 'chtMultiRegionSimpleFoam' and 'chtMultiRegionTwoPhaseEulerFoam'.
2022-12-14 10:54:40 +00:00
Kutalmis Bercin
a0f1e98d24 ENH: finiteArea: improve robustness in code sections vulnerable to math errors
It has been observed that the finite-area framework is prone to numerical
issues when zero-valued edge lenghts, edge/face normals and face areas exist.

To improve exception handling at identified code sections to gracefully
overcome math errors, the problematic entities are lower-bounded by SMALL.
2022-12-14 10:18:23 +00:00
Mark Olesen
ed5690ffbc STYLE: volSurfaceMapping is const 2022-12-13 11:18:16 +01:00
Mark Olesen
4b94ac97c2 ENH: dimensioned/dimensionedSet handle optional read as per dictionary 2022-12-13 10:09:46 +01:00
Mark Olesen
b69db76b67 ENH: bundle together freed/outstanding MPI request handling
- improve communicator wrapping
- avoid indexing errors when using partial subranks
- UPstream::is_subrank (for testing partial subranks)
2022-12-09 10:59:32 +01:00
Mark Olesen
3151dacccc ENH: include <algorithm> in stdFoam.H
- was already included in many places (via UList.C templates), but now
  formalise by placing in stdFoam.H
2022-12-01 15:52:48 +00:00
Mark Olesen
8ae2e5a969 ENH: fail-safe access of ITstream tokens as front(), back()
- more standard naming than peekFront() etc
2022-12-01 14:51:19 +00:00
Mark Olesen
8d4e32da22 COMP: fixup test applications 2022-12-01 14:51:19 +00:00
Mark Olesen
ffeef76d8f ENH: cleaner separation of global and local world naming
- UPstream::globalComm constant always refers to MPI_COMM_WORLD but
  UPstream::worldComm could be MPI_COMM_WORLD (single world)
  or a dedicated local communicator (for multi-world).

- provide a Pstream wrapped version of MPI_COMM_SELF,
  references as UPstream::selfComm

- UPstream::isUserComm(label)
  test for additional user-defined communicators
2022-12-01 12:18:38 +00:00
mattijs
69be54107d ENH: IOobject headerClassName now initialised to empty value
- was previously populated with "IOobject" (the typeName) but then
  cannot easily detect if the object was actually read.
  Also clear the headerClassName on a failed read

BUG: parallel inconsistency in regIOobject::readHeaderOk

- headerOk() checked with master, but possible parallel operations
  within it
2022-11-25 12:48:45 +01:00
mattijs
adf95d483c BUG: redistributePar: softlink uniform. Fixes #163 2022-11-24 14:58:07 +00:00
Kutalmis Bercin
8c02820db6 COMP: EigenMatrix: remove unused iter variable 2022-11-24 13:47:08 +00:00
Mark Olesen
cb4e026aed ENH: add support for additional filter/mapping (#2609)
- comprises a few different elements:

FilterField (currently packaged in PatchFunction1Types namespace)
~~~~~~~~~~~

  The FilterField helper class provides a multi-sweep median filter
  for a Field of data associated with a geometric point cloud.

  The points can be freestanding or the faceCentres (or points)
  of a meshedSurface, for example.

  Using an initial specified search radius, the nearest point
  neighbours are gathered and addressing/weights are built for them.
  This currently uses an area-weighted, linear RBF interpolator
  with provision for quadratic RBF interpolator etc.

  After the weights and addressing are established,
  the evaluate() method can be called to apply a median filter
  to data fields, with a specified number of sweeps.

boundaryDataSurfaceReader
~~~~~~~~~~~~~~~~~~~~~~~~~

- a surfaceReader (similar to ensightSurfaceReader) when a general
  point data reader is needed.

MappedFile
~~~~~~~~~~
- has been extended to support alternative surface reading formats.
  This allows, for example, sampled ensight data to be reused for
  mapping.  Cavaet: multi-patch entries may still needs some work.

- additional multi-sweep median filtering of the input data.
  This can be used to remove higher spatial frequencies when
  sampling onto a coarse mesh.

smoothSurfaceData
~~~~~~~~~~~~~~~~~
- standalone application for testing of filter radii/sweeps
2022-11-24 13:30:16 +01:00
Mark Olesen
98598ba0bb ENH: use simpler constructor forms for treeData types 2022-11-24 12:21:01 +00:00
Mark Olesen
fc0b980333 BUG: avoid infinite recursion in AABBTree (fixes #2616)
- since bounding boxes overlap, need to verify the splitting actually
  did something. Problem only really evident with higher tree depths.
2022-11-24 12:21:01 +00:00
Mark Olesen
38b663b6a8 ENH: add boundBox/triangle intersection test to boundBox
- replaces edge by edge tests with separating axis tests
2022-11-24 12:21:01 +00:00
Mark Olesen
ac4f580d09 ENH: cleanup treeData items (#2609)
Changes / Improvements

- more consistent subsetting, interface

  * Extend the use of subset and non-subset collections with uniform
    internal getters to ensure that the subset/non-subset versions
    are robustly handled.

  * operator[](label) and objectIndex(label) for standardized access
    to the underlying item, or the original index, regardless of
    subsetting or not.

  * centres() and centre(label) for representative point cloud
    information.

  * nDim() returns the object dimensionality (0: point, 1: line, etc)
    these can be used to determine how 'fat' each shape may be
    and whether bounds(labelList) may contribute any useful information.

  * bounds(labelList) to return the full bound box required for
    specific items. Eg, the overall bounds for various 3D cells.

- easier construction of non-caching versions. The bounding boxes are
  rarely cached, so simpler constructors without the caching bool
  are provided.

- expose findNearest (bound sphere) method to allow general use
  since this does not actually need a tree.

- static helpers

  The boxes() static methods can be used by callers that need to build
  their own treeBoundBoxList of common shapes (edge, face, cell)
  that are also available as treeData types.

  The bounds() static methods can be used by callers to determine the
  overall bound-box size prior to constructing an indexedOctree
  without writing ad hoc code inplace.

  Not implemented for treeDataPrimitivePatch since similiar
  functionality is available directly from the PrimitivePatch::box()
  method with less typing.

========
BREAKING: cellLabels(), faceLabels(), edgeLabel() access methods

- it was always unsafe to use the treeData xxxLabels() methods without
  subsetting elements. However, since the various classes
  (treeDataCell, treeDataEdge, etc) automatically provided
  an identity lookup, this problem was not apparent.

  Use objectIndex(label) to safely de-reference to the original index
  and operator[](index) to de-reference to the original object.
2022-11-24 12:21:01 +00:00
Mark Olesen
b129446221 ENH: simplify sub-octant bound-box search
- basic support for splitting into two at a given position and face to keep
2022-11-24 12:21:01 +00:00
Mark Olesen
e5006a62d7 ENH: use simpler boundBox handling
- use default initialize boundBox instead of invertedBox
- reset() instead of assigning from invertedBox
- extend (three parameter version) and grow method
- inflate(Random) instead of extend + re-assigning
2022-11-24 12:21:01 +00:00
Mark Olesen
1339c3357b ENH: general boundBox/treeBoundBox improvements
- null() static method
  * as const reference to the invertedBox with the appropriate casting.

- boundBox inflate(random)
  * refactored from treeBoundBox::extend, but allows in-place modification

- boundBox::hexFaces() instead of boundBox::faces
  * rarely used, but avoids confusion with treeBoundBox::faces
    and reuses hexCell face definitions without code duplication

- boundBox::hexCorners() for corner points corresponding to a hexCell.
  Can also be accessed from a treeBoundBox without ambiguity with
  points(), which could be hex corners (boundBox) or octant corners
  (treeBoundBox)

- boundBox::add with pairs of points
  * convenient (for example) when adding edges or a 'box' that has
    been extracted from a primitive mesh shape.

- declare boundBox nPoints(), nFaces(), nEdges() as per hexCell

ENH: return invertedBox instead of FatalError for empty trees

- similar to #2612

ENH: cellShape(HEX, ...) + boundBox hexCorners for block meshes

STYLE: cellModel::ref(...) instead of de-reference cellModel::ptr(...)
2022-11-24 12:21:01 +00:00
Mark Olesen
0ba458fdbc ENH: add primitiveMesh cellBb()
- the boundBox for a given cell, using the cheapest calculation:

  - cellPoints if already available, since this will involve the
    fewest number of min/max comparisions.

  - otherwise walk the cell faces: via the cell box() method
    to avoid creating demand-driven cellPoints etc.
2022-11-24 12:21:01 +00:00
Mark Olesen
27c2cdc040 ENH: vector mag(), magSqr() methods - complementary to dist(), distSqr()
ENH: use direct access to pointHit as point(), use dist(), distSqr()

- if the pointHit has already been checked for hit(), can/should
  simply use point() noexcept access subsequently to avoid redundant
  checks. Using vector distSqr() methods provides a minor optimization
  (no itermediate temporary), but can also make for clearer code.

ENH: copy construct pointIndexHit with different index

- symmetric with constructing from a pointHit with an index

STYLE: prefer pointHit point() instead of rawPoint()
2022-11-24 12:21:01 +00:00
Mark Olesen
e4139898d2 ENH: face::connected() method
- return true if two faces share a common vertex.

  Same idea as the existing edge::connected() method
  (previously spelled 'connects()')
2022-11-24 12:21:01 +00:00
Mark Olesen
d3e285b48b ENH: add FixedList templated get<unsigned>() methods
- provides fast compile-time indexing for FixedList
  (invalid indices trigger a compiler error).

  This enables noexcept access, which can propagate into various
  other uses (eg, triFace, triPoints, ...)

ENH: add triangle edge vectors
2022-11-24 12:21:01 +00:00
Mark Olesen
c7e6ae30bf ENH: add front(), back() methods to List containers
- traditionally used first(), last() methods,
  but front(), back() are well-known from std::vector etc
  which makes the access more familiar.

- support push_back() method for containers that already had append().
  This increases name familiar and can help when porting between
  different C++ code bases.

- support pop_back() method for List containers.
  This is similar to std::vector
2022-11-24 12:21:01 +00:00
Mark Olesen
f3ba6c6da0 ENH: linked-lists accept more familiar STL method names
- ie, front(), back(), push_front(), push_back(), pop_front()

ENH: add CircularBuffer flattening operator() and list() method

- useful if assigning content to a List etc

BUG: CircularBuffer find() did not return logical index
2022-11-24 12:21:01 +00:00
Mark Olesen
a8f369fd2b ENH: region support for foamRestoreFields (#2638) 2022-11-22 13:14:53 +01:00
Mark Olesen
013f3cccc4 ENH: improve handling of finiteArea mesh with distributed roots
- in makeFaMesh, the serial fields are now only read on the master
  process and broadcast to the other ranks. The read+distribute is
  almost identical to that used in redistributePar, except that in
  this case entire fields are sent and not a zero-sized subset.

- improved internal faMesh checking for files so that the TryNew
  method works with distributed roots.
2022-11-20 19:59:52 +01:00
Mark Olesen
21e7ce8f42 STYLE: place HashTable trivial methods in the header (reduce clutter) 2022-11-20 16:55:58 +01:00
Mark Olesen
94c7e180fb ENH: more fault-tolerance in makeFaMesh decomposition
- if the volume faceProcAddressing is missing, it is not readily
  possible to determine equivalent area procAddressing.

  Instead of throwing an error, be more fault-tolerant by having it
  create with READ_IF_PRESENT and then detect and warn
  if there are problems.
2022-11-19 20:49:12 +01:00
Mark Olesen
67b58c28c0 ENH: IOobjectList simpler construction of unregistered
- accept IOobjectOption::registerOption with (MUST_READ, NO_WRITE)
  being implicit. Direct handling of IOobjectOption itself, for
  consistency with IOobject.

  The disabling of object registration is currently the only case
  where IOobjectList doesn't use default construction parameters,
  but it was previously a bit awkward to specify.
2022-11-19 20:48:54 +01:00
Mark Olesen
1b11e4b3ac CONFIG: restrict wmakeLnInclude to header/template files
- source-code (.c, .cpp etc) only adds to clutter in the lnInclude
  directory
2022-11-19 12:41:55 +01:00
Mark Olesen
5e0a23edd5 STYLE: compacter help information for -debug-switch etc. 2022-11-18 21:24:17 +01:00
Mark Olesen
d7bf2d400d BUG: string wrapping (eg, argList help) truncates character (#2625)
- had an off-by-one in the accounting for some corner caes,
  partly because the logic was a bit convoluted

ENH: improved string wrapping (#2625)

- reworked logic (like a state machine) to handle backtracking
  with fallback of splitting near punctuation characters.

  Still doesn't compete with nroff or TeX, but does avoid long lines
  and many funny splits.  With this change the help for mapFieldsPar
  now like this:

  =====
      Specify the mapping method
      (direct|mapNearest|cellVolumeWeight|
      correctedCellVolumeWeight)
  =====

  Since the list of options is very long without any spaces, it takes
  '|' as the best split point, which definitely reads better
2022-11-18 21:14:22 +01:00
Mark Olesen
0fabbcb404 ENH: direct ensight output of float/double
- since ensight format is always float and also always written
  component-wise, perform the double -> float narrowing when
  extracting the components.  This reduces the amount of data
  transferred between processors.

ENH: avoid vtk/ensight parallel communication of empty messages

- since ensight writes by element type (eg, tet, hex, polyhedral) the
  individual written field sections will tend to be relatively sparse.
  Skip zero-size messages, which should help reduce some of the
  synchronization bottlenecks.

ENH: use 'data chunking' when writing ensight files in parallel

- since ensight fields are written on a per-element basis, the
  corresponding segment can become rather sparsely distributed. With
  'data chunking', we attempt to get as many send/recv messages in
  before flushing the buffer for writing. This should make the
  sequential send/recv less affected by the IO time.

ENH: allow use of an external buffer when writing ensight components

STYLE: remove last vestiges of autoPtr<ensightFile> for output routines
2022-11-15 17:26:09 +01:00
Mark Olesen
5338e56c73 ENH: add support for OFstream atomic file creation (#2631)
- with ATOMIC, an intermediary file is created - eg, (fileAbc~tmp~)
  where all of the output is written to. When the stream goes out of
  scope, this intermediary file is moved/renamed to the actually
  output name - eg, (fileAbc~tmp~) -> (fileAbc).

  This adds some safety if the simulation crashes while writing the
  file, since it will the partial (corrupt) file will be left
  behind as (fileAbc~tmp~) and not as (fileAbc), which means it will
  will be treated as a backup file and not loaded again on restart.

ENH: provided enumeration for APPEND/NON_APPEND

- clearer than using bool (with comments).
  Since append mode is primarily only used by masterOFstream etc
  this change is unlikely to affect user coding.

ENH: use file atomic for ensight file creation

- avoids corrupt (truncated) files being referenced by the ensight
  case file if the simulation crashes while writing the ensight file.
2022-11-15 14:10:01 +01:00
Mark Olesen
9f7cfa9419 ENH: support libz disabling via WM_COMPILE_CONTROL (as ~libz)
- eg, for partially incomplete systems (without libz devel header)

ENH: clearer binding of dummy Pstream in OpenFOAM/Make/options

- link of dummy stub Pstream now contingent on linking libOpenFOAM as
  well. This makes the purpose slightly clearer

ENH: cleaner option naming/handling in wmake script

- allow special purpose -no-openfoam option.
  Eg, compiling test programs without OpenFOAM and Pstream libraries
  but using the rest of the wmake system.

ENH: add +openmp support into WM_COMPILE_CONTROL (#2633)

- this adds compile/link flags for openmp.
  For single-use, can also use 'wmake -openmp'.

  If both +openmp and ~openmp are specified in WM_COMPILE_CONTROL
  the ~openmp will have priority.

  This is actually done indirectly since ~openmp will set empty
  COMP_OPENMP, LINK_OPENMP internal variables, which the +openmp then
  adds to the c++FLAGS and linkexe targets (ie, won't actually add
  anything).

ENH: add +ccache or ccache=... support into WM_COMPILE_CONTROL (#2633)

- with the first version (+ccache), simply use ccache from the path
  without any extra options.

- with the second version (ccache=...), can be more specific about
  what is called.

  Using "+ccache" is identical to "ccache=ccache", but the later could
  be used in other ways. For example,

     ccache=/strange/install/path/ccache
     ccache=</path/my-tooling --option>

  Have the choice of unquoted, single or double quoted or '< >' quoted

STYLE: relocate FOAM_EXTRA_LDFLAGS in general makefile

- removes clutter for different linkers (eg, gold, mold, ldd)
  making it easier to extend for other linkers.

STYLE: protect makefile checks with 'strip' function
2022-11-15 14:00:18 +01:00
Mark Olesen
25e874a4f0 ENH: provide MPI native minOp, maxOp reduce multiple values
- consistent with sumOp

ENH: globalIndex with gatherNonLocal tag, and use leading dispatch tags

- useful for gather/write where the master data can be written
 separately.  Leading vs trailing dispatch tags for more similarity to
 other C++ conventions.
2022-11-15 14:00:18 +01:00
sergio
2a406bbb25 ENH: overset: various improvements in the framework
The improvements include:

- Allowing overset patches to be displaced outside background domain.
  - The approach does not support overlapping of multiple inset meshes
    on top of background domain.
- Allowing fringe faces to walk away from hole cells in background domain.
  - The approach was not extensibly tested with overlapping patches.
- Improving mass conservation.
- Various experimental entries are removed: massFluxInterpolation, ddtCorr.
- New entries:
  - oversetAdjustPhi: adds a flux correction outside the pressure equation.
  - massCorrection: adds an implicit correction.
2022-11-11 10:19:47 +00:00
Mark Olesen
5b29ff0e42 ENH: consolidate 'formatOptions' handling for coordSetWriter/surfaceWriter
- replaced ad hoc handling of formatOptions with coordSetWriter and
  surfaceWriter helpers.

  Accompanying this change, it is now possible to specify "default"
  settings to be inherited, format-specific settings and have a
  similar layering with surface-specific overrides.

- snappyHexMesh now conforms to setFormats

  Eg,

      formatOptions
      {
          default
          {
              verbose     true;
              format      binary;
          }
          vtk
          {
              precision   10;
          }
     }

     surfaces
     {
         surf1
         {
             ...

             formatOptions
             {
                 ensight
                 {
                     scale   1000;
                 }
             }
         }
     }
2022-11-08 16:48:08 +00:00
Mark Olesen
799d247142 ENH: PatchTools::gatherAndMerge with recovery of the globalIndex
- support globalIndex for points/faces as an output parameter,
  which allows reuse in subsequent field merge operations.

- make pointMergeMap an optional parameter. This information is not
  always required. Eg, if only using gatherAndMerge to combine faces
  but without any point fields.

ENH: make globalIndex() noexcept, add globalIndex::clear() method
2022-11-08 16:48:08 +00:00
Mark Olesen
70208a7399 ENH: use returnReduceAnd(), returnReduceOr() functions
DOC: document which MPI send/recv are associated with commType
2022-11-08 16:48:08 +00:00
Mark Olesen
473e14418a ENH: more consistent use of broadcast, combineReduce etc.
- broadcast           : (replaces scatter)
  - combineReduce       == combineGather + broadcast
  - listCombineReduce   == listCombineGather + broadcast
  - mapCombineReduce    == mapCombineGather + broadcast
  - allGatherList       == gatherList + scatterList

  Before settling on a more consistent naming convention,
  some intermediate namings were used in OpenFOAM-v2206:

    - combineReduce       (2206: combineAllGather)
    - listCombineReduce   (2206: listCombineAllGather)
    - mapCombineReduce    (2206: mapCombineAllGather)
2022-11-08 16:48:08 +00:00