Commit Graph

24000 Commits

Author SHA1 Message Date
d3d03de48c DOC: relocate cross-compile (mingw) information to wiki content 2020-07-28 15:48:42 +02:00
74a062d1d5 Merge remote-tracking branch 'origin/master' into develop 2020-07-28 08:42:12 +02:00
65d640e58e BUG: potential memory leaks in HashPtrTable (#1787)
- using HashPtrTable::set() with the same key twice did not guarantee
  proper cleanup of memory since it simply used the underlying
  HashTable::set() without doing anything about the old memory. Now
  check for pre-existing storage and delete it when it does not
  correspond to the newly stored pointer.

  This problem is independent of potential memory slicing previously
  flagged (#1286) and only partially resolved.
2020-07-28 08:40:43 +02:00
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
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
6461eec886 CONFIG: increment patch level 2020-07-27 10:28:44 +02:00
3455d556c4 BUG: potential memory leaks in HashPtrTable::set (#1787)
- backported fix from develop

COMP: incorrect variable names in PtrListOpsTemplates.C
2020-07-27 10:28:40 +02:00
540589fc22 SUBMODULE: visualization installation prefix on older ubuntu (#1757) 2020-07-27 09:58:24 +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
c411c0cc09 SUBMODULE: adios (style), external-solver (bugfix), visualization (style) 2020-07-23 18:12:06 +02:00
e8b06ac222 STYLE: remove incorrect branch condition in setExprFields 2020-07-23 16:52:15 +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
dc6c3c8add TUT: Correction for Alltest 2020-07-20 10:19:54 +01: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
fa86a98482 BUG: Minor correction to lumpedPointState.C for debug build 2020-07-17 14:09:34 +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
5dc04530d9 COMP: additional linkage libraries for AMD compiler (#1627) 2020-07-14 12:17:09 +02: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
a86860430a BUG: checkMesh: index into surfaceScalarField. Fixes #1771. 2020-07-13 13:02:07 +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