Commit Graph

475 Commits

Author SHA1 Message Date
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
mattijs
adf95d483c BUG: redistributePar: softlink uniform. Fixes #163 2022-11-24 14:58:07 +00: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
5e0a23edd5 STYLE: compacter help information for -debug-switch etc. 2022-11-18 21:24:17 +01: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
Mark Olesen
d5cdc60a54 BUG: processorMeshes removeFiles does not remove collated (fixes #2607)
ENH: extend rmDir to handle removal of empty directories only

- recursively remove directories that only contain other directories
  but no other contents. Treats dead links as non-content.
2022-10-11 17:58:22 +02:00
Mark Olesen
ea51c2c0e4 STYLE: return orientedType, Switch directly instead of const reference
- noexcept on some Time methods

ENH: pass through is_oriented() method for clearer coding

- use logical and/or/xor instead of bitwise versions (clearer intent)
2022-10-04 15:51:26 +02:00
Mark Olesen
88061f3b28 ENH: improved argList handling of libs, functionObjects
- include -no-libs option by default, similar to '-lib',
  which makes it available to all solvers/utilities.
  Add argList allowLibs() method to query it.

- relocate with/no functionObjects logic from Time to argList
  itself as argList allowFunctionObjects()

- add libs/functionObjects override handling to decomposePar etc

ENH: report the stream relativeName for IOerrors (see c9333a5ac8)
2022-09-22 16:08:52 +02:00
Mark Olesen
c031f7d00a ENH: improve autoPtr/refPtr/tmp consistency (#2571)
- disallow inadvertant casting and hidden copy constructions etc
2022-09-22 11:50:51 +02:00
Mark Olesen
3d892ace29 STYLE: set readOpt(..), writeOpt(..) by parameter, not by assignment
STYLE: qualify format/version/compression with IOstreamOption not IOstream

STYLE: reduce number of lookups when scanning {fa,fv}Solution

STYLE: call IOobject::writeEndDivider as static
2022-07-19 11:17:47 +02:00
Mark Olesen
71246b94b7 ENH: minor update of particle methods 2022-07-08 11:13:00 +02:00
Mark Olesen
3c64283364 BUG: redistributePar -reconstruct lagrangian trashes fields (fixes #2494)
- the file removal cleanup, which makes reasonable sense for
  redistribute mode, always forced the removal of the reconstructed
  lagrangian fields (since all of the non-master fields are empty by
  definition)!

  Detect reconstruct mode (by using constructSize from the map) to
  circumvent this logic.
2022-06-24 14:49:14 +02:00
Mark Olesen
39d8964851 BUG: distributed roots cause redistributePar failure (fixes #2523)
- zero-sized faMeshSubset and fvMeshSubset had READ_IF_PRESENT instead
  of simply copying the schemes/solution setting from the baseMesh
2022-06-24 13:18:41 +02:00
Mark Olesen
7b94573add BUG: distributed roots cause redistributePar failure (fixes #2523)
- fvMeshSubset zero constructor triggers readIfPresent for
  fvSchemes/fvSolution: causing mismatched parallel communication
2022-06-23 18:26:28 +02:00
Mark Olesen
b51e0d4c1c STYLE: verbose point field decompose/reconstruct (#120)
TUT: use redistributePar for multiphase/interFoam/RAS/DTCHull
2022-06-22 19:45:08 +02:00
Mark Olesen
ba10afea77 ENH: add 'filtered' polyMesh regionName() method
- in various situations with mesh regions it is also useful to
  filter out or remove the defaultRegion name (ie, "region0").

  Can now do that conveniently from the polyMesh itself or as a static
  function. Simply use this

      const word& regionDir = polyMesh::regionName(regionName);

  OR  mesh.regionName()

  instead of

      const word& regionDir =
      (
           regionName != polyMesh::defaultRegion
         ? regionName
         : word::null
      );

  Additionally, since the string '/' join operator filters out empty
  strings, the following will work correctly:

      (polyMesh::regionName(regionName)/polyMesh::meshSubDir)

      (mesh.regionName()/polyMesh::meshSubDir)
2022-05-27 14:10:31 +02:00
Mark Olesen
f00f236cb3 STYLE: use zero-gradient for cellDist field (reconstructParMesh)
- consistent with what decomposePar and redistributePar create
2022-05-27 14:10:31 +02:00
Mark Olesen
cc1e6c12bb ENH: redistributePar support for finiteArea (#2436) 2022-05-25 13:12:38 +00:00
Mark Olesen
6644cf8ddb ENH: cleanup/reorganize parts of redistributePar
- separate out lagrangian routines etc

- align names with regular decompose/reconstruct methods
2022-05-25 13:12:38 +00:00
mattijs
f976a02bd0 ENH: redistributePar - add support for pointFields (#2436) 2022-05-25 13:12:38 +00:00
Mark Olesen
3b6761afed ENH: code modernization for decompose/reconstruct
- simplify procAddressing read/write

- avoid accessing points in faMeshReconstructor.
  Can rely on the patch meshPoints (labelList), which does not need
  access to a pointField

- report number of points on decomposed mesh.
  Can be useful additional information.
  Additional statistics for finite area decomposition

- provide bundled reconstructAllFields for various reconstructors

- remove reconstructPar checks for very old face addressing
  (from foam2.0 - ie, older than OpenFOAM itself)

- bundle all reading into fieldsDistributor tools,
  where it can be reused by various utilities as required.

- combine decomposition fields as respective fieldsCache
  which eliminates most of the clutter from decomposePar
  and similfies reuse in the future.

STYLE: remove old wordHashSet selection (deprecated in 2018)

BUG: incorrect face flip handling for faMeshReconstructor

- a latent bug which is not yet triggered since the faMesh faces are
  currently only definable on boundary faces (which never flip)
2022-05-25 13:12:38 +00:00
Mark Olesen
68b692fdfc ENH: combine loadOrCreateMesh from redistributePar into fvMeshTools.
- similar functionality as newMesh etc.
  Relocated to finiteVolume since there are no dynamicMesh dependencies.

- use simpler procAddressing (with updated mapDistributeBase).
  separated from redistributePar
2022-05-17 17:35:51 +02:00
mattijs
809fc70166 BUG: redistributePar: reconstruct mesh 2022-05-11 16:06:52 +01:00
Mark Olesen
efe057897f ENH: foamToVTK attempt finite-area write if -with-ids is specified
- previously filtered on the existence of area fields, but with
  faMesh::TryNew this is not required anymore.

STYLE: enable -verbose for various parallel utilities (consistency)
2022-05-11 11:34:04 +02:00
Mark Olesen
cf7dbf4d42 ENH: relocate/refactor fvMeshSubset
- direct construct and reset method for creating a zero-sized (dummy)
  subMesh. Has no exposed faces and no parallel synchronization
  required.

- core mapping (interpolate) functionality with direct handling
  of subsetting in fvMeshSubset (src/finiteVolume).
  Does not use dynamicMesh topology changes

- two-step subsetting as fvMeshSubsetter (src/dynamicMesh).
  Does use dynamicMesh topology changes.
  This is apparently only needed by the subsetMesh application itself.

DEFEATURE: remove deprecated setLargeCellSubset() method

- was deprecated JUL-2018, now removed (see issue #951)
2022-04-29 11:44:29 +02:00
Mark Olesen
6e21d6f78c ENH: refactor/centralize handling of direct and distributed mappers (#2436)
- added templating level to avoid code duplication and provide future
  extensibility
2022-04-29 11:44:29 +02:00
Mark Olesen
b68193088c ENH: add GeometricBoundaryField evaluateCoupled method (#2436)
- allows restricted evaluation to specific coupled patch types.
  Code relocated/refactored from redistributePar.

STYLE: ensure use of waitRequests() also corresponds to nonBlocking

ENH: additional copy/move construct GeometricField from DimensionedField

STYLE: processorPointPatch owner()/neighbour() as per processorPolyPatch

STYLE: orientedType with bool cast operator and noexcept
2022-04-29 11:44:29 +02:00
Mark Olesen
18e0d7e4d6 ENH: bundle broadcasts (#2371)
- additional Pstream::broadcasts() method to serialize/deserialize
  multiple items.

- revoke the broadcast specialisations for std::string and List(s) and
  use a generic broadcasting template. In most cases, the previous
  specialisations would have required two broadcasts:
    (1) for the size
    (2) for the contiguous content.

  Now favour reduced communication over potential local (intermediate)
  storage that would have only benefited a few select cases.

ENH: refine PstreamBuffers access methods

- replace 'bool hasRecvData(label)' with 'label recvDataCount(label)'
  to recover the number of unconsumed receive bytes from specified
  processor.  Can use 'labelList recvDataCounts()' to recover the
  number of unconsumed receive bytes from all processor.

- additional peekRecvData() method (for transcribing contiguous data)

ENH: globalIndex whichProcID - check for isLocal first

- reasonable to assume that local items are searched for more
  frequently, so do preliminary check for isLocal before performing
  a more costly binary search of globalIndex offsets

ENH: masterUncollatedFileOperation - bundled scatter of status
2022-04-29 11:44:28 +02:00
Mark Olesen
d38de84d21 ENH: bundle Pstream:: AllGather methods
- bundles frequently used 'gather/scatter' patterns more consistently.

  - combineAllGather     -> combineGather + broadcast
  - listCombineAllGather -> listCombineGather + broadcast
  - mapCombineAllGather  -> mapCombineGather + broadcast
  - allGatherList        -> gatherList + scatterList
  - reduce               -> gather + broadcast (ie, allreduce)

- The allGatherList currently wraps gatherList/scatterList, but may be
  replaced with a different algorithm in the future.

STYLE: PstreamCombineReduceOps.H is mostly unneeded now
2022-03-31 15:56:04 +02:00
Mark Olesen
e98acdc4fc ENH: extend type aliases to include geometric boundary fields (#2348)
STYLE: LduInterfaceFieldPtrsList as alias instead of a class

STYLE: define patch lists typedefs when defining the base patch

- eg, polyPatchList typedef within polyPatch.H

INT: relocate GeometricField::Boundary -> GeometricBoundaryField

- was internal to GeometricField but moving it outside simplifies
  forward declarations etc. Code adapted from openfoam.org
2022-03-30 16:36:03 +02:00
Mark Olesen
62fc3bbc33 STYLE: broadcast instead of combineScatter/listCombineScatter/mapCombineScatter
- these are the same thing now and 'broadcast' expresses the intention
  more directly/consistently
2022-03-12 21:16:30 +01:00
Mark Olesen
0cf02eb384 ENH: globalIndex with direct gather/broadcast
- less communication than gatherList/scatterList

ENH: refine send granularity in Pstream::exchange

STYLE: ensure PstreamBuffers and defaultCommsType agree

- simpler loops for lduSchedule
2022-03-12 21:16:29 +01:00
Mark Olesen
14631984df ENH: additional control and access methods for PstreamBuffers
- PstreamBuffers nProcs() and allProcs() methods to recover the rank
  information consistent with the communicator used for construction

- allowClearRecv() methods for more control over buffer reuse
  For example,

      pBufs.allowClearRecv(false);

      forAll(particles, particlei)
      {
          pBufs.clear();

          fill...

          read via IPstream(..., pBufs);
       }

  This preserves the receive buffers memory allocation between calls.

- finishedNeighbourSends() method as compact wrapper for
  finishedSends() when send/recv ranks are identically
  (eg, neighbours)

- hasSendData()/hasRecvData() methods for PstreamBuffers.

  Can be useful for some situations to skip reading entirely.
  For example,

      pBufs.finishedNeighbourSends(neighProcs);

      if (!returnReduce(pBufs.hasRecvData(), orOp<bool>()))
      {
          // Nothing to do
          continue;
      }
      ...

  On an individual basis:

      for (const int proci : pBufs.allProcs())
      {
          if (pBufs.hasRecvData(proci))
          {
             ...
          }
      }

  Also conceivable to do the following instead (nonBlocking only):

      if (!returnReduce(pBufs.hasSendData(), orOp<bool>()))
      {
          // Nothing to do
          pBufs.clear();
          continue;
      }

      pBufs.finishedNeighbourSends(neighProcs);
      ...
2022-03-04 17:49:23 +00:00
Mark Olesen
af8161925b ENH: use mpi gather for list values in a few places
- avoid gatherList/scatterList when value are only need on master
2022-03-04 17:49:23 +00:00
Mark Olesen
f3674eee36 ENH: simpler use of broadcast (via Pstream::scatter)
- avoids worrying about forgetting a (Pstream::parRun()) guard
  and reduces code. The Pstream::scatter does the same thing under the
  hood.
2022-03-04 17:49:23 +00:00
Mark Olesen
1348cd7e7b ENH: use broadcasting Pstreams for one-to-all sends 2022-03-04 17:49:23 +00:00
Mark Olesen
62ec2f2ddf COMP: deprecate domainName and full hostName (#2280)
- unused in regular OpenFOAM code
- POSIX version uses deprecated gethostbyname()
- Windows version never worked

COMP: localize, noexcept on internal OSspecific methods

STYLE: support fileName::Type SYMLINK and LINK as synonyms
2022-02-10 16:46:12 +01:00
mattijs
debbcfb7df BUG: redistributePar: handle cyclicA(C)MI cleaner. See #1558.
Should test on patch, not patch field
2022-02-10 13:46:21 +00:00
mattijs
7fa44e3c19 BUG: redistributePar: handle cyclicA(C)MI cleaner. See #1558. 2022-02-09 14:17:17 +00:00
Mark Olesen
d2961eec09 STYLE: avoid deprecation warnings for autoPtr set() method
- set() was silently deprecated in favour of reset() FEB-2018
  since the original additional check for overwriting an existing
  pointer was never used. The reset(...) name is more consistent
  with unique_ptr, tmp etc.

  Now emit deprecations for set().

- use direct test for autoPtr, tmp instead of valid() method.
  More consistent with unique_ptr etc.

STYLE: eliminate redundant ptr() use on cloned quantities
2022-01-24 12:26:38 +01:00
mattijs
fa5d79d0e5 ENH: redistributePar: add comment 2022-01-12 09:16:04 +00:00
mattijs
7da2a5e096 ENH: redistributePar: reconstruct mode in collated. Fixes #2194 2021-12-10 15:24:04 +00:00
Mark Olesen
a78e79908b ENH: additional decompose options
- decomposePar: -no-fields to suppress decomposition of fields

- makeFaMesh: -no-decompose to suppress creation of *ProcAddressing
  and fields, -no-fields to suppress decomposition of fields only
2021-11-09 15:44:54 +01:00
Mark Olesen
5a121119e6 ENH: add -verbose support into argList
- similar to -dry-run handling, can be interrogated from argList,
  which makes it simpler to add into utilities.

- support multiple uses of -dry-run and -verbose to increase the
  level. For example, could have

    someApplication -verbose -verbose

 and inside of the application:

    if (args.verbose() > 2) ...

BUG: error with empty distributed roots specification (fixes #2196)

- previously used the size of distributed roots to transmit if the
  case was running in distributed mode, but this behaves rather poorly
  with bad input. Specifically, the following questionable setup:

      distributed true;
      roots ( /*none*/ );

  Now transmit the ParRunControl distributed() value instead,
  and also emit a gentle warning for the user:

      WARNING: running distributed but did not specify roots!
2021-11-09 15:44:54 +01:00
Mark Olesen
b364a9e72c ENH: argList improvements
- argList::envExecutable() static method.
  This is identical to getEnv("FOAM_EXECUTABLE"), where the name of
  the executable has typically been set from the argList construction.

  Provides a singleton access to this value from locations that
  do not have knowledge of the originating command args (argList).
  This is a similar rationale as for the argList::envGlobalPath() static.

- additional argList::envRelativePath() static method.

- make -dry-run handling more central and easier to use by adding into
  argList itself.

STYLE: drop handling of -srcDoc (v1706 option)

- replaced with -doc-source for 1712 and never used much anyhow
2021-11-03 11:38:21 +01:00
mattijs
b157614e00 ENH: redistributePar: write collated format. #806
- supports redistributePar -decompose -fileHandler collated
- supports redistributePar -reconstruct
- does not support redistributePar with collated in redistribution mode
2021-10-19 12:18:07 +01:00
Mark Olesen
fe8c630936 BUG: Foam::cp inadvertently creates recursive directories (fixes #2235)
- noticed by Robin Knowles with `decomposePar -fields -copyZero`

  The internals for the Foam:cp method combine the behaviour of
  a regular `cp` and `cp -R` combined.

  When source and target are both directories, the old implementation
  created a subdirectory for the contents.
  This normally fine,

      ok:  cp "path1/0/" to "path2/1" -> "path2/1/2"
      BUT: cp "path1/0/" to "path2/0" -> "path2/0/0" !!

  Now add check for the basenames first.
  If they are identical, we probably meant to copy directory contents
  only, without the additional subdir layer.

BUG: decomposePar -fields -copyZero copies the wrong directory

- was using the current time name (usually latest) instead of copying
  the 0 directory

ENH: accept 0.orig directories as a fallback to copy if the 0 directory
is missing
2021-10-18 14:58:17 +02:00
Mark Olesen
8a3dc0527c ENH: -no-finite-area, -no-lagrangian options for some parallel utils 2021-10-01 15:26:50 +02:00
Mark Olesen
96adf3ae80 ENH: add IOobject::objectRelPath() for compact output (#2195) 2021-09-07 16:35:34 +02:00