Commit Graph

100 Commits

Author SHA1 Message Date
53af711c6a ENH: simplify assign zero for Dimensioned and Geometric fields (#3402)
- regular or forced assignment from `zero` does not need dimension
  checking:

    Old:  U = dimensionedVector(U.dimensions(), Zero);
    New:  U = Zero;

  this eliminates a fair bit of clutter and simplifies new coding
  without losing general dimension checking capabilities.
2025-07-30 09:29:53 +02:00
1078234f18 ENH: Added new bladeForces function object
Calculates thrust, drag, torque and lift/drag/pressure coefficients
of single or multiple blades (eg, propeller, turbine blades)

This function object differs from the propellerInfo and forces
function objects in that all forces are calculated within the local
cylindrical coordinate system, which yields thrust and drag values
within the expected reference frame.

The output comprises:
- coefficients per radial bin
- area-weighted total coefficients
- integrated forces and torque

For convenient post-processing, the results are also written in a VTK
(.vtp) output format. All surface results are registered internally,
which makes them available for other function objects.
2025-06-18 21:16:03 +02:00
9bc6f2f91f ENH: support 'rpm' input for propeller functionObject (as per rotorDisk)
- update code style for forces/propeller.
- simplify coordinate handling in propeller functionObject
2025-06-10 10:32:03 +02:00
20b2f46315 STYLE: prefer listReduce() to using listCombineReduce() when possible
- potentially allows access into the builtin MPI operations
2025-03-06 16:54:31 +01:00
1bce1e44c4 ENH: propellerInfo - updated to work in postProcess mode. Fixes #2588 2024-06-07 12:36:59 +01:00
71d4a23ec0 ENH: use tmp field factory methods [6] (#2723)
- src/functionObjects
2024-02-21 14:31:40 +01:00
ac574a6ccb STYLE: use static call for regIOobject::store (#1507) 2024-02-20 16:56:22 +01: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
ed314b2740 ENH: use sorted order for patch IDs in fieldFunctionObjects (#2819)
- replaces labelHashSet with a sorted labelList to ensure that patches
  will be processed in consistent order in parallel
2023-07-31 20:11:32 +02:00
5397c9ac04 COMP: use csorted() instead of sorted() 2023-07-31 20:11:32 +02:00
945e3e41b1 ENH: more consistent use of good() or direct testing instead valid() 2023-07-27 16:52:03 +02:00
59b1cf080e ENH: Tensor/SymmTensor: add devSymm and devTwoSymm funcs to avoid intermediates 2023-05-15 17:05:10 +01:00
f98ecb38dc ENH: forces: avoid redundant volumetric operations 2023-05-15 17:05:10 +01:00
ee39e3d276 STYLE: use explicit REGISTER option when storing fields 2023-04-25 13:45:08 +02:00
ac4f580d09 ENH: cleanup treeData items (#2609)
Changes / Improvements

- more consistent subsetting, interface

  * Extend the use of subset and non-subset collections with uniform
    internal getters to ensure that the subset/non-subset versions
    are robustly handled.

  * operator[](label) and objectIndex(label) for standardized access
    to the underlying item, or the original index, regardless of
    subsetting or not.

  * centres() and centre(label) for representative point cloud
    information.

  * nDim() returns the object dimensionality (0: point, 1: line, etc)
    these can be used to determine how 'fat' each shape may be
    and whether bounds(labelList) may contribute any useful information.

  * bounds(labelList) to return the full bound box required for
    specific items. Eg, the overall bounds for various 3D cells.

- easier construction of non-caching versions. The bounding boxes are
  rarely cached, so simpler constructors without the caching bool
  are provided.

- expose findNearest (bound sphere) method to allow general use
  since this does not actually need a tree.

- static helpers

  The boxes() static methods can be used by callers that need to build
  their own treeBoundBoxList of common shapes (edge, face, cell)
  that are also available as treeData types.

  The bounds() static methods can be used by callers to determine the
  overall bound-box size prior to constructing an indexedOctree
  without writing ad hoc code inplace.

  Not implemented for treeDataPrimitivePatch since similiar
  functionality is available directly from the PrimitivePatch::box()
  method with less typing.

========
BREAKING: cellLabels(), faceLabels(), edgeLabel() access methods

- it was always unsafe to use the treeData xxxLabels() methods without
  subsetting elements. However, since the various classes
  (treeDataCell, treeDataEdge, etc) automatically provided
  an identity lookup, this problem was not apparent.

  Use objectIndex(label) to safely de-reference to the original index
  and operator[](index) to de-reference to the original object.
2022-11-24 12:21:01 +00:00
5b29ff0e42 ENH: consolidate 'formatOptions' handling for coordSetWriter/surfaceWriter
- replaced ad hoc handling of formatOptions with coordSetWriter and
  surfaceWriter helpers.

  Accompanying this change, it is now possible to specify "default"
  settings to be inherited, format-specific settings and have a
  similar layering with surface-specific overrides.

- snappyHexMesh now conforms to setFormats

  Eg,

      formatOptions
      {
          default
          {
              verbose     true;
              format      binary;
          }
          vtk
          {
              precision   10;
          }
     }

     surfaces
     {
         surf1
         {
             ...

             formatOptions
             {
                 ensight
                 {
                     scale   1000;
                 }
             }
         }
     }
2022-11-08 16:48:08 +00:00
473e14418a ENH: more consistent use of broadcast, combineReduce etc.
- broadcast           : (replaces scatter)
  - combineReduce       == combineGather + broadcast
  - listCombineReduce   == listCombineGather + broadcast
  - mapCombineReduce    == mapCombineGather + broadcast
  - allGatherList       == gatherList + scatterList

  Before settling on a more consistent naming convention,
  some intermediate namings were used in OpenFOAM-v2206:

    - combineReduce       (2206: combineAllGather)
    - listCombineReduce   (2206: listCombineAllGather)
    - mapCombineReduce    (2206: mapCombineAllGather)
2022-11-08 16:48:08 +00:00
3c214e99df ENH: propellerInfo - protection against Uref = 0 2022-11-03 09:43:39 +00:00
7b2bcfda0b ENH: improved handling of coordinateSystems
- in continuation of #2565 (rotationCentre for surface output formats)
  it is helpful to also support READ_IF_PRESENT behaviour for the
  'origin' keyword.

  This can be safely used wherever the coordinate system definition
  is embedded within a sub-dictionary scope.

  Eg,
      dict1
      {
          coordinateSystem
          {
              origin (0 0 0);  // now optional here
              rotation ...;
          }
      }

   but remains mandatory if constructed without a sub-dict:

      dict2
      {
          origin (0 0 0);   // still mandatory
          e1  (1 0 0);
          e3  (0 0 1);
      }

   With this change, the "transform" sub-dictionary can written
   more naturally:

       formatOptions
       {
           vtk
           {
               scale 1000;  // m -> mm
               transform
               {
                   rotationCentre  (1 0 0);
                   rotation axisAngle;
                   axis    (0 0 1);
                   angle   -45;
               }
           }
       }

ENH: simplify handling of "coordinateSystem" dictionary lookups

- coordinateSystems::NewIfPresent method for optional entries:

    coordSysPtr_ = coordinateSystem::NewIfPresent(mesh, dict);

  Instead of

    if (dict.found(coordinateSystem::typeName, keyType::LITERAL))
    {
        coordSysPtr_ =
            coordinateSystem::New
            (
                mesh_,
                dict,
                coordinateSystem::typeName
            );
    }
    else
    {
        coordSysPtr_.reset();
    }

ENH: more consistent handling of priorities for binModels, forces (#2598)

- if the dictionaries are overspecified, give a 'coordinateSystem'
  entry a higher prioriy than the 'CofR' shortcuts.

  Was previously slightly inconsistent between the different models.
2022-10-04 15:51:27 +02:00
f87f0040b8 ENH: writeFile - add newFile function
ENH: writeFile - renamed createFile functions
     to newFileAtTime and newFileAtStartTime
2022-10-04 13:10:39 +00:00
0b37234804 Merge remote-tracking branch 'origin/master' into develop 2022-09-07 16:24:54 +02:00
4965dc4cfb COMP: declare forceCoeffs operator<< in Foam namespace (fixes #2576) 2022-09-07 16:00:50 +02:00
5218bfd721 Merge remote-tracking branch 'origin/master' into develop 2022-08-19 12:50:50 +02:00
f249022bfe ENH: binModel: make decomposePatchValues entry optional (#2530)
DOC: forceCoeffs: correct the header file content (#2530)
2022-08-09 15:58:40 +01:00
9f40db8977 BUG: forceCoeffs: correct the order of pressure and viscous components (fixes #2552) 2022-08-02 16:59:41 +01:00
307e380f8f BUG: forces/forceCoeffs - fields to be owned by mesh. See #2511 2022-06-21 12:09:24 +01:00
e96990c8bf DOC: Doxygen corrections 2022-06-17 11:49:23 +01:00
6a4f7c9c68 ENH: forces/forceCoeffs: refactor function objects
- enables runtime selection of operand coefficients by 'coefficients' entry
- removes binning - now handled using the new 'binField' FO

Co-authored-by: Kutalmis Bercin <kutalmis.bercin@esi-group.com>
2022-06-09 09:32:53 +00:00
d38de84d21 ENH: bundle Pstream:: AllGather methods
- bundles frequently used 'gather/scatter' patterns more consistently.

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

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

STYLE: PstreamCombineReduceOps.H is mostly unneeded now
2022-03-31 15:56:04 +02:00
62fc3bbc33 STYLE: broadcast instead of combineScatter/listCombineScatter/mapCombineScatter
- these are the same thing now and 'broadcast' expresses the intention
  more directly/consistently
2022-03-12 21:16:30 +01:00
734a3143dc ENH: Added new propellerInfo function object
Calculates propeller performance and wake field properties.

Controlled by executeControl:
- Propeller performance
  - Thrust coefficient, Kt
  - Torque coefficient, 10*Kq
  - Advance coefficient, J
  - Open water efficiency, etaO
  - Written to postProcessing/<name>/<time>/propellerPerformance.dat

Controlled by writeControl:
- Wake field text file
  - Wake: 1 - UzMean/URef
  - Velocity in cylindrical coordinates at xyz locations
  - Written to postProcessing/<name>/<time>/wake.dat
- Axial wake field text file
  - 1 - Uz/URef at r/R and angle
  - Written to postProcessing/<name>/<time>/axialWake.dat
- Velocity surface
  - Written to postProcessing/<name>/surfaces/time>/disk.<fileType>

Usage

    Example of function object specification:
    \verbatim
    propellerInfo1
    {
        type            propellerInfo;
        libs            (forces);
        writeControl    writeTime;

        patches         ("propeller.*");

        URef            5; // Function1 type; 'constant' form shown here
        rho             rhoInf; // incompressible
        rhoInf          1.2;

        // Optionally write propeller performance data
        writePropellerPerformance yes;

        // Propeller data:

        // Radius
        radius          0.1;

        rotationMode    specified; // specified | MRF

        // rotationMode = specified:
        origin          (0 -0.1 0);
        n               25.15;
        axis            (0 1 0);

        // Optional reference direction for angle (alpha) = 0
        alphaAxis       (1 0 0);

        //// rotationMode = mrf
        //// MRF             MRFZoneName;
        //// (origin, n and axis retrieved from MRF model)

        // Optionally write wake text files
        // Note: controlled by writeControl
        writeWakeFields yes;

        // Sample plane (disk) properties
        // Note: controlled by writeControl
        sampleDisk
        {
            surfaceWriter   vtk;
            r1              0.05;
            r2              0.2;
            nTheta          36;
            nRadial         10;
            interpolationScheme cellPoint;
            errorOnPointNotFound false;
        }
    }
    \endverbatim

    Where the entries comprise:
    \table
        Property        | Description                   | Required | Deflt value
        type            | Type name: propellerInfo      | yes      |
        log             | Write to standard output      | no       | no
        patches         | Patches included in the forces calculation | yes |
        p               | Pressure field name           | no       | p
        U               | Velocity field name           | no       | U
        rho             | Density field name            | no       | rho
        URef            | Reference velocity            | yes      |
        rotationMode    | Rotation mode (see below)     | yes      |
        origin          | Sample disk centre            | no*      |
        n               | Revolutions per second        | no*      |
        axis            | Propeller axis                | no*      |
        alphaAxis       | Axis that defines alpha=0 dir | no       |
        MRF             | Name of MRF zone              | no*      |
        originOffset    | Origin offset for MRF mode    | no       | (0 0 0)
        writePropellerPerformance| Write propeller performance text file | yes |
        writeWakeFields | Write wake field text files   | yes      |
        surfaceWriter   | Sample disk surface writer    | no*      |
        r1              | Sample disk inner radius      | no       | 0
        r2              | Sample disk outer radius      | no*      |
        nTheta          | Divisions in theta direction  | no*      |
        nRadial         | Divisions in radial direction | no*      |
        interpolationScheme | Sampling interpolation scheme | no* | cell
    \endtable

Note
- URef is a scalar Function1 type, i.e. supports constant, table, lookup values
- rotationMode is used to set the origin, axis and revolutions per second
  - if set to 'specified' all 3 entries are required
    - note: origin is the sample disk origin
  - if set to 'MRF' only the MRF entry is required
    - to move the sample disk away from the MRF origin, use the originOffset
- if writePropellerPerformance is set to on|true:
  - propellerPerformance text file will be written
- if writeWakeFields is set to on|true:
  - wake and axialWake text files will be written
- if the surfaceWriter entry is set, the sample disk surface will be written
  - extents set according to the r1 and r2 entries
  - discretised according to the nTheta and nRadial entries
2021-12-14 16:45:03 +00:00
53e9c8eb5a ENH: forces|Coeffs FO - updated coordinate system 2021-12-03 13:48:33 +00:00
c233961d45 ENH: function objects - apply scoped name when registering objects 2021-11-26 11:22:36 +00:00
a870be6511 BUG: forces: ensure UName entry can be used (fixes #2093)
Previously, for basic incompressible and compressible simulations,
the "force" function object has not been using the user-specified "UName"
for the "devRhoReff" computation (affecting the tangential component),
but using the "U" of the latest available step. In contrast,
the user-specified "pName" has always been being used correctly.

This has been causing issues for users when they wish to use a specific
"UMean" field in various force and forceCoeff function object computations.
2021-08-05 12:40:47 +00: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
01ec92fd35 GIT: remove leading/trailing blank lines, trailing whitespace 2020-06-17 10:46:26 +02:00
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
997c9a232c STYLE: use compact form for libs () entries 2020-05-23 18:42:47 +02:00
8cfb483054 STYLE: some general spelling fixes 2020-05-04 09:15:21 +02:00
2a24bab057 STYLE: consistent looping of patchSet entries 2020-05-01 17:31:01 +02:00
86e78ac3c1 BUG: forces - corrected moment field calculation 2020-04-09 10:00:43 +01:00
31aad2159f STYLE: writeFile - renamed writeTime to writeCurrentTime to avoid conflicts 2019-09-09 09:19:38 +01:00
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
3f955cac07 STYLE: Updated header documentation 2019-06-19 11:32:53 +01:00
e184e1e72c ENH: Updated function object reading and output messages 2019-06-18 13:55:16 +01:00
aa1a0a85fa ENH: Forces function object - updated header documentation 2019-06-14 11:38:06 +01:00
58471a332b ENH: Forces function object - more feedback at run-time for user field selections 2019-02-20 12:37:17 +00:00
17260280a4 ENH: Forces function object - user can now select bin limits 2019-02-20 12:36:37 +00:00
a1f9256829 ENH: extend header documentation for forceCoeffs 2019-06-11 16:19:37 +01:00
65f3faa203 WIP: Refactored forces/Coeffs to always use a co-ord system and simplified inputs [UNCHECKED] 2019-06-11 11:57:22 +01:00