Commit Graph

626 Commits

Author SHA1 Message Date
1340bc50bd STYLE: qualify zero/one dispatch tags with Foam:: prefix
- use Foam::zero{} instead of Zero with tagged re-dispatch
2023-08-10 11:51:04 +02:00
97a42df7ba ENH: add VectorSpace trait tests and evaluations
- is_vectorspace :
  test existence and non-zero value of the Type 'rank' static variable

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

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

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

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

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

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

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

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

GIT: relocate ListLoopM.H to src/OpenFOAM/fields/Fields (future isolation)
2023-08-10 10:38:39 +02:00
db16d80840 ENH: use objectRegistry/IOobjectList sorted instead of lookupClass
- in most cases a parallel-consistent order is required.
  Even when the order is not important, it will generally require
  fewer allocations to create a UPtrList of entries instead of a
  HashTable or even a wordList.
2023-07-31 20:11:32 +02:00
0eb4354ee0 ENH: use DynamicList for handling stored objects (ReadFields)
- DynamicList can be used as a LIFO with fewer allocations than a
  linked-list would have.

- support generic name matcher for readFields()
2023-07-31 20:11:32 +02:00
76efcba4c7 ENH: simpler handling of dictionary start/end line numbers
STYLE: use front(), back(), push_front(), push_back() methods
2023-07-27 16:52:03 +02:00
7cae3b9660 ENH: add HashTable zero-size construct, move construct is noexcept
BUG: HashTable::operator+= self-assignment check was being ignored

STYLE: minor code cleanup for templated Dictionary types
2023-07-27 16:52:03 +02:00
7a857b318a DOC: document/warn about GeometricField constructor being always read (#2926)
- no change in behaviour except to emit a warning when called with the
  a non-reading readOption

STYLE: remove redundant size check

- size checking is already done by Field::assign() within the
  DimensionedField::readField
2023-07-04 17:25:22 +02:00
a3e6af8fcf BUG: processorCyclic: cell->point interpolation. Fixes #2817 2023-06-22 15:10:04 +01:00
97459771ad ENH: more consistent handling/documentation of 'value' entry (#2703)
- for boundary conditions such as uniformFixed, uniformMixed etc the
  optional 'value' entry (optional) is used for the initial values and
  restarts.  Otherwise the various Function1 or PatchFunction1 entries
  are evaluated and used determine the boundary condition values.

  In most cases this is OK, but in some case such coded or expression
  entries with references to other fields it can be problematic since
  they may reference fields (eg, phi) that have not yet been created.

  For these cases the 'value' entry will be needed: documentation
  updated accordingly.

STYLE: eliminate some unneeded/unused declaration headers
2023-06-19 17:47:03 +02:00
fc86e52451 ENH: extrapolateInternal() method for patch fields
- provides a more succinct way of writing

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

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

ENH: readGradientEntry helper method for fixedGradient conditions

- simplifies coding and logic.
- support different read construct modes for fixedGradient
2023-06-19 17:47:03 +02:00
34f12219bd ENH: base-level construct patch field with value
- more consistent with fvPatchField
2023-06-19 17:47:02 +02:00
f4df00a4e9 ENH: support alternative registration name for solution "data" (#2797) 2023-06-13 20:41:53 +02:00
59b1cf080e ENH: Tensor/SymmTensor: add devSymm and devTwoSymm funcs to avoid intermediates 2023-05-15 17:05:10 +01:00
dfa5c05a16 ENH: use New factory methods for Dimensioned/Geometric functions (#2723) 2023-05-09 19:30:58 +02:00
1685e8e418 INT: objectRegistry: optionally caching temporary objects (#2723)
- functionality introduced by openfoam.org to support selective
  caching of temporary fields. The purpose is two-fold: to enable
  diagnostics and to allow more places to use unregistered fields by
  default.

  For example to cache the grad(k) field in

    cacheTemporaryObjects
    (
        grad(k)
    );

  If the name of a field which in never constructed is added to the
  cacheTemporaryObjects list a waning message is generated which
  includes a useful list of ALL the temporary fields constructed
  during the time step

  Multiple regions are also supported by specifying individual region
  names in a cacheTemporaryObjects dictionary.

    cacheTemporaryObjects
    {
        porous
        (
            porosityBlockage:UNbr
        );
    }

    functions
    {
        writePorousObjects
        {
            type        writeObjects;
            libs        (utilityFunctionObjects);

            region      porous;
            writeControl writeTime;
            writeOption anyWrite;

            objects     (porosityBlockage:UNbr);
        }
    }
2023-05-09 19:30:58 +02:00
ee39e3d276 STYLE: use explicit REGISTER option when storing fields 2023-04-25 13:45:08 +02:00
a7c4c184b8 ENH: respect value of dimensionSet::checking() for pow() function
STYLE: remove unused/meaningless pow(dimensionScalar, dimensionSet)
2023-04-24 15:46:04 +02:00
5042d1296f ENH: consistent UniformDimensionedField naming
- construct from components, or use word::null to ensure
  consistent avoid naming between IOobject vs dimensioned type.

- support construct with parameter ordering as per DimensionedField

ENH: instantiate a uniformDimensionedLabelField

- eg, for registering standalone integer counters
2023-04-24 15:46:04 +02:00
a96dcf706b ENH: robuster handling of inv() of fields with singular tensors (#2724)
- replace the "one-size-fits-all" approach of tensor field inv()
  with individual 'failsafe' inverts.

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

  This seems to have worked reasonably well with 3D volume meshes, but
  breaks down for 2D area meshes, which can be axis-aligned
  differently on different sections of the mesh.
2023-04-18 13:59:09 +02:00
87eed5e3b8 ENH: place more patch field attributes under template invariant Base
- attributes such as assignable(), coupled() etc

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

ENH: add some basic patchField types to fieldTypes namespace

- allows more general use of the names

ENH: set extrapolated/calculated from patchInternalField directly

- avoids intermediate tmp
2023-04-03 13:33:56 +02:00
66cae2b9d1 ENH: robuster handling inv() of singular tensor for finite-area LSQ (#2724)
- with the current handling of small edges (finite-area), the LSQ
  vectors can result in singular/2D tensors. However, the regular
  2D handling in field inv() only detects based on the first element.

  Provide a 'failsafe' inv() method for symmTensor and tensor that
  follows a similar logic for avoiding zero determinates, but it is
  applied on a per element basis, instead of deciding based on the
  first field element.

  The symmTensor::inv(bool) and tensor::inv(bool) methods have a
  fairly modest additional overhead.

- unroll the field inv() function to avoid creating an intermediate
  field.  Reduce the number of operations when adjusting/re-adjusting
  the diagonal.
2023-03-23 12:12:44 +01:00
726787b0d2 BUG: remove overly optimistic short-cut when reading BCs
- had an optimisation to skip attempted reading for zero-sized
  patches. But this leads to inconsistency in the code branching, thus
  removing it.
2023-03-23 10:31:54 +01:00
80a416d253 ENH: support construct Geometric field from separate value/dimensions
- can be easier to specify than copying into a dimensioned type.

  Eg,
      volSymmTensorField(io, mesh, Zero, dimLength);

      fluxFieldType
      (
          io
          mesh,
          Zero,
          Uf.dimensions()*dimArea/dimTime
      );

  vs
      volSymmTensorField
      (
          io,
          mesh,
          dimensionedSymmTensor("0", dimLength, Zero)
      );

      fluxFieldType
      (
          io
          mesh,
          dimensioned<typename flux<Type>::type>
          (
              Uf.dimensions()*dimArea/dimTime, Zero
          )
      );
2023-03-23 10:31:54 +01:00
34e36b83ab ENH: initEvaluate()/evaluate() for faePatchField, fvsPatchField
- no-op implementations, but makes the call to
  GeometricBoundaryField::evaluate() less dependent on PatchField type

- add updated()/manipulatedMatrix() methods to faePatchField,
  fvsPatchField etc. These are mostly no-ops, but provide name
  compatible with fvPatchField etc.
2023-03-16 11:15:35 +01:00
b17422ef1a ENH: use readValueEntry, readMixedEntries for simpler program control 2023-03-08 15:30:04 +00:00
063227baed ENH: support readOption handling for patch fields (base level)
- constructing with valueRequired as a bool is still supported,
  but now also support more refined requirements
  (eg, NO_READ, MUST_READ, LAZY_READ)

- continue with LAZY_READ for finite-area fields
2023-03-07 17:24:28 +00:00
28b492bd54 ENH: unroll loops for complexVector functions
STYLE: prefer STL naming real(), imag() instead of Re(), Im()
2023-02-27 15:41:25 +01:00
d51aa5a74d STYLE: merge EdgeMap definition into edgeHashes.H
STYLE: combine some list typedefs, add documentation comments

GIT: relocate some compat includes
2023-02-27 15:41:25 +01:00
e1a710014c ENH: define lerp field functions
- defined for lerp between two fields,
  either with a constant or a field of interpolation factors.

  * plain Field, DimensionedField, FieldField, GeometricFields

- using a field to lerp between two constants is not currently
  supported
2023-02-21 10:05:27 +01:00
ab10b4a05c EHN: add FieldFunction interface for 0/1 clamping
- enables clamp(field, zero_one{}) returning a tmp Field
2023-02-21 10:05:27 +01:00
6f68ce5239 ENH: update field function macros and 'reuse' field handling
- clearer, more consistent parameter naming, which helps when
  maintaining different field function types (eg, DimensionedFields,
  GeometricFields)

- provide reuseTmpGeometricField::New taking a reference (not a tmp),
  with forwarding. This helps centralise naming and acquisition etc

- split binary function macros into transform/interface
  for easier support of different transform loops.

- initial field macros for looping over ternaries
2023-02-21 10:05:26 +01:00
4d7180ae7c COMP: rename field methods clamp() -> clamp_range()
- this is slightly longer to write (but consistent with clamp_min
  etc). The main reason is that this allows easier use of the clamp()
  free function.

STYLE: skip checks for bad/invalid clamping ranges

- ranges are either already validated before calling, the caller logic
  has already made the branching decision.
2023-02-21 10:05:26 +01:00
0767e21d8c ENH: more consistent convenience macros for creating patchFields 2023-02-20 11:18:29 +01:00
fe4688c27f ENH: patch fields writeValueEntry method (frequently used)
- add base-level readValueEntry, readMixedEntries methods
  that allow optional or mandatory reading.

STYLE: wording for patch fields comments
2023-02-20 11:13:43 +01:00
8b63f64503 STYLE: use std::ostringstream instead of std::to_string for complex
- std::to_string(double) is locale sensitive.
2023-01-31 15:55:21 +01:00
72bfaa2be9 ENH: Field assign and construct from dictionary with readOption
- This simplifies definition of 'lazier' (READ_IF_PRESENT)
  construction or assignment.

  For construction:
    - For MUST_READ and key not found: FatalIOError.
    - For LAZY_READ and key not found: initialise field with Zero.
    - For NO_READ and key not found: simply size the field.

  For assignment:
    - If len == 0 : a no-op and return True.
    - For NO_READ : a no-op and return False.
    - For MUST_READ and key not found : FatalIOError
2023-01-31 12:45:39 +01:00
0190fed56b ENH: support slicing for finiteArea fields 2023-01-31 12:45:38 +01:00
7c60c80edd ENH: new/revised emplace_back() [for DynamicList/List/PtrDynList/PtrList]
- returns reference as per C++17 std::vector

STYLE: drop unused, redundant DynamicField remove() method
2023-01-27 09:50:45 +01:00
ba153df8db ENH: improved handling for clamping
- proper component-wise clamping for MinMax clamp().

- construct clampOp from components

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

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

- top-level checks to skip applying invalid min/max ranges
  and bypass the internal checks of MinMax::clamp() etc.
2023-01-23 14:52:29 +01:00
8a70c898ae STYLE: make IOobject time() noexcept. Use explicit REGISTER/NO_REGISTER 2023-01-23 14:52:29 +01:00
a50d32b587 ENH: define transform(symmTensor, int/float) as no-op
- avoids implicit promotion of label to scalar for no-op,
  or alternatively promotion of symmTensor to tensor for no-op
  (ie, ambiguous).

- fix incorrect transform(.., symmTensor, ...) declarations.
2023-01-23 11:38:54 +01:00
b15638a2d2 ENH: consistent use of resize_nocopy for processor transfers
STYLE: rename some internal buffers with the data types

  low-level  : byteSendBuf_, byteRecvBuf_
  field level: sendBuf_, recvBuf_
  solve level: scalarSendBuf_, scalarRecvBuf_
2023-01-12 21:19:12 +01:00
bf99c104eb ENH: avoid faPatch/fvPatch patchInternalField ambiguity
- with alternative faceCell addressing, use the three-parameter
  version only. This avoids potential future ambiguity with the
  two-parameter version (eg, with a label type)

ENH: add faPatchField patchInternalField() for symmetry with fvPatchField

ENH: direct reference to mesh thisDb instead of inferring

ENH: pointMesh::boundaryMesh() method (eg, similar to fvMesh)
2023-01-12 21:19:12 +01:00
2d4ecc4326 GIT: remove unnecessary PatchField Fwd headers
- reduces clutter. In some cases the Fwd typedefs were also incorrect

STYLE: combine Scalar specialisations into corresponding PatchFields.C

- reduces clutter, simplifies future adjustments
2023-01-12 21:19:12 +01:00
248e5ff86f ENH: simpler logic for doTransform() check
- test pTraits rank first (compile-time) and then parallel()
2023-01-11 13:16:14 +01:00
33c9df7741 ENH: construct DynamicField, DynamicList from subset of elements
STYLE: inline some size(), empty() members
2023-01-11 13:15:56 +01:00
9b379398c5 ENH: tensor-symmTensor: new pseudo-inverse function
REVERT: add heuristic handling of tensor-field inverses - simplify algorithm
2022-12-07 13:17:26 +00:00
3151dacccc ENH: include <algorithm> in stdFoam.H
- was already included in many places (via UList.C templates), but now
  formalise by placing in stdFoam.H
2022-12-01 15:52:48 +00:00
e190df9033 ENH: inv: fall back to pseudo-inverse for singular tensors
- remove heuristic handling of tensor-field inverses
2022-11-30 12:24:32 +00:00
3f87aec01a ENH: improve construct UniformDimensionedFields from components
- ensure that the name is non-empty.
- allow construct from IOobject, dimensions and value

ENH: gravity lookup accessors
2022-11-25 12:48:45 +01:00