Compare commits

..

153 Commits

Author SHA1 Message Date
82c405882d ENH: fvPatch: allow explicit coupled provision for any patch. 2021-12-14 16:07:18 +00:00
c46216e645 COMP: Added missed file 2021-12-10 15:43:22 +00:00
7da2a5e096 ENH: redistributePar: reconstruct mode in collated. Fixes #2194 2021-12-10 15:24:04 +00:00
33b2e0df3d Merge branch 'feature-fvExpressionField' into 'develop'
New "exprField" function object

See merge request Development/openfoam!516
2021-12-10 14:46:33 +00:00
8d4ad0438d ENH: add exprField function object
- provides a simple means of defining/modifying fields. For example,

  ```
  <name1>
  {
      type    exprField;
      libs    (fieldFunctionObjects);
      field   pTotal;

      expression  "p + 0.5*(rho*magSqr(U))";
      dimensions  [ Pa ];
  }
  ```
  It is is also possible to modify an existing field.
  For example, to modify the previous one.
  ```
  <name2>
  {
      type    exprField;
      libs    (fieldFunctionObjects);
      field   pTotal;
      action  modify;

      // Static pressure only in these regions
      fieldMask
      #{
          (mag(pos()) < 0.05) && (pos().y() > 0)
       || cellZone(inlet)
      #};
      expression  "p";
  }
  ```

  To use as a simple post-process calculator, simply avoid storing the
  result and only generate on write:
  ```
  <name2>
  {
      store            false;
      executionControl none;
      writeControl     writeTime;
      ...
  }
  ```
2021-12-10 14:46:21 +00:00
a6cbfcb9ba STYLE: qualify expression debug flags
- for debug/tracing handle the following keywords:

   * debug.driver   (was "debugBaseDriver")
   * debug.scanner  (was "debugScanner")
   * debug.parser   (was "debugParser")
2021-12-10 14:46:21 +00:00
510ffb3322 ENH: code reduction, improvements for expressions
- literal lookups only for expression strings

- code reduction for setExprFields.

- changed keyword "condition" to "fieldMask" (option -field-mask).
  This is a better description of its purpose and avoids possible
  naming ambiguities with functionObject triggers (for example)
  if we apply similar syntax elsewhere.

BUG: erroneous check in volumeExpr::parseDriver::isResultType()

- not triggered since this method is not used anywhere
  (may remove in future version)
2021-12-10 14:46:21 +00:00
39f6618d3a TUT: counterFlowFlame2D - corrected CH4 fraction. Fixes #2292 2021-12-10 14:34:05 +00:00
6be31e3feb ENH: pimpleFoam - added LTS support 2021-12-10 14:34:05 +00:00
af0b20779e Merge branch 'issues-2021-2' into 'develop'
BUG: 2021-2: Various bug fixes and developments

See merge request Development/openfoam!492
2021-12-09 18:49:20 +00:00
cad325f41f BUG: icoReactingMultiphaseInterFoam: enable phasesSystem surface tension models (Fixes #2228) 2021-12-09 18:49:02 +00:00
de90b2b28e BUG: rotateMesh: prevent double rotations (Fixes #2186) 2021-12-09 18:49:02 +00:00
8ac0548c6a BUG: solidificationMeltingSource: allow topology changes (Fixes #2026) 2021-12-09 18:49:02 +00:00
c8db0d135f BUG: solitaryWaveModel: avoid reference access to an operand object (Fixes #2178) 2021-12-09 18:49:02 +00:00
b053e2214c BUG: LESdelta: avoid double object registrations (Fixes #1171) 2021-12-09 18:49:02 +00:00
0c20256be5 BUG: LiquidEvapFuchsKnudsen: add missing particle surface area (Fixes #2069) 2021-12-09 18:49:02 +00:00
ae555ec744 BUG: alphatWallBoilingWallFunction: remove redundant phaseType=vapor entries (Fixes #2243) 2021-12-09 18:49:02 +00:00
ee955b19e5 STYLE: snappyHexMeshDict: remove excess entries 2021-12-09 17:09:34 +00:00
5b61013cf5 Merge branch 'feature-casting-oxide' into 'develop'
ENH: interfaceOxideRate: new mass transfer model for icoReactingMultiphaseInterFoam solver

See merge request Development/openfoam!510
2021-12-09 17:05:23 +00:00
1fca0d8d23 TUT: icoReactingMultiphaseInterFoam: new tutorial oxideFormation
Co-authored-by: sergio <s.ferraris@opencfd.co.uk>
2021-12-09 17:04:10 +00:00
60f3d416a6 ENH: InterfaceCompositionModels: add new thermo types for oxidation mass model 2021-12-09 17:04:10 +00:00
402bc0fef0 ENH: multiphaseSystem: add alpha1 boundary manipulation 2021-12-09 17:04:10 +00:00
437ea6917a ENH: timeVaryingMassSorption: new boundary condition for icoReacting solvers
Co-authored-by: Kutalmis Bercin <kutalmis.bercin@esi-group.com>
2021-12-09 17:04:10 +00:00
ea9d424e24 ENH: interfaceOxideRate: New mass transfer model
Based on:

    Cao, L., Sun, F., Chen, T., Tang, Y., & Liao, D. (2018).
    Quantitative prediction of oxide inclusion defects inside
    the casting and on the walls during cast-filling processes.
    International Journal of Heat and Mass Transfer, 119, 614-623.
    DOI:10.1016/j.ijheatmasstransfer.2017.11.127

Co-authored-by: Kutalmis Bercin <kutalmis.bercin@esi-group.com>
2021-12-09 17:04:10 +00:00
6580f1bbef ENH: interfaceCompositionModel: refactor Tactivate and includeDivU funcs 2021-12-09 17:04:10 +00:00
142fc55f44 TUT: icoReactingMultiphaseInterFoam: correct the directory name 2021-12-09 17:04:10 +00:00
f67406ddb2 Merge branch 'feature-liquidFilm' into 'develop'
ENH: New liquid film features

See merge request Development/openfoam!508
2021-12-09 17:02:18 +00:00
e479f842b3 ENH: liquidFilmModel: change default write option to NO_WRITE for few fields 2021-12-09 17:01:46 +00:00
b69ceb54a7 ENH: Adding shear stress to the film from the wall function
TUT: inclinedPlaneFilm/pitzDailyWithSprinklers: add shearStress model
2021-12-09 17:01:46 +00:00
9e8fd66ed2 BUG: faOption-limitVelocity: remove remnants of fvOption
COMP: ensure compilation of faOption-limitVelocity
2021-12-09 17:01:46 +00:00
eabafe5f9e BUG: filmTurbulenceModel: fix film friction models
STYLE: filmTurbulenceModel: add default destructor
2021-12-09 17:01:46 +00:00
9024441566 ENH: iglooWithFridges: demonstrate threaded, collated handling. See #2194. 2021-12-09 16:33:26 +00:00
c3c23c3cb2 ENH: allow top-level definition of function object name scoping
- this refines commit c233961d45, which added prefix scoping.

  Default is now off (v2106 behaviour).

  The 'useNamePrefix' keyword can be specified on a per function basis
  or at the top-level of "functions".

  ```
      functions
      {
          errors          warn;
          useNamePrefix   true;

          func1
          {
              type  ...;
              useNamePrefix   false;
          }

          func2
          {
              type  ...;
              // Uses current default for useNamePrefix
          }
      }
  ```
2021-12-09 15:42:51 +01:00
638d1fe8f6 BUG: blockMesh verbosity set too late
- sort out the command-line vs dictionary vs default logic *before*
  constructing any other members since they too are influenced by the
  verbosity.
2021-12-09 15:42:51 +01:00
fde3904796 GIT: relocate PrecisionAdaptor to memory/ 2021-12-09 15:42:51 +01:00
698ff5eedc STYLE: inherit SubField from FieldBase instead of refCount
- at the moment there is no significant difference since FieldBase is
  essentially just a refCount anyhow, but changing the inheritance
  ensures that reinterpret casting from SubField -> Field will
  continue to work if FieldBase is changed in the future.
2021-12-09 15:42:51 +01:00
efb187e3f7 ENH: support optional dimensionSet reading 2021-12-09 15:42:46 +01:00
8c98906780 ENH: MRFZone|List - enable re-reading; code clean-up 2021-12-09 13:33:13 +00:00
d7f7267165 Merge branch 'fix-2291-patchProbes' into 'develop'
ENH: patchProbes: output patch. Fixes #2291.

See merge request Development/openfoam!515
2021-12-09 09:23:00 +00:00
f19883c0c6 ENH: patchProbes: output patch. Fixes #2291. 2021-12-09 09:20:19 +00:00
aaf4f40bf7 Merge branch 'feature-adjoint-smoothed-sensitivity-map' into 'develop'
Added functionality for smoothing the sensitivity derivatives

See merge request Development/openfoam!504
2021-12-09 09:18:36 +00:00
f6dfa76f6d TUT: updated the motorbike tutorial
to also compute smoothed sensitivity maps
2021-12-09 09:18:02 +00:00
90d62c33e4 INT: Minor integration updates 2021-12-09 09:18:02 +00:00
3ef0d19ef4 ENH: added functionality for smoothing the sensitivity derivatives
A Helmholtz-like filter is applied to the original field of sensitivity
derivatives. The corresponding PDE is solved on the sensitivity patches,
using the finite area infrastructure. A smoothing radius is needed,
which is computed based on the average 'length' of the boundary faces,
if not provided by the user explicitly.

If an faMesh is provided, it will be used; otherwise it will be created
on the fly based on either an faMeshDefinition dictionary in system or
one constructed internally based on the sensitivity patches.
2021-12-09 09:18:02 +00:00
0343d3d7e9 Merge branch 'feature-nonorthogonal-correction-schemes' into 'develop'
ENH: New schemes for non-orthogonal meshes

See merge request Development/openfoam!502
2021-12-08 12:08:01 +00:00
ada3d1c77e TUT: nonOrthogonalChannel: new non-orthogonality test case 2021-12-08 12:07:26 +00:00
86da88cdfd ENH: Added relaxed nonOrthogonal laplacian corrector scheme 2021-12-08 12:07:26 +00:00
391c1eaa40 ENH: snGradSchemes: new scheme relaxedSnGrad
Surface gradient scheme with under-/over-relaxed
full or limited explicit non-orthogonal correction.

A minimal example by using system/fvSchemes:

  snGradSchemes
  {
      snGrad(<term>)       relaxed;
  }

and by using system/fvSolution:

  relaxationFactors
  {
      fields
      {
          snGrad(<term>)   <relaxation factor>;
      }
  }
2021-12-08 12:07:26 +00:00
37a6fc8db3 STYLE: snGradSchemes: modernise and clean up code
ENH: removes an unused scalarField from skewCorrectedSnGrad

DOC: snGradSchemes: improve header-file documentation
2021-12-08 12:07:26 +00:00
96821f70cd Merge branch 'feature-skew-corrected-gradient' into 'develop'
ENH: New gradient scheme iterativeGaussGrad

See merge request Development/openfoam!500
2021-12-08 11:05:43 +00:00
cac0bf856b TUT: skewnessCavity: new skewness test case 2021-12-08 11:05:06 +00:00
adf6869bba ENH: gradSchemes: new gradient scheme iterativeGaussGrad
A second-order gradient scheme using face-interpolation,
Gauss' theorem and iterative skew correction.

Minimal example by using system/fvSchemes:

  gradSchemes
  {
    grad(<term>) iterativeGauss <interpolation scheme> <number of iters>;
  }
2021-12-08 11:05:06 +00:00
563456087c STYLE: gradSchemes: modernise and clean up code 2021-12-08 11:05:06 +00:00
41b30af01a TUT: pisoFoam/RAS/cavity - updated FOreference 2021-12-08 10:00:46 +00:00
f6ccd77d8c BUG: sampledSets - ensure results are written on all procs 2021-12-07 21:09:14 +00:00
65bc8d1140 STYLE: remove local version of momentum::scopedName
BUG: incorrect return for unscoped functionObject name
2021-12-07 15:48:19 +01:00
b25e1486de CONFIG: adjust paraview libs, intelmpi handling
- fix overly aggressive match in the API value

- allow `INTELMPI*` generic value, this can be used to specify something
  like INTELMPI_custom and populate the corresponding wmake rule
  manually

STYLE: mention FOAM_BUILDROOT in wmake -help-full output

STYLE: adjust openfoam shell session welcome information

- adjust internal variable names to reduce collision potential

- improve handling of openfoam -etc=...
2021-12-07 15:22:32 +01:00
810d0c72ee Merge branch 'feature-sampled-sets-extension' into 'develop'
sampledSets - enable writer construction from dictionary; glTF export

See merge request Development/openfoam!503
2021-12-06 13:14:09 +00:00
34b4770949 TUT: Added glTF export example for field and track data 2021-12-06 12:26:49 +01:00
85b405206d ENH: Added new glTF sammpled set writer
Description
    Writes point data in glTF v2 format

    Two files are generated:
    - filename.bin  : a binary file containing all scene entities
    - filename.gltf : a JSON file that ties fields to the binary data

    The output can contain both geometry and fields, with additional support
    for colours using a user-supplied colour map, and animation of particle
    tracks.

    Controls are provided via the optional formatOptions dictionary.

    For non-particle track data:

    \verbatim
    formatOptions
    {
        // Apply colours flag (yes | no ) [optional]
        colours     yes;

        // List of options per field
        fieldInfo
        {
            p
            {
                // Colour map [optional]
                colourMap       <colourMap>;

                // Colour map minimum and maximum limits [optional]
                // Uses field min and max if not specified
                min             0;
                max             1;

                // Alpha channel [optional] (uniform | field)
                alpha           uniform;
                alphaValue      0.5;

                //alpha           field;
                //alphaField      T;
                //normalise       yes;
            }
        }
    }
    \verbatim

    For particle tracks:

    \verbatim
    formatOptions
    {
        // Apply colours flag (yes | no) [optional]
        colours     yes;

        // Animate tracks (yes | no) [optional]
        animate     yes;

        // Animation properties [optional]
        animationInfo
        {
            // Colour map [optional]
            colourMap       <colourMap>;

            // Colour [optional] (uniform | field)
            colour          uniform;
            colourValue     (1 0 0); // RGB in range [0-1]

            //colour          field;
            //colourField     d;

            // Colour map minimum and maximum limits [optional]
            // Note: for colour = field option
            // Uses field min and max if not specified
            min             0;
            max             1;

            // Alpha channel [optional] (uniform | field)
            alpha           uniform;
            alphaValue      0.5;

            //alpha           field;
            //alphaField      T;
            //normalise       yes;
        }
    }
    \endverbatim

Note
    When writing particle animations, the particle field and colour properties
    correspond to initial particle state (first data point) and cannot be
    animated (limitation of the file format).

    For more information on the specification see
    https://www.khronos.org/registry/glTF/
2021-12-06 12:26:49 +01:00
0f155daf86 ENH: particleTracks - updated to include field data
The utility will now add field data to all tracks (previous version only
created the geometry)

The new 'fields' entry can be used to output specific fields.

Example

    cloud           reactingCloud1;

    sampleFrequency 1;

    maxPositions    1000000;

    fields          (d U); // includes wildcard support

STYLE: minor typo fix
2021-12-06 12:26:49 +01:00
98c25d163a ENH: sampledSets - enable writer construction from dictionary
Users can now include additional controls via a new formatOptions dictionary.
2021-12-06 12:26:48 +01:00
e5267bf81d ENH: sampledSetWriters - updated writing of particle tracks 2021-12-06 12:26:48 +01:00
79fafda22c ENH: Cloud - added function to read cloud fields from disk to obr 2021-12-06 12:26:48 +01:00
f5f93e81d8 COMP: temperatureCoupledBase: make API consistent. Fixes #2287. 2021-12-06 10:54:43 +00:00
29f7fcc515 COMP: workaround clang-13 optimization issue (vtk handling) 2021-12-03 21:23:44 +01:00
9a5125111e ENH: add coded Function1 (#2282)
- update coded templates with qualified names

GIT: add in missing PatchFunction1 constant() method

- was missed in a previous commit
2021-12-03 20:56:10 +01:00
8624d65c5a ENH: support alternative build-root location (#2286)
- specify any of these

    ./Allwmake -build-root=...
    wmake -build-root=...
    FOAM_BUILDROOT=... wmake

  these specify an alternative root where build artifacts are to land.
  Currently only used as an alternative for the 'build/' hierarchy
  since the 'platforms/' target normally includes inputs as well.

  Possible use:
  ```
  (
      export WM_MPLIB="%{foam_mplib}"
      export FOAM_MPI="%{foam_mpi}"
      export MPI_ARCH_PATH="%{mpi_prefix}"

      export FOAM_BUILDROOT=/tmp/mpibuild
      export FOAM_MPI_LIBBIN="$FOAM_BUILDROOT/platforms/$WM_OPTIONS/lib/$FOAM_MPI"

      src/Pstream/Allwmake-mpi
   )
   ```
2021-12-03 17:10:22 +01:00
27e57c29f7 BUG: dangling dictionary reference for expression BCs
- exposed by the new embedded function handling.

  Requires local copies of dictionary content instead
  (similar to coded BCs handling)

BUG: incorrect formatting for expression function output

ENH: simpler copyDict version taking wordList instead of wordRes

- corresponds to the most common use case at the moment

ENH: expression string writeEntry method

- write as verbatim for better readability
2021-12-03 17:10:22 +01:00
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
49e26dd7d2 ENH: consistent specification of fan conditions (fixes #2279) 2021-12-03 17:10:22 +01:00
31a7c2a9cd ENH: initial use of ReactionTable to wrap information 2021-12-03 17:10:22 +01:00
c7f30a0989 STYLE: use Hash<word> instead of string::hasher for runTimeSelectionTables 2021-12-03 15:55:19 +01:00
bdf77bbdd1 ENH: simplify hashing overloads of string-types
- this revises the changes made in 95cd8ee75c to replace the
  SFINAE-type of handling of string hashes with direct definitions.

  This places a bit more burden on the developer if creating hashable
  classes derived from std::string or variants of Foam::string, but
  improves reliability when linking.

STYLE: drop template key defaulting from HashSet

- this was never used and `HashSet<>` is much less transparent
  than writing `HashSet<word>` or `wordHashSet`
2021-12-03 15:55:19 +01:00
939c335504 INT: liquidProperties: support for user defined liquid properties (#2141)
- Generic thermophysical properties class for a liquid in which the
  functions and coefficients for each property are run-time selected.

  Code adapted from openfoam.org
2021-12-03 15:54:48 +01:00
e9054ec636 COMP: consistent FatalError/FatalIOError exit types
STYLE: hostName() is short name, don't need parameter
2021-12-03 15:32:37 +01:00
ed5dee71a4 BUG: ccm region merge fails (fixes #2048)
- had lookups into the merge-point map instead of
  determining/remapping the duplicate points directly.
  The result was a jumble of face/point addressing.

STYLE: additional debug/verbosity comment for mergePoints
2021-12-03 15:32:37 +01:00
e6f4ae927a LINT: script not marked as bash-specific
CONFIG: cleanup additional build-related env variables
2021-12-03 15:32:37 +01:00
8ed6a61106 CONFIG: set API level to 2109
- Function1, sampledSets, expressions, runTime selection tables
2021-12-03 15:32:37 +01:00
78cc5f8676 SUBMODULE: entries marked as removable, compilation fixes 2021-12-03 15:32:37 +01:00
f7c7fa94a3 ENH: add Function1 constant() member
- marks if the value is considered to be independent of 'x'.
  Propagate into PatchFunction1 instead ad hoc checks there.

- adjust method name in PatchFunction1 to 'whichDb()' to reflect
  final changes in Function1 method names.

ENH: add a Function1 'none' placeholder function

- This is principally useful for interfaces that expect a Function1
  but where it is not necessarily used by a particular submodel.

TUT: update Function1 creation to use objectRegistry
2021-12-03 15:32:37 +01:00
b96cef1339 ENH: [sampled]DistanceSurface - added construct from searchableSurface 2021-12-03 13:48:34 +00:00
9cf26ac7c5 BUG: InjectionModel::findCellAtPosition - celli can be zero 2021-12-03 13:48:34 +00:00
9833e614da BUG: surfaceAlignedSBRStressFvMotionSolver - corrected units (see #2265)
Note - this resolves the reported dimensions error, but it is not clear
if this code (has ever?) run or if this change is appropriate...
2021-12-03 13:48:34 +00:00
6aa608cf33 ENH: MRF - exposed origin and axis; added lookup from name 2021-12-03 13:48:33 +00:00
53e9c8eb5a ENH: forces|Coeffs FO - updated coordinate system 2021-12-03 13:48:33 +00:00
8fc4501c46 Merge branch 'feature-turbulentTemperature_Function1' into 'develop'
ENH: coupling BC: allow Function1. Fixes #2277.

See merge request Development/openfoam!507
2021-12-02 18:03:17 +00:00
29c70e9bbb ENH: coupling BC: allow Function1. Fixes #2277. 2021-12-02 18:03:16 +00:00
6abbcb3eac BUG: GAMG: processorAgglomerator crashes. Fixes #2281.
Problem was extending the storage, copying the
original contents.
2021-11-29 14:44:24 +00:00
2880a54373 Merge branch 'feature-expr-improvements' into 'develop'
Updates for expressions to improve robustness and support functions, external context etc.

See merge request Development/openfoam!501
2021-11-26 12:16:45 +00:00
c0adccf826 ENH: generalize volField lookups to include 'context' objects
- allows an additional HashTable of pointers to reference external
  content which not otherwise directly available via an
  objectRegistry.

  This could typically be used to provide a function-local "rho"
  to the expression evaluation.
2021-11-26 12:24:35 +01:00
643763d258 ENH: add cell/face set/zone support for patch expressions
- for cell quantities, these evaluate on the faceCells associated with
  that patch to produce a field of true/false values

- for face quantities, these simply correspond to the mesh faces
  associated with that patch to produce a field of true/false values
2021-11-26 12:24:35 +01:00
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
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
adbcd3a19f Merge branch 'feature-functionObject-Function1' into 'develop'
Function1 objectRegistry access

See merge request Development/openfoam!499
2021-11-26 11:24:13 +00:00
adcf41bd13 ENH: add Function1 wrapping for functionObject trigger
Returns a 0/1 value corresponding to function object trigger levels.

    Usage:
    \verbatim
        <entryName> functionObjectTrigger;
        <entryName>Coeffs
        {
            triggers        (1 3 5);
            defaultValue    false;  // Default when no triggers activated
        }
    \endverbatim

ENH: add reset() method for Constant Function1

ENH: allow forced change of trigger index

- the triggers are normally increase only,
  but can now override this optionally
2021-11-26 11:22:36 +00:00
30a2fa4b27 BUG: dsmcFields fails with scoped field names 2021-11-26 11:22:36 +00:00
89ddc271c7 ENH: LimitRange Function1 - extended and renamed
Description
    Function1 wrapper that maps the input value prior to it being used by
    another Function1.

    Example usage for limiting a polynomial:
    \verbatim
        <entryName>
        {
            type            inputValueMapper;
            mode            minMax;

            min             0.4;
            max             1.4;

            value polynomial
            (
                (5 1)
                (-2 2)
                (-2 3)
                (1 4)
            );
        }
    \endverbatim

    Here the return value will be:
    - poly(0.4) for x <= 0.4;
    - poly(1.4) for x >= 1.4; and
    - poly(x) for 0.4 < x < 1.4.

    Example usage for supplying a patch mass flux for a table lookup:
    \verbatim
        <entryName>
        {
            type            inputValueMapper;
            mode            function;

            function
            {
                type            functionObjectValue;
                functionObject  surfaceFieldValue1;
                functionObjectResult sum(outlet,phi);
            }

            value
            {
                type        table;
                file        "<system>/fanCurve.txt";
            }
        }
    \endverbatim

    Where:
    \table
        Property | Description                                  | Required
        mode     | Mapping mode (see below)                     | yes
        function | Mapping Function1                            | no*
        min      | Minimum input value                          | no*
        max      | Maximum input value                          | no*
        value    | Function of type Function1<Type>             | yes
    \endtable

    Mapping modes include
    - none     : the input value is simply passed to the 'value' Function1
    - function : the input value is passed through the 'function' Function1
                 before being passed to the 'value' Function1
    - minMax   : limits the input value to 'min' and 'max' values before being
                 passed to the 'value' Function1

Note
    Replaces the LimitRange Function1 (v2106 and earlier)
2021-11-26 11:22:36 +00:00
ba45fb2cba ENH: Function1 - updated time-based Function1 usage 2021-11-26 11:22:36 +00:00
f6ee1811e7 STYLE: renamed convertTimeBase to more descriptive userTimeToTime 2021-11-26 11:22:36 +00:00
098aec4962 ENH: Function1's - added objectRegistry access 2021-11-26 11:22:36 +00:00
889bc171d9 TUT: Added example showing use of functionObject result lookup from a Function1 2021-11-26 11:22:36 +00:00
c233961d45 ENH: function objects - apply scoped name when registering objects 2021-11-26 11:22:36 +00:00
9194cd5203 ENH: Deprecated TimeFunction1 usage in favour of Function1 2021-11-26 11:22:36 +00:00
925a2e724b ENH: add caching selector to PatchFunction1
- extend handling of uniform PatchFunction1 to include new Function1
  types and pass through the objectRegistry information
2021-11-26 11:22:36 +00:00
f29eb55cee ENH: Refactored TimeFunction1 - now possible using Function1 directly 2021-11-26 11:22:36 +00:00
b9b011f5ea ENH: Added new sample Function1 2021-11-26 11:22:36 +00:00
bc2b469f9d ENH: Added new Function1: FunctionObjectValue
Returns a value retrieved from a function object result.

Usage:
    <entryName> functionObjectValue;
    <entryName>Coeffs
    {
        functionObject          <name>;
        functionObjectResult    <function object result field name>
    }
2021-11-26 11:22:36 +00:00
2c2310dc17 ENH: reference function object - retrieve reference using Function1
Note: previous behaviour to set the reference to a cell value can be recovered
by using the new 'sample' Function1
2021-11-26 11:22:36 +00:00
70b55be684 COMP: Function1 - propagated API change resulting from new objectRegistry access 2021-11-26 11:22:36 +00:00
c1a04abd96 ENH: Function1 - added optional objectRegistry reference
Function1 can now be created with an object registry, e.g. time or mesh
database. This enables access to other stored objects, e.g. fields,
dictionaries etc. making Function1 much more flexible.

Note: will allow TimeFunction1 to be deprecated
2021-11-26 11:22:36 +00:00
aeef96251f ENH: Refactored stateFunctionObject
- created new functionObjects::properties class derived from IOdictionary
  - replaces raw state IOdictionary owned by functionObjectList
  - state dictionary access/manipulators moved from stateFunctionObject
- stateFunctionObject now acts as a light wrapper around
  functionObjecties::properties
- updated dependent code
2021-11-26 11:22:36 +00:00
b19e767b8f ENH: sampledSets - added min,max,average values to the results dict 2021-11-26 11:22:36 +00:00
f078643f8c ENH: add blockFaces.vtp output for blockMesh -write-vtk 2021-11-25 20:02:09 +01:00
f459b11e24 STYLE: direct iteration over dictionary entries 2021-11-25 20:02:08 +01:00
bcf8a48c68 CONFIG: add build information into shell session
- more closely reflect what the binaries report
- report the installation path
- change PS1 case/separator to roughly correspond to package names

STYLE: adjust README to mention upcoming v2112
2021-11-25 17:36:37 +01:00
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
55af2fc2c6 BUG: missing unit-normal weighting for surfaceFieldValue (fixes #2273)
- when using a vector field for weighting, it either used mag()
  or mag * area, but did not have a unit-normal projection version
2021-11-25 09:39:20 +01:00
ccb0fd9cf0 EMH: Adding layers option and writing out HR and Tdew fields for
humidityTemperature BC
2021-11-24 15:52:24 -08:00
6712548137 Merge branch 'feature-electrodeposition' into 'develop'
ENH: New suite for electrostatic deposition applications

See merge request Development/openfoam!496
2021-11-24 18:06:39 +00:00
27f4cee78d TUT: interFoam: new tutorial for electrostatic deposition 2021-11-24 18:05:58 +00:00
19f7825a04 ENH: electrostaticDeposition: new finiteVolume boundary condition 2021-11-24 18:05:58 +00:00
aaeddba466 ENH: electricPotential: new solver function object 2021-11-24 18:05:58 +00:00
fd9670d4a3 ENH: add objectRegistry handling to expressions driver
- needed for future embedding
2021-11-23 13:37:37 +01:00
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
141403ed98 BUG: compare of two zero-sized faces was returning false 2021-11-23 10:31:24 +01:00
d710bb6595 TUT: Rename tutorial 2021-11-22 09:44:46 -08:00
bb7d8d0f4d BUG: mapped: make consistent with AMI. Fixes #2275 2021-11-22 12:21:13 +00:00
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
1af0380edc Merge branch 'feature-dictionary-reporting' into 'develop'
ENH: report dictionary defaults with Executable prefix

See merge request Development/openfoam!498
2021-11-17 17:33:01 +00:00
3d889b6dbf ENH: report dictionary defaults with Executable prefix
- provides better context when default values are accessed from
  a dictionary than reporting a source file location.
2021-11-17 16:04:46 +01:00
bb771a3caf GIT: remove spurious method declaration in regIOobject
STYLE: adjust param/return for internal readStream method
2021-11-17 16:04:40 +01:00
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
96735dce20 ENH: expose ITstream hasPutback to allow better handling
STYLE: relocate ITstream::parseStream from static to file-scope
2021-11-17 16:04:40 +01:00
4e59ad9d8d ENH: make objectRegistry::cfindIOobject public 2021-11-15 22:13:21 +01:00
28800dcbbc LINT: fix permissions 2021-11-15 21:22:36 +01:00
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
9c9d6c64b5 DEFEATURE: remove general objects storage from exprResult
- unused, generally fragile.
2021-11-15 19:19:55 +01:00
adb01bddf4 ENH: use float-narrowing for ensight set writer
- replaces hand-rolled checks

STYLE: minor cleanup of ensightPTraits
2021-11-15 18:14:16 +01:00
e62a260bdd ENH: rhoThermos: enable new set of combinations 2021-11-15 18:14:16 +01:00
8e887d3395 BUG: snappyHexMesh: parallel consistency. Fixes #2271. 2021-11-15 11:46:38 +00:00
168c13c514 ENH: cht: suppress printing of thicknessLayers. Fixes #2266 2021-11-11 08:54:42 +00:00
ba93392f69 Merge branch 'feature-Function1-fvSolution' into 'develop'
ENH: fvSolution: allow Function1 for all scalars

See merge request Development/openfoam!497
2021-11-10 19:06:49 +00:00
53e8f2a807 ENH: fvSolution: allow Function1 for all scalars
TUT: demonstrate some ramping

- compressible/rhoPimpleFoam/RAS/angledDuct
2021-11-10 17:28:52 +01:00
ba95b89e5f ENH: add Function1 caching selector 2021-11-10 17:28:45 +01:00
fd82f3e47a ENH: distinguish between compressible/incompressible coded source
- previously had codeAddSup used for both incompressible and
  compressible source terms. However, it was not actually possible to
  use it for compressible sources since any references to the 'rho'
  parameter would cause a compilation error for the incompressible case.

  Added 'codeAddSupRho' to distinguish the compressible case.
  User must supply one or both of them on input.
2021-11-09 21:48:42 +01:00
8638d82325 ENH: additional dictionary controls, methods
STYLE: declaration order of topoSet, resize_nocopy for sortedOrder

STYLE: remove cstring dependency from SHA1

STYLE: use Ostream endEntry()
2021-11-09 21:33:32 +01:00
79e110aeb0 ENH: update lemon version, wmake wrappers 2021-11-09 21:17:51 +01:00
a78e79908b ENH: additional decompose options
- decomposePar: -no-fields to suppress decomposition of fields

- makeFaMesh: -no-decompose to suppress creation of *ProcAddressing
  and fields, -no-fields to suppress decomposition of fields only
2021-11-09 15:44:54 +01:00
e8aa3aad25 ENH: simple detection for collapsed block descriptions
- switch from default topology merge to point merge if degenerate
  blocks are detected. This should alleviate the problems noted in
  #1862.

  NB: this detection only works for blocks with duplicate vertex
      indices, not ones with geometrically duplicate points.

ENH: add patch block/face summary in blockMesh generation

- add blockMesh -verbose option to override the static or dictionary
  settings.  The -verbose option can be used multiple times to increase
  the verbosity.

ENH: extend hexCell handling with more cellShape-type methods

- allows better reuse in blockMesh.
  Remove blockMesh-local hex edge definitions that shadowed the
  hexCell values.

ENH: simplify some of the block-edge internals
2021-11-09 15:44:54 +01:00
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
c45c649d15 ENH: portable scoping char for solver info names (#2224, #1675)
COMP: implicit cast scope name to C++-string in IOobject::scopedName

- handles 'const char*' and allows a check for an empty scope name

COMP: avoid potential name conflict in local function (Istream)

- reportedly some resolution issues (unconfirmed) with Fujitsu clang
2021-11-09 15:44:54 +01:00
9371c517b9 COMP: adjust include guards 2021-11-09 12:18:07 +01:00
1447 changed files with 39216 additions and 13881 deletions

View File

@ -49,7 +49,7 @@
<!--
Providing details of your set-up can help us identify any issues, e.g.
OpenFOAM version : v1806|v1812|v1906|v1912|v2006|v2012|v2106 etc
OpenFOAM version : v2112|v2106|v2012|v2006|v1912|v1906 etc
Operating system : ubuntu|openSUSE|centos etc
Hardware info : any info that may help?
Compiler : gcc|intel|clang etc

View File

@ -1,2 +1,2 @@
api=2108
api=2109
patch=0

View File

@ -40,9 +40,9 @@ Violations of the Trademark are monitored, and will be duly prosecuted.
If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
For example, for the OpenFOAM-v2106 version:
For example, for the OpenFOAM-v2112 version:
```
source /installation/path/OpenFOAM-v2106/etc/bashrc
source /installation/path/OpenFOAM-v2112/etc/bashrc
```
## Compiling OpenFOAM
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
to the OpenFOAM directory. For example,
```
/path/parent
|-- OpenFOAM-v2106
\-- ThirdParty-v2106
|-- OpenFOAM-v2112
\-- ThirdParty-v2112
```
There are, however, many cases where this simple convention is inadequate:
@ -136,7 +136,7 @@ There are, however, many cases where this simple convention is inadequate:
operating system or cluster installation provides it)
* When we have changed the OpenFOAM directory name to some arbitrary
directory name, e.g. openfoam-sandbox2106, etc..
directory name, e.g. openfoam-sandbox2112, etc..
* When we would like any additional 3rd party software to be located
inside of the OpenFOAM directory to ensure that the installation is
@ -156,9 +156,9 @@ when locating the ThirdParty directory with the following precedence:
2. PREFIX/ThirdParty-VERSION
* this corresponds to the traditional approach
3. PREFIX/ThirdParty-vAPI
* allows for an updated value of VERSION, *eg*, `v2106-myCustom`,
* allows for an updated value of VERSION, *eg*, `v2112-myCustom`,
without requiring a renamed ThirdParty. The API value would still
be `2106` and the original `ThirdParty-v2106/` would be found.
be `2112` and the original `ThirdParty-v2112/` would be found.
4. PREFIX/ThirdParty-API
* same as the previous example, but using an unadorned API value.
5. PREFIX/ThirdParty-common

View File

@ -138,13 +138,6 @@ public:
const surfaceScalarField& phi
);
//- Return a clone
virtual refPtr<regIOobject> deepClone() const
{
NotImplemented;
return nullptr;
}
//- Destructor
virtual ~PDRDragModel();

View File

@ -49,7 +49,7 @@
);
}
// Update tho boundary values of the reciprocal time-step
// Update the boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions();
Info<< "Flow time scale min/max = "

View File

@ -1,3 +1,5 @@
#include "createRDeltaT.H"
Info<< "Reading field p\n" << endl;
volScalarField p
(

View File

@ -81,6 +81,8 @@ Note
#include "pimpleControl.H"
#include "CorrectPhi.H"
#include "fvOptions.H"
#include "localEulerDdtScheme.H"
#include "fvcSmooth.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -107,6 +109,12 @@ int main(int argc, char *argv[])
turbulence->validate();
if (!LTS)
{
#include "CourantNo.H"
#include "setInitialDeltaT.H"
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
@ -114,8 +122,16 @@ int main(int argc, char *argv[])
while (runTime.run())
{
#include "readDyMControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"
if (LTS)
{
#include "setRDeltaT.H"
}
else
{
#include "CourantNo.H"
#include "setDeltaT.H"
}
++runTime;

View File

@ -0,0 +1,69 @@
{
volScalarField& rDeltaT = trDeltaT.ref();
const dictionary& pimpleDict = pimple.dict();
scalar maxCo
(
pimpleDict.getOrDefault<scalar>("maxCo", 0.8)
);
scalar rDeltaTSmoothingCoeff
(
pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.02)
);
scalar rDeltaTDampingCoeff
(
pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 1.0)
);
scalar maxDeltaT
(
pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT)
);
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
// Set the reciprocal time-step from the local Courant number
rDeltaT.ref() = max
(
1/dimensionedScalar("maxDeltaT", dimTime, maxDeltaT),
fvc::surfaceSum(mag(phi))()()
/((2*maxCo)*mesh.V())
);
// Update the boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions();
Info<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
if (rDeltaTSmoothingCoeff < 1.0)
{
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
}
Info<< "Smoothed flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
// Limit rate of change of time scale
// - reduce as much as required
// - only increase at a fraction of old time scale
if
(
rDeltaTDampingCoeff < 1.0
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
)
{
rDeltaT =
rDeltaT0
*max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff);
Info<< "Damped flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}
}

View File

@ -123,7 +123,7 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
)
:
fv::cellSetOption(sourceName, modelType, dict, mesh),
alphaSolidT_(Function1<scalar>::New("alphaSolidT", coeffs_)),
alphaSolidT_(Function1<scalar>::New("alphaSolidT", coeffs_, &mesh)),
L_("L", dimEnergy/dimMass, coeffs_),
relax_(coeffs_.getOrDefault("relax", 0.9)),
Cu_(coeffs_.getOrDefault<scalar>("Cu", 100000)),

View File

@ -33,7 +33,7 @@ bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict)
{
if (fv::cellSetOption::read(dict))
{
alphaSolidT_ = Function1<scalar>::New("alphaSolidT", coeffs_);
alphaSolidT_ = Function1<scalar>::New("alphaSolidT", coeffs_, &mesh_);
coeffs_.readEntry("L", L_);
coeffs_.readIfPresent("relax", relax_);
coeffs_.readIfPresent("Cu", Cu_);

View File

@ -11,7 +11,6 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \

View File

@ -343,12 +343,12 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
focalLaserPosition_
(
Function1<point>::New("focalLaserPosition", *this)
Function1<point>::New("focalLaserPosition", *this, &mesh_)
),
laserDirection_
(
Function1<vector>::New("laserDirection", *this)
Function1<vector>::New("laserDirection", *this, &mesh_)
),
focalLaserRadius_(get<scalar>("focalLaserRadius")),
@ -359,7 +359,7 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
sigma_(0),
I0_(0),
laserPower_(Function1<scalar>::New("laserPower", *this)),
laserPower_(Function1<scalar>::New("laserPower", *this, &mesh_)),
powerDistribution_(),
reflectionSwitch_(false),
@ -441,11 +441,11 @@ Foam::radiation::laserDTRM::laserDTRM
focalLaserPosition_
(
Function1<point>::New("focalLaserPosition", *this)
Function1<point>::New("focalLaserPosition", *this, &mesh_)
),
laserDirection_
(
Function1<vector>::New("laserDirection", *this)
Function1<vector>::New("laserDirection", *this, &mesh_)
),
focalLaserRadius_(get<scalar>("focalLaserRadius")),
@ -456,7 +456,7 @@ Foam::radiation::laserDTRM::laserDTRM
sigma_(0),
I0_(0),
laserPower_(Function1<scalar>::New("laserPower", *this)),
laserPower_(Function1<scalar>::New("laserPower", *this, &mesh_)),
powerDistribution_(),
reflectionSwitch_(false),

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2112 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -138,4 +138,53 @@ cosine6
}
expr1
{
type expression;
functions<scalar>
{
func1 constant 21;
func2 constant 15;
sin constant -5;
}
functions<vector>
{
vfunc3 constant (1 2 3);
vfunc4 constant (3 2 1);
}
expression
#{
100 * fn:vfunc3() & fn:vfunc4() * (vector::z) .z()
* (fn:sin(arg()) + fn:func1(fn:func2()))
#};
}
expr2
{
type expression;
functions<scalar>
{
func1 constant 21;
func2 constant 15;
sin constant -5;
}
functions<vector>
{
vfunc3 constant (1 2 3);
vfunc4 constant (3 2 1);
}
expression
#{
(fn:vfunc3() & vector::z) * arg()
#};
}
// ************************************************************************* //

View File

@ -121,6 +121,9 @@ int main(int argc, char *argv[])
argList::addArgument("label");
argList::noMandatoryArgs();
argList::addDryRunOption("Just for testing");
argList::addVerboseOption("Increase verbosity");
#include "setRootCase.H"
Pout<< "command-line ("
@ -133,6 +136,10 @@ int main(int argc, char *argv[])
<< "globalPath: " << args.globalPath() << nl
<< nl;
Pout<< "dry-run: " << args.dryRun()
<< " verbose: " << args.verbose() << nl;
if (args.found("relative"))
{
Pout<< "input path: " << args["relative"] << nl

View File

@ -57,9 +57,8 @@ int main(int argc, char *argv[])
#include "addAllRegionOptions.H"
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"more information about decomposition"
);
@ -71,7 +70,6 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const auto decompFile = args.get<fileName>(1);
const bool verbose = args.found("verbose");
// Set time from database
#include "createTime.H"
@ -146,7 +144,7 @@ int main(int argc, char *argv[])
nDomains
);
if (verbose)
if (args.verbose())
{
info.printDetails(Info);
Info<< nl;

View File

@ -18,6 +18,8 @@ FoamFile
#sinclude "$FOAM_CASE/someUnknownFile"
#includeIfPresent "$FOAM_CASE/someUnknownFile-$FOAM_CASENAME"
zeroVelocity uniform (0 0 0);
internalField uniform 1;
// supply defaults
@ -48,7 +50,7 @@ x 5;
varName x;
//Indirection for keys
// Indirection for keys
key inlet_9;
@ -67,13 +69,17 @@ boundaryField
inlet_5 { $inactive }
inlet_6a { $...inactive } // Relative scoping - fairly horrible to use
inlet_6b { $^inactive } // Absolute scoping
inlet_6c { key ${/key}; } // Absolute scoping
inlet_7 { ${inactive}} // Test variable expansion
inlet_8 { $inactive }
// Variable expansion for a keyword
${key} { $inactive }
#include "testDictInc"
outlet
outletBase
{
type inletOutlet;
inletValue $internalField;
@ -83,16 +89,36 @@ boundaryField
y 6;
}
// this should have no effect
outlet
{
$outletBase
}
Default_Boundary_Region
{
valueOut $zeroVelocity;
}
// this should have no effect (not in scope)
#remove inactive
inlet_7 { ${${varType}}} // Test indirection/recursive expansion
inlet_8 { $active }
// But this should work to remove things in different scopes
#remove "/zeroVelocity"
inlet_7 { ${inactive} } // Test variable expansion
inlet_8 { $inactive }
inlet_7a { ${${varType}} } // Test indirection/recursive expansion
inlet_7b { ${${varType}} } // Test indirection/recursive expansion
#overwrite inlet_8 { type none; }
}
// No patterns with scoped removal
// #remove "/boundaryField/outletB.*"
#remove "/boundaryField/outletBase"
#include "testDict2"
verbatim #{
@ -123,10 +149,25 @@ baz
$active
}
// this should work
#remove active
// This should work
#remove x
// this should work too
// This should work too
#remove ( bar baz )
// Remove a sub-dictionary entry
#remove "/anynumber.*/value"
// Removal does not auto-vivify
#remove "/nonExistentDict/value"
// Add into existing dictionary
"/anynumber.*/someValue" 100;
// Auto-vivify
// - but currently cannot auto-vivify entries with dictionary patterns
"/abd/someValue" 100;
"/def/'someValue.*" 100;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,3 @@
Test-exprTraits.C
EXE = $(FOAM_USER_APPBIN)/Test-exprTraits

View File

@ -0,0 +1,2 @@
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Basic tests of expression traits
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "ITstream.H"
#include "exprTraits.H"
#include "uLabel.H"
#include "error.H"
#include "stringList.H"
#include "exprScanToken.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T>
void printTraits()
{
const auto typeCode = exprTypeTraits<T>::value;
Info<< "type " << pTraits<T>::typeName
<< " code:" << int(typeCode)
<< " name:" << exprTypeTraits<T>::name;
if (pTraits<T>::typeName != word(exprTypeTraits<T>::name))
{
Info<< " (UNSUPPORTED)";
}
Info << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main()
{
Info<< nl << "Traits:" << nl;
printTraits<word>();
printTraits<string>();
printTraits<bool>();
printTraits<label>();
printTraits<scalar>();
printTraits<vector>();
printTraits<tensor>();
printTraits<symmTensor>();
printTraits<sphericalTensor>();
const auto getName = nameOp<expressions::valueTypeCode>();
Info<< nl;
Info<< "Name of typeCode: "
<< Foam::name(expressions::valueTypeCode::type_scalar) << nl;
Info<< "Name of typeCode: "
<< getName(expressions::valueTypeCode::type_bool) << nl;
{
expressions::scanToken tok;
expressions::scanToken tok2;
Info<< nl << "sizeof(scanToken): "
<< sizeof(tok) << nl;
Info<< " type:" << int(tok.type_) << nl;
Info<< " ptr:" << Foam::name(tok.name_) << nl;
Info<< " type:" << int(tok2.type_) << nl;
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
tok.setWord("hello");
Info<< " type:" << int(tok.type_) << nl;
Info<< " ptr:" << Foam::name(tok.name_) << nl;
tok2 = tok;
Info<< " type:" << int(tok2.type_) << nl;
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
tok2.destroy();
Info<< " type:" << int(tok2.type_) << nl;
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
}
Info<< nl << "Done" << nl;
return 0;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::noFunctionObjects();
argList::addArgument("start size .. startN sizeN");
argList::addOption("verbose");
argList::addVerbose("enable labelRange::debug");
argList::addNote
(
"The default is to add ranges, use 'add' and 'del' to toggle\n\n"
@ -65,7 +65,7 @@ int main(int argc, char *argv[])
argList args(argc, argv, false, true);
if (args.found("verbose"))
if (args.verbose())
{
labelRange::debug = 1;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -146,6 +146,9 @@ int main(int argc, char *argv[])
const objectRegistry& db = (optMesh ? mesh.thisDb() : runTime);
Info<<"## start ##" << nl;
Info<< "db isTime:" << db.isTimeDb() << " addr:" << Foam::name(&db)
<< " time: " << Foam::name(&(db.time())) << nl;
printRegistry(Info, db);
Info<< nl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -124,16 +124,13 @@ int main(int argc, char *argv[])
"(vector angle)",
"Rotate about the <vector> by <angle> degrees - eg, '((1 0 0) 45)'"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
"Report euler angles"
);
argList args(argc, argv);
const bool verbose = args.found("verbose");
vector rotVector;
@ -327,7 +324,7 @@ int main(int argc, char *argv[])
tensor rotQ(quaternion(order, angles).R());
tensor rotE(euler::rotation(order, angles, false));
if (verbose)
if (args.verbose())
{
Info<< "euler " << orderName << angles << nl;
printRotation(rotE);

View File

@ -32,14 +32,22 @@ struct myScalarField : public scalarField
template<class T>
void printInfo(const refPtr<T>& item, const bool verbose = false)
{
Info<< "refPtr valid:" << Switch::name(item.valid())
Info<< "refPtr good:" << Switch::name(item.good())
<< " pointer:" << Switch::name(item.is_pointer())
<< " addr: " << name(item.get())
<< " addr: " << Foam::name(item.get())
<< " movable:" << Switch(item.movable());
Info<< nl;
Info<< " move-constructible:"
<< std::is_move_constructible<refPtr<T>>::value
<< " move-assignable:"
<< std::is_move_assignable<refPtr<T>>::value
<< " nothrow:"
<< std::is_nothrow_move_assignable<refPtr<T>>::value
<< " trivially:"
<< std::is_trivially_move_assignable<refPtr<T>>::value
<< nl;
if (verbose && item.valid())
if (verbose && item)
{
Info<< "content: " << item() << nl;
}

View File

@ -252,12 +252,16 @@ void testExpressions(const UList<regexTest>& tests)
}
else if (re.search(str))
{
Info<< "partial match";
Info<< "partial";
}
else
{
Info<< "false";
}
if (re.negated())
{
Info<< " (negated)";
}
Info<< endl;
}
catch (const Foam::error& err)
@ -329,6 +333,15 @@ int main(int argc, char *argv[])
}
#endif
Info<< "sizeof std::regex: " << sizeof(std::regex) << nl;
Info<< "sizeof regex C++11: " << sizeof(regExpCxx) << nl;
#ifndef _WIN32
Info<< "sizeof regex POSIX: " << sizeof(regExpPosix) << nl;
#endif
Info<< "sizeof word: " << sizeof(Foam::word) << nl;
Info<< "sizeof wordRe: " << sizeof(Foam::wordRe) << nl;
Info<< "sizeof keyType: " << sizeof(Foam::keyType) << nl;
if (!args.count({"cxx", "posix"}))
{
args.setOption("cxx");

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2112 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -12,6 +12,8 @@
(
( true "(U|k|epsilon)" "U" )
( false "(U|k|epsilon)" "alpha" )
( true "(?!)(U|k|epsilon)" "alpha" )
( true "(?! *&)(U|k|epsilon)" "alpha" ) // Ignore unknown content
( true "ab.*" "abc" )
( true ".*" "abc" )

View File

@ -39,6 +39,7 @@ Description
#include "argList.H"
#include "Time.H"
#include "IOobject.H"
#include "scalarField.H"
namespace Foam
{
@ -139,6 +140,8 @@ int main(int argc, char *argv[])
cout<<"PstreamBuffers:" << sizeof(Foam::PstreamBuffers) << nl;
cout<<"Time:" << sizeof(Foam::Time) << nl;
cout<<"tmp<>:" << sizeof(tmp<scalarField>) << nl;
Info << "---\nEnd\n" << endl;
return 0;

View File

@ -32,18 +32,26 @@ struct myScalarField : public scalarField
template<class T>
void printInfo(const tmp<T>& item, const bool verbose = false)
{
Info<< "tmp valid:" << Switch::name(item.valid())
Info<< "tmp good:" << Switch::name(item.good())
<< " pointer:" << Switch::name(item.is_pointer())
<< " addr: " << name(item.get())
<< " addr: " << Foam::name(item.get())
<< " movable:" << Switch(item.movable());
if (item.valid())
if (item)
{
Info<< " refCount:" << item->count();
}
Info<< nl;
if (verbose && item.valid())
Info<< " move-constructible:"
<< std::is_move_constructible<tmp<T>>::value
<< " move-assignable:"
<< std::is_move_assignable<tmp<T>>::value
<< " nothrow:"
<< std::is_nothrow_move_assignable<tmp<T>>::value
<< " trivially:"
<< std::is_trivially_move_assignable<tmp<T>>::value
<< nl;
if (verbose && item)
{
Info<< "content: " << item() << nl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,18 +50,16 @@ int main(int argc, char *argv[])
argList::addArgument("string .. stringN");
argList::addOption("file", "name");
argList::addOption("repeat", "count");
argList::addBoolOption("verbose", "report for each repeat");
argList::addVerboseOption("report each repeat");
argList args(argc, argv, false, true);
const label repeat = args.getOrDefault<label>("repeat", 1);
const bool optVerbose = args.found("verbose");
cpuTime timer;
for (label count = 0; count < repeat; ++count)
{
const bool verbose = (optVerbose || count == 0);
const bool verbose = (args.verbose() || count == 0);
for (label argI=1; argI < args.size(); ++argI)
{
@ -120,7 +118,7 @@ int main(int argc, char *argv[])
for (label count = 0; count < repeat; ++count)
{
const bool verbose = (optVerbose || count == 0);
const bool verbose = (args.verbose() || count == 0);
label nTokens = 0;
if (count)

View File

@ -11,11 +11,11 @@ License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Decompose area fields, when mesh was generated in parallel
Write proc addressing and decompose area fields (parallel only).
\*---------------------------------------------------------------------------*/
if (Pstream::parRun())
if (doDecompose && Pstream::parRun())
{
faMeshReconstructor reconstructor(aMesh);
reconstructor.writeAddressing();
@ -43,24 +43,42 @@ if (Pstream::parRun())
reconstructor.writeMesh();
const bool oldDistributed = fileHandler().distributed();
auto oldHandler = fileHandler(fileOperation::NewUncollated());
fileHandler().distributed(true);
IOobjectList objects(fullMesh.time(), runTime.timeName());
faFieldDecomposer::readFields(fullMesh, objects, areaScalarFields);
faFieldDecomposer::readFields(fullMesh, objects, areaVectorFields);
faFieldDecomposer::readFields(fullMesh, objects, areaSphTensorFields);
faFieldDecomposer::readFields(fullMesh, objects, areaSymmTensorFields);
faFieldDecomposer::readFields(fullMesh, objects, areaTensorFields);
// Restore old settings
if (oldHandler)
if (doDecompFields)
{
fileHandler(std::move(oldHandler));
const bool oldDistributed = fileHandler().distributed();
auto oldHandler = fileHandler(fileOperation::NewUncollated());
fileHandler().distributed(true);
IOobjectList objects(fullMesh.time(), runTime.timeName());
faFieldDecomposer::readFields
(
fullMesh, objects, areaScalarFields
);
faFieldDecomposer::readFields
(
fullMesh, objects, areaVectorFields
);
faFieldDecomposer::readFields
(
fullMesh, objects, areaSphTensorFields
);
faFieldDecomposer::readFields
(
fullMesh, objects, areaSymmTensorFields
);
faFieldDecomposer::readFields
(
fullMesh, objects, areaTensorFields
);
// Restore old settings
if (oldHandler)
{
fileHandler(std::move(oldHandler));
}
fileHandler().distributed(oldDistributed);
}
fileHandler().distributed(oldDistributed);
}
const label nAreaFields =
@ -124,4 +142,5 @@ if (Pstream::parRun())
}
}
// ************************************************************************* //

View File

@ -71,10 +71,21 @@ int main(int argc, char *argv[])
);
argList::addOption("dict", "file", "Alternative faMeshDefinition");
argList::addDryRunOption
(
"Create but do not write"
);
argList::addBoolOption
(
"dry-run",
"Create but do not write"
"no-decompose",
"Suppress procAddressing creation and field decomposition"
" (parallel)"
);
argList::addBoolOption
(
"no-fields",
"Suppress field decomposition"
" (parallel)"
);
argList::addBoolOption
(
@ -93,7 +104,17 @@ int main(int argc, char *argv[])
#include "createTime.H"
#include "createNamedPolyMesh.H"
const bool dryrun = args.found("dry-run");
const bool doDecompose = !args.found("no-decompose");
const bool doDecompFields = !args.found("no-fields");
if (!doDecompose)
{
Info<< "Skip decompose of finiteArea mesh/fields" << nl;
}
else if (!doDecompFields)
{
Info<< "Skip decompose of finiteArea fields" << nl;
}
// Reading faMeshDefinition dictionary
#include "findMeshDefinitionDict.H"
@ -122,7 +143,7 @@ int main(int argc, char *argv[])
#include "faMeshWriteVTK.H"
}
if (dryrun)
if (args.dryRun())
{
Info<< "\ndry-run: not writing mesh or decomposing fields\n" << nl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -75,6 +75,7 @@ Usage
#include "blockMesh.H"
#include "foamVtkInternalMeshWriter.H"
#include "foamVtkSurfaceWriter.H"
#include "attachPolyTopoChanger.H"
#include "polyTopoChange.H"
#include "cyclicPolyPatch.H"
@ -96,23 +97,24 @@ int main(int argc, char *argv[])
argList::addNote
(
"Block mesh generator.\n"
" \n"
" The ordering of vertex and face labels within a block as shown "
"below.\n"
" For the local vertex numbering in the sequence 0 to 7:\n"
" Faces 0, 1 (x-direction) are left, right.\n"
" Faces 2, 3 (y-direction) are front, back.\n"
" Faces 4, 5 (z-direction) are bottom, top.\n"
"\n"
" \n"
" 7 ---- 6\n"
" f5 |\\ |\\ f3\n"
" f5 |\\ :\\ f3\n"
" | | 4 ---- 5 \\\n"
" | 3 |--- 2 | \\\n"
" | 3.|....2 | \\\n"
" | \\| \\| f2\n"
" f4 0 ---- 1\n"
" Y Z\n"
" \\ | f0 ------ f1\n"
" \\|\n"
" O--- X\n"
" o--- X\n"
);
argList::noParallel();
@ -129,7 +131,11 @@ int main(int argc, char *argv[])
argList::addBoolOption
(
"write-vtk",
"Write topology as VTK file and exit"
"Write topology as VTU file and exit"
);
argList::addVerboseOption
(
"Force verbose output. (Can be used multiple times)"
);
argList::addBoolOption
@ -170,12 +176,12 @@ int main(int argc, char *argv[])
const bool writeCellSets = args.found("sets");
// Default merge (topology), unless otherwise specified
blockMesh::mergeStrategy strategy(blockMesh::DEFAULT_MERGE);
if (args.found("merge-points"))
{
strategy = blockMesh::MERGE_POINTS;
}
const blockMesh::mergeStrategy strategy =
(
args.found("merge-points")
? blockMesh::MERGE_POINTS
: blockMesh::DEFAULT_MERGE
);
word regionName(polyMesh::defaultRegion);
word regionPath;
@ -216,7 +222,7 @@ int main(int argc, char *argv[])
// Locate appropriate blockMeshDict
#include "findBlockMeshDict.H"
blockMesh blocks(meshDict, regionName, strategy);
blockMesh blocks(meshDict, regionName, strategy, args.verbose());
if (!blocks.valid())
{

View File

@ -13,22 +13,25 @@ License
Description
VTK output of blockMesh topology blocks
Always write in ASCII since the mesh is small and we want easily
readable output for inspection.
\*---------------------------------------------------------------------------*/
// Common
refPtr<polyMesh> topoMeshPtr(blocks.topology(true));
const polyMesh& topoMesh = topoMeshPtr();
// Internal mesh - ie, the blocks
{
// Non-legacy and ASCII (mesh is small, want readable output)
const vtk::outputOptions writeOpts = vtk::formatType::INLINE_ASCII;
refPtr<polyMesh> topoMeshPtr(blocks.topology(true));
const polyMesh& topoMesh = topoMeshPtr();
const vtk::vtuCells topoCells(topoMesh, writeOpts);
const vtk::vtuCells topoCells(topoMesh, vtk::formatType::INLINE_ASCII);
vtk::internalMeshWriter writer
(
topoMesh,
topoCells,
writeOpts,
vtk::formatType::INLINE_ASCII,
runTime.path()/"blockTopology"
);
@ -99,4 +102,64 @@ Description
}
// Block boundary faces
{
const label nIntFaces = topoMesh.nInternalFaces();
const label nBndFaces = topoMesh.nBoundaryFaces();
faceList bndFaces
(
faceList::subList(topoMesh.faces(), nBndFaces, nIntFaces)
);
vtk::surfaceWriter writer
(
topoMesh.points(),
bndFaces,
vtk::formatType::INLINE_ASCII,
runTime.path()/"blockFaces"
);
labelList blockIds(nBndFaces, -1);
labelList cellFaceIds(nBndFaces, -1);
labelList patchIds(nBndFaces, -1);
{
const labelList& own = topoMesh.faceOwner();
const cellList& cells = topoMesh.cells();
const polyPatchList& patches = topoMesh.boundaryMesh();
for (const polyPatch& pp : patches)
{
label bndFacei = pp.start() - nIntFaces;
label meshFacei = pp.start();
forAll(pp, bfacei)
{
const label celli = own[meshFacei];
const label cellFacei = cells[celli].find(meshFacei);
blockIds[bndFacei] = celli;
cellFaceIds[bndFacei] = cellFacei;
patchIds[bndFacei] = pp.index();
++bndFacei;
++meshFacei;
}
}
}
Info<< "Writing block boundary faces in vtk format: "
<< args.relativePath(writer.output()).c_str() << endl;
writer.writeGeometry();
writer.beginCellData();
writer.writeCellData("block", blockIds);
writer.writeCellData("face", cellFaceIds);
writer.writeCellData("patch", patchIds);
}
// ************************************************************************* //

View File

@ -125,6 +125,8 @@ int main(int argc, char *argv[])
// ------------------------------------------------------------------------
#include "createNamedMeshes.H"
forAll(regionNames, regioni)
{
const word& regionName = regionNames[regioni];
@ -166,8 +168,6 @@ int main(int argc, char *argv[])
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createNamedMeshes.H"
forAll(timeDirs, timei)
{
runTime.setTime(timeDirs[timei], timei);

View File

@ -78,9 +78,8 @@ int main(int argc, char *argv[])
"detail",
"Additional detail"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
@ -94,7 +93,6 @@ int main(int argc, char *argv[])
const bool testOr = args.found("or");
const bool detail = args.found("detail");
const bool verbose = args.found("verbose");
label ngood = 0;
label nbad = 0;
@ -127,7 +125,7 @@ int main(int argc, char *argv[])
{
++ngood;
if (verbose)
if (args.verbose())
{
const word addr(Foam::name(ptr));

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,9 +101,8 @@ int main(int argc, char *argv[])
"rm",
"Remove selected time directories"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Report progress of -rm option"
);
profiling::disable(); // Disable profiling (and its output)
@ -111,7 +110,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const bool removeFiles(args.found("rm"));
bool verbose(args.found("verbose"));
bool verbose(args.verbose());
// Get times list from the master processor and subset based on

View File

@ -232,9 +232,8 @@ int main(int argc, char *argv[])
(
"Report action without moving/renaming"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
@ -247,7 +246,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
dryrun = args.dryRun();
verbose = args.found("verbose");
verbose = args.verbose();
// Construct time

View File

@ -141,11 +141,15 @@ Usage
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "OSspecific.H"
#include "fvCFD.H"
#include "IOobjectList.H"
#include "decompositionModel.H"
#include "domainDecomposition.H"
#include "domainDecompositionDryRun.H"
#include "labelIOField.H"
#include "labelFieldIOField.H"
#include "scalarIOField.H"
@ -165,9 +169,7 @@ Usage
#include "fvFieldDecomposer.H"
#include "pointFieldDecomposer.H"
#include "lagrangianFieldDecomposer.H"
#include "decompositionModel.H"
#include "faCFD.H"
#include "emptyFaPatch.H"
#include "faMeshDecomposition.H"
#include "faFieldDecomposer.H"
@ -306,6 +308,8 @@ void decomposeUniform
} // End namespace Foam
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
@ -330,9 +334,8 @@ int main(int argc, char *argv[])
"Test without writing the decomposition. "
"Changes -cellDist to only write VTK output."
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
argList::addOption
@ -385,6 +388,11 @@ int main(int argc, char *argv[])
"fields",
"Use existing geometry decomposition and convert fields only"
);
argList::addBoolOption
(
"no-fields",
"Suppress conversion of fields (volume, finite-area, lagrangian)"
);
argList::addBoolOption
(
@ -409,9 +417,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const bool dryrun = args.dryRun();
const bool writeCellDist = args.found("cellDist");
const bool verbose = args.found("verbose");
// Most of these are ignored for dry-run (not triggered anywhere)
const bool copyZero = args.found("copyZero");
@ -420,6 +426,7 @@ int main(int argc, char *argv[])
const bool decomposeIfRequired = args.found("ifRequired");
const bool doDecompFields = !args.found("no-fields");
const bool doFiniteArea = !args.found("no-finite-area");
const bool doLagrangian = !args.found("no-lagrangian");
@ -432,13 +439,25 @@ int main(int argc, char *argv[])
// Allow override of time (unless dry-run)
instantList times;
if (dryrun)
if (args.dryRun())
{
Info<< "\ndry-run: ignoring -copy*, -fields, -force, time selection"
<< nl;
}
else
{
if (decomposeFieldsOnly && !doDecompFields)
{
FatalErrorIn(args.executable())
<< "Options -fields and -no-fields are mutually exclusive"
<< " ... giving up" << nl
<< exit(FatalError);
}
if (!doDecompFields)
{
Info<< "Skip decompose of all fields" << nl;
}
if (!doFiniteArea)
{
Info<< "Skip decompose of finiteArea mesh/fields" << nl;
@ -451,6 +470,7 @@ int main(int argc, char *argv[])
times = timeSelector::selectIfPresent(runTime, args);
}
// Allow override of decomposeParDict location
fileName decompDictFile(args.get<fileName>("decomposeParDict", ""));
if (!decompDictFile.empty() && !decompDictFile.isAbsolute())
@ -477,7 +497,7 @@ int main(int argc, char *argv[])
regionName == polyMesh::defaultRegion ? word::null : regionName
);
if (dryrun)
if (args.dryRun())
{
Info<< "dry-run: decomposing mesh " << regionName << nl << nl
<< "Create mesh..." << flush;
@ -498,7 +518,7 @@ int main(int argc, char *argv[])
args.getOrDefault<word>("method", word::null)
);
decompTest.execute(writeCellDist, verbose);
decompTest.execute(writeCellDist, args.verbose());
continue;
}
@ -510,7 +530,8 @@ int main(int argc, char *argv[])
Info<< nl << endl;
// Determine the existing processor count directly
label nProcs = fileHandler().nProcs(runTime.path(), regionDir);
const label nProcsOld =
fileHandler().nProcs(runTime.path(), regionDir);
// Get requested numberOfSubdomains directly from the dictionary.
// Note: have no mesh yet so cannot use decompositionModel::New
@ -541,22 +562,22 @@ int main(int argc, char *argv[])
if (decomposeFieldsOnly)
{
// Sanity check on previously decomposed case
if (nProcs != nDomains)
if (nProcsOld != nDomains)
{
FatalErrorInFunction
FatalErrorIn(args.executable())
<< "Specified -fields, but the case was decomposed with "
<< nProcs << " domains"
<< nProcsOld << " domains"
<< nl
<< "instead of " << nDomains
<< " domains as specified in decomposeParDict" << nl
<< exit(FatalError);
}
}
else if (nProcs)
else if (nProcsOld)
{
bool procDirsProblem = true;
if (decomposeIfRequired && nProcs == nDomains)
if (decomposeIfRequired && nProcsOld == nDomains)
{
// We can reuse the decomposition
decomposeFieldsOnly = true;
@ -574,7 +595,7 @@ int main(int argc, char *argv[])
if (forceOverwrite)
{
Info<< "Removing " << nProcs
Info<< "Removing " << nProcsOld
<< " existing processor directories" << endl;
// Remove existing processors directory
@ -617,8 +638,8 @@ int main(int argc, char *argv[])
if (procDirsProblem)
{
FatalErrorInFunction
<< "Case is already decomposed with " << nProcs
FatalErrorIn(args.executable())
<< "Case is already decomposed with " << nProcsOld
<< " domains, use the -force option or manually" << nl
<< "remove processor directories before decomposing. e.g.,"
<< nl
@ -647,7 +668,6 @@ int main(int argc, char *argv[])
if (!decomposeFieldsOnly)
{
mesh.decomposeMesh();
mesh.writeDecomposition(decomposeSets);
if (writeCellDist)
@ -750,7 +770,7 @@ int main(int argc, char *argv[])
}
else
{
// Decompose the field files
// Decompose field files, lagrangian, finite-area
// Cached processor meshes and maps. These are only preserved if
// running with multiple times.
@ -759,8 +779,9 @@ int main(int argc, char *argv[])
PtrList<labelIOList> faceProcAddressingList(mesh.nProcs());
PtrList<labelIOList> cellProcAddressingList(mesh.nProcs());
PtrList<labelIOList> boundaryProcAddressingList(mesh.nProcs());
PtrList<fvFieldDecomposer> fieldDecomposerList(mesh.nProcs());
PtrList<labelIOList> pointProcAddressingList(mesh.nProcs());
PtrList<fvFieldDecomposer> fieldDecomposerList(mesh.nProcs());
PtrList<pointFieldDecomposer> pointFieldDecomposerList
(
mesh.nProcs()
@ -768,83 +789,139 @@ int main(int argc, char *argv[])
// Loop over all times
forAll(times, timeI)
forAll(times, timei)
{
runTime.setTime(times[timeI], timeI);
runTime.setTime(times[timei], timei);
Info<< "Time = " << runTime.timeName() << endl;
// Search for list of objects for this time
IOobjectList objects(mesh, runTime.timeName());
// Field objects at this time
IOobjectList objects;
if (doDecompFields)
{
objects = IOobjectList(mesh, runTime.timeName());
// Ignore generated fields: (cellDist)
objects.remove("cellDist");
}
// Finite area handling
autoPtr<faMeshDecomposition> faMeshDecompPtr;
if (doFiniteArea)
{
IOobject io
(
"faBoundary",
mesh.time().findInstance
(
mesh.dbDir()/polyMesh::meshSubDir,
"boundary"
),
faMesh::meshSubDir,
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false // not registered
);
if (io.typeHeaderOk<faBoundaryMesh>(true))
{
// Always based on the volume decomposition!
faMeshDecompPtr.reset
(
new faMeshDecomposition
(
mesh,
mesh.nProcs(),
mesh.model()
)
);
}
}
// Construct the vol fields
// ~~~~~~~~~~~~~~~~~~~~~~~~
// Vol fields
// ~~~~~~~~~~
PtrList<volScalarField> volScalarFields;
readFields(mesh, objects, volScalarFields, false);
PtrList<volVectorField> volVectorFields;
readFields(mesh, objects, volVectorFields, false);
PtrList<volSphericalTensorField> volSphericalTensorFields;
readFields(mesh, objects, volSphericalTensorFields, false);
PtrList<volSphericalTensorField> volSphTensorFields;
PtrList<volSymmTensorField> volSymmTensorFields;
readFields(mesh, objects, volSymmTensorFields, false);
PtrList<volTensorField> volTensorFields;
readFields(mesh, objects, volTensorFields, false);
if (doDecompFields)
{
readFields(mesh, objects, volScalarFields, false);
readFields(mesh, objects, volVectorFields, false);
readFields(mesh, objects, volSphTensorFields, false);
readFields(mesh, objects, volSymmTensorFields, false);
readFields(mesh, objects, volTensorFields, false);
}
// Construct the dimensioned fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Internal fields
// ~~~~~~~~~~~~~~~
PtrList<DimensionedField<scalar, volMesh>> dimScalarFields;
readFields(mesh, objects, dimScalarFields);
PtrList<DimensionedField<vector, volMesh>> dimVectorFields;
readFields(mesh, objects, dimVectorFields);
PtrList<DimensionedField<sphericalTensor, volMesh>>
dimSphericalTensorFields;
readFields(mesh, objects, dimSphericalTensorFields);
dimSphTensorFields;
PtrList<DimensionedField<symmTensor, volMesh>>
dimSymmTensorFields;
readFields(mesh, objects, dimSymmTensorFields);
PtrList<DimensionedField<tensor, volMesh>> dimTensorFields;
readFields(mesh, objects, dimTensorFields);
if (doDecompFields)
{
readFields(mesh, objects, dimScalarFields);
readFields(mesh, objects, dimVectorFields);
readFields(mesh, objects, dimSphTensorFields);
readFields(mesh, objects, dimSymmTensorFields);
readFields(mesh, objects, dimTensorFields);
}
// Construct the surface fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Surface fields
// ~~~~~~~~~~~~~~
PtrList<surfaceScalarField> surfaceScalarFields;
readFields(mesh, objects, surfaceScalarFields, false);
PtrList<surfaceVectorField> surfaceVectorFields;
readFields(mesh, objects, surfaceVectorFields, false);
PtrList<surfaceSphericalTensorField>
surfaceSphericalTensorFields;
readFields(mesh, objects, surfaceSphericalTensorFields, false);
surfaceSphTensorFields;
PtrList<surfaceSymmTensorField> surfaceSymmTensorFields;
readFields(mesh, objects, surfaceSymmTensorFields, false);
PtrList<surfaceTensorField> surfaceTensorFields;
readFields(mesh, objects, surfaceTensorFields, false);
if (doDecompFields)
{
readFields(mesh, objects, surfaceScalarFields, false);
readFields(mesh, objects, surfaceVectorFields, false);
readFields(mesh, objects, surfaceSphTensorFields, false);
readFields(mesh, objects, surfaceSymmTensorFields, false);
readFields(mesh, objects, surfaceTensorFields, false);
}
// Construct the point fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
// Point fields
// ~~~~~~~~~~~~
const pointMesh& pMesh = pointMesh::New(mesh);
PtrList<pointScalarField> pointScalarFields;
readFields(pMesh, objects, pointScalarFields, false);
PtrList<pointVectorField> pointVectorFields;
readFields(pMesh, objects, pointVectorFields, false);
PtrList<pointSphericalTensorField> pointSphericalTensorFields;
readFields(pMesh, objects, pointSphericalTensorFields, false);
PtrList<pointSphericalTensorField> pointSphTensorFields;
PtrList<pointSymmTensorField> pointSymmTensorFields;
readFields(pMesh, objects, pointSymmTensorFields, false);
PtrList<pointTensorField> pointTensorFields;
readFields(pMesh, objects, pointTensorFields, false);
if (doDecompFields)
{
readFields(pMesh, objects, pointScalarFields, false);
readFields(pMesh, objects, pointVectorFields, false);
readFields(pMesh, objects, pointSphTensorFields, false);
readFields(pMesh, objects, pointSymmTensorFields, false);
readFields(pMesh, objects, pointTensorFields, false);
}
// Construct the Lagrangian fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Lagrangian fields
// ~~~~~~~~~~~~~~~~~
fileNameList cloudDirs;
if (doLagrangian)
if (doDecompFields && doLagrangian)
{
cloudDirs = fileHandler().readDir
(
@ -892,13 +969,17 @@ int main(int argc, char *argv[])
cloudDirs.size()
);
PtrList<PtrList<sphericalTensorIOField>>
lagrangianSphericalTensorFields
lagrangianSphTensorFields
(
cloudDirs.size()
);
PtrList<PtrList<sphericalTensorFieldCompactIOField>>
lagrangianSphericalTensorFieldFields(cloudDirs.size());
PtrList<PtrList<symmTensorIOField>> lagrangianSymmTensorFields
lagrangianSphTensorFieldFields
(
cloudDirs.size()
);
PtrList<PtrList<symmTensorIOField>>
lagrangianSymmTensorFields
(
cloudDirs.size()
);
@ -917,6 +998,7 @@ int main(int argc, char *argv[])
cloudDirs.size()
);
label cloudI = 0;
for (const fileName& cloudDir : cloudDirs)
@ -980,7 +1062,7 @@ int main(int argc, char *argv[])
// Check
if (celli < 0 || celli >= mesh.nCells())
{
FatalErrorInFunction
FatalErrorIn(args.executable())
<< "Illegal cell number " << celli
<< " for particle with index "
<< p.index()
@ -1062,14 +1144,14 @@ int main(int argc, char *argv[])
(
cloudI,
lagrangianObjects,
lagrangianSphericalTensorFields
lagrangianSphTensorFields
);
lagrangianFieldDecomposer::readFieldFields
(
cloudI,
lagrangianObjects,
lagrangianSphericalTensorFieldFields
lagrangianSphTensorFieldFields
);
lagrangianFieldDecomposer::readFields
@ -1100,29 +1182,34 @@ int main(int argc, char *argv[])
lagrangianTensorFieldFields
);
cloudI++;
++cloudI;
}
}
lagrangianPositions.setSize(cloudI);
cellParticles.setSize(cloudI);
lagrangianLabelFields.setSize(cloudI);
lagrangianLabelFieldFields.setSize(cloudI);
lagrangianScalarFields.setSize(cloudI);
lagrangianScalarFieldFields.setSize(cloudI);
lagrangianVectorFields.setSize(cloudI);
lagrangianVectorFieldFields.setSize(cloudI);
lagrangianSphericalTensorFields.setSize(cloudI);
lagrangianSphericalTensorFieldFields.setSize(cloudI);
lagrangianSymmTensorFields.setSize(cloudI);
lagrangianSymmTensorFieldFields.setSize(cloudI);
lagrangianTensorFields.setSize(cloudI);
lagrangianTensorFieldFields.setSize(cloudI);
lagrangianPositions.resize(cloudI);
cellParticles.resize(cloudI);
lagrangianLabelFields.resize(cloudI);
lagrangianLabelFieldFields.resize(cloudI);
lagrangianScalarFields.resize(cloudI);
lagrangianScalarFieldFields.resize(cloudI);
lagrangianVectorFields.resize(cloudI);
lagrangianVectorFieldFields.resize(cloudI);
lagrangianSphTensorFields.resize(cloudI);
lagrangianSphTensorFieldFields.resize(cloudI);
lagrangianSymmTensorFields.resize(cloudI);
lagrangianSymmTensorFieldFields.resize(cloudI);
lagrangianTensorFields.resize(cloudI);
lagrangianTensorFieldFields.resize(cloudI);
Info<< endl;
// split the fields over processors
for (label proci = 0; proci < mesh.nProcs(); ++proci)
for
(
label proci = 0;
doDecompFields && proci < mesh.nProcs();
++proci
)
{
Info<< "Processor " << proci << ": field transfer" << endl;
@ -1210,22 +1297,19 @@ int main(int argc, char *argv[])
const fvFieldDecomposer& fieldDecomposer =
fieldDecomposerList[proci];
// vol fields
// Vol fields
fieldDecomposer.decomposeFields(volScalarFields);
fieldDecomposer.decomposeFields(volVectorFields);
fieldDecomposer.decomposeFields
(
volSphericalTensorFields
);
fieldDecomposer.decomposeFields(volSphTensorFields);
fieldDecomposer.decomposeFields(volSymmTensorFields);
fieldDecomposer.decomposeFields(volTensorFields);
// surface fields
// Surface fields
fieldDecomposer.decomposeFields(surfaceScalarFields);
fieldDecomposer.decomposeFields(surfaceVectorFields);
fieldDecomposer.decomposeFields
(
surfaceSphericalTensorFields
surfaceSphTensorFields
);
fieldDecomposer.decomposeFields
(
@ -1236,7 +1320,7 @@ int main(int argc, char *argv[])
// internal fields
fieldDecomposer.decomposeFields(dimScalarFields);
fieldDecomposer.decomposeFields(dimVectorFields);
fieldDecomposer.decomposeFields(dimSphericalTensorFields);
fieldDecomposer.decomposeFields(dimSphTensorFields);
fieldDecomposer.decomposeFields(dimSymmTensorFields);
fieldDecomposer.decomposeFields(dimTensorFields);
@ -1253,7 +1337,7 @@ int main(int argc, char *argv[])
(
pointScalarFields.size()
|| pointVectorFields.size()
|| pointSphericalTensorFields.size()
|| pointSphTensorFields.size()
|| pointSymmTensorFields.size()
|| pointTensorFields.size()
)
@ -1287,10 +1371,7 @@ int main(int argc, char *argv[])
pointDecomposer.decomposeFields(pointScalarFields);
pointDecomposer.decomposeFields(pointVectorFields);
pointDecomposer.decomposeFields
(
pointSphericalTensorFields
);
pointDecomposer.decomposeFields(pointSphTensorFields);
pointDecomposer.decomposeFields(pointSymmTensorFields);
pointDecomposer.decomposeFields(pointTensorFields);
@ -1354,12 +1435,12 @@ int main(int argc, char *argv[])
fieldDecomposer.decomposeFields
(
cloudDirs[cloudI],
lagrangianSphericalTensorFields[cloudI]
lagrangianSphTensorFields[cloudI]
);
fieldDecomposer.decomposeFieldFields
(
cloudDirs[cloudI],
lagrangianSphericalTensorFieldFields[cloudI]
lagrangianSphTensorFieldFields[cloudI]
);
fieldDecomposer.decomposeFields
(
@ -1385,17 +1466,24 @@ int main(int argc, char *argv[])
}
}
// Decompose the "uniform" directory in the time region
// directory
decomposeUniform(copyUniform, mesh, processorDb, regionDir);
// For a multi-region case, also decompose the "uniform"
// directory in the time directory
if (regionNames.size() > 1 && regioni == 0)
if (doDecompFields)
{
decomposeUniform(copyUniform, mesh, processorDb);
// Decompose "uniform" directory in the time region
// directory
decomposeUniform
(
copyUniform, mesh, processorDb, regionDir
);
// For a multi-region case, also decompose "uniform"
// directory in the time directory
if (regionNames.size() > 1 && regioni == 0)
{
decomposeUniform(copyUniform, mesh, processorDb);
}
}
// We have cached all the constant mesh data for the current
// processor. This is only important if running with
// multiple times, otherwise it is just extra storage.
@ -1409,72 +1497,46 @@ int main(int argc, char *argv[])
}
}
// Finite area mesh and field decomposition
IOobject faMeshBoundaryIOobj
(
"faBoundary",
mesh.time().findInstance
(
mesh.dbDir()/polyMesh::meshSubDir,
"boundary"
),
faMesh::meshSubDir,
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false // not registered
);
if
(
doFiniteArea
&& faMeshBoundaryIOobj.typeHeaderOk<faBoundaryMesh>(true)
)
if (faMeshDecompPtr)
{
Info<< "\nFinite area mesh decomposition" << endl;
// Always based on the volume decomposition!
faMeshDecomposition aMesh
(
mesh,
mesh.nProcs(),
mesh.model()
);
faMeshDecomposition& aMesh = faMeshDecompPtr();
aMesh.decomposeMesh();
aMesh.writeDecomposition();
// Construct the area fields
// ~~~~~~~~~~~~~~~~~~~~~~~~
// Area fields
// ~~~~~~~~~~~
PtrList<areaScalarField> areaScalarFields;
readFields(aMesh, objects, areaScalarFields);
PtrList<areaVectorField> areaVectorFields;
readFields(aMesh, objects, areaVectorFields);
PtrList<areaSphericalTensorField> areaSphericalTensorFields;
readFields(aMesh, objects, areaSphericalTensorFields);
PtrList<areaSphericalTensorField> areaSphTensorFields;
PtrList<areaSymmTensorField> areaSymmTensorFields;
readFields(aMesh, objects, areaSymmTensorFields);
PtrList<areaTensorField> areaTensorFields;
readFields(aMesh, objects, areaTensorFields);
// Construct the edge fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Edge fields (limited number of types)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<edgeScalarField> edgeScalarFields;
readFields(aMesh, objects, edgeScalarFields);
if (doDecompFields)
{
readFields(aMesh, objects, areaScalarFields);
readFields(aMesh, objects, areaVectorFields);
readFields(aMesh, objects, areaSphTensorFields);
readFields(aMesh, objects, areaSymmTensorFields);
readFields(aMesh, objects, areaTensorFields);
readFields(aMesh, objects, edgeScalarFields);
}
const label nAreaFields =
(
areaScalarFields.size()
+ areaVectorFields.size()
+ areaSphericalTensorFields.size()
+ areaSphTensorFields.size()
+ areaSymmTensorFields.size()
+ areaTensorFields.size()
+ edgeScalarFields.size()
@ -1577,10 +1639,7 @@ int main(int argc, char *argv[])
fieldDecomposer.decomposeFields(areaScalarFields);
fieldDecomposer.decomposeFields(areaVectorFields);
fieldDecomposer.decomposeFields
(
areaSphericalTensorFields
);
fieldDecomposer.decomposeFields(areaSphTensorFields);
fieldDecomposer.decomposeFields(areaSymmTensorFields);
fieldDecomposer.decomposeFields(areaTensorFields);

View File

@ -52,7 +52,7 @@ void Foam::domainDecomposition::writeVolField
false
),
this->mesh(),
dimensionedScalar(dimless, Zero),
dimensionedScalar("cellDist", dimless, -1),
zeroGradientFvPatchScalarField::typeName
);

View File

@ -44,13 +44,6 @@ void Foam::readFields
// Search list of objects for fields of type GeoField
IOobjectList fieldObjects(objects.lookupClass<GeoField>());
// Remove the cellDist field
auto iter = fieldObjects.find("cellDist");
if (iter.found())
{
fieldObjects.erase(iter);
}
// Use sorted set of names
// (different processors might read objects in different order)
const wordList masterNames(fieldObjects.sortedNames());

View File

@ -147,7 +147,7 @@ void createTimeDirs(const fileName& path)
// Just to make sure remove all state and re-scan
fileHandler().flush();
(void)fileHandler().findTimes(path, "constant");
(void)Time::findTimes(path, "constant");
}
@ -2665,9 +2665,11 @@ int main(int argc, char *argv[])
// e.g. latestTime will pick up a different time (which causes createTime.H
// to abort). So for now make sure to have master times on all
// processors
Info<< "Creating time directories on all processors" << nl << endl;
createTimeDirs(args.path());
if (!reconstruct)
{
Info<< "Creating time directories on all processors" << nl << endl;
createTimeDirs(args.path());
}
// Construct time
// ~~~~~~~~~~~~~~
@ -2932,6 +2934,10 @@ int main(int argc, char *argv[])
}
}
// Make sure all is finished writing until re-reading in pass2
// below
fileHandler().flush();
// Pass2 : read mesh and addressing and reconstruct fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -15,4 +15,12 @@ const label sampleFrequency(propsDict.get<label>("sampleFrequency"));
const label maxPositions(propsDict.get<label>("maxPositions"));
const label maxTracks(propsDict.getOrDefault<label>("maxTracks", -1));
const word setFormat(propsDict.getOrDefault<word>("setFormat", "vtk"));
const wordRes fieldNames(propsDict.getOrDefault<wordRes>("fields", wordRes()));
const word UName(propsDict.getOrDefault<word>("U", "U"));
const dictionary formatOptions = propsDict.subOrEmptyDict("formatOptions");

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,8 +31,8 @@ Group
grpPostProcessingUtilities
Description
Generate a legacy VTK file of particle tracks for cases that were
computed using a tracked-parcel-type cloud.
Generate particle tracks for cases that were computed using a
tracked-parcel-type cloud.
\*---------------------------------------------------------------------------*/
@ -44,16 +45,206 @@ Description
#include "OFstream.H"
#include "passiveParticleCloud.H"
#include "writer.H"
#include "ListOps.H"
#define createTrack(field, trackValues) \
createTrackField \
( \
field, \
sampleFrequency, \
maxPositions, \
startIds, \
allOrigProcs, \
allOrigIds, \
trackValues \
);
#define setFields(fields, fieldNames) \
setTrackFields \
( \
obr, \
fields, \
fieldNames, \
nTracks, \
startIds, \
allOrigProcs, \
allOrigIds, \
maxPositions, \
sampleFrequency \
);
#define writeFields(fields, fieldNames, tracks, times, dirs) \
writeTrackFields \
( \
fields, \
fieldNames, \
tracks, \
times, \
dirs, \
setFormat, \
formatOptions, \
cloudName \
);
using namespace Foam;
template<class Type>
void createTrackField
(
const Field<Type>& values,
const label sampleFrequency,
const label maxPositions,
const labelList& startIds,
const List<labelField>& allOrigProcs,
const List<labelField>& allOrigIds,
List<DynamicList<Type>>& trackValues
)
{
List<Field<Type>> procField(Pstream::nProcs());
procField[Pstream::myProcNo()] = values;
Pstream::gatherList(procField);
if (!Pstream::master())
{
return;
}
const label nTracks = trackValues.size();
forAll(procField, proci)
{
forAll(procField[proci], i)
{
const label globalId =
startIds[allOrigProcs[proci][i]] + allOrigIds[proci][i];
if (globalId % sampleFrequency == 0)
{
const label trackId = globalId/sampleFrequency;
if
(
trackId < nTracks
&& trackValues[trackId].size() < maxPositions
)
{
trackValues[trackId].append(procField[proci][i]);
}
}
}
}
}
template<class Type>
void writeTrackFields
(
List<List<DynamicList<Type>>>& fieldValues,
const wordList& fieldNames,
const PtrList<coordSet>& tracks,
const List<scalarField>& times,
const List<vectorField>& dirs,
const word& setFormat,
const dictionary& formatOptions,
const word& cloudName
)
{
if (fieldValues.empty())
{
return;
}
auto writerPtr = writer<Type>::New(setFormat, formatOptions);
const fileName outFile(writerPtr().getFileName(tracks[0], wordList(0)));
const fileName outPath
(
functionObject::outputPrefix/cloud::prefix/cloudName/"particleTracks"
);
mkDir(outPath);
OFstream os(outPath/(pTraits<Type>::typeName & "tracks." + outFile.ext()));
Info<< "Writing " << pTraits<Type>::typeName << " particle tracks in "
<< setFormat << " format to " << os.name() << endl;
List<List<Field<Type>>> fields(fieldValues.size());
forAll(fields, fieldi)
{
fields[fieldi].setSize(fieldValues[fieldi].size());
forAll(fields[fieldi], tracki)
{
fields[fieldi][tracki].transfer(fieldValues[fieldi][tracki]);
}
}
writerPtr().write(true, times, tracks, fieldNames, fields, os);
}
template<class Type>
Foam::label setTrackFields
(
const objectRegistry& obr,
List<List<DynamicList<Type>>>& fields,
List<word>& fieldNames,
const label nTracks,
const labelList& startIds,
const List<labelField>& allOrigProcs,
const List<labelField>& allOrigIds,
const label maxPositions,
const label sampleFrequency
)
{
const auto availableFieldPtrs = obr.lookupClass<IOField<Type>>();
fieldNames = availableFieldPtrs.toc();
if (Pstream::parRun())
{
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
Pstream::combineScatter(fieldNames);
Foam::sort(fieldNames);
}
const label nFields = fieldNames.size();
if (fields.empty())
{
fields.setSize(nFields);
fieldNames.setSize(nFields);
forAll(fields, i)
{
fields[i].setSize(nTracks);
}
}
forAll(fieldNames, fieldi)
{
const word& fieldName = fieldNames[fieldi];
const auto* fldPtr = obr.cfindObject<IOField<Type>>(fieldName);
createTrack
(
fldPtr ? static_cast<const Field<Type>>(*fldPtr) : Field<Type>(),
fields[fieldi]
);
}
return nFields;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Generate a legacy VTK file of particle tracks for cases that were"
"Generate a file of particle tracks for cases that were"
" computed using a tracked-parcel-type cloud"
);
@ -76,9 +267,9 @@ int main(int argc, char *argv[])
<< nl << endl;
labelList maxIds(Pstream::nProcs(), -1);
forAll(timeDirs, timeI)
forAll(timeDirs, timei)
{
runTime.setTime(timeDirs[timeI], timeI);
runTime.setTime(timeDirs[timei], timei);
Info<< "Time = " << runTime.timeName() << endl;
Info<< " Reading particle positions" << endl;
@ -92,6 +283,8 @@ int main(int argc, char *argv[])
const label origId = p.origId();
const label origProc = p.origProc();
// Handle case where we are processing particle data generated in
// parallel using more cores than when running this application.
if (origProc >= maxIds.size())
{
maxIds.setSize(origProc+1, -1);
@ -124,7 +317,7 @@ int main(int argc, char *argv[])
// Calculate starting ids for particles on each processor
labelList startIds(numIds.size(), Zero);
for (label i = 0; i < numIds.size()-1; i++)
for (label i = 0; i < numIds.size()-1; ++i)
{
startIds[i+1] += startIds[i] + numIds[i];
}
@ -132,130 +325,135 @@ int main(int argc, char *argv[])
// Number of tracks to generate
label nTracks = nParticle/sampleFrequency;
const label nTracks =
maxTracks > 0
? min(nParticle/sampleFrequency, maxTracks)
: nParticle/sampleFrequency;
// Storage for all particle tracks
List<DynamicList<vector>> allTracks(nTracks);
List<DynamicList<scalar>> allTrackTimes(nTracks);
// Lists of field, tracki, trackValues
//List<List<DynamicList<label>>> labelFields;
List<List<DynamicList<scalar>>> scalarFields;
List<List<DynamicList<vector>>> vectorFields;
List<List<DynamicList<sphericalTensor>>> sphTensorFields;
List<List<DynamicList<symmTensor>>> symTensorFields;
List<List<DynamicList<tensor>>> tensorFields;
//List<word> labelFieldNames;
List<word> scalarFieldNames;
List<word> vectorFieldNames;
List<word> sphTensorFieldNames;
List<word> symTensorFieldNames;
List<word> tensorFieldNames;
Info<< "\nGenerating " << nTracks << " particle tracks for cloud "
<< cloudName << nl << endl;
forAll(timeDirs, timeI)
forAll(timeDirs, timei)
{
runTime.setTime(timeDirs[timeI], timeI);
runTime.setTime(timeDirs[timei], timei);
Info<< "Time = " << runTime.timeName() << endl;
List<pointField> allPositions(Pstream::nProcs());
List<labelField> allOrigIds(Pstream::nProcs());
List<labelField> allOrigProcs(Pstream::nProcs());
// Read particles. Will be size 0 if no particles.
Info<< " Reading particle positions" << endl;
passiveParticleCloud myCloud(mesh, cloudName);
pointField localPositions(myCloud.size(), Zero);
scalarField localTimes(myCloud.size(), Zero);
List<labelField> allOrigIds(Pstream::nProcs());
List<labelField> allOrigProcs(Pstream::nProcs());
// Collect the track data on all processors that have positions
allPositions[Pstream::myProcNo()].setSize
(
myCloud.size(),
point::zero
);
allOrigIds[Pstream::myProcNo()].setSize(myCloud.size(), Zero);
allOrigProcs[Pstream::myProcNo()].setSize(myCloud.size(), Zero);
label i = 0;
for (const passiveParticle& p : myCloud)
{
allPositions[Pstream::myProcNo()][i] = p.position();
allOrigIds[Pstream::myProcNo()][i] = p.origId();
allOrigProcs[Pstream::myProcNo()][i] = p.origProc();
localPositions[i] = p.position();
localTimes[i] = runTime.value();
++i;
}
// Collect the track data on the master processor
Pstream::gatherList(allPositions);
Pstream::gatherList(allOrigIds);
Pstream::gatherList(allOrigProcs);
Info<< " Constructing tracks" << nl << endl;
if (Pstream::master())
{
forAll(allPositions, proci)
{
forAll(allPositions[proci], i)
{
label globalId =
startIds[allOrigProcs[proci][i]]
+ allOrigIds[proci][i];
objectRegistry obr
(
IOobject
(
"cloudFields",
runTime.timeName(),
runTime
)
);
if (globalId % sampleFrequency == 0)
{
label trackId = globalId/sampleFrequency;
if (allTracks[trackId].size() < maxPositions)
{
allTracks[trackId].append
(
allPositions[proci][i]
);
}
}
}
}
}
myCloud.readFromFiles(obr, fieldNames);
// Create track positions and track time fields
// (not registered as IOFields)
// Note: createTrack is a local #define to reduce arg count...
createTrack(localPositions, allTracks);
createTrack(localTimes, allTrackTimes);
// Create the track fields
// Note: setFields is a local #define to reduce arg count...
//setFields(labelFields, labelFieldNames);
setFields(scalarFields, scalarFieldNames);
setFields(vectorFields, vectorFieldNames);
setFields(sphTensorFields, sphTensorFieldNames);
setFields(symTensorFields, symTensorFieldNames);
setFields(tensorFields, tensorFieldNames);
}
if (Pstream::master())
{
PtrList<coordSet> tracks(allTracks.size());
forAll(allTracks, trackI)
List<scalarField> times(tracks.size());
forAll(tracks, tracki)
{
tracks.set
(
trackI,
new coordSet
(
"track" + Foam::name(trackI),
"distance"
)
tracki,
new coordSet("track" + Foam::name(tracki), "distance")
);
tracks[trackI].transfer(allTracks[trackI]);
tracks[tracki].transfer(allTracks[tracki]);
times[tracki].transfer(allTrackTimes[tracki]);
}
autoPtr<writer<scalar>> scalarFormatterPtr = writer<scalar>::New
(
setFormat
);
Info<< nl;
//OFstream vtkTracks(vtkPath/"particleTracks.vtk");
fileName vtkFile
(
scalarFormatterPtr().getFileName
(
tracks[0],
wordList(0)
)
);
const label Uid = vectorFieldNames.find(UName);
List<vectorField> dirs(nTracks);
OFstream vtkTracks
(
vtkPath/("particleTracks." + vtkFile.ext())
);
if (Uid != -1)
{
const auto& UTracks = vectorFields[Uid];
forAll(UTracks, tracki)
{
const auto& U = UTracks[tracki];
dirs[tracki] = U/(mag(U) + ROOTVSMALL);
}
}
Info<< "\nWriting particle tracks in " << setFormat
<< " format to " << vtkTracks.name()
<< nl << endl;
scalarFormatterPtr().write
(
true,
tracks,
wordList(0),
List<List<scalarField>>(0),
vtkTracks
);
// Write track fields
// Note: writeFields is a local #define to reduce arg count...
//writeFields(allLabelFields, labelFieldNames, tracks);
writeFields(scalarFields, scalarFieldNames, tracks, times, dirs);
writeFields(vectorFields, vectorFieldNames, tracks, times, dirs);
writeFields(sphTensorFields, sphTensorFieldNames, tracks, times, dirs);
writeFields(symTensorFields, symTensorFieldNames, tracks, times, dirs);
writeFields(tensorFields, tensorFieldNames, tracks, times, dirs);
}
Info<< "End\n" << endl;
Info<< nl << "End\n" << endl;
return 0;
}

View File

@ -27,7 +27,7 @@ Application
steadyParticleTracks
Group
grpPostProcessingUtilitie
grpPostProcessingUtilities
Description
Generate a legacy VTK file of particle tracks for cases that were

View File

@ -72,24 +72,19 @@ int main(int argc, char *argv[])
"Suppress calculation/display of point interpolators"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
const bool noInterpolate = args.found("no-interpolate");
// const bool verbose = args.found("verbose");
args.readIfPresent("visual-length", lumpedPointState::visLength);
#include "createTime.H"
if (args.dryRun())
{
// Create without a mesh

View File

@ -203,7 +203,8 @@ static inline scalar averageSurrounding
template<class Type>
static inline Ostream& putUniform(Ostream& os, const word& key, const Type& val)
{
os.writeKeyword(key) << word("uniform") << token::SPACE
os.writeKeyword(key)
<< word("uniform") << token::SPACE
<< val << token::END_STATEMENT << nl;
return os;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,7 +54,7 @@ void Foam::PDRparams::readDefaults(const dictionary& dict)
outer_orthog = dict.found("outer_orthog");
dict.readIfPresent("debugLevel", debugLevel);
dict.readIfPresent("debug.level", debugLevel);
dict.readIfPresent("nFacesToBlockC", nFacesToBlockC);
dict.readIfPresent("nPairsToBlockC", nPairsToBlockC);
dict.readIfPresent("overlaps", overlaps);

View File

@ -16,7 +16,7 @@ const vector L(dict.get<vector>("L"));
const Vector<label> N(dict.get<Vector<label>>("N"));
// Wave number vs energy profile
autoPtr<Function1<scalar>> Ek(Function1<scalar>::New("Ek", dict));
autoPtr<Function1<scalar>> Ek(Function1<scalar>::New("Ek", dict, &runTime));
// Number of modes
const label nModes = dict.get<label>("nModes");

View File

@ -137,7 +137,7 @@ composedFunctionImplicitFunction
{
FatalIOErrorInFunction(funcDict)
<< "Entry " << key << " is not a dictionary" << endl
<< exit(FatalError);
<< exit(FatalIOError);
}
const dictionary& subdict = dEntry.dict();

View File

@ -231,18 +231,21 @@ int main(int argc, char *argv[])
dictionary& patchDict = boundaryFieldDict.subDict(patchName);
expressions::exprString expr
auto valueExpr_
(
currDict.get<string>("expression"),
currDict,
true // strip comments
expressions::exprString::getEntry
(
"expression",
currDict,
true // strip comments
)
);
Info<< "Set boundaryField/" << patchName << '/'
<< targetName << nl
<< "with expression" << nl
<< "<<<<" << nl
<< expr.c_str() << nl
<< valueExpr_.c_str() << nl
<< ">>>>" << nl;
expressions::patchExprDriver driver(currDict, mesh);
@ -255,7 +258,7 @@ int main(int argc, char *argv[])
);
driver.clearVariables();
driver.parse(expr);
driver.parse(valueExpr_);
// Serializing via Field::writeEntry etc
OStringStream serialize;

View File

@ -53,18 +53,17 @@ Note
using namespace Foam;
using FieldAssociation = expressions::volumeExpr::FieldAssociation;
using FieldAssociation = expressions::FieldAssociation;
word fieldGeoType(const FieldAssociation geoType)
{
switch (geoType)
{
case FieldAssociation::VOLUME_DATA : return "cells"; break;
case FieldAssociation::SURFACE_DATA : return "faces"; break;
case FieldAssociation::POINT_DATA : return "points"; break;
case FieldAssociation::FACE_DATA : return "faces"; break;
case FieldAssociation::VOLUME_DATA : return "cells"; break;
default: break;
}
return "unknown";
}
@ -75,7 +74,7 @@ struct setExprFieldsControl
bool dryRun;
bool debugParsing;
bool cacheVariables;
bool useDimensions;
bool hasDimensions;
bool createNew;
bool keepPatches;
bool correctPatches;
@ -123,13 +122,12 @@ void doCorrectBoundaryConditions
{}
template<class GeoField, class Mesh>
void setField
template<class GeoField>
bool setField
(
const word& fieldName,
const Mesh& mesh,
const GeoField& result,
const scalarField& cond,
const GeoField& evaluated,
const boolField& fieldMask,
const dimensionSet& dims,
const wordList& valuePatches,
@ -139,6 +137,8 @@ void setField
Info<< "setField(" << fieldName << "): "
<< pTraits<GeoField>::typeName << endl;
const auto& mesh = evaluated.mesh();
tmp<GeoField> toutput;
if (ctrl.createNew)
@ -171,55 +171,57 @@ void setField
auto& output = toutput.ref();
label setCells = 0;
label numValuesChanged = 0;
if (cond.empty())
// Internal field
if (fieldMask.empty())
{
// No condition - set all
output = result;
// No field-mask - set entire internal field
numValuesChanged = output.size();
setCells = output.size();
output.primitiveFieldRef() = evaluated;
}
else
{
forAll(output, celli)
auto& internal = output.primitiveFieldRef();
forAll(internal, idx)
{
if (expressions::boolOp<scalar>()(cond[celli]))
if (fieldMask[idx])
{
output[celli] = result[celli];
++setCells;
internal[idx] = evaluated[idx];
++numValuesChanged;
}
}
}
const label totalCells = returnReduce(output.size(), plusOp<label>());
reduce(setCells, plusOp<label>());
forAll(result.boundaryField(), patchi)
// Boundary fields
forAll(evaluated.boundaryField(), patchi)
{
auto& pf = output.boundaryFieldRef()[patchi];
if (pf.patch().coupled())
{
pf == result.boundaryField()[patchi];
pf == evaluated.boundaryField()[patchi];
}
}
doCorrectBoundaryConditions(ctrl.correctBCs, output);
if (setCells == totalCells)
const label numTotal = returnReduce(output.size(), plusOp<label>());
reduce(numValuesChanged, plusOp<label>());
if (numValuesChanged == numTotal)
{
Info<< "Set all ";
}
else
{
Info<< "Set " << setCells << " of ";
Info<< "Set " << numValuesChanged << " of ";
}
Info<< totalCells << " cells" << endl;
Info<< numTotal << " values" << endl;
doCorrectBoundaryConditions(ctrl.correctBCs, output);
if (ctrl.useDimensions)
if (ctrl.hasDimensions)
{
Info<< "Setting dimensions to " << dims << endl;
output.dimensions().reset(dims);
@ -234,6 +236,8 @@ void setField
Info<< "Writing to " << output.name() << nl;
output.writeObject(ctrl.streamOpt, true);
}
return true;
}
@ -241,8 +245,8 @@ void evaluate
(
const fvMesh& mesh,
const word& fieldName,
const expressions::exprString& expression,
const expressions::exprString& condition,
const expressions::exprString& valueExpr_,
const expressions::exprString& maskExpr_,
const dictionary& dict,
const dimensionSet& dims,
const wordList& valuePatches,
@ -273,10 +277,8 @@ void evaluate
if (oldFieldType == IOobject::typeName)
{
FatalErrorInFunction
<< "Field " << fieldName << " is "
<< oldFieldType
<< ". Seems that it does not exist. Use 'create'"
<< nl
<< "Field " << fieldName << "(type: " << oldFieldType
<< ") seems to be missing. Use 'create'" << nl
<< exit(FatalError);
}
@ -284,17 +286,21 @@ void evaluate
<< " (type " << oldFieldType << ')';
}
Info<< " time=" << mesh.thisDb().time().timeName() << nl
<< "Expression:" << nl
<< ">>>>" << nl
<< expression.c_str() << nl
<< valueExpr_.c_str() << nl
<< "<<<<" << nl;
if (condition.size() && condition != "true")
bool evalFieldMask =
(maskExpr_.size() && maskExpr_ != "true" && maskExpr_ != "1");
if (evalFieldMask)
{
Info<< "Condition:" << nl
Info<< "field-mask:" << nl
<< ">>>>" << nl
<< condition.c_str() << nl
<< maskExpr_.c_str() << nl
<< "<<<<" << nl;
}
@ -318,128 +324,95 @@ void evaluate
if (ctrl.debugParsing)
{
Info<< "Parsing expression: " << expression << "\nand condition "
<< condition << nl << endl;
Info<< "Parsing expression: " << valueExpr_ << "\nand field-mask "
<< maskExpr_ << nl << endl;
driver.setDebugging(true, true);
}
driver.clearVariables();
scalarField conditionField;
bool evaluatedCondition = false;
// Handle "field-mask" evaluation
FieldAssociation conditionDataType(FieldAssociation::VOLUME_DATA);
boolField fieldMask;
FieldAssociation maskFieldAssoc(FieldAssociation::NO_DATA);
if (condition.size() && condition != "true")
if (evalFieldMask)
{
if (ctrl.debugParsing)
{
Info<< "Parsing condition:" << condition << endl;
Info<< "Parsing field-mask:" << maskExpr_ << endl;
}
driver.parse(condition);
driver.parse(maskExpr_);
if (ctrl.debugParsing)
{
Info<< "Parsed condition" << endl;
Info<< "Parsed field-mask" << endl;
}
// Process any/all scalar fields. May help with diagnosis
bool goodCond = true;
while (goodCond)
if (driver.isLogical())
{
// volScalarField
auto& result = driver.result();
if (result.is_bool())
{
const auto* ptr = driver.isResultType<volScalarField>();
if (ptr)
{
conditionField = ptr->internalField();
break;
}
fieldMask = result.getResult<bool>();
maskFieldAssoc = driver.fieldAssociation();
}
// surfaceScalarField
{
const auto* ptr = driver.isResultType<surfaceScalarField>();
if (ptr)
{
conditionField = ptr->internalField();
conditionDataType = FieldAssociation::SURFACE_DATA;
break;
}
}
// pointScalarField
{
const auto* ptr = driver.isResultType<pointScalarField>();
if (ptr)
{
conditionField = ptr->internalField();
conditionDataType = FieldAssociation::POINT_DATA;
break;
}
}
// No matching field types
goodCond = false;
}
// Verify that it also logical
goodCond = goodCond && driver.isLogical();
// Slightly pedantic...
driver.clearField();
driver.clearResult();
if (!goodCond)
evalFieldMask = (maskFieldAssoc != FieldAssociation::NO_DATA);
if (!evalFieldMask)
{
FatalErrorInFunction
<< " condition: " << condition
<< " mask: " << maskExpr_
<< " does not evaluate to a logical expression: "
<< driver.resultType() << nl
#ifdef FULLDEBUG
<< "contents: " << conditionField
<< "contents: " << fieldMask
#endif
<< exit(FatalError);
}
if (ctrl.debugParsing)
{
Info<< "Condition evaluates to "
<< conditionField << nl;
Info<< "Field-mask evaluates to "
<< fieldMask << nl;
}
evaluatedCondition = true;
}
if (ctrl.debugParsing)
{
Info<< "Parsing expression:" << expression << endl;
Info<< "Parsing expression:" << valueExpr_ << endl;
}
driver.parse(expression);
driver.parse(valueExpr_);
if (ctrl.debugParsing)
{
Info<< "Parsed expression" << endl;
}
if (evaluatedCondition)
if (evalFieldMask && maskFieldAssoc != driver.fieldAssociation())
{
if (conditionDataType != driver.fieldAssociation())
{
FatalErrorInFunction
<< "Mismatch between condition geometric type ("
<< fieldGeoType(conditionDataType) << ") and" << nl
<< "expression geometric type ("
<< fieldGeoType(driver.fieldAssociation()) << ')' << nl
<< nl
<< "Expression: " << expression << nl
<< "Condition: " << condition << nl
<< nl
<< exit(FatalError);
}
FatalErrorInFunction
<< "Mismatch between field-mask geometric type ("
<< fieldGeoType(maskFieldAssoc) << ") and" << nl
<< "expression geometric type ("
<< fieldGeoType(driver.fieldAssociation()) << ')' << nl
<< nl
<< "expression: " << valueExpr_ << nl
<< "field-mask: " << maskExpr_ << nl
<< nl
<< exit(FatalError);
}
if (!ctrl.createNew && driver.resultType() != oldFieldType)
if (!oldFieldType.empty() && driver.resultType() != oldFieldType)
{
FatalErrorInFunction
<< "Inconsistent types: " << fieldName << " is "
@ -451,81 +424,69 @@ void evaluate
Info<< "Dispatch ... " << driver.resultType() << nl;
#undef setFieldDispatch
#define setFieldDispatch(FieldType) \
{ \
/* FieldType */ \
const auto* ptr = driver.isResultType<FieldType>(); \
if (ptr) \
{ \
/* driver.getResult<FieldType>(correctPatches), */ \
\
setField \
( \
fieldName, \
mesh, \
*ptr, \
conditionField, \
dims, \
valuePatches, \
ctrl \
); \
return; \
} \
} \
bool applied = false;
switch (driver.fieldAssociation())
{
#undef doLocalCode
#define doLocalCode(GeoField) \
{ \
const auto* ptr = driver.isResultType<GeoField>(); \
if (ptr) \
{ \
applied = setField \
( \
fieldName, \
*ptr, \
fieldMask, \
dims, \
valuePatches, \
ctrl \
); \
break; \
} \
}
setFieldDispatch(volScalarField);
setFieldDispatch(volVectorField);
setFieldDispatch(volTensorField);
setFieldDispatch(volSymmTensorField);
setFieldDispatch(volSphericalTensorField);
case FieldAssociation::VOLUME_DATA:
{
doLocalCode(volScalarField);
doLocalCode(volVectorField);
doLocalCode(volTensorField);
doLocalCode(volSymmTensorField);
doLocalCode(volSphericalTensorField);
break;
}
case FieldAssociation::FACE_DATA:
{
doLocalCode(surfaceScalarField);
doLocalCode(surfaceVectorField);
doLocalCode(surfaceTensorField);
doLocalCode(surfaceSymmTensorField);
doLocalCode(surfaceSphericalTensorField);
break;
}
case FieldAssociation::POINT_DATA:
{
doLocalCode(pointScalarField);
doLocalCode(pointVectorField);
doLocalCode(pointTensorField);
doLocalCode(pointSymmTensorField);
doLocalCode(pointSphericalTensorField);
break;
}
setFieldDispatch(surfaceScalarField);
setFieldDispatch(surfaceVectorField);
setFieldDispatch(surfaceTensorField);
setFieldDispatch(surfaceSymmTensorField);
setFieldDispatch(surfaceSphericalTensorField);
default: break;
#undef doLocalCode
}
#undef setFieldDispatch
#define setFieldDispatch(FieldType) \
{ \
/* FieldType */ \
const auto* ptr = driver.isResultType<FieldType>(); \
\
if (ptr) \
{ \
/* driver.getResult<FieldType>(correctPatches), */ \
\
setField \
( \
fieldName, \
pointMesh::New(mesh), \
*ptr, \
conditionField, \
dims, \
valuePatches, \
ctrl \
); \
return; \
} \
} \
setFieldDispatch(pointScalarField);
setFieldDispatch(pointVectorField);
setFieldDispatch(pointTensorField);
setFieldDispatch(pointSymmTensorField);
setFieldDispatch(pointSphericalTensorField);
#undef setFieldDispatch
// Nothing dispatched?
FatalErrorInFunction
<< "Expression evaluates to an unsupported type: "
<< driver.resultType() << nl << nl
<< "Expression " << expression << nl << endl
<< exit(FatalError);
if (!applied)
{
FatalErrorInFunction
<< "Expression evaluates to an unsupported type: "
<< driver.resultType() << nl << nl
<< "Expression " << valueExpr_ << nl << endl
<< exit(FatalError);
}
}
@ -553,9 +514,8 @@ int main(int argc, char *argv[])
(
"Evaluate but do not write"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity",
true // Advanced option
);
@ -584,12 +544,13 @@ int main(int argc, char *argv[])
);
argList::addOption
(
"condition",
"field-mask",
"logic",
"The logical condition when to apply the expression"
"The field mask (logical condition) when to apply the expression"
" (command-line operation)",
true // Advanced option
);
argList::addOptionCompat("field-mask", {"condition", 2106});
argList::addOption
(
"dimensions",
@ -662,9 +623,6 @@ int main(int argc, char *argv[])
#include "createTime.H"
const bool dryrun = args.dryRun();
const bool verbose = args.found("verbose");
const word dictName("setExprFieldsDict");
instantList times = timeSelector::select0(runTime, args);
@ -729,7 +687,7 @@ int main(int argc, char *argv[])
wordHashSet badOptions
({
"create", "keepPatches", "value-patches",
"condition", "expression", "dimensions"
"field-mask", "expression", "dimensions"
});
badOptions.retain(args.options());
@ -797,7 +755,7 @@ int main(int argc, char *argv[])
setExprFieldsControl ctrl;
ctrl.dryRun = dryrun;
ctrl.dryRun = args.dryRun();
ctrl.debugParsing = args.found("debug-parser");
ctrl.cacheVariables = !args.found("no-variable-caching");
@ -805,25 +763,24 @@ int main(int argc, char *argv[])
ctrl.keepPatches = args.found("keepPatches");
ctrl.correctPatches = !args.found("noCorrectPatches");
ctrl.correctBCs = args.found("correctResultBoundaryFields");
ctrl.useDimensions = args.found("dimensions");
ctrl.hasDimensions = args.found("dimensions");
ctrl.streamOpt.format(runTime.writeFormat());
if (args.found("ascii"))
{
ctrl.streamOpt.format(IOstream::ASCII);
}
expressions::exprString
expression
(
args["expression"],
dictionary::null
);
expressions::exprString valueExpr_
(
args["expression"],
dictionary::null
);
expressions::exprString condition;
args.readIfPresent("condition", condition);
expressions::exprString maskExpr_;
args.readIfPresent("field-mask", maskExpr_);
dimensionSet dims;
if (ctrl.useDimensions)
if (ctrl.hasDimensions)
{
ITstream is(args.lookup("dimensions"));
is >> dims;
@ -833,8 +790,8 @@ int main(int argc, char *argv[])
(
mesh,
fieldName,
expression,
condition,
valueExpr_,
maskExpr_,
dictionary::null,
dims,
args.getList<word>("value-patches", false),
@ -869,7 +826,7 @@ int main(int argc, char *argv[])
setExprFieldsControl ctrl;
ctrl.dryRun = dryrun;
ctrl.dryRun = args.dryRun();
ctrl.debugParsing = args.found("debug-parser");
ctrl.cacheVariables = !args.found("no-variable-caching");
@ -902,22 +859,28 @@ int main(int argc, char *argv[])
const word fieldName(dict.get<word>("field"));
expressions::exprString expression
auto valueExpr_
(
dict.get<string>("expression"),
dict
expressions::exprString::getEntry
(
"expression",
dict
)
);
expressions::exprString condition;
if (dict.found("condition"))
expressions::exprString maskExpr_;
{
condition =
expressions::exprString
(
dict.get<string>("condition"),
dict
);
const entry* eptr = dict.findCompat
(
"fieldMask", {{"condition", 2106}},
keyType::LITERAL
);
if (eptr)
{
maskExpr_.readEntry(eptr->keyword(), dict);
maskExpr_.trim();
}
}
dimensionSet dims;
@ -931,10 +894,10 @@ int main(int argc, char *argv[])
{
dimPtr->stream() >> dims;
}
ctrl.useDimensions = bool(dimPtr);
ctrl.hasDimensions = bool(dimPtr);
}
if (verbose && !timei)
if (args.verbose() && !timei)
{
// Report once
Info<< "Processing" << dict << nl;
@ -944,8 +907,8 @@ int main(int argc, char *argv[])
(
mesh,
fieldName,
expression,
condition,
valueExpr_,
maskExpr_,
dict,
dims,
dict.getOrDefault<wordList>("valuePatches", wordList()),

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2112 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -31,7 +31,7 @@ expressions
"radius = 0.1"
);
condition
fieldMask
#{
// Within the radius
(mag(pos() - $[(vector)constants.centre]) < radius)

View File

@ -308,9 +308,8 @@ int main(int argc, char *argv[])
"Split surface along non-manifold edges "
"(default split is fully disconnected)"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
argList::addBoolOption

View File

@ -46,6 +46,9 @@
# The '-show-api' and '-show-patch' options extract values from
# the "META-INFO/api-info" file
#
# The '-show-build' options extract values from
# the "META-INFO/build-info" file
#
# SeeAlso
# META-INFO/README.md for other routines that also use META-INFO.
#
@ -71,6 +74,7 @@ options:
-etc=[DIR] set/unset FOAM_CONFIG_ETC for alternative etc directory
-show-api Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-show-build Print META-INFO build value and exit
-with-api=NUM Specify alternative api value to search with
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
@ -155,6 +159,14 @@ getApiInfo()
}
# Get 'build' from META-INFO/build-info
getBuildValue()
{
value="$(sed -ne 's@^build *= *\([^ ]*\).*@\1@p' "$projectDir"/META-INFO/build-info 2>/dev/null)"
echo "$value"
}
#-------------------------------------------------------------------------------
unset shellOutput verboseOutput
unset optAll optConfig optList projectApi
@ -177,6 +189,10 @@ do
getApiInfo patch
exit $?
;;
-show-build) # Show build information and exit
getBuildValue
exit $?
;;
-with-api=*)
projectApi="${1#*=}"
;;

View File

@ -123,7 +123,7 @@ cleanCase()
rm -rf system/machines
# Possible blockMesh output
rm -f blockTopology.vtu blockTopology.obj blockCentres.obj
rm -f blockTopology.vtu blockFaces.vtp blockTopology.obj blockCentres.obj
# From mpirunDebug
rm -f gdbCommands mpirun.schema

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019-2020 OpenCFD Ltd.
# Copyright (C) 2019-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -39,16 +39,18 @@ fi
#------------------------------------------------------------------------------
if [ -d "$projectDir" ]
_com_openfoam_projectDir="$projectDir"
if [ -d "$_com_openfoam_projectDir" ]
then
_foamSourceBashEnv="$projectDir/etc/bashrc"
_com_openfoam_bashrcFile="${_com_openfoam_projectDir}/etc/bashrc"
else
unset _foamSourceBashEnv
unset _com_openfoam_bashrcFile
fi
# Source the user bashrc first.
# Simply hope that they don't unset/reset _foamSourceBashEnv !!
# Source the user bashrc first. Improbable they use the following variables:
# * _com_openfoam_bashrcFile
# * _com_openfoam_projectDir
if [ -f "$HOME/.bashrc" ]
then
@ -58,40 +60,90 @@ fi
# Source the OpenFOAM etc/bashrc
if [ -f "$_foamSourceBashEnv" ]
if [ -f "$_com_openfoam_bashrcFile" ]
then
. "$_foamSourceBashEnv" $FOAM_SETTINGS
. "$_com_openfoam_bashrcFile" $FOAM_SETTINGS
# Avoid further inheritance
unset FOAM_SETTINGS
else
echo "Missing OpenFOAM etc/bashrc in '${_com_openfoam_projectDir}'" 1>&2
fi
unset _com_openfoam_bashrcFile _com_openfoam_projectDir
# Some feedback
if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ]
# Welcome banner - format somewhat like Ubuntu welcome
#----
## Welcome to Ubuntu VER (GNU/Linux ... x86_64)
##
## * Documentation: ...
#----
if [ -n "$PS1" ] ## Interactive
then
if [ -d "$WM_PROJECT_DIR" ]
then
info="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
_foam_api="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-api 2>/dev/null)"
_foam_patch="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
_foam_build="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-build 2>/dev/null)"
# echo "Using: OpenFOAM-$WM_PROJECT_VERSION ($FOAM_API${info:+ patch=$info}) - visit www.openfoam.com" 1>&2
echo "Using: OpenFOAM-$WM_PROJECT_VERSION${info:+ (patch=$info)} - visit www.openfoam.com" 1>&2
echo "Arch: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2
unset _foam_arch1
case "$WM_OPTIONS" in # Or WM_LABEL_SIZE?
(*Int32*) _foam_arch1="label=32" ;;
(*Int64*) _foam_arch1="label=64" ;;
esac
## echo "$WM_PROJECT_DIR" 1>&2
## echo 1>&2
unset _foam_arch2
case "$WM_OPTIONS" in # Or WM_PRECISION_OPTION?
(*SPDPInt*) _foam_arch2="scalar=32;solveScalar=64" ;;
(*SPInt*) _foam_arch2="scalar=32" ;;
(*DPInt*) _foam_arch2="scalar=64" ;;
esac
if [ "${_foam_patch:-0}" = 0 ]
then
unset _foam_patch
fi
if [ -n "$_foam_build" ]
then
# Everything there - format like binary -help output
_foam_build="${_foam_build}${_foam_patch:+ (patch=${_foam_patch})}"
_foam_verinfo="${_foam_api}"
else
# Missing build info - combine api and patch info together
_foam_verinfo="${_foam_api}${_foam_patch:+ patch=${_foam_patch}}"
fi
echo "openfoam = $WM_PROJECT_DIR" 1>&2
echo 1>&2
echo " * Using: OpenFOAM-$WM_PROJECT_VERSION (${_foam_verinfo}) - visit www.openfoam.com" 1>&2
if [ -n "$_foam_build" ]
then
echo " * Build: ${_foam_build}" 1>&2
fi
# Arch: LSB;label=32;scalar=64
echo " * Arch: $_foam_arch1;$_foam_arch2" 1>&2
echo " * Platform: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2
echo 1>&2
# Set prompt as reminder that this is a shell session
# Chalmers likes this one:
# PS1="OpenFOAM${FOAM_API:+-$FOAM_API}:"'$(foamPwd)\n\u\$ '
# PS1="openfoam${_foam_api}:"'$(foamPwd)\n\u\$ '
PS1="OpenFOAM${FOAM_API:+-$FOAM_API}:"'\w/\n\u\$ '
PS1="openfoam${_foam_api}:"'\w/\n\u\$ '
unset _foam_arch1 _foam_arch2
unset _foam_api _foam_patch _foam_build _foam_verinfo
else
# Adjust prompt if not found - reminder that it is a shell session
PS1="openfoam(not-found):"'\w/\n\u\$ '
fi
else
echo "Could not locate OpenFOAM etc/bashrc in '$projectDir'" 1>&2
echo "OpenFOAM shell session - use 'exit' to quit" 1>&2
echo 1>&2
fi
echo "OpenFOAM shell session - use exit to quit" 1>&2
echo 1>&2
# Cleanup variables (done as final statement for a clean exit code)
unset _foamSourceBashEnv projectDir
unset projectDir
#------------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
## Known Build Issues (v2012, v2106)
## Known Build Issues (v2012, v2106, v2112)
### Windows cross-compilation

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2112 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -34,7 +34,7 @@ expressions
"radius = 0.1"
);
condition
fieldMask
#{
// Within the radius
(mag(pos() - $[(vector)constants.centre]) < radius)

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Version: v2106
\\ / O peration | Version: v2112
\\ / A nd | Website: www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
@ -15,11 +15,12 @@ Description
\*---------------------------------------------------------------------------*/
type dsmcFields;
libs ("liblagrangianFunctionObjects.so");
type dsmcFields;
libs ("liblagrangianFunctionObjects.so");
fields (rhoNMean rhoMMean momentumMean linearKEMean internalEMean
iDofMean fDMean);
// Names for reference purposes only
fields ( rhoNMean rhoMMean momentumMean linearKEMean internalEMean
iDofMean fDMean );
executeControl writeTime;
writeControl writeTime;

View File

@ -78,7 +78,7 @@ CONSTRUCT
scalarData_(dict.get<scalar>("scalarData")),
data_(dict.get<TYPE>("data")),
fieldData_("fieldData", dict, p.size()),
timeVsData_(Function1<TYPE>::New("timeVsData", dict)),
timeVsData_(Function1<TYPE>::New("timeVsData", dict, &this->db())),
wordData_(dict.getOrDefault<word>("wordName", "wordDefault")),
labelData_(-1),
boolData_(false)

View File

@ -0,0 +1,121 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR,AFFILIATION
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "codedFunction1Template.H"
#include "addToRunTimeSelectionTable.H"
#include "unitConversion.H"
//{{{ begin codeInclude
${codeInclude}
//}}} end codeInclude
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
//{{{ begin localCode
${localCode}
//}}} end localCode
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void ${typeName}_${SHA1sum}(bool load)
{
if (load)
{
// Code that can be explicitly executed after loading
}
else
{
// Code that can be explicitly executed before unloading
}
}
namespace Function1Types
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
//makeFunction1(${typeName}Function1, ${TemplateType});
defineTypeNameAndDebug
(
${typeName}Function1_${TemplateType},
0
);
Function1<${TemplateType}>::addRemovabledictionaryConstructorToTable
<${typeName}Function1_${TemplateType}>
addRemovable${typeName}Function1_${TemplateType}ConstructorToTable_;
} // namespace Function1Types
} // namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::Function1Types::
${typeName}Function1_${TemplateType}::
${typeName}Function1_${TemplateType}
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<${TemplateType}>(entryName, dict, obrPtr)
{
if (${verbose:-false})
{
printMessage("Construct ${typeName} Function1 from dictionary");
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::${TemplateType}
Foam::Function1Types::${typeName}Function1_${TemplateType}::value
(
const scalar x
) const
{
//{{{ begin code
${code}
//}}} end code
}
// ************************************************************************* //

View File

@ -0,0 +1,119 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Template for use with dynamic code generation of a Function1
SourceFiles
codedFunction1Template.C
\*---------------------------------------------------------------------------*/
#ifndef dynamicCode_codedFunction1_${typeName}_${TemplateType}_H
#define dynamicCode_codedFunction1_${typeName}_${TemplateType}_H
#include "Function1.H"
#include "dictionaryContent.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Function1Types
{
/*---------------------------------------------------------------------------*\
A coded version Function1
\*---------------------------------------------------------------------------*/
class ${typeName}Function1_${TemplateType}
:
public Function1<${TemplateType}>,
public dictionaryContent
{
// Private Member Functions
//- Report a message with the SHA1sum
inline static void printMessage(const char* message)
{
Info<< message << " sha1: " << SHA1sum << '\n';
}
public:
//- SHA1 representation of the code content
static constexpr const char* const SHA1sum = "${SHA1sum}";
//- Runtime type information
TypeName("${typeName}");
// Constructors
//- Construct from entry name, dictionary and registry
${typeName}Function1_${TemplateType}
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
${typeName}Function1_${TemplateType}
(
const ${typeName}Function1_${TemplateType}& rhs
) = default;
//- Construct and return a clone
virtual tmp<Function1<${TemplateType}>> clone() const
{
return tmp<Function1<${TemplateType}>>
(
new ${typeName}Function1_${TemplateType}(*this)
);
}
//- Destructor
virtual ~${typeName}Function1_${TemplateType}() = default;
// Member Functions
//- Return value as a function of (scalar) independent variable
virtual ${TemplateType} value(const scalar x) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Function1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -83,9 +83,13 @@ addRemovableToRunTimeSelectionTable
dictionary
);
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::
${typeName}FvOption${SourceType}::
${typeName}FvOption${SourceType}
(
@ -106,6 +110,7 @@ ${typeName}FvOption${SourceType}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fv::
${typeName}FvOption${SourceType}::
~${typeName}FvOption${SourceType}()
{
@ -119,6 +124,7 @@ ${typeName}FvOption${SourceType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam::fv::
${typeName}FvOption${SourceType}::correct
(
GeometricField<${TemplateType}, fvPatchField, volMesh>& fld
@ -136,6 +142,7 @@ ${typeName}FvOption${SourceType}::correct
void
Foam::fv::
${typeName}FvOption${SourceType}::addSup
(
fvMatrix<${TemplateType}>& eqn,
@ -147,13 +154,14 @@ ${typeName}FvOption${SourceType}::addSup
Info<< "${typeName}FvOption${SourceType}::addSup()\n";
}
//{{{ begin code
//{{{ begin code - warn/fatal if not implemented?
${codeAddSup}
//}}} end code
}
void
Foam::fv::
${typeName}FvOption${SourceType}::addSup
(
const volScalarField& rho,
@ -163,16 +171,17 @@ ${typeName}FvOption${SourceType}::addSup
{
if (${verbose:-false})
{
Info<< "${typeName}FvOption${SourceType}::addSup()\n";
Info<< "${typeName}FvOption${SourceType}::addSup(rho)\n";
}
//{{{ begin code
${codeAddSup}
//{{{ begin code - warn/fatal if not implemented?
${codeAddSupRho}
//}}} end code
}
void
Foam::fv::
${typeName}FvOption${SourceType}::constrain
(
fvMatrix<${TemplateType}>& eqn,
@ -190,9 +199,4 @@ ${typeName}FvOption${SourceType}::constrain
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// ************************************************************************* //

View File

@ -35,7 +35,14 @@ Description
codeAddSup
(
fvMatrix<Type}>& eqn,
fvMatrix<Type>& eqn,
const label fieldi
)
codeAddSupRho
(
const volScalarField& rho,
fvMatrix<Type>& eqn,
const label fieldi
)
@ -156,7 +163,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const
const dictionary& codeContext() const noexcept
{
return dictionaryContent::dict();
}

View File

@ -80,14 +80,17 @@ defineTypeNameAndDebug
${typeName}PatchFunction1${FieldType},
0
);
PatchFunction1<${TemplateType}>::adddictionaryConstructorToTable
PatchFunction1<${TemplateType}>::addRemovabledictionaryConstructorToTable
<${typeName}PatchFunction1${FieldType}>
add${typeName}PatchFunction1${FieldType}ConstructorToTable_;
addRemovable${typeName}PatchFunction1${FieldType}ConstructorToTable_;
} // namespace PatchFunction1Types
} // namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::PatchFunction1Types::
${typeName}PatchFunction1${FieldType}::
${typeName}PatchFunction1${FieldType}
(
@ -107,6 +110,7 @@ ${typeName}PatchFunction1${FieldType}
}
Foam::PatchFunction1Types::
${typeName}PatchFunction1${FieldType}::
${typeName}PatchFunction1${FieldType}
(
@ -121,7 +125,7 @@ ${typeName}PatchFunction1${FieldType}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::Field<Foam::${TemplateType}>>
${typeName}PatchFunction1${FieldType}::value
Foam::PatchFunction1Types::${typeName}PatchFunction1${FieldType}::value
(
const scalar x
) const
@ -132,10 +136,4 @@ ${typeName}PatchFunction1${FieldType}::value
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace PatchFunction1Types
} // End namespace Foam
// ************************************************************************* //

View File

@ -31,8 +31,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef codedPatchFunction1Template${FieldType}_H
#define codedPatchFunction1Template${FieldType}_H
#ifndef dynamicCode_codedPatchFunction1_${typeName}_${FieldType}_H
#define dynamicCode_codedPatchFunction1_${typeName}_${FieldType}_H
#include "PatchFunction1.H"
#include "dictionaryContent.H"
@ -126,20 +126,11 @@ public:
// Member Functions
//- Is value uniform (i.e. independent of coordinate)
virtual bool uniform() const { return false; }
//- Return value as a function of (scalar) independent variable
virtual tmp<Field<${TemplateType}>> value(const scalar x) const;
//- Is value constant (i.e. independent of x)
virtual bool constant() const
{
return false;
}
//- Is value uniform (i.e. independent of coordinate)
virtual bool uniform() const
{
return false;
}
};

View File

@ -75,10 +75,14 @@ extern "C" void ${typeName}_${SHA1sum}(bool load)
${localCode}
//}}} end localCode
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
${typeName}Points0MotionSolver::${typeName}Points0MotionSolver
Foam::
${typeName}Points0MotionSolver::
${typeName}Points0MotionSolver
(
const polyMesh& mesh,
const IOdictionary& dict
@ -90,13 +94,16 @@ ${typeName}Points0MotionSolver::${typeName}Points0MotionSolver
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
${typeName}Points0MotionSolver::~${typeName}Points0MotionSolver()
Foam::
${typeName}Points0MotionSolver::
~${typeName}Points0MotionSolver()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<pointField> ${typeName}Points0MotionSolver::curPoints() const
Foam::tmp<Foam::pointField>
Foam::${typeName}Points0MotionSolver::curPoints() const
{
if (${verbose:-false})
{
@ -109,8 +116,4 @@ tmp<pointField> ${typeName}Points0MotionSolver::curPoints() const
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -103,7 +103,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const
const dictionary& codeContext() const noexcept
{
return dictionaryContent::dict();
}

View File

@ -78,9 +78,12 @@ makeRemovablePatchTypeField
${typeName}FixedValueFvPatch${FieldType}
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -97,6 +100,7 @@ ${typeName}FixedValueFvPatch${FieldType}
}
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -115,6 +119,7 @@ ${typeName}FixedValueFvPatch${FieldType}
}
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -132,6 +137,7 @@ ${typeName}FixedValueFvPatch${FieldType}
}
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -147,6 +153,7 @@ ${typeName}FixedValueFvPatch${FieldType}
}
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -165,6 +172,7 @@ ${typeName}FixedValueFvPatch${FieldType}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::
${typeName}FixedValueFvPatch${FieldType}::
~${typeName}FixedValueFvPatch${FieldType}()
{
@ -178,6 +186,7 @@ ${typeName}FixedValueFvPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam::
${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
{
if (this->updated())
@ -198,8 +207,4 @@ ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -143,7 +143,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const
const dictionary& codeContext() const noexcept
{
return dictionaryContent::dict();
}

View File

@ -77,9 +77,12 @@ makePointPatchTypeField
${typeName}FixedValuePointPatch${FieldType}
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -96,6 +99,7 @@ ${typeName}FixedValuePointPatch${FieldType}
}
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -114,6 +118,7 @@ ${typeName}FixedValuePointPatch${FieldType}
}
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -132,6 +137,7 @@ ${typeName}FixedValuePointPatch${FieldType}
}
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -147,6 +153,7 @@ ${typeName}FixedValuePointPatch${FieldType}
}
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -165,6 +172,7 @@ ${typeName}FixedValuePointPatch${FieldType}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::
${typeName}FixedValuePointPatch${FieldType}::
~${typeName}FixedValuePointPatch${FieldType}()
{
@ -178,6 +186,7 @@ ${typeName}FixedValuePointPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam::
${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
{
if (this->updated())
@ -198,8 +207,4 @@ ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -144,7 +144,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const
const dictionary& codeContext() const noexcept
{
return dictionaryContent::dict();
}

View File

@ -75,10 +75,13 @@ extern "C" void ${typeName}_${SHA1sum}(bool load)
${localCode}
//}}} end localCode
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const fvMesh& ${typeName}FunctionObject::mesh() const
const Foam::fvMesh&
Foam::${typeName}FunctionObject::mesh() const
{
return refCast<const fvMesh>(obr_);
}
@ -86,7 +89,9 @@ const fvMesh& ${typeName}FunctionObject::mesh() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
${typeName}FunctionObject::${typeName}FunctionObject
Foam::
${typeName}FunctionObject::
${typeName}FunctionObject
(
const word& name,
const Time& runTime,
@ -101,13 +106,16 @@ ${typeName}FunctionObject::${typeName}FunctionObject
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
${typeName}FunctionObject::~${typeName}FunctionObject()
Foam::
${typeName}FunctionObject::
~${typeName}FunctionObject()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool
Foam::
${typeName}FunctionObject::read(const dictionary& dict)
{
if (${verbose:-false})
@ -124,6 +132,7 @@ ${typeName}FunctionObject::read(const dictionary& dict)
bool
Foam::
${typeName}FunctionObject::execute()
{
if (${verbose:-false})
@ -140,6 +149,7 @@ ${typeName}FunctionObject::execute()
bool
Foam::
${typeName}FunctionObject::write()
{
if (${verbose:-false})
@ -156,6 +166,7 @@ ${typeName}FunctionObject::write()
bool
Foam::
${typeName}FunctionObject::end()
{
if (${verbose:-false})
@ -171,8 +182,4 @@ ${typeName}FunctionObject::end()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -32,8 +32,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef functionObjectTemplate_H
#define functionObjectTemplate_H
#ifndef coded_functionObjectTemplate_H
#define coded_functionObjectTemplate_H
#include "regionFunctionObject.H"
#include "dictionaryContent.H"
@ -116,7 +116,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const
const dictionary& codeContext() const noexcept
{
return dictionaryContent::dict();
}

View File

@ -77,9 +77,12 @@ makeRemovablePatchTypeField
${typeName}MixedValueFvPatch${FieldType}
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -96,6 +99,7 @@ ${typeName}MixedValueFvPatch${FieldType}
}
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -114,6 +118,7 @@ ${typeName}MixedValueFvPatch${FieldType}
}
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -131,6 +136,7 @@ ${typeName}MixedValueFvPatch${FieldType}
}
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -146,6 +152,7 @@ ${typeName}MixedValueFvPatch${FieldType}
}
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -164,6 +171,7 @@ ${typeName}MixedValueFvPatch${FieldType}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::
${typeName}MixedValueFvPatch${FieldType}::
~${typeName}MixedValueFvPatch${FieldType}()
{
@ -177,6 +185,7 @@ ${typeName}MixedValueFvPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam::
${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
{
if (this->updated())
@ -197,8 +206,4 @@ ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -143,7 +143,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const
const dictionary& codeContext() const noexcept
{
return dictionaryContent::dict();
}

View File

@ -437,10 +437,10 @@ case SGIMPI:
# ----
# Also support any ending (eg, INTELMPI_custom) to allow custom wmake rules
case intelmpi:
case intelmpi-[1-9]*:
case INTELMPI:
case INTELMPI-[1-9]*:
case INTELMPI*: ## Also includes (INTELMPI | INTELMPI-[1-9]*)
setenv FOAM_MPI intelmpi
## Add version embedded in the naming

View File

@ -99,7 +99,7 @@ case "none":
breaksw
case "system":
# Obtain major.minor from `paraview --version`
# Obtain (major.minor) from `paraview --version`
set pv_api=`paraview --version | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
if ("${pv_api}" == "") then
@ -183,7 +183,7 @@ default:
set pvLibDir="${libDir}/paraview-${pv_api}"
if ( -d "${ParaView_DIR}/${pvLibDir}" ) then
switch ("$pv_api")
case 5.[0-4]*:
case 5.[0-4]:
set libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib)
breaksw
endsw
@ -203,8 +203,8 @@ default:
# Any extra library directories
if ( -n "$pv_libdirs" != "" ) then
switch "WM_ARCH" in
if ( "$pv_libdirs" != "" ) then
switch ("$WM_ARCH")
case darwin*:
setenv DYLD_LIBRARY_PATH "${pv_libdirs}:$DYLD_LIBRARY_PATH"
breaksw

View File

@ -106,6 +106,11 @@ unsetenv FOAM_USER_APPBIN
unsetenv FOAM_USER_LIBBIN
unsetenv FOAM_UTILITIES
# Build related
unsetenv FOAM_BUILDROOT
unsetenv FOAM_THIRD_PARTY_BUILDROOT
unsetenv FOAM_THIRD_PARTY_SOURCES
# Older, unused variables
# Before 1812

View File

@ -442,8 +442,9 @@ SGIMPI)
# ----
# Also support any ending (eg, INTELMPI_custom) to allow custom wmake rules
intelmpi | intelmpi-[1-9]* |\
INTELMPI | INTELMPI-[1-9]* )
INTELMPI*) # Also includes (INTELMPI | INTELMPI-[1-9]*)
export FOAM_MPI=intelmpi
_foamMpiEmbedVersion intelmpi INTELMPI

View File

@ -118,7 +118,7 @@ case "$ParaView_VERSION" in
;;
([0-9]*)
# Extract API from VERSION
# Extract API (major.minor) from VERSION
pv_api=$(echo "$ParaView_VERSION" | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p')
;;
@ -162,7 +162,7 @@ case "$ParaView_VERSION" in
if [ -d "$ParaView_DIR/$pvLibDir" ]
then
case "$pv_api" in
(5.[0-4]*)
(5.[0-4])
libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib)
;;
esac

View File

@ -264,7 +264,7 @@ GCC_NOT_FOUND
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
echo "Using ThirdParty compiler"
echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})"
echo " ${gccDir##*/} (${gmpDir##*/} ${mpfrDir##*/} ${mpcDir##*/})"
fi
;;

View File

@ -130,22 +130,19 @@ then
;;
(*=)
# name= -> unset name
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
&& echo "unset ${foamVar_eval%=}" 1>&2
_foamEcho "unset ${foamVar_eval%=}"
eval "unset ${foamVar_eval%=}"
;;
(*=*)
# name=value -> export name=value
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
&& echo "export $foamVar_eval" 1>&2
_foamEcho "export $foamVar_eval"
eval "export $foamVar_eval"
;;
(*)
# Filename: source it
if [ -f "$foamVar_eval" ]
then
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
&& echo "Using: $foamVar_eval" 1>&2
_foamEcho "Use file: $foamVar_eval"
. "$foamVar_eval"
elif [ -n "$foamVar_eval" ]
then
@ -229,7 +226,7 @@ then
_foamAddMan "$WM_PROJECT_DIR/doc"
fi
# Interactive shell (use PS1, not tty)
# Interactive shell
if [ -n "$PS1" ]
then
_foamEtc -config aliases

View File

@ -95,6 +95,11 @@ unset FOAM_USER_APPBIN
unset FOAM_USER_LIBBIN
unset FOAM_UTILITIES
# Build related
unset FOAM_BUILDROOT
unset FOAM_THIRD_PARTY_BUILDROOT
unset FOAM_THIRD_PARTY_SOURCES
# Older, unused variables
# Before 1812

View File

@ -107,7 +107,8 @@ getApiInfo()
# - No inheritance of FOAM_SETTINGS
# - No default verbosity (only as command-line option)
unset FOAM_CONFIG_ETC FOAM_SETTINGS FOAM_VERBOSE
unset _foamEtcDir _foamSettings _foamScriptCommand _foamSourceBashEnv
unset _foam_config_etc _foam_bashrcFile
unset _foamSettings _foamScriptCommand
unset optTestTut
# Parse options
@ -162,9 +163,14 @@ do
_foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}"
;;
#TDB: -etc-*)
#TDB: # Define FOAM_CONFIG_ETC for finding files
#TDB: _foam_config_etc="${1#*-}"
#TDB: ;;
-etc=*)
# Define FOAM_CONFIG_ETC for finding files
_foamEtcDir="${1#*=}"
_foam_config_etc="${1#*=}"
;;
-prefix=*)
@ -172,7 +178,7 @@ do
;;
-init=*)
_foamSourceBashEnv="${1#*=}"
_foam_bashrcFile="${1#*=}"
;;
-verbose)
@ -227,28 +233,48 @@ then
interactive=true
fi
if [ -z "$_foamSourceBashEnv" ]
if [ -z "$_foam_bashrcFile" ]
then
if [ -n "$interactive" ]
then
# Interactive shell, chain off via a file
_foamSourceBashEnv="$projectDir/bin/tools/source-bashrc"
_foam_bashrcFile="$projectDir/bin/tools/source-bashrc"
else
# Default: OPENFOAM etc/bashrc
_foamSourceBashEnv="$projectDir/etc/bashrc"
_foam_bashrcFile="$projectDir/etc/bashrc"
fi
fi
[ -f "$_foamSourceBashEnv" ] || {
echo "Error: file not found: $_foamSourceBashEnv" 1>&2
[ -f "$_foam_bashrcFile" ] || {
echo "Error: file not found: $_foam_bashrcFile" 1>&2
exit 2
}
if [ -n "$_foamEtcDir" ] && [ -d "$_foamEtcDir" ]
# FOAM_CONFIG_ETC: additional etc directory
case "$_foam_config_etc" in
('') # Empty - ignore
;;
(/*) # Absolute
[ -d "$_foam_config_etc" ] || unset _foam_config_etc
;;
(*) # Relative
if [ -d "$_foam_config_etc" ]
then
# Qualify local dir
_foam_config_etc="$PWD/$_foam_config_etc"
else
[ -d "$projectDir/$_foam_config_etc" ] || unset _foam_config_etc
fi
;;
esac
if [ -n "$_foam_config_etc" ]
then
# Additional etc directory
export FOAM_CONFIG_ETC="$_foamEtcDir"
export FOAM_CONFIG_ETC="$_foam_config_etc"
fi
if [ -n "$interactive" ]
@ -266,10 +292,10 @@ then
export FOAM_SETTINGS="$_foamSettings"
fi
## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2
## echo "Source with $_foam_bashrcFile with '$FOAM_SETTINGS'" 1>&2
# Newer bash can use --init-file instead of --rcfile
exec bash --rcfile "$_foamSourceBashEnv" -i
exec bash --rcfile "$_foam_bashrcFile" -i
exit $? # Safety
fi
@ -281,7 +307,7 @@ fi
# Suppresses aliases as a side-effect, but non-interactive anyhow.
sourceBashrc()
{
. "$_foamSourceBashEnv" $_foamSettings
. "$_foam_bashrcFile" $_foamSettings
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,16 +49,98 @@ static inline bool fullMatch(const regmatch_t& m, const regoff_t len)
} // End anonymous namespace
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::regExpPosix::set_pattern
(
const char* pattern,
size_t len,
bool ignoreCase
)
{
clear(); // Also sets ctrl_ = 0
const char* pat = pattern;
bool doNegate = false;
// Handle known embedded prefixes
if (len > 2 && pat[0] == '(' && pat[1] == '?')
{
pat += 2;
len -= 2;
for (bool done = false; !done && len; ++pat, --len)
{
switch (*pat)
{
case '!':
{
// Negated (inverted) match
doNegate = true;
break;
}
case 'i':
{
// Ignore-case
ignoreCase = true;
break;
}
case ')':
{
// End of prefix parsing
done = true;
break;
}
}
}
}
// Avoid zero-length patterns
if (len)
{
int flags = REG_EXTENDED;
if (ignoreCase)
{
flags |= REG_ICASE;
}
{
preg_ = new regex_t;
int err = regcomp(preg_, pat, flags);
if (err == 0)
{
ctrl_ = (doNegate ? ctrlType::NEGATED : ctrlType::NORMAL);
return true;
}
else
{
char errbuf[200];
regerror(err, preg_, errbuf, sizeof(errbuf));
FatalErrorInFunction
<< "Failed to compile regular expression '"
<< pattern << "'\n" << errbuf
<< exit(FatalError);
}
}
}
return false;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::regExpPosix::clear()
{
ctrl_ = 0;
if (preg_)
{
regfree(preg_);
delete preg_;
preg_ = nullptr;
return true;
}
@ -66,71 +148,40 @@ bool Foam::regExpPosix::clear()
}
bool Foam::regExpPosix::set(const char* pattern, bool ignoreCase)
{
clear();
// Avoid nullptr and zero-length patterns
if (pattern && *pattern)
{
int cflags = REG_EXTENDED;
if (ignoreCase)
{
cflags |= REG_ICASE;
}
const char* pat = pattern;
// Check for embedded prefix for ignore-case
// this is the only embedded prefix we support
// - a simple check is sufficient
if (!strncmp(pattern, "(?i)", 4))
{
cflags |= REG_ICASE;
pat += 4;
// avoid zero-length patterns
if (!*pat)
{
return false;
}
}
preg_ = new regex_t;
int err = regcomp(preg_, pat, cflags);
if (err != 0)
{
char errbuf[200];
regerror(err, preg_, errbuf, sizeof(errbuf));
FatalErrorInFunction
<< "Failed to compile regular expression '" << pattern << "'"
<< nl << errbuf
<< exit(FatalError);
}
return true;
}
return false; // Was cleared and nothing was set
}
bool Foam::regExpPosix::set(const std::string& pattern, bool ignoreCase)
{
return set(pattern.c_str(), ignoreCase);
}
std::string::size_type Foam::regExpPosix::find(const std::string& text) const
{
if (preg_ && !text.empty())
// Find with negated is probably not very reliable...
if (!preg_ || !ctrl_)
{
// Undefined: never matches
return std::string::npos;
}
else if (text.empty())
{
if (ctrl_ == ctrlType::NEGATED)
{
return 0; // No match - pretend it starts at position 0
}
else
{
return std::string::npos;
}
}
else
{
const size_t nmatch = 1;
regmatch_t pmatch[1];
if (regexec(preg_, text.c_str(), nmatch, pmatch, 0) == 0)
const bool ok = (regexec(preg_, text.c_str(), nmatch, pmatch, 0) == 0);
if (ctrl_ == ctrlType::NEGATED)
{
if (!ok)
{
return 0; // No match - claim that is starts at position 0
}
}
else if (ok)
{
return pmatch[0].rm_so;
}
@ -142,23 +193,31 @@ std::string::size_type Foam::regExpPosix::find(const std::string& text) const
bool Foam::regExpPosix::match(const std::string& text) const
{
const auto len = text.size();
bool ok = false;
if (preg_ && len)
if (!preg_ || !ctrl_)
{
// Undefined: never matches
return false;
}
const auto len = text.length();
if (len)
{
const size_t nmatch = 1;
regmatch_t pmatch[1];
// Verify that the entire string was matched
// - [0] is the entire match result
return
ok =
(
regexec(preg_, text.c_str(), nmatch, pmatch, 0) == 0
&& fullMatch(pmatch[0], len)
);
}
return false;
return (ctrl_ == ctrlType::NEGATED ? !ok : ok);
}
@ -170,6 +229,12 @@ bool Foam::regExpPosix::match
{
matches.clear();
// Probably does not make sense for negated pattern...
if (negated())
{
return match(text);
}
const auto len = text.size();
if (preg_ && len)
{

View File

@ -28,10 +28,20 @@ Class
Foam::regExpPosix
Description
Wrapper around POSIX extended regular expressions.
Wrapper around POSIX extended regular expressions
with some additional prefix-handling. The prefix-handling is
loosely oriented on PCRE regular expressions and provides a
simple means of tuning the expressions.
The PCRE '(?i)' extension is provided to compile the regular expression
as being case-insensitive.
The prefixes are detected as \c (?...) at the beginning of
the regular expression. Any unknown/unsupported prefixes are silently
ignored.
- "(?!i)" :
one or more embedded pattern-match modifiers for the entire pattern.
- the \c 'i' indicates ignore-case
- the \c '!' (exclamation) indicates negated (inverted) matching
.
SeeAlso
The manpage regex(7) for more information about POSIX regular expressions.
@ -49,8 +59,8 @@ Warning
for regular expressions continues to improve.
SourceFiles
regExpPosixI.H
regExpPosix.C
regExpPosixI.H
\*---------------------------------------------------------------------------*/
@ -74,11 +84,27 @@ template<class StringType> class SubStrings;
class regExpPosix
{
// Data Types
//- Simple control types
enum ctrlType { EMPTY = 0, NORMAL = 1, NEGATED = 2 };
// Private Data
//- Compiled regular expression
regex_t* preg_;
//- Track if input pattern is non-empty, negated etc.
unsigned char ctrl_;
// Private Member Functions
//- Assign pattern
bool set_pattern(const char* pattern, size_t len, bool ignoreCase);
public:
// Public Types
@ -158,7 +184,14 @@ public:
//- Return true if a precompiled expression exists
inline bool exists() const noexcept;
//- The number of capture groups for a non-empty expression
//- True if pattern matching is negated
inline bool negated() const noexcept;
//- Change pattern negation, return previous value
inline bool negate(bool on) noexcept;
//- The number of capture groups for a non-empty,
//- non-negated expressions
inline unsigned ngroups() const;
@ -173,17 +206,19 @@ public:
//- Compile pattern into a regular expression, optionally ignore case.
// \return True if the pattern was compiled
bool set(const char* pattern, bool ignoreCase=false);
inline bool set(const char* pattern, bool ignoreCase=false);
//- Compile pattern into a regular expression, optionally ignore case.
// \return True if the pattern was compiled
bool set(const std::string& pattern, bool ignoreCase=false);
inline bool set(const std::string& pattern, bool ignoreCase=false);
// Matching/Searching
//- Find position within the text.
// \return The index where it begins or string::npos if not found
//
// \note does not properly work with negated regex!
std::string::size_type find(const std::string& text) const;
//- True if the regex matches the entire text.
@ -193,6 +228,8 @@ public:
//- True if the regex matches the text, set the matches.
// The first group starts at index 1 (0 is the entire match).
// The begin-of-line (^) and end-of-line ($) anchors are implicit
//
// \note does not properly work with negated regex!
bool match(const std::string& text, results_type& matches) const;
//- Return true if the regex was found within the text

View File

@ -31,15 +31,18 @@ License
inline Foam::regExpPosix::regExpPosix() noexcept
:
preg_(nullptr)
preg_(nullptr),
ctrl_(0)
{}
inline Foam::regExpPosix::regExpPosix(regExpPosix&& rgx) noexcept
:
preg_(rgx.preg_)
preg_(rgx.preg_),
ctrl_(rgx.ctrl_)
{
rgx.preg_ = nullptr;
rgx.ctrl_ = 0;
}
@ -49,7 +52,8 @@ inline Foam::regExpPosix::regExpPosix
const bool ignoreCase
)
:
preg_(nullptr)
preg_(nullptr),
ctrl_(0)
{
set(pattern, ignoreCase);
}
@ -61,7 +65,8 @@ inline Foam::regExpPosix::regExpPosix
const bool ignoreCase
)
:
preg_(nullptr)
preg_(nullptr),
ctrl_(0)
{
set(pattern, ignoreCase);
}
@ -89,14 +94,72 @@ inline bool Foam::regExpPosix::exists() const noexcept
}
inline bool Foam::regExpPosix::negated() const noexcept
{
return (ctrl_ == ctrlType::NEGATED);
}
inline bool Foam::regExpPosix::negate(bool on) noexcept
{
bool old(ctrl_ == ctrlType::NEGATED);
if (on)
{
if (ctrl_)
{
ctrl_ = ctrlType::NEGATED;
}
}
else if (old)
{
ctrl_ = ctrlType::NORMAL;
}
return old;
}
inline unsigned Foam::regExpPosix::ngroups() const
{
return preg_ ? preg_->re_nsub : 0;
return (preg_ && ctrl_ == ctrlType::NORMAL) ? preg_->re_nsub : 0;
}
inline bool Foam::regExpPosix::set(const char* pattern, bool ignoreCase)
{
// Silently handle nullptr
return set_pattern
(
pattern,
(pattern ? std::char_traits<char>::length(pattern) : 0),
ignoreCase
);
}
inline bool Foam::regExpPosix::set(const std::string& pattern, bool ignoreCase)
{
return set_pattern
(
pattern.data(),
pattern.length(),
ignoreCase
);
}
inline bool Foam::regExpPosix::search(const std::string& text) const
{
if (!ctrl_)
{
return false;
}
else if (text.empty())
{
return (ctrl_ == ctrlType::NEGATED);
}
return std::string::npos != find(text);
}
@ -107,6 +170,7 @@ inline void Foam::regExpPosix::swap(regExpPosix& rgx)
{
// Self-swap is a no-op
std::swap(preg_, rgx.preg_);
std::swap(ctrl_, rgx.ctrl_);
}
}

View File

@ -162,9 +162,13 @@ $(expr)/exprResult/exprResultStored.C
$(expr)/exprResult/exprResultStoredStack.C
$(expr)/exprString/exprString.C
$(expr)/exprTools/exprTools.C
$(expr)/scanToken/exprScanToken.C
$(expr)/traits/exprTraits.C
$(expr)/exprDriver/exprDriver.C
$(expr)/exprDriver/exprDriverFields.C
$(expr)/exprDriver/exprDriverFunctions.C
$(expr)/exprDriver/exprDriverIO.C
fieldExpr = $(expr)/fields
@ -301,13 +305,15 @@ $(functionEntries)/calcEntry/calcEntry.C
$(functionEntries)/codeStream/codeStream.C
$(functionEntries)/evalEntry/evalEntry.C
$(functionEntries)/functionEntry/functionEntry.C
$(functionEntries)/ifEntry/ifEntry.C
$(functionEntries)/ifeqEntry/ifeqEntry.C
$(functionEntries)/includeEntry/includeEntry.C
$(functionEntries)/includeEtcEntry/includeEtcEntry.C
$(functionEntries)/includeFuncEntry/includeFuncEntry.C
$(functionEntries)/inputMode/inputMode.C
$(functionEntries)/message/messageDirective.C
$(functionEntries)/removeEntry/removeEntry.C
$(functionEntries)/ifeqEntry/ifeqEntry.C
$(functionEntries)/ifEntry/ifEntry.C
$(functionEntries)/word/wordDirective.C
IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/baseIOdictionary.C
@ -350,6 +356,7 @@ $(dll)/codedBase/codedBase.C
funcObjs = db/functionObjects
$(funcObjs)/functionObject/functionObject.C
$(funcObjs)/functionObjectProperties/functionObjectProperties.C
$(funcObjs)/functionObjectList/functionObjectList.C
$(funcObjs)/stateFunctionObject/stateFunctionObject.C
$(funcObjs)/timeFunctionObject/timeFunctionObject.C
@ -451,6 +458,8 @@ $(GAMGInterfaces)/GAMGInterface/GAMGInterfaceNew.C
$(GAMGInterfaces)/processorGAMGInterface/processorGAMGInterface.C
$(GAMGInterfaces)/processorCyclicGAMGInterface/processorCyclicGAMGInterface.C
$(GAMGInterfaces)/cyclicGAMGInterface/cyclicGAMGInterface.C
$(GAMGInterfaces)/primitiveGAMGInterface/primitiveGAMGInterface.C
GAMGInterfaceFields = $(GAMG)/interfaceFields
$(GAMGInterfaceFields)/GAMGInterfaceField/GAMGInterfaceField.C

View File

@ -52,7 +52,7 @@ Typedef
Foam::wordHashSet
Description
A HashSet with (the default) word keys.
A HashSet with word keys and string hasher.
Typedef
Foam::labelHashSet
@ -75,12 +75,22 @@ namespace Foam
// Forward Declarations
template<class T> class MinMax;
template<class Key, class Hash> class HashSet;
// Common hash-set types
//- A HashSet of words, uses string hasher.
typedef HashSet<word, Hash<word>> wordHashSet;
//- A HashSet of labels, uses label hasher.
typedef HashSet<label, Hash<label>> labelHashSet;
/*---------------------------------------------------------------------------*\
Class HashSet Declaration
\*---------------------------------------------------------------------------*/
template<class Key=word, class Hash=Foam::Hash<Key>>
template<class Key, class Hash=Foam::Hash<Key>>
class HashSet
:
public HashTable<zero::null, Key, Hash>
@ -401,14 +411,7 @@ public:
};
// Typedefs
//- A HashSet with word keys.
typedef HashSet<word> wordHashSet;
//- A HashSet with label keys and label hasher.
typedef HashSet<label, Hash<label>> labelHashSet;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global Functions

View File

@ -39,9 +39,10 @@ Description
namespace Foam
{
template<class Key, class Hash> class HashSet;
template<class T, class Key, class Hash> class HashTable;
template<class T, class Key, class Hash> class HashPtrTable;
template<class Key, class Hash> class HashSet;
template<class T> class Map;
template<class T> class PtrMap;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -327,7 +327,7 @@ Foam::labelList Foam::sortedOrder
const UList<T>& input
)
{
labelList order(input.size());
labelList order;
sortedOrder(input, order, typename UList<T>::less(input));
return order;
}
@ -352,15 +352,8 @@ void Foam::sortedOrder
const ListComparePredicate& comp
)
{
const label len = input.size();
// List lengths must be identical
if (order.size() != len)
{
// Avoid copying elements, they are overwritten anyhow
order.clear();
order.resize(len);
}
// List lengths must be identical. Old content is overwritten
order.resize_nocopy(input.size());
ListOps::identity(order);
@ -374,7 +367,7 @@ Foam::labelList Foam::duplicateOrder
const UList<T>& input
)
{
labelList order(input.size());
labelList order;
duplicateOrder(input, order, typename UList<T>::less(input));
return order;
}
@ -427,7 +420,7 @@ Foam::labelList Foam::uniqueOrder
const UList<T>& input
)
{
labelList order(input.size());
labelList order;
uniqueOrder(input, order, typename UList<T>::less(input));
return order;
}

View File

@ -35,7 +35,7 @@ Foam::labelList Foam::sortedOrder
const UPtrList<T>& input
)
{
labelList order(input.size());
labelList order;
sortedOrder(input, order, typename PtrListOps::less<T>(input));
return order;
}
@ -60,15 +60,8 @@ void Foam::sortedOrder
const ListComparePredicate& comp
)
{
const label len = input.size();
// List lengths must be identical
if (order.size() != len)
{
// Avoid copying elements, they are overwritten anyhow
order.clear();
order.resize(len);
}
// List lengths must be identical. Old content is overwritten
order.resize_nocopy(input.size());
ListOps::identity(order);
@ -79,7 +72,7 @@ void Foam::sortedOrder
template<class T>
void Foam::sort(UPtrList<T>& list)
{
labelList order(list.size());
labelList order;
sortedOrder(list, order);
list.sortOrder(order, false); // false = allow nullptr
}
@ -88,7 +81,7 @@ void Foam::sort(UPtrList<T>& list)
template<class T, class Compare>
void Foam::sort(UPtrList<T>& list, const Compare& comp)
{
labelList order(list.size());
labelList order;
sortedOrder(list, order, comp);
list.sortOrder(order, false); // false = allow nullptr
}

View File

@ -314,9 +314,12 @@ public:
static word member(const word& name);
//- Create scope:name or scope_name string
// An empty scope or name is ignored.
template<class StringType>
static inline word scopedName(StringType scope, const word& name);
// An empty scope is ignored.
static inline word scopedName
(
const std::string& scope,
const word& name
);
//- Return the IOobject, but also consider an alternative file name.
//

View File

@ -43,18 +43,13 @@ inline Foam::word Foam::IOobject::groupName
}
template<class StringType>
inline Foam::word Foam::IOobject::scopedName
(
StringType scope,
const std::string& scope,
const word& name
)
{
if (name.empty())
{
return scope;
}
else if (scope.empty())
if (scope.empty())
{
return name;
}

View File

@ -106,12 +106,6 @@ public:
//- Construct by transferring the Field contents
CompactIOField(const IOobject& io, Field<T>&& content);
//- Return a clone
virtual refPtr<regIOobject> deepClone() const
{
return regIOobject::DeepClone(*this);
}
//- Destructor
virtual ~CompactIOField() = default;

Some files were not shown because too many files have changed in this diff Show More