Commit Graph

23983 Commits

Author SHA1 Message Date
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
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
c77afff48f COMP: fix sloppy (and now ambiguous) use of PtrList::set()
- constructs such as the following will no longer worked, but that is
  also a good thing.

     ptrlist.set(i, scalarField(nFaces, Zero));

  this called set(.., const tmp<scalarField>&), which meant under
  the hood:

     - create local temporary const scalarField&
     - wrap as const tmp&
     - use tmp::ptr(), to clone the const-ref

  This implies an additional allocation (for the const scalarField&)
  which is immediately discarded. Doubtful that compiler optimization
  would do anything.
2020-07-28 08:35:42 +02:00
dc52e5ae67 STYLE: use range-for with labelHashSet in MULES 2020-07-27 09:47:33 +02:00
d5884c8d85 STYLE: use HashSet xor instead of two operations (faceZoneSet)
STYLE: use global operator instead of HashSet -= operator
2020-07-27 09:47:33 +02:00
6e75cf2e7d STYLE: unify HashSet list insertion (use iterator pair) 2020-07-27 09:47:33 +02:00
85e74567ff ENH: added subtraction operator for HashSet
- offers similarity with bitSet

STYLE: remove remnant parent::operator= from HashSet

STYLE: code formatting in HashTables
2020-07-27 09:47:33 +02:00
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
181e27a90f ENH: improve abort/exception handling in error class (#1780)
- previously setting FOAM_ABORT would preempt checks for throwing
  exceptions.

  Now check for throwing first, to allow try/catch code to do its job.
  However, ignore exception throwing for abort(). These are used
  infrequently in the code, but indicate that recovery is deemed
  impossible.

STYLE: use unique_ptr for internal stream buffer management
2020-07-22 19:11:57 +02:00
707b29bbbd STYLE: minor doc and formatting changes 2020-07-22 19:11:28 +02:00
bcda061f54 ENH: checkMesh: improved checking on writeFields. Fixes #1786. 2020-07-23 17:26:09 +01:00
d3c76d8ec8 ENH: ListOps: added findIndices with predicate 2020-07-23 17:26:09 +01:00
f1e950ce83 ENH: snappyHexMeshDict: document small region removal. See #1772 2020-07-23 17:26:09 +01:00
45982d97fa BUG: Correct evaluate function for ddt0 in CrankNicolson scheme. Fixes
The function evaluate was returning true every outer loop, triggering
the re-calculation of ddt0 in every outer loop.

The evaluation of the term ddt0 should be performed once per time step.
The corrected function updates the timeIndex of ddt0 to avoid the
re-evaluation of this term in the outer loops.
2020-07-21 16:23:13 -07:00
be058bec7d ENH: support writable reference for tmp (#1775)
- improves flexibility. Can tag a tmp as allowing non-const access to
  the reference and skip additional const_cast in following code. For
  example,

      tmp<volScalarField> tfld(nullptr);
      auto* ptr = getObjectPtr<volScalarField>("field");
      if (ptr)
      {
          tfld.ref(*ptr);
      }
      else
      {
          tfld.reset(volScalarField::New(...));
      }
      auto& fld = tfld.ref();

ENH: renamed tmpNrc to refPtr

- the name 'refPtr' (reference|pointer) should be easier to remember
  than tmpNrc (tmp, but non-ref-counted).

- provide tmpNrc typedef and header for code compatibility

NOTE

- in some places refPtr and tmp can be used instead of a
  std::reference_wrapper for handling external references.

  Unlike std::reference_wrapper, it can be default constructed
  (holding nothing), whereas reference_wrapper may need a dummy
  reference. However, the lifetime extension of references _may_ be
  better with reference_wrapper.
2020-07-21 11:02:20 +02:00
5acb5f3580 STYLE: rename/adjust local pointer naming and handling 2020-07-20 16:59:19 +02:00
065db9a7b8 Merge branch 'enh-memory-cleanup' into 'develop'
autoPtr/tmp cleanup

See merge request Development/openfoam!378
2020-07-17 16:29:16 +01:00
6d4928d585 ENH: extend nullptr check for tmp ptr() method (#1775)
- Cannot call ptr_->clone() with a null pointer!
2020-07-16 15:09:57 +02:00
fde93b6603 STYLE: compile-type deprecate empty() method for autoPtr/tmp (#1775)
- autoPtr: less clutter using plain tests with the bool operator

    (!ptr)  vs  (ptr.empty())
    (ptr)   vs  (!ptr.empty())

- tmp: was entirely unused.
2020-07-16 15:09:57 +02:00
35a0fd3e8e ENH: reset tmp via assignment from literal nullptr (#1775)
- previously this was marked as '= delete' for consistency with
  assignment from an empty pointer being a runtime error.
  However, these can be considered semantically different and it makes
  sense to permit this as equivalent to reset(nullptr).

  This change does not break existing code since the operator was
  previously unavailable (deleted).

STYLE: refactor tmp operator=(T*)

- delegate to reset() after initial checks
2020-07-16 15:09:56 +02:00
59bfbb9541 ENH: simpler, more consistent checks for tmp validity (#1775)
- Previously considered to be valid() if it was any reference
  (null or non-null) or a non-null pointer.

  This appears to be a holdover from old code (pre-2015) where
  reinterpret_cast<..>(0) was used instead of the NullObject.

  A reference via a null pointer isn't really possible anywhere. Even
  for things like labelList::null(), they now use the NullObject,
  which has a non-zero memory location.

- now simply check for a non-zero memory address. Regardless of
  pointer or referenced object.
2020-07-16 15:09:56 +02:00
d282d1a285 STYLE: minor code reduction/simplification for tmp (#1775)
- combine reset() methods by adding a default parameter

- improve top-level visibility of empty/valid/get methods for symmetry
  symmetry with autoPtr, future adjustment
2020-07-16 15:09:56 +02:00
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
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
3baebcb101 STYLE: replace uses of autoPtr::empty() with bool check (#1775)
- less clutter using plain tests with the bool operator:

      (!ptr)  vs  (ptr.empty())
      (ptr)   vs  (!ptr.empty())
2020-07-16 08:58:22 +02:00
53eda1c4f1 ENH: use boolVector for NURBS3DVolume constraints
- same as FixedList<bool,3> for I/O
2020-07-15 14:34:52 +02:00
5e954d2881 STYLE: use autoPtr instead of tmp for holding sensitivities
- since only pointers are stored, autoPtr is better fit than tmp
2020-07-15 13:41:15 +02:00
e2021550fd Merge branch 'feature-dynamicLibrary' into 'develop'
Feature dynamic library - issue #1737

See merge request Development/openfoam!375
2020-07-14 16:41:39 +01:00
1e7c6ea2f1 ENH: mutable libs() access in Time and other classes (#1737)
- This reflects the pre-existing coding situation where const_cast was
  used throughout to effect the same.

STYLE: fix private/protected access

- CodedField, codedMixedFvPatchField
2020-07-14 11:19:05 +02:00
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
950e667259 ENH: snappyHexMesh: optionally remove 'small' regions. Fixes #1772.
This is for a very specific use case where the faceZones are
imprinted after meshing the normal geometry. This sometimes
splits off badly connected bits of the mesh. One way to remove
these is to use e.g. subsetMesh. This embeds the
same functionality inside snappyHexMesh.
2020-07-13 15:29:12 +01:00
331e86cf17 BUG: checkMesh: index into surfaceScalarField. Fixes #1771. 2020-07-13 13:00:13 +01:00
8594fb43c8 ENH: snappyHexMesh: Cleanup of parallel cyclics. See #1731. 2020-07-13 09:45:00 +01:00
6365bab800 ENH: update lemon version and linkage directive (#1768)
- replace `%namespace` directive with simpler `%static` directive.

  We always encapsulate Lemon parser routines in an anonymous
  namespace, so a simpler static linkage directive suffices.

  This reduces the size of the Lemon patch (program and template).
2020-07-10 12:01:58 +02:00
a088bda4d2 ENH: use unique_ptr for memory management of profiling
- makes it easier to distinguish between pointers referring to pool
  data versus pointers actually holding storage, avoids
  manual demand-driven deletion and autoPtr.

ENH: simplify/improve Pstream profiling

- times now double (not scalar) for consistency with what cpuTime
  delivers

- use bool to track suspend state
2020-07-09 16:17:33 +02:00
b64ada3dde BUG: argList: use fileHandler to read decomposeParDict. Fixes #1765 2020-07-09 15:11:39 +01:00
c06c63f49f ENH: snappyHexMesh: handle parallel cyclics. Fixes #1731. 2020-07-08 16:48:14 +01:00
423bbcefa8 Update Build.md 2020-07-03 09:48:50 +01:00
ae76b38270 BUG: TableBase: illegal reference. Fixes #1753 2020-07-01 14:53:26 +01:00
0dc07fb00f CONFIG: reset version 2020-06-30 12:45:36 +01:00
b45f8f6f58 MOD: updated OpenQBMM reference OpenFOAM-v2006 2020-06-29 18:16:22 +01:00
294cfc4a77 REL: Updated completions cache 2020-06-29 17:27:54 +01:00
780c156103 REL: Updated config to v2006 2020-06-29 17:27:54 +01:00
538d749220 REL: Updated headers to version v2006 2020-06-29 17:27:54 +01:00
b244cd1b21 Merge remote-tracking branch 'origin/master' into develop 2020-06-29 11:08:27 +01:00
d1dae159ad BUG: Corrected use of ddtCorr off 2020-06-29 11:07:09 +01:00
b325cb86c0 TUT: added mixerVesselAMI2DRefined to show example of AMI with topology change 2020-06-29 11:07:09 +01:00
2ba6243862 CONFIG: refine handling of git information for debian builds
- When OpenFOAM is under git control and a 'debian/' directory exists,
  this could mean two things:

  1) Additional debian control has been added to OpenFOAM
  2) OpenFOAM has been imported into a debian project

For the case that OpenFOAM has been imported into a debian project,
using the git information would be highly misleading. There will be no
OpenFOAM SHA1 correspondence.

However, if additional debian control has been added to OpenFOAM the
SHA1 will be valid.

The ad hoc solution is to use an additional "openfoam.debian"
directory to flag the addition of debian controls into openfoam.

When a "debian/" directory exists without a "openfoam.debian", assume
that the OpenFOAM has been imported into debian and do not use the SHA1.
2020-06-29 10:33:30 +02:00
5754beeab4 COMP: remove old, unused/unusable lnInclude path (fixes #1752) 2020-06-29 09:32:14 +02:00
d93dd11ae4 ENH: add heatTransferCoeff caseDicts template (#1751) 2020-06-26 14:48:05 +02:00