Commit Graph

1459 Commits

Author SHA1 Message Date
Mark Olesen
e11fde900c ENH: direct support for broadcast of bitSet
- the internal data are contiguous so can broadcast size and internals
  directly without an intermediate stream.

ENH: split out broadcast time for profilingPstream information

STYLE: minor Pstream cleanup

- UPstream::commsType_ from protected to private, since it already has
  inlined noexcept getters/setters that should be used.

- don't pass unused/unneed tag into low-level MPI reduction templates.
  Document where tags are not needed

- had Pstream::broadcast instead of UPstream::broadcast in internals
2022-03-04 17:49:23 +00:00
Mark Olesen
341d9c402d BUG: incorrect chunk handling in Pstream::exchange (fixes #2375)
- used Pstream::maxCommsSize (bytes) for the lower limit when sending.
  This would have send more data on each iteration than expected based
  on maxCommsSize and finish with a number of useless iterations.

  Was generally not a serious bug since maxCommsSize (if used) was
  likely still far away from the MPI limits and exchange() is primarily
  harnessed by PstreamBuffers, which is sending character data
  (ie, number of elements and number of bytes is identical).
2022-03-04 17:49:23 +00: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
c086f22298 ENH: extend/improve broadcast handling
- split off a Pstream::genericBroadcast() which uses UOPBstream during
  serialization and UOPBstream during de-serialization.
  This function will not normally be used directly by callers, but
  provides a base layer for higher-level broadcast calls.

- low-level UPstream broadcast of string content.
  Since std::string has length and contiguous content, it is possible
  to handle directly by the following:
     1. broadcast size
     2. resize
     3. broadcast content when size != 0

  Although this is a similar amount of communication as the generic
  streaming version (min 1, max 2 broadcasts) it is more efficient
  by avoiding serialization/de-serialization overhead.

- handle broadcast of List content distinctly.
  Allows an optimized path for contiguous data, similar to how
  std::string is handled (broadcast size, resize container, broadcast
  content when size != 0), but can revert to genericBroadcast (streamed)
  for non-contiguous data.

- make various scatter variants simple aliases for broadcast, since
  that is what they are doing behind the scenes anyhow:

    * scatter()
    * combineScatter()
    * listCombineScatter()
    * mapCombineScatter()

  Except scatterList() which remains somewhat different.
  Beyond the additional (size == nProcs) check, the only difference to
  using broadcast(List<T>&) or a regular scatter(List<T>&) is that
  processor-local data is skipped. So leave this variant as-is.

STYLE: rename/prefix implementation code with 'Pstream'

- better association with its purpose and provides a unique name
2022-03-04 17:49:23 +00:00
Mark Olesen
8478595a15 ENH: new broadcast version of Pstreams (#2371)
- The idea of broadcast streams is to replace multiple master to
  subProcs communications with a single MPI_Bcast.

    if (Pstream::master())
    {
        OPBstream toAll(Pstream::masterNo());
        toAll << data;
    }
    else
    {
        IPBstream fromMaster(Pstream::masterNo());
        fromMaster >> data;
    }

    // vs.
    if (Pstream::master())
    {
        for (const int proci : Pstream::subProcs())
        {
            OPstream os(Pstream::commsTypes::scheduled, proci);
            os << data;
        }
    }
    else
    {
        IPstream is(Pstream::commsTypes::scheduled, Pstream::masterNo());
        is >> data;
    }

  Can simply use UPstream::broadcast() directly for contiguous data
  with known lengths.

Based on ideas from T.Aoyagi(RIST), A.Azami(RIST)
2022-03-04 17:49:23 +00:00
Mark Olesen
b0ef650a12 ENH: Pstream specialization for float/scalar, FixedList (#2351)
- native MPI min/max/sum reductions for float/double
  irrespective of WM_PRECISION_OPTION

- native MPI min/max/sum reductions for (u)int32_t/(u)int64_t types,
  irrespective of WM_LABEL_SIZE

- replace rarely used vector2D sum reduction with FixedList as a
  indicator of its intent and also generalizes to different lengths.

  OLD:
      vector2D values;  values.x() = ...;  values.y() = ...;
      reduce(values, sumOp<vector2D>());

  NEW:
      FixedList<scalar,2> values;  values[0] = ...;  values[1] = ...;
      reduce(values, sumOp<scalar>());

- allow returnReduce() to use native reductions. Previous code (with
  linear/tree selector) would have bypassed them inadvertently.

ENH: added support for MPI broadcast (for a memory span)

ENH: select communication schedule as a static method

- UPstream::whichCommunication(comm) to select linear/tree
  communication instead of ternary or
  if (Pstream::nProcs() < Pstream::nProcsSimpleSum) ...

STYLE: align nProcsSimpleSum static value with etc/controlDict override
2022-03-04 17:49:23 +00:00
Mark Olesen
055a7b29e0 ENH: ensure indices are properly reset in SortList
- use more ListOps functions, add uniqueSort() method
2022-02-21 19:53:21 +01:00
Mark Olesen
7db2a29413 ENH: type aliases for common GeometricField forms (#2348)
ENH: provide fieldTypes::surface names (as per fieldTypes::volume)

ENH: reduce number of files for surface fields

- combine face and point field declarations/definitions,
  simplify typeName definitions
2022-02-10 19:28:50 +01:00
Mark Olesen
ddcc04dadc BUG: vtk write of uniform field in parallel (fixes #2349)
- used low-level MPI gather, but the wrapping routine contains an
  additional safety check for is_contiguous which is not defined for
  various std::pair<..> combination.

  So std::pair<label,vector> (which is actually contiguous, but not
  declared as is_contiguous) would falsely trip the check.

  Avoid by simply gathering unbundled values instead.
2022-02-10 16:46:13 +01:00
Mark Olesen
2919c9b675 STYLE: minor changes
- do not need STRINGIFY macros in ragel code
- remove wordPairHashTable.H and use equivalent wordPairHashes.H instead

STYLE: replace addDictOption with explicit option

 - the usage text is otherwise misleading

GIT: combine Pair/Tuple2 directories
2022-02-10 16:46:13 +01: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
Mark Olesen
e1f06bf38e ENH: globalIndex gather ops with reduced communication (#2332)
- for contiguous data, added mpiGatherOp() to complement the
  gatherOp() static method

- the gather ops (static methods) populate the globalIndex on the
  master only (not needed on other procs) for reduced communication

- rename inplace gather methods to include 'inplace' in their name.
  Regular gather methods return the gathered data directly, which
  allows the following:

      const scalarField mergedWeights(globalFaces().gather(wghtSum));

  vs.
      scalarField mergedWeights;
      globalFaces().gather(wghtSum, mergedWeights());

  or even:

      scalarField mergedWeights;
      List<scalarField> allWeights(Pstream::nProcs());
      allWeights[Pstream::myProcNo()] = wghtSum;
      Pstream::gatherList(allWeights);
      if (Pstream::master())
      {
          mergedWeights =
              ListListOps::combine<scalarField>
              (
                  allWeights, accessOp<scalarField>()
              );
       }

- add parRun guards on various globalIndex gather methods
  (simple copies or no-ops in serial) to simplify the effort for callers.
2022-01-31 20:09:49 +01:00
Mark Olesen
ab065cd5d3 BUG: avoid memory slicing in LList (#2300)
ENH: reduce code effort for clearing linked-lists

ENH: adjust linked-list method name

- complement linked-list append() method with prepend() method
  instead of 'insert', which is not very descriptive
2022-01-31 20:08:52 +01:00
Andrew Heather
a2014242cf RELEASE: Updated headers for v2112 2021-12-20 14:18:01 +00:00
Mark Olesen
e09298092d ENH: support negated regular expressions (#2283)
- extendes the prefix syntax to handle '!' values.

  For example,  "(?!).*processor.*" or "(?!i)inlet.*"
2021-12-03 17:10:22 +01:00
Mark Olesen
fc6239d96e ENH: add expression support for scalar/vector expression lookups
- similar idea to swak timelines/lookuptables but combined together
  and based on Function1 for more flexibility.

  Specified as 'functions<scalar>' or 'functions<vector>'.
  For example,

  functions<scalar>
  {
      intakeType table ((0 0) (10 1.2));

      p_inlet
      {
          type        sine;
          frequency   3000;
          scale       50;
          level       101325;
      }
  }

  These can be referenced in the expressions as a nullary function or a
  unary function.

  Within the parser, the names are prefixed with "fn:" (function).
  It is thus possible to define "fn:sin()" that is different than
  the builtin "sin()" function.

     * A nullary call uses time value
       - Eg, fn:p_inlet()

     * A unary call acts as a remapper function.
       - Eg, fn:intakeType(6.25)
2021-11-26 12:24:35 +01:00
Mark Olesen
e6697edb52 ENH: robuster lemon parsing
- previously simply reused the scan token, which works fine for
  non-nested tokenizations but becomes too fragile with nesting.

  Now changed to use tagged unions that can be copied about
  and still retain some rudimentary knowledge of their types,
  which can be manually triggered with a destroy() call.

- provide an 'identifier' non-terminal as an additional catch
  to avoid potential leakage on parsing failure.

- adjust lemon rules and infrastructure:

  - use %token to predefine standard tokens.
    Will reduce some noise on the generated headers by retaining the
    order on the initial token names.

  - Define BIT_NOT, internal token rename NOT -> LNOT

- handle non-terminal vector values.
  Support vector::x, vector::y and vector::z constants

- permit fieldExpr access to time().
  Probably not usable or useful for an '#eval' expression,
  but useful for a Function1.

- provisioning for hooks into function calls. Establishes token
  names for next commit(s).
2021-11-26 12:24:35 +01:00
Mark Olesen
1804d3fed5 ENH: additional #word and #message dictionary directives (#2276)
- use `#word` to concatenate, expand content with the resulting string
  being treated as a word token. Can be used in dictionary or
  primitive context.

  In dictionary context, it fills the gap for constructing dictionary
  names on-the-fly. For example,

  ```
  #word "some_prefix_solverInfo_${application}"
  {
      type    solverInfo;
      libs    (utilityFunctionObjects);
      ...
  }
  ```

  The '#word' directive will automatically squeeze out non-word
  characters. In the block content form, it will also strip out
  comments. This means that this type of content should also work:

  ```
  #word {
     some_prefix_solverInfo
     /* Appended with application name (if defined) */
     ${application:+_}  // Use '_' separator
     ${application}     // The application
  }
  {
      type    solverInfo;
      libs    (utilityFunctionObjects);
      ...
  }
  ```
  This is admittedly quite ugly, but illustrates its capabilities.

- use `#message` to report expanded string content to stderr.
  For example,

  ```
  T
  {
     solver          PBiCG;
     preconditioner  DILU;
     tolerance       1e-10;
     relTol          0;
     #message "using solver: $solver"
  }
  ```
  Only reports on the master node.
2021-11-25 17:05:37 +01:00
Mark Olesen
fbd7b78999 ENH: make expressions::FieldAssociation a common enum
- use FACE_DATA (was SURFACE_DATA) for similarity with polySurface

ENH: add expression value enumerations and traits

- simple enumeration of standard types (bool, label, scalar, vector)
  that can be used as a value type-code for internal bookkeeping.

GIT: relocate pTraits into general traits/ directory
2021-11-23 12:53:45 +01:00
Mark Olesen
39d244ad91 ENH: add check for isTimeDb() into objectRegistry
- add missing time() into pointMesh

STYLE: use static_cast instead of dynamic_cast for Time -> objectRegistry
2021-11-17 19:52:33 +01:00
Mark Olesen
92d52243af ENH: support cref() and shallow copies (refPtr and tmp)
- enables building HashTables with shadowed variables

- support good() and valid() as synonyms in memory classes
2021-11-17 16:04:40 +01:00
Mark Olesen
28800dcbbc LINT: fix permissions 2021-11-15 21:22:36 +01:00
Mark Olesen
effd69a005 ENH: add refPtr release() method
- releases ownership of the pointer. A no-op (and returns nullptr)
  for references.

  Naming consistent with unique_ptr and autoPtr.

DOC: adjust wording for memory-related classes

- add is_const() method for tmp, refPtr.

  Drop (ununsed and confusing looking) isTmp method from refPtr
  in favour of is_pointer() or movable() checks

ENH: noexcept for some pTraits methods, remove redundant 'inline'

- test for const first for tmp/refPtr (simpler logic)
2021-11-15 19:34:01 +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
c9333a5ac8 ENH: improve flexibility of error, messageStream output
- provide a plain stream() method on messageStream to reduce reliance
  on casting operators and slightly opaque operator()() calls etc

- support alternative stream for messageStream serial output.
  This can be used to support local redirection of output.
  For example,

     refPtr<OFstream> logging;   // or autoPtr, unique_ptr etc

     // Later...
     Info.stream(logging.get())
        << "Detailed output ..." << endl;

  This will use the stdout semantics in the normal case, or allow
  redirection to an output file if a target output stream is defined,
  but still effectively use /dev/null on non-master processes.

  This is mostly the same as this ternary

      (logging ? *logging : Info())

  except that the ternary could be incorrect on sub-processes,
  requires more typing etc.

ENH: use case-relative names of dictionary, IOstream for FatalIOError

- normally yields more easily understandable information
2021-11-03 11:46:13 +01:00
Mark Olesen
851be8ea33 ENH: use consistent naming when toggling exception throwing on/off 2021-11-02 21:14:41 +01:00
Mark Olesen
b6539cd02e ENH: additional MPI gather/scatter routines, globalIndex gather methods
- UPstream::mpiGather (MPI_Gather)   - used by Pstream::listGatherValues
- UPstream::mpiScatter (MPI_Scatter) - used by Pstream::listScatterValues

  These are much simpler forms for gather/scatter of fixed-sized
  contiguous types data types (eg, primitives, simple pairs etc).

  In the gather form, creates a list of gathered values on the master
  process. The subranks have a list size of zero.

  Similarly, scatter will distribute a list of values to single values
  on each process.

  Instead of

      labelList sendSizes(Pstream::nProcs());
      sendSizes[Pstream::myProcNo()] = sendData.size();
      Pstream::gatherList(sendSizes);

  Can write

      const labelList sendSizes
      (
          UPstream::listGatherValues<label>(sendData.size())
      );

  // Less code, lower overhead and list can be const.

  For scattering an individual value only,
  instead of

      labelList someValues;
      if (Pstream::master()) someValues = ...;

      Pstream::gatherList(sendSizes);
      const label localValue
      (
          someValues[Pstream::myProcNo()]
      );

  Can write

      labelList someValues;
      if (Pstream::master()) someValues = ...;

      Pstream::gatherList(sendSizes);
      const label localValue
      (
          UPstream::listScatterValues<label>(someValues)
      );

   Can of course also mix listGatherValues to assemble a list on master
   and use Pstream::scatterList to distribute.

ENH: adjusted globalIndex gather methods

- added mpiGather() method [contiguous data only] using MPI_Gatherv

- respect localSize if gathering master data to ensure that a
  request for 0 master elements is properly handled.
2021-10-29 17:04:52 +02:00
Mark Olesen
b8a4b7e80d ENH: additional 'nocopy' methods for List resize/reserve methods
- the size of a List often requires adjustment prior to an operation,
  but old values (if any) are not of interest and will be overwritten.

  In these cases can use the _nocopy versions to avoid additional memory
  overhead of the intermediate list and the copy/move overhead of
  retaining the old values (that we will subsequently discard anyhow).

  No equivalent for PtrList/UPtrList - this would be too fragile.

- add swap DynamicField with DynamicList

BUG: fixed Dynamic{Field,List} setCapacity corner case

- for the case when the newly requested capacity coincides with the
  current addressable size, the resize of the underlying list would have
  been bypassed - ie, the real capacity was not actually changed.

- remove (unused) PtrDynList setCapacity method as too fragile
2021-10-29 17:04:51 +02:00
Mark Olesen
e2861cc200 ENH: return UList range slice as a SubList
- previously returned the range slice as a UList,
  but this prevents convenient assignment.
  Apply similar handling for Field/SubField

  Allows the following

     labelRange range(...);
     fullList.slice(range) = identity(range.size());

  and

     fullList.slice(range) = UIndirectList<T>(other, addr);

ENH: create SubList from full FixedList (simplifies interface)

- allow default constructed SubList. Use shallowCopy to 'reset' later
2021-10-29 17:04:51 +02:00
mattijs
2a2edf5fee ENH: Added contact resistance to multi-world. See #1535.
- added contact resistance to turbulentTemperatureCoupledBaffleMixed
- added basic multi-world to turbulentTemperatureRadCoupledMixed
- added unit-testcase to $FOAM_APP/test/multiWorld
2021-10-18 19:22:23 +01:00
Mark Olesen
7ad75fa18e ENH: add single-parameter PtrListOps::names (ie, no name filtering)
ENH: adjust fileName component method

- the location \c npos returns the last component
2021-10-12 10:11:05 +02:00
Mark Olesen
a0d7933360 ENH: support vtu mesh subsetting, creation from cellShapes
- support simple mesh subsetting to vtu formats to enable debug output
  for a subsection of an existing polyMesh

- rudimentary support for VTK from cellShapes is intended for handling
  basic primitive cell shapes without a full blown polyMesh description.

  For example,

     // Create an empty polyMesh with points only
     polyMesh debugMesh
     (
         io,
         std::move(points),
         faceList(),     // faces
         labelList(),    // owner
         labelList(),    // neighbour
         true            // syncPar
     );

    // Establish the appropriate VTK sizing for the TET shapes
    vtk::vtuCells vtuCells;
    vtuCells.resetShapes(debugCutTets);
    vtuCells.nPoints(debugMesh.nPoints());

  NOTE
  Since the vtk::internalMeshWriter only uses the polyMesh reference
  for the points, it is also possible to create the vtuCells
  description without a pointField (or from a different mesh
  description) and write out the connectivity using the pointField
  from a different mesh.
2021-09-27 13:26:02 +02:00
Mark Olesen
5e4d678c98 ENH: make precision adaptors modifiable (#2173)
- allows reuse similar to refPtr for wrapping different content.

- additional control for when contents are copied back,
  instead of waiting for the adaptor to go out of scope.

  Eg,

  if (adaptor.active())
  {
      adaptor.commit();
      adaptor.clear();
  }

- static ConstPrecisionAdaptor::get method renamed to 'select' as a
  better description of its purpose and avoid confusion with
  non-static 'get' method.

  Was previously only used within GAMGPreconditioner, but even there
  it is better just to use the ConstPrecisionAdaptor directly.
2021-09-07 11:29:11 +02:00
Mark Olesen
9d26b25c46 TUT: multi-world tutorial setup with circular connectivity 2021-07-28 16:21:14 +02:00
Mark Olesen
5b09e59b3f ENH: support direct specification of coordinate rotation "none"
- Can specify
  ```
  transform
  {
      origin      (1 2 3);
      rotation    none;
  }
  ```
  instead of the longer form
  ```
  transform
  {
      origin      (1 2 3);
      e1          (1 0 0);
      e3          (0 0 1);
  }
  ```

COMPAT: remove old (pre-1812) Euler and STARCD keywords

- use "angles", remove old compat name "rotation"
  as clutter and possible confusion with "coordinate rotation"

STYLE: remove coordinate rotation move constructors

- an unnecessary holdover from older code.
2021-07-28 10:02:27 +02:00
Mark Olesen
db9460f0bc ENH: copy construct FixedList from fixed subset of input
- remove construct from two iterators (#2083)
2021-07-15 16:47:27 +02:00
Mark Olesen
aca366d293 TUT: replace remaining templated thermoType
TUT: some simplification for multiWorld test

STYLE: remove some editor junk
2021-07-15 16:47:22 +02:00
Mark Olesen
cc5aa20931 ENH: simplify exit/abort handling and jobinfo (code reduction)
- handle failures more robustly
- add static shutdown() for similarity with Pstream etc.
2021-07-05 14:55:48 +02:00
Mark Olesen
8a1f667067 COMP: cannot resolve read in UnsortedMeshedSurface constructor
- fix linkage for cellModeller compat methods
2021-07-05 14:55:37 +02:00
Mark Olesen
8884d58a52 STYLE: fix/correct some tests. Remove useless tests 2021-07-05 14:55:37 +02:00
Mark Olesen
6a390f6ad1 COMP: remove includes of defunct locations (fixes #2143) 2021-06-29 13:43:44 +02:00
Andrew Heather
e3796745ed CONFIG: Updated headers to v2106
Minor clean-up
2021-06-28 09:14:42 +01:00
Mark Olesen
096b9dc52e TUT: add parallel version for various squareBend cases
- adjust commented-out evaluation to avoid warnings.

  With code like this
  ```
  #if 0
  nxin    #eval{ round($nxin / 5) };
  #endif
  ```

  The handling of the "#if 0 / #endif" clause uses the plain ISstream
  parser to tokenize. This means that the "round(" is parsed as a word
  with a mismatched closing ')', whereas the "#eval" parser will slurp
  everything in until the closing brace and send it off as a string
  to the expression parser.
2021-06-18 17:14:22 +02:00
Mark Olesen
ae02a86562 ENH: multi-region support for reconstructParMesh (#2072) 2021-06-11 17:18:35 +02:00
Mark Olesen
6120e13d29 ENH: add tmp/refPtr support for setting cref/ref from pointer
- makes it easier to use for local or alternative storage.
  Eg,

  ```
      tmp<volScalarField> tfld;

      tfld.cref(obj.cfindObject<volScalarField>("name"));

      if (!tfld)
      {
          tfld = volScalarField::New("name", ...);
      }
  ```
2021-06-08 14:01:08 +02:00
Mark Olesen
0ba43df9c5 STYLE: remove erroneous reference in dynamicCast use 2021-05-31 09:11:49 +02:00
Mark Olesen
2990b14d89 ENH: add more direct methods for getting meshEdge (PrimitivePatch)
- refine definition of patch boundary faces to distinguish between
  boundaryFaces() and uniqBoundaryFaces().

  * boundaryFaces() for edge to face lookup on boundary edges.
  * uniqBoundaryFaces() for accessing quantities such as face areas
    or eroding an outer layer

ENH: LabelledItem container, replaces unused 'Keyed' container

- method names in alignment with objectHit, pointIndexHit etc.
  Top-level name aligns with labelledTri.
2021-05-27 15:42:46 +02:00
Mark Olesen
0df219d1b3 ENH: expose decomposePar -dry-run options -domains, -method
- can now drop older Test-decomposePar for exploration purposes
  and simply use -dry-run with the -domains and -method options.

- write VTK file instead of volScalarField in combination
  with -dry-run and -cellDist.

  Avoids adding any OpenFOAM fields and is usually faster to load.
  Also easier to rename than a volScalarField would be when exploring
  multiple decompositions.
2021-05-19 18:16:05 +02:00
Mark Olesen
2dbabb242b ENH: namedDictionary for managing keyword/dictionary combinations
- reworked from the openfoam.org wordAndDictionary version.

Allows, for example, named entries in topoSet.
2021-05-19 17:13:24 +02:00
Mark Olesen
c9fda67b5f ENH: refactor function arg splitting -> stringOps::splitFunctionArgs 2021-05-19 16:20:12 +02:00
Mark Olesen
efd1ac4b5f ENH: adjust token in preparation for separate expression tokenization
- minor simplification of #if/#endif handling

ENH: improve input robustness with negative-prefixed expansions (#2095)

- especially in blockMeshDict it is useful to negate an value directly.
  Eg,
  ```
     xmax  100;
     xmin  -$xmax;
  ```
  However, this fails since the dictionary expansion is a two-step
  process of tokenization followed by expansion. After the expansion
  the given input would now be the following:
  ```
     xmax  100;
     xmin  - 100;
  ```
  and retrieving a scalar value for 'xmin' fails.

  Counteract this by being more generous on tokenized input when
  attempting to retrieve a label or scalar value.
  If a '-' is found where a number is expected, use it to negate the
  subsequent value.

  The previous solution was to invoke an 'eval':
  ```
     xmax  100;
     xmin  #eval{-$xmax};
  ```
  which adds additional clutter.
2021-05-18 15:30:00 +02:00
Mark Olesen
2a438385a3 STYLE: make polyMesh constructor explicit
- use polyMesh::defaultRegion instead of fvMesh::defaultRegion and
  others via static inheritance. (92 vs ~25 occurrences)
2021-05-12 11:24:57 +02:00
Mark Olesen
3bc8ab2839 ENH: improve PrimitivePatch access for edges
- return internalEdges() and boundaryEdges() sub lists directly

- calculate and return boundaryFaces() to identify faces attached to
  boundary edges.

- minor code cleanup, and add PrimitivePatchBase class for
  non-templated code.

STYLE: mark unused parameter in globalMeshData mergePoints
2021-05-12 11:24:57 +02:00
Mark Olesen
ea2bf72740 ENH: support gather of indirect list via globalIndex 2021-05-12 11:24:57 +02:00
Mark Olesen
17e6a14773 ENH: improve support for assignment from indirect list
- copy assignment from indirect list to SubList and Field
2021-05-12 11:24:57 +02:00
Mark Olesen
40567b844a DEFEATURE: remove construct List from two iterators (#2083)
- this constructor was added for similarity with std::vector,
  but continues to cause various annoyances.

  The main problem is that the templated parameter tends to grab
  anything that is not a perfect match for other constructors.

  Typically seen with two integers (in 64-bit mode), but various other
  cases as well.

  If required, the ListOps::create() function provides a lengthier
  alternative but one that can also incorporate transformations.
  Eg,

      pointField pts = ....;

      List<scalar> mags
      (
          List<scalar>::create
          (
              pts.begin(),
              pts.end(),
              [](const vector& v){ return magSqr(v); }
      );
2021-05-12 11:24:57 +02:00
Mark Olesen
8eef91c5e2 ENH: improve edge access for face/triFace
- additional rcEdge(), rcEdges() methods for reverse order walk

- accept generic edge() method as alternative to faceEdge() for
  single edge retrieval.

- edge() method with points -> returns the vector

- reduce the number of operations in edgeDirection methods

DEFEATURE: remove longestEdge global function

- deprecated and replaced by face::longestEdge() method (2017-04)
2021-05-12 11:24:57 +02:00
Mark Olesen
c410edf928 ENH: centralized handling of -allRegions, -regions, -region (#2072)
Step 1.
    include "addAllRegionOptions.H"

    Adds the -allRegions, -regions and -region options to argList.

Step 2.
    include "getAllRegionOptions.H"

    Processes the options with -allRegions selecting everything
    from the regionProperties.

    OR use -regions to specify multiple regions (from
       regionProperties), and can also contain regular expressions

    OR use the -region option

    Specifying a single -regions NAME (not a regular expresssion)
    is the same as -region NAME and doesn't use regionProperties

    Creates a `wordList regionNames`

Step 3.
    Do something with the region names.
    Either directly, or quite commonly with the following

    include "createNamedMeshes.H"

    Creates a `PtrList<fvMesh> meshes`

STYLE: add description to some central include files
2021-05-07 09:46:33 +02:00
Mark Olesen
86a2ae4f03 ENH: add maxSize() and maxNonLocalSize() to globalIndex
- useful for establishing and preallocating a max buffer size
  when reading from sub-procs
2021-05-07 09:43:42 +02:00
Mark Olesen
5a5fd1a43c COMP: sign check to avoid warnings about new[] range 2021-04-27 12:28:35 +02:00
Mark Olesen
86f627b9e6 ENH: consolidate decomposition model, constructors for decomposition methods
- make regionName an optional constructor parameter, which eliminates
  a separate set of constructors and construction tables. Adjust
  internals to treat a missing/empty regionName as a no-op.

- pass in fallback dictionary content via new IOdictionary constructor
  with a pointer

ENH: further relax check for matching number of processor dirs

- if the "numberOfSubdomains" entry is missing (or even zero)
  ignore checks of processor dirs as meaningless.
2021-04-27 09:14:48 +02:00
Mark Olesen
399c21d76c ENH: adjustments for Function1/PatchFunction1
- additional debug information

- improve support for dictionary specification of constant, polynomial
  and table entries. These previously only worked properly for
  primitiveEntry, which causes confusion.

- extend table Function1 to include TableFile functionality.
  Simplifies switching and modifying content.
2021-04-26 17:09:39 +02:00
Mark Olesen
b267f8b6da ENH: add failsafe accessors for ITstream
- failsafe examine elements: peek(), peekFirst(), peekLast()
- failsafe traversing: skip()

  For example,

      ITstream& is = dict.lookup(key);
      if (is.peek().isWord())
      {
          is.skip();
      }
2021-04-26 17:09:39 +02:00
Mark Olesen
9dc3d2bf40 ENH: additional ITstream constructors
- additional default construct

- add explicit zero-size constructor for ITstream.
  For tagged dispatching, without ambiguity

- elminate mandatory name for parsing versions.
  This makes it easier to use ITstream, IStringStream, UListStream
  interchangeable.
2021-04-26 17:09:39 +02:00
Mark Olesen
eb01cab052 ENH: failsafe version of Istream peek()
- return undefinedToken on error

STYLE: fix slicing of ITstream from dictionary lookup
2021-04-26 17:09:38 +02:00
Mark Olesen
2b7b3700c2 ENH: replace keyType with wordRe for matching selectors.
- The keyType is primarily used within dictionary reading, whereas
  wordRe and wordRes are used for selectors in code.
  Unifying on wordRe and wordRes reduces the number matching options.
2021-04-19 16:33:42 +00:00
Mark Olesen
95cd8ee75c ENH: improve hashing overloads of string-types and HashTable/HashSet
- additional dummy template parameter to assist with supporting
  derived classes. Currently just used for string types, but can be
  extended.

- provide hash specialization for various integer types.
  Removes the need for any forwarding.

- change default hasher for HashSet/HashTable from 'string::hash'
  to `Hash<Key>`. This avoids questionable hashing calls and/or
  avoids compiler resolution problems.

  For example,
  HashSet<label>::hasher and labelHashSet::hasher now both properly
  map to Hash<label> whereas previously HashSet<label> would have
  persistently mapped to string::hash, which was incorrect.

- standardize internal hashing functors.

  Functor name is 'hasher', as per STL set/map and the OpenFOAM
  HashSet/HashTable definitions.

  Older code had a local templated name, which added unnecessary
  clutter and the template parameter was always defaulted.
  For example,

      Old:  `FixedList<label, 3>::Hash<>()`
      New:  `FixedList<label, 3>::hasher()`
      Unchanged:  `labelHashSet::hasher()`

  Existing `Hash<>` functor namings are still supported,
  but deprecated.

- define hasher and Hash specialization for bitSet and PackedList

- add symmetric hasher for 'face'.
  Starts with lowest vertex value and walks in the direction
  of the next lowest value. This ensures that the hash code is
  independent of face orientation and face rotation.

NB:
  - some of keys for multiphase handling (eg, phasePairKey)
    still use yet another function naming: `hash` and `symmHash`.
    This will be targeted for alignment in the future.
2021-04-19 16:33:42 +00:00
Mark Olesen
b060378dca ENH: improve consistency of fileName handling windows/non-windows (#2057)
- wrap command-line retrieval of fileName with an implicit validate.

  Instead of this:
      fileName input(args[1]);
      fileName other(args["someopt"]);

  Now use this:
      auto input = args.get<fileName>(1);
      auto other = args.get<fileName>("someopt");

  which adds a fileName::validate on the inputs

  Because of how it is implemented, it will automatically also apply
  to argList getOrDefault<fileName>, readIfPresent<fileName> etc.

- adjust fileName::validate and clean to handle backslash conversion.
  This makes it easier to ensure that path names arising from MS-Windows
  are consistently handled internally.

- dictionarySearch: now check for initial '/' directly instead of
  relying on fileName isAbsolute(), which now does more things

BREAKING: remove fileName::clean() const method

- relying on const/non-const to control the behaviour (inplace change
  or return a copy) is too fragile and the const version was
  almost never used.

  Replace:
      fileName sanitized = constPath.clean();

  With:
      fileName sanitized(constPath);
      sanitized.clean());

STYLE: test empty() instead of comparing with fileName::null
2021-04-19 16:33:42 +00:00
Mark Olesen
96a1b86fb9 ENH: consistency improvements for keyType and wordRe
- simplify compile/uncompile, reading, assignment

- implicit construct wordRe from keyType (was explicit) to simplify
  future API changes.

- make Foam::isspace consistent with std::isspace (C-locale)
  by including vertical tab and form feed

ENH: improve #ifeq float/label comparisons
2021-04-19 16:33:42 +00:00
Mark Olesen
57c1fceabf ENH: disentangle testing and quoting of regex characters
- originally had tests for regex meta characters strewn across
  regExp classes as well as wordRe, keyType, string.
  And had special-purpose quotemeta static function within string
  that relied on special naming convention for testing the meta
  characters.

  The regex meta character testing/handling now relegated entirely
  to the regExp class(es).
  Relocate quotemeta to stringOps, with a predicate.

- avoid code duplication. Reuse some regExpCxx methods in regExpPosix
2021-04-19 16:33:42 +00:00
Mark Olesen
cdbc3e2de6 ENH: List/DynamicList appendUniq() method
- affords some code reduction.

STYLE: use HashSet insert() without found() check in more places
2021-04-19 16:33:42 +00:00
Mark Olesen
bb86eecdc4 ENH: add filtering version of dictionary copy
- can be useful when extracting portions of larger field files
2021-04-15 10:41:53 +02:00
Mark Olesen
21720bea12 ENH: support field width for #eval expressions
For example,
```
entry #eval 10 { vector(rand(), 0, 0) };
```

ENH: be more generous and ignore trailing ';' in expressions

STYLE: adjust parse token name for tensor::I
2021-03-29 16:00:11 +02:00
Mark Olesen
d4ac96cdf3 ENH: support use of 'vector' in #calc directive (fixes #2039) 2021-03-29 16:00:11 +02:00
Mark Olesen
221c3c0200 ENH: add OFstream rewind() method.
- truncates output file, handles compressed streams
2021-03-23 18:00:14 +01:00
Mark Olesen
9a2a22a03a ENH: provide setter methods for IOobject read/write options etc.
- simplifies local toggling.

- centralize fileModification static variables into IOobject.
  They were previously scattered between IOobject and regIOobject
2021-03-17 15:10:00 +01:00
Mark Olesen
0c985edfc8 ENH: additional routines for reading/writing/parsing IOObject headers
- support selective enable/disable of the file banner.

ENH: improve code isolation for decomposedBlockData

- use readBlockEntry/writeBlockEntry to encapsulate the IO handling,
  which ensures more consistency

- new decomposedBlockData::readHeader for chaining into the
  block header information.

- remove unused constructors for decomposedBlockData

ENH: minor cleanup of collated fileOperations
2021-03-16 08:47:59 +00:00
Mark Olesen
e8cf2a2c62 ENH: more consistent use of IOstreamOption
- improves interface and data consistency.
  Older signatures are still active (via the Foam_IOstream_extras
  define).

- refine internals for IOstreamOption streamFormat, versionNumber

ENH: improve data alignment for IOstream and IOobject

- fit sizeof label/scalar into unsigned char

STYLE: remove dead code
2021-03-16 08:47:59 +00:00
Mark Olesen
e3c8af0c8f ENH: add read/write specialization for lists of character data
- read/write lists of character data in binary only.
  This is the only means of preserving data.
  If character data are written as an ASCII list, there is no means of
  determining if spaces or newlines are content or separators.
2021-03-16 08:47:58 +00:00
Mark Olesen
498de8a74a ENH: unify read/write for containers
- handle binary/contiguous first as being the most obvious, followed
  by increasing complexity of ascii.
  Structure reading and writing routines similarly by introducing a
  readList method to compliment the writeList method.
2021-03-16 08:47:58 +00:00
Mark Olesen
a76a3d760c ENH: add operator* to refPtr - makes it more like autoPtr
- would ideally like the same for tmp, but there is too much existing
  code that uses a multiply operation that would be interpreted as a
  dereference.
2021-03-16 08:47:58 +00:00
Mark Olesen
fa645c2dac ENH: noexcept size_bytes() method for lists
- for use when the is_contiguous check has already been done outside
  the loop. Naming as per std::span.

STYLE: use data/cdata instead of begin

ENH: replace random_shuffle with shuffle, fix OSX int64 ambiguity
2021-03-09 09:49:31 +01:00
Mark Olesen
51cd7ceecb ENH: improvements for token methods
- direct check of punctuation.
  For example,

      while (!tok.isPunctuation(token::BEGIN_LIST)) ..

  instead of

  while (!(tok.isPunctuation() && tok.pToken() == token::BEGIN_LIST)) ..

  Using direct comparison (tok != token::BEGIN_LIST) can be fragile
  when comparing int values:

      int c = readChar(is);
      while (tok != c) ..  // Danger, uses LABEL comparison!

- direct check of word.
  For example,

      if (tok.isWord("uniform")) ..

  instead of

      if (tok.isWord() && tok.wordToken() == "uniform") ..

- make token lineNumber() a setter method

ENH: adjust internal compound method empty() -> moved()

- support named compound tokens

STYLE: setter method for stream indentation
2021-03-09 09:23:41 +01:00
Kutalmis Bercin
66d1b54a79 ENH: 'Math' namespace for mathematical functions
- centralises existing functions (erfInv, incGamma*, invIncGamma*).
  Provides a location for additional functions in the future.

- adjusted existing models to use these functions
  (e.g. distributionModels::normal)
2021-02-16 18:08:50 +01:00
Mark Olesen
b97cd5c380 ENH: add HashPtrTable release method
- effectively 'steals' the pointer from the table but leaves its
  name as a placeholder
2021-02-16 14:30:36 +01:00
mattijs
0e7a2d1529 ENH: syncTools: specialisation for contiguous data. Fixes #1986. 2021-01-20 09:33:44 +00:00
mattijs
c036d4207b ENH: syncTools: edge orientation test. See #1974. 2021-01-06 09:58:17 +00:00
Andrew Heather
79e353b84e RELEASE: Updated version to v2012 2020-12-23 10:01:39 +01:00
Mark Olesen
7bdb509494 TUT: adjust tutorials for test loop 2020-12-22 12:27:21 +01:00
Mark Olesen
18cd5d864e ENH: reinstate Test-decomposePar -cellDist, add -cellDist-internal
- Useful for diagnosis, the -cellDist-internal produces a
  volScalarField::Internal instead
2020-12-21 09:17:37 +01:00
Mark Olesen
e9dcc59c4d STYLE: trim trailing space 2020-12-18 09:24:01 +01:00
mattijs
b017ef47bb ENH: Added new multiWorld test case 2020-12-09 15:17:45 +00:00
Mark Olesen
df74e8448c ENH: robuster fileOperations splitProcessorPath
- robuster matching behaviour when encountering paths that themselves
  contain the word "processor" in them. For example,

    "/path/processor0generation2/case1/processor10/system"
    will now correctly match on processor10 instead of failing.

- use procRangeType for encapsulating the processor ranges

- provision for information of distributed vs non-distributed roots.
  The information is currently available from the initial setup, but
  can useful to access directly within fileOperation.

STYLE: modernize list iteration
2020-12-08 11:58:28 +01:00
Mark Olesen
a939042e1b ENH: add bitSet::null() and clarify some documentation
- the NullObject singleton can also be cast to a bitSet
  (sufficient size and bit-pattern). Useful for places that
  need to hold a reference on construction
2020-12-08 11:58:28 +01:00
Mark Olesen
be7a3f21be ENH: add BitOps::set(), unset() functions for boolList, labelHashSet 2020-11-25 19:53:03 +01:00
Mark Olesen
0de32a6e6f ENH: improve flexiblity for flat output of items (#1929)
- change to a templated implementation instead of relying on
  the container's writeList() method.

  This inlines the generation while also adding the flexibility to
  define different delimiters (at compile time) without the
  performance penalty of passing run-time parameters.
2020-11-25 19:53:03 +01:00
Mark Olesen
d2f1690536 ENH: align Enum methods with HashTable
- deprecate get(key, deflt) in favour of lookup(key, deflt).
  Method name compatibility with HashTable.

- deprecate operator().
  The meaning is too opaque and equally served by other means:

  - use get(key) instead of operator()(key).
    Const access whereas HashTable::operator()(key)
    creates missing entry.

  - lookup(key, deflt) - instead of operator()(key, deflt).
    Const access whereas HashTable::operator()(key, deflt)
    creates a missing entry.

- make Enum iterable to allow participation in range-for etc.
2020-11-25 19:53:02 +01:00
Mark Olesen
7349b97ecc STYLE: use labelRange for identity 2020-11-25 19:53:02 +01:00
Mark Olesen
8d2d894ae0 ENH: support frequency or period for Sine/Square Function1 (#1917)
- For slow oscillations it can be more intuitive to specify the
  period.

ENH: separate mark/space for Square

- makes it easier to tailor the desired intervals.

BUG: incorrect square wave fraction with negative phase shifts

ENH: additional cosine Function1

STYLE: avoid code duplication by inheriting Cosine/Square from Sine.
2020-11-19 16:57:45 +01:00
Mark Olesen
6e3bc1f7d0 STYLE: can add compile-time deprecated message for autoPtr::set()
- deprecated Feb-2018, but not marked as such.

  The set() method originally enforce an additional run-time check
  (Fatal if pointer was already set), but this was rarely used.
  In fact, the set() method was invariably used in constructors
  where the pointer by definition was unset.

  Can now mark as deprecated to catch the last of these.
  We prefer reset() for similarity with std::unique_ptr

  Eg,
  FOAM_EXTRA_CXXFLAGS="-DFoam_autoPtr_deprecate_setMethod"  wmake
2020-11-19 16:57:45 +01:00
Mark Olesen
98d05fa80a STYLE: prefix zero/one with Foam:: qualifier
ENH: support construction of zero-sized IndirectList

- useful when addressing is to be generated in-place after construction.
  Eg,

      indirectPrimitivePatch myPatches
      (
          IndirectList<face>(mesh.faces(), Zero),
          mesh.points()
      );
      labelList& patchFaces = myPatches.addressing();

      patchFaces.resize(...);
      // populate patchFaces

STYLE: add noexcept for zero/one fields and remove old dependency files

COMP: correct typedefs for geometricOneField, geometricZeroField
2020-11-19 16:55:29 +01:00
Mark Olesen
9fd514bbe6 ENH: support OFstream "/dev/null" equivalent directly
- uses ocountstream for the output, which swallows all output.
  Improves portability

ENH: improved efficiency in countstreambuf

- xsputn() instead of overflow
- more consistent seek* methods
2020-11-17 14:43:00 +01:00
Mark Olesen
c91fc6f41c CONFIG: rationalize mpi config tuning (#1910)
- prefix FOAM_MPI and library directories with 'sys-' for system
  versions for uniform identication.

  WM_MPLIB      | libdir (FOAM_MPI)  | old naming |
  SYSTEMMPI     | sys-mpi            | mpi        |
  SYSTEMOPENMPI | sys-openmpi        | openmpi-system |

- prefix preferences with 'prefs.' to make them more easily
  identifiable, and update bin/tools/create-mpi-config accordingly

      Old name: config.{csh,sh}/openmpi
      New name: config.{csh,sh}/prefs.openmpi

- additional mpi preferences now available:
    * prefs.intelmpi
    * prefs.mpich
    ...

CONFIG: added hook for EASYBUILDMPI (eb-mpi), somewhat like USERMPI

- EasyBuild uses mpicc when compiling, so no explicit wmake rules are
  used

ENH: support different major versions for system openmpi

- for example, with

     WM_MPLIB=SYSTEMOPENMPI2

  defines FOAM_MPI=sys-openmpi2 and thus creates lib/sys-openmpi2

ENH: centralize handling of mpi as 'mpi-rules'

    Before:
        sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
        sinclude $(DEFAULT_RULES)/mplib$(WM_MPLIB)

        ifeq (,$(FOAM_MPI_LIBBIN))
            FOAM_MPI_LIBBIN := $(FOAM_LIBBIN)/$(FOAM_MPI)
        endif

    After:
        include $(GENERAL_RULES)/mpi-rules

- also allows variants such as SYSTEMOPENMPI2 to be handled separately
2020-11-11 18:36:01 +01:00
Mark Olesen
1d544540d9 ENH: handle wmake -debug option via FOAM_EXTRA_CXX_FLAGS
- ensures that subsequent Allwmake scripts know about it.

ENH: add bin/tools/query-detect wrapper for wmake have_* scripts

CONFIG: use project/ThirdParty without additional sanity checks

- no need to test for Allwmake or platforms/ if ThirdParty is located
  within the project directory itself.

COMP: add simple mpi test to 00-dummy

- for testing library linkage, etc.
2020-11-04 15:17:28 +01:00
Victor Olesen
e9d130f022 ENH: support general searchable spheroid (issue #1901)
- a sphere/spheroid can be specified as a single radius or three radii.
  If all three values happen to be identical, they are collapsed to a
  single value. Examples,

      radius 2;
      radius (2 2 2);
      radius (2 3 4);
      radius (2 2 4);

  The search for nearest point on an ellipse or ellipsoid follows the
  description given by Geometric Tools (David Eberly), which also
  include some pseudo code. The content is CC-BY 4.0

  In the search algorithm, symmetry is exploited and the searching is
  confined to the first (+x,+y,+z) octant, and the radii are ordered
  from largest to smallest.

  Searching is optimized for sphere, prolate and oblate spheroids.
2020-10-28 16:04:12 +01:00
Mark Olesen
4258f8059f ENH: adjustments to searchable surfaces
- code reduction, documentation, code stubs for spheroid (#1901)

- make searchableSurfaceCollection available as 'collection'
  for consistency with other objects
2020-10-28 16:04:12 +01:00
Mark Olesen
1071d413a3 ENH: add ROOTGREAT constants (symmetry with ROOTSMALL)
ENH: add some scalar constants for .org compatibility (#1881)

Although it can very much be a moving target, it can prove partly
useful to have some compatibility constants/methods.

- The wholesale change of 'GREAT' -> 'great' etc (JAN-2018), makes
  user coding for multiple versions problematic. When
  COMPAT_OPENFOAM_ORG is defined, now define constants (aliases) named
  as per the openfoam.org version. Values, however, remain identical.

- For type-safe dictionary value retrieval, we have the templated
  get<> methods added around NOV-2018 and deprecated the lookupType
  method.

  The .org version followed suit in NOV-2019, but opted for renaming
  the templated lookupType method as a templated 'lookup' method.

  Using this is discouraged, but allowed when COMPAT_OPENFOAM_ORG is
  defined.
2020-10-19 21:14:17 +02:00
Mark Olesen
cb47decbf1 ENH: add Switch::negate() method (no-op for invalid state)
- flips state while preserving the textual representation.
  Eg, OFF <-> ON, YES <-> NO etc.

- fix test case to avoid triggering abort(), which we cannot try/catch
2020-10-15 17:21:33 +02:00
Mark Olesen
f1d9fea6f2 ENH: construct token::compound from object and token from compound (#1879)
- provides a more direct means of generating a compound token without
  an Istream

- add transferCompoundToken() without Istream reference

- mark more token methods as noexcept
2020-10-15 17:21:33 +02:00
Mark Olesen
525ad206be BUG: compilation error for DimensionedField::T() fixes #1868
- incorrectly used const access for the tmp instead of ref()
2020-10-07 09:18:23 +02:00
Mark Olesen
833ee40904 ENH: add pTraits for uint8_t 2020-10-07 09:17:00 +02:00
Mark Olesen
56c9134ccc ENH: add identity(IntRange) and Istream operator for common types
- provides consistency with identity(label, label) and looks more
  familiar than using labelRange::labels()

- relocates labelRange IO operators to IntRange

ENH: make sliceRange interators random access

STYLE: scalarRanges::match() instead of predicate operator
2020-10-01 11:35:43 +02:00
Mark Olesen
5dc5ea928a ENH: add UPstream::subProcs() static method
- returns a range of `int` values that can be iterated across.
  For example,

      for (const int proci : Pstream::subProcs()) { ... }

  instead of

      for
      (
          int proci = Pstream::firstSlave();
          proci <= Pstream::lastSlave();
          ++proci
      )
      {
          ...
      }
2020-09-28 14:26:07 +02:00
Mark Olesen
e18ff114a6 ENH: add UPstream::allProcs() method
- returns a range of `int` values that can be iterated across.
  For example,

      for (const int proci : Pstream::allProcs()) { ... }

  instead of

      for (label proci = 0; proci < Pstream::nProcs(); ++proci) { ... }
2020-09-28 14:25:59 +02:00
Mark Olesen
413ccd5ce3 STYLE: adjust tests and one code instance for updated labelRange 2020-09-23 10:46:04 +02:00
Mark Olesen
d204d33c4e ENH: new IntRange class, enhancements to labelRange, sliceRange
- add reverse iterators and replace std::iterator
  (deprecated in C++17) with full definitions

- simplify construction of iterators

- construct labelRange from a single single parameter.
  This creates a (0,len) range.

- make basic constructors forms constexpr.
  Remove unused size checks.

- Derive labelRange from new IntRange template class.
  Allows reuse of base functionality with different integral sizes.

Deprecations:

  - deprecate labelRange::valid() in favour of using
    labelRange::empty() or the bool operator.
    For example,

        if (range) ...  vs older  if (range.valid()) ...

DEFEATURE: drop labelRange::null, scalarRange::null static variables

- turned out to be not particularly useful.
  Can simply use constexpr contructor forms

DEFEATURE: drop labelRange::identity static method

- simply use the single-parameter constructor
2020-09-23 10:45:57 +02:00
Mark Olesen
48cb2de4eb STYLE: adjust send/receive in tests 2020-09-23 09:25:07 +02:00
Mark Olesen
bf3b4fabb4 ENH: UniformList to wrap a single value into a list-like container
- refactor UniformField accordingly
2020-09-16 17:27:56 +02:00
Mark Olesen
9423d2bd83 CONFIG: improve support for compiler/link options (#1830)
- introduce WM_COMPILE_CONTROL variable to convey control information
  into the build rules.

  The convention (as per spack):
      - '+' to select a feature
      - '~' to deselect a feature

  Eg, to select the gold linker, and disable openmp
  (spaces are not required):

      WM_COMPILE_CONTROL="+gold ~openmp"

CONFIG: accept FOAM_EXTRA_LDFLAGS for AMD, gold, Mingw linkers

CONFIG: generalize PROJECT_LIBS (-ldl used almost universally)
2020-09-07 09:45:51 +02:00
Mark Olesen
fbfcdfc723 ENH: allow default parameter for Tuple2 (#1827)
- simplifies cases where Tuple2 is used as a Pair replacement
  (for output format reasons)
2020-09-07 09:37:05 +02:00
Mark Olesen
6a1efe3b5c ENH: support construct/reset refPtr from autoPtr and unique_ptr (#1775)
- makes it easier to use in combination with various 'New' selectors,
  which mostly return an autoPtr.

ENH: add very simple FFT test

- basic sanity test that the library links properly
2020-08-11 13:15:28 +02:00
Mark Olesen
6e2b7be983 ENH: direct access to wrapped ifstream/ofstream with compression (#1805)
- previously hidden as Detail::[IO]FstreamAllocator, now exposed
  directly as [io]fstreamPointer, which allows reuse for
  std::ifstream, std::ofstream wrapping, without the additional
  ISstream, OSstream layers.

  These stream pointers have some characteristics similar to a
  unique_ptr.

- restrict direct gzstream usage to two files (fstreamPointers.C,
  gzstream.C) which improves localization and makes it simpler to
  enable/disable with the `HAVE_LIBZ` define.

  The HAVE_LIBZ define is currently simply hard-coded in the
  Make/options.

  If compiled WITHOUT libz support:
    - reading gz files : FatalError
    - writing gz files : emit warning and downgrade to uncompressed
    - warn if compression is specified in the case controlDict
      and downgrade to uncompressed

ENH: minor updates to gzstream interface for C++11

- support construct/open with std::string for the file names.

CONFIG: provisioning for have_libz detection as wmake/script
2020-08-10 12:40:08 +02:00
Mark Olesen
b2bded48c9 STYLE: use Time::printExecutionTime() method
- makes format of ExecutionTime = ... output configurable (#788)
  and reduces code clutter.

STYLE: more consistent line-breaks after "End" tag
2020-08-07 09:24:56 +02:00
Mark Olesen
14c9582458 ENH: provide wordPair typedef in Pair.H, and separate wordPair.H 2020-08-04 12:13:33 +02:00
Mark Olesen
fa71840d8b ENH: add get() retrieval of a pointer from PtrLists, HashPtrTable
- naming similarity with autoPtr, unique_ptr and other containers.

  For UPtrList derivatives, this is equivalent to the existing
  operator(). The read-only variant is also equivalent to the
  single-parameter 'set(label)' method.

  With PtrList<T> list(...) :

      const T* ptr = list.get(10);
      if (ptr)
      {
          ptr->method();
      }

  vs.
      if (list.set(10))
      {
          list[10].method();
      }

  For HashPtrTable there is only a read-only variant which is equivalent
  to testing for existence and for value.

  With HashPtrTable<T> hash(...) :

      const T* ptr = list.get("key");
      if (ptr)
      {
          ptr->method();
      }

  vs.
      if (list.found("key"))
      {
          // Fails on null pointer!!
          list["key"].method();
      }

Use of get() is largely a matter of taste or local coding requirements
2020-07-28 08:40:43 +02:00
Mark Olesen
872c9d370b ENH: support emplace methods and std::unique_ptr for PtrList-derivatives
- emplace methods
  Eg,
      m.internalCoeffs().emplace(patchi, fc.size(), Zero);
  vs.
      m.internalCoeffs().set(patchi, new Field<Type>(fc.size(), Zero));

- handle insert/append of refPtr wherever tmp was already supported

COMP: incorrect variable names in PtrListOpsTemplates.C
2020-07-28 08:40:43 +02:00
Mark Olesen
4110699d90 ENH: HashTable::emplace_set() method, HashPtrTable support for unique_ptr
- forwarding like the emplace() method, but overwriting existing
  entries as required

- propagate similar changes to HashPtrTable

  For example, with HashPtrTable<labelList> table(...) :

  With 'insert' semantics

      table.emplace("list1", 1000);

  vs
      if (!table.found("list1"))
      {
          table.set("list1", new labelList(1000));
      }
  or
      table.insert("list1", autoPtr<labelList>::New(1000));

  Note that the last example invokes an unnecessary allocation/deletion
  if the insertion is unsuccessful.

  With 'set' semantics:

      table.emplace_set("list1", 15);

  vs
      table.set("list1", new labelList(15));
2020-07-28 08:40:43 +02:00
Mark Olesen
2de4501e47 ENH: add testFunctionObjects library with fakeError function object
The fakeError function object emits FatalError at different stages (or
does nothing), which is useful for testing purposes (issue #1779).

Can request errors from constructor, execute and write methods.
2020-07-24 09:04:07 +02:00
Mark Olesen
12c91b9472 STYLE: check autoPtr as plain bool instead of valid()
- cleaner code, more similarity with unique_ptr

  Now
      if (ptr)
      if (!ptr)

  instead
      if (ptr.valid())
      if (!ptr.valid())
2020-07-16 11:39:24 +02:00
Mark Olesen
9af3f85cf9 STYLE: simplify short-circuit involving autoPtr (#1775)
- with '&&' conditions, often better to check for non-null autoPtr
  first (it is cheap)

- check as bool instead of valid() method for cleaner code, especially
  when the wrapped item itself has a valid/empty or good.
  Also when handling multiple checks.

  Now
      if (ptr && ptr->valid())
      if (ptr1 || ptr2)

  instead
      if (ptr.valid() && ptr->valid())
      if (ptr1.valid() || ptr2.valid())
2020-07-16 10:17:25 +02:00
Mark Olesen
41d3e6f1d4 ENH: various dlLibraryTable improvements/refinements (#1737)
- libs() singleton method for global library handling

- explicit handling of empty filename for dlLibraryTable open/close.
  Largely worked before, but now be more explicit about its behaviour.

- add (key, dict) constructor and open() methods.
  More similarity to dimensionedType, Enum etc, and there is no
  ambiguity with the templated open().

- construct or open from initializer_list of names

- optional verbosity when opening with auxiliary table,
  avoid duplicate messages or spurious messages for these.

- basename and fullname methods (migrated from dynamicCode).

- centralise low-level load/unload hooks

- adjust close to also dlclose() aliased library names.
2020-07-14 11:19:05 +02:00
Andrew Heather
538d749220 REL: Updated headers to version v2006 2020-06-29 17:27:54 +01:00
OpenFOAM bot
01ec92fd35 GIT: remove leading/trailing blank lines, trailing whitespace 2020-06-17 10:46:26 +02:00
Mark Olesen
5982a1aab4 STYLE: update tutorials
- use simpler decomposeParDict in tutorials, several had old
  'boilerplate' decomposeParDict

- use simpler libs () format

- update surface sampling to use dictionary format
2020-06-17 10:11:33 +02:00
mattijs
5bf440956a ENH: timeVaryingMapped: abstract IFstream/regIOobject handling. See #1640.
This change abstracts out the reading of "boundaryData". It should
now support OpenFOAM headers and with that also binary input.
2020-06-11 12:00:51 +01:00
Mark Olesen
076bcc25c9 ENH: relocate externalFileCoupler from finiteVolume to meshTools 2020-06-10 15:29:07 +02:00
Henning Scheufler
44a84d4778 CONT: Addition of compressibleIsoInterFOam and PLIC
1) Implementation of the compressibleIsoInterFOam solver
   2) Implementation of a new PLIC interpolation scheme.
   3) New tutorials associated with the solvers

This implementation was carried out by Henning Scheufler (DLR) and Johan
Roenby (DHI), following :

\verbatim

Henning Scheufler, Johan Roenby,
Accurate and efficient surface reconstruction from volume fraction data
on general meshes, Journal of Computational Physics, 2019, doi
10.1016/j.jcp.2019.01.009

\endverbatim

The integration of the code was carried out by Andy Heather and Sergio
Ferraris from OpenCFD Ltd.
2020-06-09 08:11:04 +01:00
Mark Olesen
f6bd56ddae STYLE: some tests built into FOAM_APPBIN (should be FOAM_USER_APPBIN) 2020-06-05 16:34:51 +02:00
Kutalmis Bercin
ef9ee7a8b1 ENH: add iterative eigen decomposition solver, EigenMatrix
ENH: add Test-EigenMatrix application

  The new iterative eigen decomposition functionality is
  derived from:

    Passalacqua et al.'s OpenQBMM (openqbmm.org/),
    which is mostly derived from JAMA (math.nist.gov/javanumerics/jama/).
2020-06-05 14:35:36 +01:00
Kutalmis Bercin
af22163492 ENH: improve Matrix classes and tests 2020-06-05 14:35:36 +01:00
Mark Olesen
ea4c8f4bea ENH: boolVector for specialized bundling of boolean values
- bundled of boolean values as a vector of 3 components with
  element access using x(), y() and z() member functions.
  It also has some methods similar to bitSet.

- Not derived from Vector or VectorSpace since it does not share very
  many vector-like characteristics.
2020-06-04 16:56:21 +02:00
Mark Olesen
bc9e97cf36 ENH: additional polynomial constructors, improved I/O
- support construct from initializer_list, which can help simplify
  code with constant coefficients.

- add default constructor for polynomialFunction and Istream reading
  to support resizable lists of polynomialFunction.

  A default constructed polynomialFunction is simply equivalent to
  a constant zero.

- no special IO handling for Polynomial required,
  it is the same as VectorSpace anyhow.
2020-06-04 15:02:21 +02:00
Mark Olesen
3e43edf056 ENH: unify use of dictionary method names
- previously introduced `getOrDefault` as a dictionary _get_ method,
  now complete the transition and use it everywhere instead of
  `lookupOrDefault`. This avoids mixed usage of the two methods that
  are identical in behaviour, makes for shorter names, and promotes
  the distinction between "lookup" access (ie, return a token stream,
  locate and return an entry) and "get" access (ie, the above with
  conversion to concrete types such as scalar, label etc).
2020-06-02 17:26:03 +02:00
Mark Olesen
f721b5344f ENH: report dictionary name actually used (for -dict option) 2020-06-02 14:29:36 +02:00
Mark Olesen
31b172217c ENH: support predicate checks for argList (similar to dictionary methods)
- Favour use of argList methods that are more similar to dictionary
  method names with the aim of reducing the cognitive load.

  * Silently deprecate two-parameter get() method in favour of the
    more familiar getOrDefault.
  * Silently deprecate opt() method in favour of get()

  These may be verbosely deprecated in future versions.
2020-06-02 13:51:18 +02:00
Mark Olesen
727ea48e0c STYLE: include scalar.H instead of floatScalar.H/doubleScalar.H separately
STYLE: adjust code comments
2020-05-29 15:55:56 +02:00
Mark Olesen
1d2391e0b4 ENH: add swallow assignment to nullObject
- similar to the behaviour of std::ignore and consistent with the
  no input / no output nature of nullObject. Similarly accept a
  const reference for its Istream operator.

- make most nullObject methods constexpr
2020-05-29 15:55:27 +02:00
Mark Olesen
e3367dbdc1 ENH: inline and extend clockValue, clockTime
- mostly wraps std::chrono so can inline much of it, which is potentially
  helpful when used for inner timings.

- add elapsedTime() method for direct cast to double and for
  naming similarity with wall-clock method.

Potential breaking change (minor):

- clockValue construct with a bool parameter is now simply tagged
  dispatch (value is ignored) and always queries the current clock
  value. This avoids needless branching.
  Since this constructor form has primarily been used internally (eg,
  clockTime), breakages in user code are not expected.
2020-05-29 15:48:21 +02:00
Mark Olesen
5eebe5050b ENH: reduce dependencies for foamVersion.H
- have printBuildInfo output to std::ostream
- removed extraneous include "stdFoam.H"

ENH: revert to pre-processor defines for hard-coded paths (#1712)

- redundant information, but more robust at run-time without relying
  on initialization order
2020-05-29 15:48:20 +02:00
Mark Olesen
997c9a232c STYLE: use compact form for libs () entries 2020-05-23 18:42:47 +02:00
Mark Olesen
5105154b88 ENH: expression versions of Function1 and PatchFunction1 (#1709) 2020-05-23 18:42:47 +02:00
Mark Olesen
435957ac87 ENH: exposed access to compile-time project, etc directories
- less frequently used, but the information was previously inaccessible
  under etcFiles.C.

  Now exposed within the foamVersion namespace and defined under
  <global.Cver> to improve configuration possibilities.
2020-05-11 14:14:59 +02:00
Mark Olesen
6a16db3708 ENH: use hasEnv() instead of env() for naming symmetry with getEnv, setEnv
- less confusing than the env() name, which could look like a
  setter/getter instead of a test
2020-05-11 10:12:26 +02:00
Mark Olesen
8cfb483054 STYLE: some general spelling fixes 2020-05-04 09:15:21 +02:00
Mark Olesen
8a5d108fd2 STYLE: update PrimitivePatch (#1648)
- simplified templating, which cleans up code and does not appear to
  break any normal user coding.

ENH: unique_ptr instead of homegrown demand-driven handling.
2020-04-30 15:52:42 +02:00
Mark Olesen
14e2dbfb2a ENH: add string replaceAny() method
- takes a search string and a replacement character.
  The replacement character can also be a nul char ('\0'), which
  simply removes the characters.

  Possible uses:

  * Replace reserved characters
      str.replaceAny("<>:", '_');

  * Remove shell meta-characters or reserved filesystem characters
      str.replaceAny("*?<>{}[]:", '\0');
2020-04-28 16:21:34 +02:00
Mark Olesen
79048eb68f STYLE: use writeEntry(), beginBlock(), endBlock() methods
- use dictionary::get<..> instead of lookup in a few more places
2020-04-28 10:41:23 +02:00
Mark Olesen
560c053bc8 ENH: support independent specification of surface read/write format (#1600)
- adjustments to internal handling to improve run-time addition of
  other formats (eg, with additional user library)

  For example, to write a binary STL with a '.stl' extension:

    $ surfaceMeshConvert input.obj  -write-format stlb  output.stl

  Or in a sampler,
  to specify the input type without ambiguity:

  surf
  {
      type        meshedSurface;
      surface     sampling.inp;

      fileType    starcd;
      scale       0.001;
      ...
  }

STYLE: regularize naming for input/output scaling

  * -read-scale   (compat: -scaleIn)
  * -write-scale  (compat: -scaleOut)

CONFIG: change edge/surface selection name for STARCD format

- now select as "starcd" instead of "inp" to avoid naming ambiguity
  with abaqus
2020-04-03 19:11:50 +02:00
Mark Olesen
7f32509abc STYLE: additional surface-related typedefs
- face_type, point_type (similar to STL value_type, etc).
  The naming avoids potential confusion with template parameters.

- rename private typedef from ParentType to MeshReference for more
  consistency with polySurface etc.
2020-04-02 23:18:09 +02:00
Mark Olesen
01f6505442 ENH: add a Pstream::shutdown() method (#1660)
- previously used a Pstream::exit() invoked from the argList
  destructor to handle all MPI shutdown, but this has the unfortunate
  side-effect of using a fixed return value for the program exit.

  Instead use the Pstream::shutdown() method in the destructor and allow
  the normal program exit codes as usual. This means that the
  following code now works as expected.

  ```
  argList args(...);

  if (...)
  {
      InfoErr<< "some error\n";
      return 1;
  }
  ```
2020-04-01 12:33:39 +02:00
Mark Olesen
179d9fd61d ENH: correct pow(complex, ..) functions (fixes #1638)
* Use cast for std::pow(??, z).
* No cast for std::pow(z, ??) - already properly specialized.
2020-03-19 12:31:49 +01:00
Mark Olesen
8e27022ea2 STYLE: find(), cfind() methods instead of lookupPtr()
- coordinateSystems, DictionaryBase
2020-03-11 22:05:15 +01:00
Mark Olesen
a18617bbd1 ENH: add line number for dictionary getCheck errors 2020-03-11 19:54:51 +01:00
Kutalmis Bercin
6576397e81 ENH: improve analytic eigen for small off-diagonals 2020-02-28 10:49:58 +00:00
Mark Olesen
a456e9ae92 STYLE: relocate nonCoupledBoundaryTree into meshSearcher
- use point::uniform in more places
2020-02-24 18:41:02 +01:00
Mark Olesen
5f93f20652 ENH: add stringOps::inplaceRemoveSpace()
Style changes:
  - use std algorithm for some stringOps internals
  - pass SubStrings iterators by const reference

ENH: special nullptr handling for ISstream getLine
  - pass through to istream::ignore to support read and discard
2020-02-19 23:36:46 +01:00
Mark Olesen
42299dca22 ENH: use IOstreamOption for writeObject() calls.
- reduces the number of parameters that are being passed around
  and allows future additions into the IOstreamOption with mininal
  effort.
2020-02-19 09:25:33 +00:00
Kutalmis Bercin
9be1772e0c BUG: surfaceInertia analytic eigendecomposition (fixes #1599)
- was missing cast to symmTensor
2020-02-19 10:14:57 +01:00
Mark Olesen
33f9ae5080 ENH: improvements to IOstreamOption
* Support default values for format/compress enum lookups.

  - Avoids situations where the preferred default format is not ASCII.
    For example, with dictionary input:

        format binar;

    The typing mistake would previously have caused formatEnum to
    default to ASCII. We can now properly control its behaviour.

        IOstream::formatEnum
        (
            dict.get<word>("format"), IOstream::BINARY
        );

    Allowing us to switch ascii/binary, using BINARY by default even in
    the case of spelling mistakes. The mistakes are flagged, but the
    return value can be non-ASCII.

* The format/compression lookup behave as pass-through if the lookup
  string is empty.

  - Allows the following to work without complaint

      IOstream::formatEnum
      (
          dict.getOrDefault("format", word::null), IOstream::BINARY
      );

  - Or use constructor-like failsafe method

      IOstream::formatEnum("format", dict, IOstream::BINARY);

  - Apply the same behaviour with setting stream format/compression
    from a word.

       is.format("binar");

    will emit a warning, but leave the stream format UNCHANGED

* Rationalize versionNumber construction

  - constexpr constructors where possible.
    Default construct is the "currentVersion"

  - Construct from token to shift the burden to versionNumber.
    Support token as argument to version().

    Now:

        is.version(headerDict.get<token>("version"));

    or failsafe constructor method

        is.version
        (
            IOstreamOption::versionNumber("version", headerDict)
        );

    Before (controlled input):

        is.version
        (
            IOstreamOption::versionNumber
            (
                headerDict.get<float>("version")
            )
        );

    Old, uncontrolled input - has been removed:

        is.version(headerDict.lookup("version"));

* improve consistency, default behaviour for IOstreamOption construct

  - constexpr constructors where possible

  - add copy construct with change of format.

  - construct IOstreamOption from streamFormat is now non-explicit.
    This is a commonly expected result with no ill-effects
2020-02-18 21:51:35 +01:00
Mark Olesen
4e1bc2d2f1 COMP: incorrect placement of compiler attributes 2020-02-18 13:51:20 +01:00
Mark Olesen
4307e1719f STYLE: adjust names, locations for fileFormats
- renamed 'core/' -> 'base/' to avoid gitignore masking when re-adding
  files

- rename 'nas/' to 'nastran/' for more clarity

- relocated OBJstream from surfMesh to fileFormats

STYLE: remove unused parseNASCoord. Was deprecated 2017-09
2020-02-18 13:51:20 +01:00
Kutalmis Bercin
55e7da670c ENH: improve analytical eigendecompositions
- `tensor` and `tensor2D` returns complex eigenvalues/vectors
  - `symmTensor` and `symmTensor2D` returns real eigenvalues/vectors
  - adds new test routines for eigendecompositions
  - improves numerical stability by:
    - using new robust algorithms,
    - reordering the conditional branches in root-type selection
2020-02-18 12:21:01 +00:00
Kutalmis Bercin
66b02ca5ca ENH: improve funcs and opers in Tensor types
- ensures each Tensor-container operates for the following base types:
    - floatScalar
    - doubleScalar
    - complex

  - adds/improves test applications for each container and base type:
    - constructors
    - member functions
    - global functions
    - global operators

  - misc:
    - silently removes `invariantIII()` for `tensor2D` and `symmTensor2D`
      since the 3rd invariant does not exist for 2x2 matrices
    - fixes `invariantII()` algorithm for `tensor2D` and `symmTensor2D`
    - adds `Cmpt` multiplication to `Vector2D` and `Vector`
    - adds missing access funcs for symmetric containers
    - improves func/header documentations
2020-02-18 12:21:01 +00:00
Kutalmis Bercin
8ca724fffa ENH: improve stability in polynomialEqns
- replaces floating-point equal comparisons in
    `linearEqn`, `quadraticEqn`, and `cubicEqn`,
  - ensures `quadraticEqn` and `cubicEqn` can return `complex` roots,
  - reorders if-branches in `quadraticEqn` and `cubicEqn` to avoid
    zero-equal comparison,
  - adds Kahan's cancellation-avoiding algorithm into `quadraticEqn` and
    `cubicEqn` for the numerically-sensitive discriminant computation,

  - adds/improves `polynomialEqns` tests:
    * adds Test-linearEqn.C
    * adds Test-quadraticEqn.C
    * improves Test-cubicEqn.C
2020-02-18 12:21:01 +00:00
Mark Olesen
53dec91cc2 COMP: add -help-man for Test-dummyLib (minimal packaging tests) 2020-02-06 10:06:20 +01:00
Mark Olesen
822d052e32 ENH: added IndirectSubList
- provides an indirect access to a sub-section of a list that is
  somewhat less efficient than a Foam::SubList, but supports the
  following:
    * adjustment of its addressing range after construction
    * recovery of the original, underlying list at any time

  This can be more convenient for some coding cases.
  For example,

      template<class Addr>
      void renumberFaces(IndirectListBase<face, Addr>& faces, ...);

  which can be called for

      * Specific faces:
        UIndirectList<face>(mesh.faces(), facesToChange)

      * A sub-range of faces:
        IndirectSubList<face>(mesh.faces(), pp.range())

      * All faces:
        IndirectSubList<face>(mesh.faces())

CONFIG: added IndirectListsFwd.H with some common forwarding
2020-01-31 17:01:22 +01:00
OpenFOAM bot
596e4aef3f STYLE: remove trailing space, tabs 2020-01-22 10:00:03 +01:00
Andrew Heather
ae2ab06312 REL: Release preparations 2019-12-23 09:49:23 +00:00
Mark Olesen
74b12c6afd ENH: improved separation of scanner/parser debug selection
- now use debug 2 for scanner and debug 4 for parser.
  Provided better feedback about what is being parsed (debug mode)

- relocate debug application to applications/tools/foamExprParserInfo
2019-12-19 13:16:26 +01:00
Mark Olesen
1cf795a40f ENH: use exprString expansions for #eval
- follows the principle of least surprise if the expansion behaviour
  for #eval and expressions (eg, exprFixedValue) are the same.  This
  is possible now that we harness the regular stringOps::expand()
  within exprString::expand()
2019-12-17 09:47:51 +01:00
Mark Olesen
1a16207e0d COMP: compilation of Test-QRMatrix (clang, int64)
- remove unused local functions from volumeExprDriver
2019-12-16 11:22:15 +01:00
Mark Olesen
33e0c4ba88 ENH: improve expression string expansions
- reuse more of stringOps expansions to reduce code and improve the
  syntax flexiblity.

  We can now embed "pre-calculated" values into an expression.
  For example,

       angle       35;
       valueExpr   "vector(${{cos(degToRad($angle))}}, 2, 3)";

  and the ${{..}} will be evaluated with the regular string evaluation
  and used to build the entire expression for boundary condition
  evaluation.

  Could also use for fairly wild indirect referencing:

       axis1   (1 0 0);
       axis2   (0 1 0);
       axis3   (0 0 1);
       index   100;
       expr   "$[(vector) axis${{ ($index % 3) +1 }}] / ${{max(1,$index)}}";
2019-12-14 00:11:28 +01:00
Mark Olesen
7aa2bf832f STYLE: header format 2019-12-13 12:33:23 +01:00
Mark Olesen
17d9969ae5 ENH: stringOps::findTrim helper
- finds beg/end indices of string trimmed of leading/trailing whitespace
2019-12-13 12:10:53 +01:00
Mark Olesen
677e314279 string trim 2019-12-13 10:05:28 +01:00
Kutalmis Bercin
af0e454ccf BUG: fix QRMatrix (#1261, #1240)
QRMatrix (i.e. QR decomposition, QR factorisation or orthogonal-triangular
    decomposition) decomposes a scalar/complex matrix \c A into the following
    matrix product:

    \verbatim
        A = Q*R,
    \endverbatim

    where
     \c Q is a unitary similarity matrix,
     \c R is an upper triangular matrix.

Usage
    Input types:
     - \c A can be a \c SquareMatrix<Type> or \c RectangularMatrix<Type>

    Output types:
     - \c Q is always of the type of the matrix \c A
     - \c R is always of the type of the matrix \c A

    Options for the output forms of \c QRMatrix (for an (m-by-n) input matrix
    \c A with k = min(m, n)):
     - outputTypes::FULL_R:     computes only \c R                   (m-by-n)
     - outputTypes::FULL_QR:    computes both \c R and \c Q          (m-by-m)
     - outputTypes::REDUCED_R:  computes only reduced \c R           (k-by-n)

    Options where to store \c R:
     - storeMethods::IN_PLACE:        replaces input matrix content with \c R
     - storeMethods::OUT_OF_PLACE:    creates new object of \c R

    Options for the computation of column pivoting:
     - colPivoting::FALSE:            switches off column pivoting
     - colPivoting::TRUE:             switches on column pivoting

    Direct solution of linear systems A x = b is possible by solve() alongside
    the following limitations:
     - \c A         = a scalar square matrix
     - output type  = outputTypes::FULL_QR
     - store method = storeMethods::IN_PLACE

Notes
    - QR decomposition is not unique if \c R is not positive diagonal \c R.
    - The option combination:
      - outputTypes::REDUCED_R
      - storeMethods::IN_PLACE
      will not modify the rows of input matrix \c A after its nth row.
    - Both FULL_R and REDUCED_R QR decompositions execute the same number of
      operations. Yet REDUCED_R QR decomposition returns only the first n rows
      of \c R if m > n for an input m-by-n matrix \c A.
    - For m <= n, FULL_R and REDUCED_R will produce the same matrices
2019-12-12 11:22:14 +00:00
Kutalmis Bercin
64614cfce8 ENH: add new funcs into SquareMatrix
- query func `symmetric()`
    - query func `tridiagonal()`
    - `resize()`
    - `labelpair` identity constructor

    STYLE: add `#if(0 | RUNALL)` to improve test control in Test-Matrix
2019-12-12 11:22:13 +00:00
Mark Olesen
eb4fec371a ENH: unified some common parser static methods
COMP: delay evaluation of fieldToken enumeration types

- lazy evaluation at runTime instead of compile-time to make the code
  independent of initialization order.
  Otherwise triggers problems on gcc-4.8.5 on some systems where
  glibc is the same age, or older.
2019-12-11 13:32:36 +01:00
Mark Olesen
c2123452b1 ENH: generalize string expression evaluation
- replace stringOps::toScalar with a more generic stringOps::evaluate
  method that handles scalars, vectors etc.

- improve #eval to handle various mathematical operations.
  Previously only handled scalars. Now produce vectors, tensors etc
  for the entries. These tokens are streamed directly into the entry.
2019-12-09 19:44:23 +01:00
Mark Olesen
9fd696e1ae ENH: add ITstream append and seek methods.
- ITstream append() would previously have used the append from the
  underlying tokenList, which leaves the tokenIndex untouched and
  renders the freshly appended tokens effectively invisible if
  interspersed with primitiveEntry::read() that itself uses tokenIndex
  when building the list.

  The new append() method makes this hidden ITstream bi-directionality
  easier to manage. For efficiency, we only append lists
  (not individual tokens) and support a 'lazy' resizing that allows
  the final resizing to occur later when all tokens have been appended.

- The new ITstream seek() method provides a conveniently means to move
  to the end of the list or reposition to the middle.
  Using rewind() and using seek(0) are identical.

ENH: added OTstream to output directly to a list of tokens

---

BUG: List::newElem resized incorrectly

- had a simple doubling of the List size without checking that this
  would indeed be sufficient for the requested index.

  Bug was not triggered since primitiveEntry was the only class using
  this call, and it added the tokens sequentially.
2019-12-06 17:23:59 +01:00
Mark Olesen
6b5da70602 ENH: add scalarOps with divide-by-zero protection
- add functor versions of floor/ceil/round for scalar
2019-12-07 16:55:18 +01:00
Mark Olesen
1310e85225 ENH: support 'get()' for retrieving argList options
- previously only had 'opt<..>()' for options, but 'get<..>()'
  provides more similarity with dictionary methods.
  The 'opt<..>()' method is retained.
2019-11-26 21:07:11 +01:00
Mark Olesen
6dd3cd0e51 ENH: add clear/append method to Enum and std::ostream output
- allows use of Enum in more situations where a tiny Map/HashTable
  replacement is desirable. The new methods can be combined with
  null constructed for to have a simple low-weight caching system
  for words/integers instead of fitting in a HashTable.
2019-11-25 18:15:31 +01:00
Mark Olesen
42a9a6ae5a ENH: add generator class for uniform/gaussian random numbers
- can be used in combination with std::generate, or as a substitute
  unary operator to supply random numbers for std::transform.
2019-11-21 09:40:00 +01:00
Mark Olesen
9e6683f7bc ENH: add conditionals to #eval (string to scalar)
Example,

     ($radius > 10) ? sin(degToRad(45)) : cos(degToRad(30))

- protect division and modulo against zero-divide.

- add scanner/parser debugging switches in the namespace,
  selectable as "stringToScalar". For example,

    debug parser:  foamDictionary -debug-switch stringToScalar=2
    debug scanner: foamDictionary -debug-switch stringToScalar=4
    debug both:    foamDictionary -debug-switch stringToScalar=6
2019-11-19 14:22:03 +01:00
Mattijs Janssens
2d080ff331 Feature single precision solve type 2019-11-19 11:10:07 +00:00
Mark Olesen
4d18fea8e1 ENH: add value_type to dimensioned type. Add Switch::name(bool) 2019-11-18 09:13:58 +01:00
Mark Olesen
2a8669b3f8 ENH: add zip/unzip for GeometricField 2019-11-15 17:29:50 +01:00
Mark Olesen
cf2b84ef32 ENH: add zip/unzip for FieldField 2019-11-15 13:32:27 +01:00
Mark Olesen
6882ed35a4 ENH: add zip/unzip for vector and tensor fields
- the full tensor also supports zip/unzip rows/cols
  and unzipRow, unzipCol, unzipDiag
2019-11-15 12:56:23 +01:00
Mark Olesen
39a1191bd5 ENH: add zip/unzip functions for complexField and vector2DField 2019-11-15 11:26:45 +01:00
Mark Olesen
6798c61047 ENH: add boolIOField to allow registering 2019-11-13 18:54:10 +01:00
Mark Olesen
98467036b3 STYLE: regularize quoting and exit on failed 'cd' 2019-11-13 13:19:16 +01:00
Mark Olesen
7c1190f0b1 ENH: rationalize some string methods.
- silently deprecate 'startsWith', 'endsWith' methods
  (added in 2016: 2b14360662), in favour of
  'starts_with', 'ends_with' methods, corresponding to C++20 and
  allowing us to cull then in a few years.

- handle single character versions of starts_with, ends_with.

- add single character version of removeEnd and silently deprecate
  removeTrailing which did the same thing.

- drop the const versions of removeRepeated, removeTrailing.
  Unused and with potential confusion.

STYLE: use shrink_to_fit(), erase()
2019-11-11 18:50:00 +01:00
Mark Olesen
71de630722 ENH: tune efficiency of stringOps::trim
- move left/right positions prior to substr
2019-11-10 10:50:49 +01:00
Mark Olesen
ec7e3c88e4 ENH: test for WM_PROJECT_DIR being set/unset in scripts 2019-11-06 09:18:51 +01:00
Mark Olesen
e8fa46230a ENH: add min/max compare/reduction operators for Tuple2 first()
- min/max ops that only compare the first element
2019-11-05 13:08:21 +01:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
177f4b79fe ENH: use direct scanning mode when lexing #eval expressions 2019-11-01 19:13:50 +01:00
Mark Olesen
28a9cde028 ENH: add boolField specializations: negate(), component()
ENH: added scalarField hypot() function
2019-10-10 13:13:20 +02:00
Mark Olesen
6b5492e3bd ENH: code simplification, improvements for reading dictionary variables
- Now accept '/' when reading variables without requiring
  a surrounding '{}'

- fix some degenerate parsing cases when the first character is
  already bad.

  Eg, $"abc" would have previously parsed as a <$"> variable, even
  although a double quote is not a valid variable character.

  Now emits a warning and parses as a '$' token and a string token.
2019-10-08 18:43:38 +02:00
Mark Olesen
46225279c0 ENH: improvements to stringOps::expand operations
- add toScalar evaluation, embedded as "${{EXPR}}".

  For example,

    "repeat ${{5 * 7}} times or ${{ pow(3, 10) }}"

- use direct string concatenation if primitive entry is only a string
  type. This prevents spurious quotes from appearing in the expansion.

     radius  "(2+4)";
     angle   "3*15";
     #eval   "$radius*sin(degToRad($angle))";

     We want to have
         '(2+4)*sin(degToRad(3*15))'
     and not
         '"(2+4)"*sin(degToRad("3*15"))'

ENH: code refactoring

- refactored expansion code with low-level service routines now
  belonging to file-scope. All expansion routines use a common
  multi-parameter backend to handle with/without dictionary etc.
  This removes a large amount of code duplication.
2019-10-07 08:27:19 +02:00
Mark Olesen
d9d29e5a8f STYLE: split off Test-string2 2019-10-04 17:52:08 +02:00
Mark Olesen
bd35981feb ENH: stringOps::toScalar improvements
- add floor/ceil/round methods
- support evaluation of sub-strings

STYLE: add blockMeshDict1.calc, blockMeshDict1.eval test dictionaries

- useful for testing and simple demonstration of equivalence
2019-10-04 17:50:55 +02:00
Mark Olesen
61e95b8471 ENH: improvements to SubList and SubField
- SubField and SubList assign from zero
- SubField +=, -=, *=, /= operators

- SubList construct from UList (as per SubField)

  Note: constructing an anonymous SubField or SubList with a single
  parameter should use '{} instead of '()' to avoid compiler
  ambiguities.
2019-10-04 14:21:18 +02:00
Mark Olesen
836d3a849f ENH: add stringOps::toScalar and dictionary #eval directive
- the #eval directive is similar to the #calc directive, but for evaluating
  string expressions into scalar values. It uses an internal parser for
  the evaluation instead of dynamic code compilation. This can make it
  more suitable for 'quick' evaluations.

  The evaluation supports the following:
    - operations:  - + * /
    - functions:  exp, log, log10, pow, sqrt, cbrt, sqr, mag, magSqr
    - trigonometric:  sin, cos, tan, asin, acos, atan, atan2, hypot
    - hyperbolic:  sinh, cosh, tanh
    - conversions:  degToRad, radToDeg
    - constants:  pi()
    - misc: rand(), rand(seed)
2019-09-30 16:40:32 +02:00
Mark Olesen
4a5569776e ENH: add cmptMagSqr for scalars, VectorSpace, Fields (#1449) 2019-09-29 16:53:42 +02:00
Mark Olesen
b6bf9129f6 DEFEATURE: pointer dereferencing for HashTable iterator
- this largely reverts 3f0f218d88 and 4ee65d12c4.

  Consistent addressing with support for wrapped pointer types (eg,
  autoPtr, std::unique_ptr) has proven to be less robust than desired.
  Thus rescind HashTable iterator '->' dereferencing (from APR-2019).
2019-09-27 19:45:54 +02:00
Mark Olesen
13967565a6 ENH: stringOps removeComments and inplaceRemoveComments
- useful for manual handling of string with comments
2019-09-24 08:25:32 +02:00
sergio
e3b05494f7 COMP: relocate regionProperties to meshTools 2019-09-20 14:06:30 -07:00
Mark Olesen
79dff5d8fe ENH: add col/row access methods for Tensor2D (#1430) 2019-09-23 14:40:47 +02:00
Mark Olesen
07fb19e9d8 ENH: add construct dimensionedType from primitiveEntry
- allows direct reading of a single entry with token checking
2019-08-28 21:16:19 +02:00
Mark Olesen
c9cb4ce34f ENH: minor improvements, cleanup of token class
- relax casting rules
  * down-cast of labelToken to boolToken
  * up-cast of wordToken to stringToken.
    Can use isStringType() test for word or string types

- simplify constructors, move construct etc.

- expose reset() method as public, which resets to UNDEFINED and
  clears allocated storage etc.

DEFEATURE: remove assign from word or string pointer.

- This was deprecated 2017-11 and now removed.
  For this type of content transfer, move assignment should be used
  instead of stealing pointers.
2019-08-20 17:48:31 +02:00
Mark Olesen
b5342c166c ENH: handle keyType type (literal/regex) as enum instead of bool
- makes its use somewhat clearer and allows more future options
2019-08-20 13:48:05 +02:00
Mark Olesen
ba69505225 ENH: add ITstream::toString() method
- creates a std::string with space-delimited tokens, which can be sent
  to another application or even re-parsed into tokens
2019-08-14 19:29:02 +02:00
Mark Olesen
1d79c0452c ENH: additional contiguous traits (#1378)
- change contiguous from a series of global functions to separate
  templated traits classes:

    - is_contiguous
    - is_contiguous_label
    - is_contiguous_scalar

  The static constexpr 'value' and a constexpr conversion operator
  allow use in template expressions.  The change also makes it much
  easier to define general traits and to inherit from them.

  The is_contiguous_label and is_contiguous_scalar are special traits
  for handling data of homogeneous components of the respective types.
2019-07-29 11:36:30 +02:00
Mark Olesen
3c07a1bb6f ENH: Foam::name() of memory address
- returns the memory address formatted in hexadecimal, which can be
  useful for detailed information
2019-08-12 10:46:29 +02:00
Mark Olesen
1dde76c8dd ENH: add bitSet::begin(pos) to provide alternative start for indexing 2019-08-07 13:49:48 +02:00
Mark Olesen
0cfd019b92 STYLE: add data/cdata to VectorSpace for consistency with FixedList etc 2019-08-06 12:00:56 +02:00
Mark Olesen
c28d785a73 STYLE: adjust name, default count for readRawLabel/readRawScalar (#1378) 2019-08-06 11:54:14 +02:00
Mark Olesen
ef9bb4ae16 ENH: add low-level readRawLabels, readRawScalars (#1378)
- these use the additional byte-size checks in IOstream to handle
  native vs non-native sizes
2019-07-29 16:01:34 +02:00
Mark Olesen
8b3d77badc ENH: make OSstream indentation adjustable
- this is principally for cases where reduced indentation is desired,
  such as when streaming to a memory location. If the indentation size
  is zero or one, only a single space will be used to separate the
  key/value.

  This change does not affect the stream allocation size, since the
  extra data falls within the padding.

ENH: relocate label/scalar sizes from Istream to IOstream.

- could allow future use for output streams as well?

  Due to padding, reorganization has no effect on allocated size
  of output streams.

STYLE: add read/write name qualifier to beginRaw, endRaw

- removes ambiguity for bi-directional streams

STYLE: fix inconsistent 'const' qualifier on std::streamsize

- base Ostream was without const, some derived streams with const
2019-07-31 12:51:54 +02:00
Mark Olesen
6f8da834a9 ENH: add OListStream::swap(DynamicList<char>&)
- allows full recovery of allocated space, not just addressable range.

  This can be particularly useful for code patterns that repeatedly
  reuse the same buffer space. For example,

      DynamicList<char> buf(1024);

      // some loop
      {
          OListStream os(std::move(buf));
          os << ...

          os.swap(buf);
      }

   Can read back from this buffer as a second operation:

      {
          UIListStream is(buf);
          is >> ...
      }
2019-07-31 11:31:40 +02:00
Mark Olesen
78ce269a52 ENH: add field operations for complex (#1365) 2019-07-28 21:19:43 +02:00
Mark Olesen
1d86fc4f6b ENH: add single-parameter sortedOrder() function 2019-07-17 11:08:40 +02:00
Mark Olesen
e03c0977f5 ENH: support Foam::mv overwrite of existing files on windows (#1238)
- the behaviour of std::rename with overwriting an existing file is
  implementation dependent:
    - POSIX: it overwrites.
    - Windows: it does not overwrite.

- for Windows need to use the ::MoveFileEx() routine for overwriting.

  More investigation is needed for proper handling of very long names.
2019-07-09 18:52:06 +02:00
Mark Olesen
bbc2d4a8b0 ENH: HashTable and HashSet improvements
- unfriend HashSet, HashTable IO operators

- global min(), max(), minMax() functions taking a labelHashSet and an
  optional limit. For example,

      labelHashSet set = ...;

      Info<< "min is " << min(set) << nl;
      Info<< "max (non-negative) " << max(set, 0) << nl;

- make HashTable iterator '->' dereferencing more consistent by also
  supporting non-pointer types as well.

- read HashTable values in-situ to avoid copying
2019-07-12 18:00:00 +02:00
Mark Olesen
488f8938b2 ENH: add invert (inverse mappings) for bitSet 2019-07-12 12:00:00 +02:00
Mark Olesen
4b8fabaa4b STYLE: relocate Allwmake-scan to src/
- reduced clutter. Mostly only need to scan source tree.

- 00-dummy: use wmake/src/Allmake to get native (not cross-compiled)
  wmake toolchain binaries
2019-06-28 09:55:25 +02:00
Mark Olesen
10a03ceba2 STYLE: relocate Allwmake-scan to src/
- reduced clutter. Mostly only need to scan source tree.

- 00-dummy: use wmake/src/Allmake to get native (not cross-compiled)
  wmake toolchain binaries
2019-06-28 09:55:25 +02:00
Andrew Heather
be44dcaf1f RELEASE: Version clean-up for release 2019-06-25 11:51:19 +01:00
Mark Olesen
fa8ab2d5b4 STYLE: add Test-copyFile 2019-06-24 14:46:38 +02:00
Mark Olesen
f863925112 STYLE: use uintptr_t instead of long 2019-06-13 19:37:27 +02:00
Mark Olesen
03de501310 STYLE: fix file permissions, inconsistent Test files 2019-06-04 17:50:18 +02:00
kuti
e42cc287de BUG: incorrect scalar/complex division (#1331)
ENH: define addition/subtraction operations for scalar and complex

- required since construct complex from scalar is explicit
- additional tests in Test-complex
2019-06-04 09:08:42 +01:00
Mark Olesen
fc11c40841 ENH: add wmake -debug option
- forces c++DBUG='-DFULLDEBUG -g -O0' for the compilation, to allow
  localized debugging during development without file editing and
  while retaining the WM_COMPILE_OPTION (eg, Opt)

  Note that switching between 'wmake' and 'wmake -debug' will not
  cause existing targets to be rebuilt. As before, these are driven by
  the dependencies. An intermediate wclean may thus be required.
2019-06-03 10:16:31 +02:00
kuti
745624c024 ENH: partial overhaul of Matrix type (#1220)
- additional operators:
  + compound assignment
  + inner product: operator&
  + outer product: operator^

- additional functions:
   - MatrixBlock methods: subColumn, subRow, subMatrix
   - L2 norms for matrix or column
   - trace, diag, round, transpose

- MatrixBlock methods: col(), block() are deprecated since their
  access patterns with (size, offset) are unnatural/unwieldy.

- verifications by test/Matrix/Test-Matrix
2019-05-23 11:32:45 +01:00
Mark Olesen
db0678bf0e TUT: incorrect regex escaping in fvSchemes
- error trapped by C++11 regex
2019-05-30 14:26:15 +02:00
Mark Olesen
96d0a8f2af ENH: harmonize matrix constructors (#1220)
- generalize identity matrix constructors for non-scalar types

- add constructors using labelPair for the row/column sizing information.
  For a SquareMatrix, this provides an unambiguous parameter resolution.

- reuse assignment operators

STYLE: adjust matrix comments
2019-05-29 09:50:46 +02:00