Compare commits

..

61 Commits

Author SHA1 Message Date
3d17825eed BUG: replced with AMDClang general includes 2022-11-07 17:10:41 +01:00
aa93427c7a Added wmake rules for AMD Clang and Hipcc compiler 2022-11-04 18:56:26 +01:00
d9226575e6 STY: added FOAM namaspace to min and max functions 2022-11-04 18:54:44 +01:00
124702190b ENH: use returnReduceAnd(), returnReduceOr() functions 2022-11-01 19:09:05 +01:00
8071f2f94b ENH: more consistent use of broadcast, combineReduce etc.
- broadcast           : (replaces scatter)
  - combineReduce       == combineGather + broadcast
  - listCombineReduce   == listCombineGather + broadcast
  - mapCombineReduce    == mapCombineGather + broadcast
  - allGatherList       == gatherList + scatterList

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

    - combineReduce       (2206: combineAllGather)
    - listCombineReduce   (2206: listCombineAllGather)
    - mapCombineReduce    (2206: mapCombineAllGather)
2022-11-01 19:09:05 +01:00
fc19ca39f3 BUG: integratedNonUniformTable: correct offsets (fixes #2614) 2022-11-01 14:47:08 +00:00
2202995f5c ENH: expose IntRange {begin,end}_value() methods
- end_value() corresponds to the infrequently used after() method, but
  with naming that corresponds better to iterator naming conventions.

  Eg,

     List<Type> list = ...;
     labelRange range = ...;

     std::transform
     (
         (list.data() + range.begin_value()),
         (list.data() + range.end_value()),

         outIter,
         op
     );

- promote min()/max() methods from labelRange to IntRange base class

STYLE: change timeSelector from "is-a" to "has-a" scalarRanges.
2022-10-31 18:36:15 +01:00
21f037e3a0 ENH: single/double value reset method for MinMax
- resets min/max to be identical to the specified value,
  which can be more convenient (and slightly more efficient) than doing
  a full reset followed by add()

- additional MinMax intersects() query, which works like overlaps()
  but with exclusive checks at the ends

- provide MinMax::operator&=() to replace (unused) intersect() method

ENH: single/double value reset method for boundBox

- boundBox::operator&=() to replace (rarely used) intersect() method.
  Deprecate boundBox::intersect() to avoid confusion with various
  intersects() method

COMP: provide triangleFwd.H
2022-10-31 18:36:14 +01:00
c973066646 ENH: supplementary vector comparison methods
- background: for some application it can be useful to have fully
  sorted points. i.e., sorted by x, followed by y, followed by z.

  The default VectorSpace 'operator<' compares *all*
  components. This is seen by the following comparisons

  1.  a = (-2.2 -3.3 -4.4)
      b = (-1.1 -2.2 3.3)

      (a < b) : True
      Each 'a' component is less than each 'b' component

  2.  a = (-2.2 -3.3 -4.4)
      b = (-2.2 3.3 4.4)

      (a < b) : False
      The a.x() is not less than b.x()

  The static definitions 'less_xyz', 'less_yzx', 'less_zxy'
  instead use comparison of the next components as tie breakers
  (like a lexicographic sort).
  - same type of definition that Pair and Tuple2 use.

      a = (-2.2 -3.3 -4.4)
      b = (-2.2 3.3 4.4)

      vector::less_xyz(a, b) : True
      The a.x() == b.x(), but a.y() < b.y()

   They can be used directly as comparators:

      pointField points = ...;

      std::sort(points.begin(), points.end(), vector::less_zxy);

ENH: make VectorSpace named access methods noexcept.

   Since the addressing range is restricted to enumerated offsets
   (eg, X/Y/Z) into storage, always remains in-range.
   Possible to make constexpr with future C++ versions.

STYLE: VectorSpace 'operator>' defined using 'operator<'

- standard rewriting rule
2022-10-31 18:36:14 +01:00
371795840c ENH: bounding sphere calculation for PrimitivePatch face
- useful when a characteristic per-face search dimension is required.
  With PrimitivePatch we are certain to have consistent evaluations
  of the face centre.

STYLE: tag PrimitivePatch compatibility headers as such
2022-10-31 18:36:14 +01:00
7a43cac55a ENH: component/element access for zero/one return themselves
STYLE: more consistent access for uniform list/fields
2022-10-31 18:36:14 +01:00
9433898941 ENH: support construction of pointIndexHit from pointHit
STYLE: combine templated/non-templated headers (reduced clutter)

STYLE: use hitPoint(const point&) combined setter

- same as setHit() + setPoint(const point&)

ENH: expose and use labelOctBits::pack method for addressing
2022-10-31 18:36:14 +01:00
454f7960b0 STYLE: expand use of ListLoop macros (#2624)
- the old List_FOR_ALL macro only remained in use in relatively few
  places. Replace with the expanded equivalent and move the looping
  parameter out of the macro and give an explicit name (eg, loopLen)
  which simplifies the addition of any loop pragmas in the various
  TFOR_ALL... macros (for example).
2022-10-31 18:36:14 +01:00
9db3547bd3 ENH: support optional average value when reading rawIOField
ENH: simplify bookkeeping within MappedFile
2022-10-31 18:36:14 +01:00
278378031e ENH: add syncState() method to serial streams (#2623)
- in places where direct reading from the std::stream is used,
  this method can be used to ensure that the OpenFOAM Sstream state
  is properly updated from the std::stream.

ENH: restrict stream renaming to ISstream

- non-const access was previously declared at the top-level (IOstream)
  but that not only added in potentially odd setting of the static
  fileName, but also meant that the OFstream name() could potentially
  be altered after opening a file and thus be inconsistent with the
  underlying file that had been opened.

  Now restrict name modification to ISstream (and ITstream
  counterpart). Does not affect any existing valid code.

STYLE: non-default OFstream destructor (for future file staging)
2022-10-31 09:34:37 +01:00
bd000d89e9 COMP: include fileFormats, surfMesh for faOptions, fvOptions 2022-10-27 16:13:41 +02:00
ac25608fbd BUG: viewFactor: smoothing when zero visible faces. Fixes #2622 2022-10-27 11:58:36 +01:00
37e90dbad7 ENH: limitTemperature: obey 'active' flag. Fixes #2621 2022-10-27 10:00:00 +01:00
2c7a7b27a3 ENH: distributedTriSurfaceMesh: support distributed running 2022-10-26 17:15:51 +01:00
7a67c1e72b DOC: redistributePar: better warning 2022-10-26 17:15:51 +01:00
b145e59049 STYLE: viewFactorsGen with std::vector (reserve) instead of std::list 2022-10-26 18:04:56 +02:00
24ffc5236d COMP: simplify openmp handling (#2617)
- remove old, unneeded -DUSE_OMP define.
- wmake -no-openmp option to add '~openmp' to WM_COMPILE_CONTROL

ENH: add bash completion handling for wmake
2022-10-26 18:04:56 +02:00
fd55151a12 SUBMODULE: cfmesh update handling of -DUSE_OMP (openmp)
- defined locally, independent of wmake rules
2022-10-26 18:02:26 +02:00
3caeeb1f51 BUG: functionObjectProperties: prevent restart failures (fixes #2618)
- regression in develop, not other branches
2022-10-26 14:49:21 +01:00
0c3a938810 Merge branch 'feature-masterCoarsest-multi-masters' into 'develop'
Feature master coarsest multi masters

See merge request Development/openfoam!565
2022-10-20 09:14:23 +00:00
62244c6caf Feature master coarsest multi masters 2022-10-20 09:14:22 +00:00
3a6a76044d BUG: objective: avoid double name registration in localIOdictionary (fixes #2596) 2022-10-18 13:08:56 +01:00
5a9dbcdadf BUG: incorrect tag/communicator order in debugSurfaceWriter 2022-10-13 18:15:21 +02:00
65dc440f3c COMP: silence clang -Wbitwise-instead-of-logical (triggered by boost/cgal) 2022-10-12 19:44:01 +02:00
4585a2d229 COMP: fix bad constructor resolution
STYLE: simpler initialization
2022-10-12 19:32:56 +02:00
18eeba116a ENH: use boundBox building blocks in misc places 2022-10-12 13:19:48 +02:00
61deacd24d ENH: boundBox improvements (#2609)
- construct boundBox from Pair<point> of min/max limits,
  make sortable

- additional bounding box intersections (linePointRef), add noexcept

- templated access for boundBox hex-corners
  (used to avoid temporary point field).
  Eg, unrolled plane/bound-box intersection with early exit

- bounding box grow() to expand box by absolute amounts
  Eg,

      bb.grow(ROOTVSMALL);   // Or: bb.grow(point::uniform(ROOTVSMALL));
  vs
      bb.min() -= point::uniform(ROOTVSMALL);
      bb.max() += point::uniform(ROOTVSMALL);

- treeBoundBox bounding box extend with two or three parameters.
  The three parameter version includes grow(...) for reduced writing.
  Eg,

      bb = bb.extend(rndGen, 1e-4, ROOTVSMALL);

  vs
      bb = bb.extend(rndGen, 1e-4);
      bb.min() -= point::uniform(ROOTVSMALL);
      bb.max() += point::uniform(ROOTVSMALL);

  This also permits use as const variables or parameter passing.
  Eg,

      const treeBoundBox bb
      (
          treeBoundBox(some_points).extend(rndGen, 1e-4, ROOTVSMALL)
      );
2022-10-12 13:19:44 +02:00
81b1c5021f ENH: provide low-level bound box() methods for meshShapes
- box method on meshShapes (cell,edge,face,triangle,...)
  returns a Pair<point>.

  Can be used directly without dependency on boundBox,
  but the limits can also passed through to boundBox.

- Direct box calculation for cell, which walks the cell-faces and
  mesh-faces.  Direct calculation for face (#2609)
2022-10-12 12:54:39 +02:00
96ff2f32e5 ENH: support direct calculation of finiteArea edgeNormals (#2592)
- with geometryOrder=1, calculate the edge normals from the adjacent
  faces (area-weighted, inverse distance squared) and also
  use that for the Le() calculation.

  Includes the contributions from processor edge neighbours, so it
  should be consistent on both sides.

  This new method (consider as 'beta') contrasts with the current
  standard method that first calculates area-weighted point normals
  and uses the average of them for the edge normal.

  Enable for testing either with a controlDict OptimisationSwitch entry
  "fa:geometryOrder", or on the command-line:

      solverName -opt-switch=fa:geometryOrder=1
2022-10-11 18:02:23 +02:00
9434972261 ENH: use fallback value if calculated Le() is degenerate (#2592)
- the Le vector is calculated from (edgeVec ^ edgeNorm)
  and should be oriented in direction (faceCentre -> edgeCentre).

  If, however, the edgeNorm value is bad for any reason, the
  cross-product falls apart and Le vector is calculated as a zero
  vector!

  For these cases, revert to using (faceCentre -> edgeCentre)
  as a better approximation than a zero vector.

  In the future, will very likely switch calculating the edge normals
  directly from the attached faces, instead of from the attached
  points as is currently done, which should improve robustness.

ENH: expose fa:geometryOrder as a registered OptimisationSwitch

ENN: reuse polyMesh data (eg, faceCentres) if possible in faMesh

STYLE: add code lambdas and static functions to isolate logic
2022-10-11 18:02:23 +02:00
d5cdc60a54 BUG: processorMeshes removeFiles does not remove collated (fixes #2607)
ENH: extend rmDir to handle removal of empty directories only

- recursively remove directories that only contain other directories
  but no other contents. Treats dead links as non-content.
2022-10-11 17:58:22 +02:00
779a2ca084 ENH: adjust fileName methods for similarity to std::filesystem::path
- stem(), replace_name(), replace_ext(), remove_ext() etc

- string::contains() method - similar to C++23 method

  Eg,
      if (keyword.contains('/')) ...
  vs
      if (keyword.find('/') != std::string::npos) ...
2022-10-11 17:58:22 +02:00
98a510c317 GIT: relocate treeDataEdge, treeDataPoint into OpenFOAM
- similar to treeDataCell, doesn't need any meshTools components
- AABBTree under algorithms (like indexedOctree)
2022-10-11 17:56:57 +02:00
0c89f38312 ENH: additional DimensionedField, GeometricField factory methods
- construct based on db and mesh information from an existing field

- check movable() instead of isTmp() when reusing fields

STYLE: isolate check for reuse GeometricField into Detail namespace
2022-10-06 12:54:06 +02:00
bcd461926c BUG: invalid pointer reference for optional coordinate system lookup
- code remnant from separate lookup + construct of coordinateSystem
  (7b2bcfda0b).
  Apply consistent use of coordinateSystem::NewIfPresent to avoid
  these types of coding mishaps
2022-10-06 12:50:06 +02:00
793433da72 DOC: snappyHexMeshDict: updated comment for blockLevel 2022-10-05 12:15:19 +01:00
34d69cad23 ENH: snappyHexMesh. Avoid excessive intermediate. Fixes #2600 2022-10-05 11:45:44 +01:00
a246a97b12 ENH: add debug surfaceWriter
- enables special purpose debugging.
  Its definition and behaviour are subject to change at any time.
2022-10-04 15:51:27 +02:00
7b2bcfda0b ENH: improved handling of coordinateSystems
- in continuation of #2565 (rotationCentre for surface output formats)
  it is helpful to also support READ_IF_PRESENT behaviour for the
  'origin' keyword.

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

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

   but remains mandatory if constructed without a sub-dict:

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

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

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

ENH: simplify handling of "coordinateSystem" dictionary lookups

- coordinateSystems::NewIfPresent method for optional entries:

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

  Instead of

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

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

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

  Was previously slightly inconsistent between the different models.
2022-10-04 15:51:27 +02:00
7eda6de6f4 ENH: use readOption to fine-tune dictionary reading
- previously had 'mandatory' (bool) for advanced control of reading
  dictionary entries but its meaning was unclear in the calling code
  without extra code comments.

  Now use IOobjectOption::readOption instead, which allows further
  options (ie, NO_READ) and is more transparent as to its purpose in
  the code than a true/false bool flag was.

  This is a minor breaking change (infrequent, advanced usage only)

- minor code cleanup in dictionary lookup methods
2022-10-04 15:51:26 +02:00
d938e01d7a ENH: refactor IOobject options
- IOobjectOption class encapsulates read/write, storage flags for
  lightweight handling, independent of objectRegistry etc.

ENH: add IOobject isReadRequired() and isReadOptional() queries

- encapsulates test of MUST_READ, MUST_READ_IF_MODIFIED,
  READ_IF_PRESENT for convenience / less clutter.

Example,

    if (isReadRequired() || (isReadOptional() && headerOk()))
    {
        ...
    }

Instead of

    if
    (
        (
            readOpt() == IOobject::MUST_READ
         || readOpt() == IOobject::MUST_READ_IF_MODIFIED
        )
     || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
    )
    {
        ...
    }
2022-10-04 15:51:26 +02:00
623c0624fb ENH: simplify stream construction
- with IOstreamOption there are no cases where we need to construct
  top-level streams (eg, IFstream, OFstream) with additional information
  about the internal IOstream 'version' (eg, version: 2.0).

  Makes it more convenient to open files with a specified
  format/compression combination - no clutter of specifying the
  version
2022-10-04 15:51:26 +02:00
36d7954004 ENH: refPtr/tmp is_reference() to complement is_pointer() method
STYLE: return nullptr instead of tmp<...>() for failure
2022-10-04 15:51:26 +02:00
159a7a5a38 ENH: simplify parallel/serial checks in ensight output
BUG: inadvertant type conversion in ensightFileTemplates::writeLabels
2022-10-04 15:51:26 +02:00
55f5f8774b ENH: use dictionary findDict() instead of isDict() + subDict()
- avoids redundant dictionary searching

STYLE: remove dictionary lookupOrDefaultCompat wrapper

- deprecated and replaced by getOrDefaultCompat (2019-05).
  The function is usually specific to internal keyword upgrading
  (version compatibility) and unlikely to exist in any user code.
2022-10-04 15:51:26 +02:00
9d5a3a5c54 STYLE: remove duplicate dimensionSet dictionary read constructor
STYLE: make dimensionedTypes access inline noexcept
2022-10-04 15:51:26 +02:00
ee9119f436 ENH: rationalize expression string reading
- read construct from dictionary.
  Calling syntax similar to dimensionedType, dimensionedSet,...

  Replaces the older getEntry(), getOptional() static methods

- support readIfPresent
2022-10-04 15:51:26 +02:00
3a6e427409 ENH: simplify dictionary search for value/refValue in BCs
- in expressions BCs in particular, there is various logic handling
  for if value/refValue/refGradient etc are found or not.

  Handle the lookups as findEntry and branch to use Field assign
  or other handling, depending on its existence.

STYLE: use wordList instead of wordRes for copy/filter dictionary
2022-10-04 15:51:26 +02:00
ea51c2c0e4 STYLE: return orientedType, Switch directly instead of const reference
- noexcept on some Time methods

ENH: pass through is_oriented() method for clearer coding

- use logical and/or/xor instead of bitwise versions (clearer intent)
2022-10-04 15:51:26 +02:00
867b5e9060 Merge branch 'feature-noise-writeFile' into 'develop'
ENH: noiseModels - replaced graph usage by writeFile

See merge request Development/openfoam!562
2022-10-04 13:50:32 +00:00
7c2311aae6 ENH: noiseModels - replaced graph usage by writeFile
Header information now includes, e.g.

    f [Hz] vs P(f) [Pa]
    Lower frequency: 2.500000e+01
    Upper frequency: 5.000000e+03
    Window model: Hanning
    Window number: 2
    Window samples: 512
    Window overlap %: 5.000000e+01
    dBRef       : 2.000000e-05
    Area average: false
    Area sum    : 6.475194e-04
    Number of faces: 473

Note: output files now have .dat extension
2022-10-04 13:10:39 +00:00
f87f0040b8 ENH: writeFile - add newFile function
ENH: writeFile - renamed createFile functions
     to newFileAtTime and newFileAtStartTime
2022-10-04 13:10:39 +00:00
c59b6db3c4 ENH: viewFactorsGen: re-enable 2D. See #2560
This reverts the v2206 behaviour so does not include
the edge-integration (2LI) optimisation - it uses
the exact same code as v2206.
2022-10-03 16:54:58 +01:00
5677e10d90 ENH: checkMesh: report overlapping zones. See #2521 2022-10-03 11:41:42 +01:00
38d68824b3 ENH: uniformInterpolatedDisplacement: Delay evaluation. Fixes #2605
If a `value` field is present use it and don't look for time
directories since this messes up the construct-from-dictionary
2022-10-03 10:31:40 +01:00
8283599c31 ENH: meshQualityDict: disable minEdgeLength by default (fixes #2599) 2022-09-29 14:16:44 +01:00
930 changed files with 10706 additions and 8945 deletions

View File

@ -36,11 +36,11 @@ Description
if (adjustTimeStep)
{
scalar maxDeltaTFact = maxCo/(CoNum + StCoNum + SMALL);
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
scalar deltaTFact = Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
min
Foam::min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -1,5 +1,5 @@
if (adjustTimeStep)
{
runTime.setDeltaT(min(dtChem, maxDeltaT));
runTime.setDeltaT(Foam::min(dtChem, maxDeltaT));
Info<< "deltaT = " << runTime.deltaT().value() << endl;
}

View File

@ -54,9 +54,9 @@ if (adjustTimeStep)
runTime.setDeltaT
(
min
Foam::min
(
dt0*min(min(TFactorFluid, min(TFactorFilm, TFactorSolid)), 1.2),
dt0*Foam::min(Foam::min(TFactorFluid, Foam::min(TFactorFilm, TFactorSolid)), 1.2),
maxDeltaT
)
);

View File

@ -18,13 +18,13 @@
const surfaceScalarField& phi2 =
phaseSystemFluid[regioni].phase2().phiRef();
sumPhi = max
sumPhi = Foam::max
(
sumPhi,
fvc::surfaceSum(mag(phi1))().primitiveField()
);
sumPhi = max
sumPhi = Foam::max
(
sumPhi,
fvc::surfaceSum(mag(phi2))().primitiveField()
@ -43,7 +43,7 @@
/ fluidRegions[regioni].V().field()
)*runTime.deltaTValue(),
CoNum = max(UrCoNum, CoNum);
CoNum = Foam::max(UrCoNum, CoNum);
}
}

View File

@ -2,7 +2,7 @@
forAll(fluidRegions, regioni)
{
CoNum = max
CoNum = Foam::max
(
compressibleCourantNo
(

View File

@ -47,10 +47,10 @@ if (adjustTimeStep)
runTime.setDeltaT
(
min
Foam::min
(
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaT().value(),
min(runTime.deltaTValue(), maxDeltaT)
Foam::min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaT().value(),
Foam::min(runTime.deltaTValue(), maxDeltaT)
)
);
Info<< "deltaT = " << runTime.deltaT().value() << endl;

View File

@ -49,17 +49,17 @@ if (adjustTimeStep)
scalar maxDeltaTSolid = maxDi/(DiNum + SMALL);
scalar deltaTFluid =
min
Foam::min
(
min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
Foam::min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
1.2
);
runTime.setDeltaT
(
min
Foam::min
(
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaT().value(),
Foam::min(deltaTFluid, maxDeltaTSolid)*runTime.deltaT().value(),
maxDeltaT
)
);

View File

@ -35,7 +35,7 @@
(
solidRegions[i],
thermos[i],
coordinateSystem::typeName_()
coordinateSystem::typeName
)
);

View File

@ -22,7 +22,7 @@ forAll(solidRegions, i)
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();
DiNum = max
DiNum = Foam::max
(
solidRegionDiffNo
(

View File

@ -15,7 +15,7 @@ if (!thermo.isotropic())
(
mesh,
thermo,
coordinateSystem::typeName_()
coordinateSystem::typeName
);
tmp<volVectorField> tkappaByCp = thermo.Kappa()/thermo.Cp();

View File

@ -17,7 +17,7 @@ scalar DiNum = -GREAT;
tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho();
DiNum = max
DiNum = Foam::max
(
solidRegionDiffNo
(

View File

@ -36,13 +36,13 @@ Description
if (adjustTimeStep)
{
const scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL));
Foam::min(maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL));
const scalar deltaTFact =
min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
min
Foam::min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -214,7 +214,7 @@
phiCN,
alphaPhi10,
Sp,
(Su + divU*min(alpha1(), scalar(1)))(),
(Su + divU*Foam::min(alpha1(), scalar(1)))(),
oneField(),
zeroField()
);

View File

@ -214,7 +214,7 @@
phiCN,
alphaPhi10,
Sp,
(Su + divU*min(alpha1(), scalar(1)))(),
(Su + divU*Foam::min(alpha1(), scalar(1)))(),
oneField(),
zeroField()
);

View File

@ -36,13 +36,13 @@ Description
if (adjustTimeStep)
{
scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
Foam::min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
scalar deltaTFact = Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
min
Foam::min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -36,13 +36,13 @@ Description
if (adjustTimeStep)
{
scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
Foam::min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
scalar deltaTFact = Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
min
Foam::min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -37,11 +37,11 @@ if (adjustTimeStep)
if (CoNum > SMALL)
{
scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
Foam::min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
runTime.setDeltaT
(
min
Foam::min
(
maxDeltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
}
else if (dgdt[celli] < 0.0)
{
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
}
}

View File

@ -1,6 +1,6 @@
// Update alpha1
#include "alphaSuSp.H"
advector.advect(Sp,(Su + divU*min(alpha1(), scalar(1)))());
advector.advect(Sp,(Su + divU*Foam::min(alpha1(), scalar(1)))());
// Update rhoPhi
rhoPhi = advector.getRhoPhi(rho1, rho2);
@ -10,6 +10,6 @@ alpha2 = 1.0 - alpha1;
Info<< "Phase-1 volume fraction = "
<< alpha1.weightedAverage(mesh.Vsc()).value()
<< " Min(" << alpha1.name() << ") = " << min(alpha1).value()
<< " Max(" << alpha1.name() << ") - 1 = " << max(alpha1).value() - 1
<< " Min(" << alpha1.name() << ") = " << Foam::min(alpha1).value()
<< " Max(" << alpha1.name() << ") - 1 = " << Foam::max(alpha1).value() - 1
<< endl;

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
}
else if (dgdt[celli] < 0.0)
{
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
}
}

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
}
else if (dgdt[celli] < 0.0)
{
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
}
}

View File

@ -157,12 +157,7 @@ void Foam::radiation::laserDTRM::initialiseReflection()
);
}
if (reflections_.size())
{
reflectionSwitch_ = true;
}
reflectionSwitch_ = returnReduce(reflectionSwitch_, orOp<bool>());
reflectionSwitch_ = returnReduceOr(reflections_.size());
}
}
@ -299,14 +294,12 @@ void Foam::radiation::laserDTRM::initialise()
DTRMCloud_.addParticle(pPtr);
}
if (returnReduce(cellI, maxOp<label>()) == -1)
if (nMissed < 10 && returnReduceAnd(cellI < 0))
{
if (++nMissed <= 10)
{
WarningInFunction
<< "Cannot find owner cell for focalPoint at "
<< p0 << endl;
}
++nMissed;
WarningInFunction
<< "Cannot find owner cell for focalPoint at "
<< p0 << endl;
}
}
}

View File

@ -36,13 +36,13 @@ Description
if (adjustTimeStep)
{
scalar maxDeltaTFact =
min
Foam::min
(
maxCo/(CoNum + SMALL),
min
Foam::min
(
maxAlphaCo/(alphaCoNum + SMALL),
min
Foam::min
(
maxAlphaDdt/(ddtAlphaNum + SMALL),
maxDi/(DiNum + SMALL)
@ -50,11 +50,11 @@ if (adjustTimeStep)
)
);
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
scalar deltaTFact = Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
min
Foam::min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -8,5 +8,5 @@
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
CoNum = max(CoNum, UrCoNum);
CoNum = Foam::max(CoNum, UrCoNum);
}

View File

@ -8,5 +8,5 @@
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
CoNum = max(CoNum, UrCoNum);
CoNum = Foam::max(CoNum, UrCoNum);
}

View File

@ -28,11 +28,6 @@ License
#include "DirLister.H"
#include <dirent.h>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
static const Foam::word extgz("gz");
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::DirLister::const_iterator::open(const fileName& dir)
@ -110,9 +105,9 @@ Foam::word Foam::DirLister::next(DIR* dirPtr) const
if (ok)
{
if (fType == fileName::FILE && stripgz_ && name.hasExt(extgz))
if (fType == fileName::FILE && stripgz_ && name.has_ext("gz"))
{
name = name.lessExt();
name.remove_ext();
}
if (!name.empty() && accept(name))

View File

@ -113,7 +113,6 @@ int main(int argc, char *argv[])
label coarseSize = max(addr)+1;
Info<< "Level : " << level << endl
<< returnReduce(addr.size(), sumOp<label>()) << endl
<< " current size : "
<< returnReduce(addr.size(), sumOp<label>()) << endl
<< " agglomerated size : "

View File

@ -90,7 +90,7 @@ void writeAndRead
const IOobject& io,
const label sz,
const word& writeType,
const IOobject::readOption rOpt,
IOobjectOption::readOption rOpt,
const word& readType
)
{
@ -208,7 +208,8 @@ int main(int argc, char *argv[])
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
IOobject::NO_WRITE,
IOobject::NO_REGISTER
);
{
@ -243,9 +244,7 @@ int main(int argc, char *argv[])
args.executable(),
"constant",
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
IOobject::NO_REGISTER // implicit convert to IOobjectOption
);
labelList ints(identity(200));

View File

@ -182,7 +182,7 @@ int main(int argc, char *argv[])
// MPI barrier
bool barrier = true;
Pstream::scatter(barrier);
Pstream::broadcast(barrier);
}

View File

@ -83,9 +83,9 @@ int main(int argc, char *argv[])
{
IOstreamOption streamOpt;
if (outputName.hasExt("gz"))
if (outputName.has_ext("gz"))
{
outputName.removeExt();
outputName.remove_ext();
streamOpt.compression(IOstreamOption::COMPRESSED);
}

View File

@ -138,8 +138,8 @@ int main()
maxFirstEqOp<label>()(maxIndexed, item);
}
Pstream::combineAllGather(minIndexed, minFirstEqOp<label>());
Pstream::combineAllGather(maxIndexed, maxFirstEqOp<label>());
Pstream::combineReduce(minIndexed, minFirstEqOp<label>());
Pstream::combineReduce(maxIndexed, maxFirstEqOp<label>());
Info<< "Min indexed: " << minIndexed << nl
<< "Max indexed: " << maxIndexed << nl;
@ -156,8 +156,8 @@ int main()
maxIndexed = maxFirstOp<label>()(maxIndexed, item);
}
Pstream::combineAllGather(minIndexed, minFirstEqOp<label>());
Pstream::combineAllGather(maxIndexed, maxFirstEqOp<label>());
Pstream::combineReduce(minIndexed, minFirstEqOp<label>());
Pstream::combineReduce(maxIndexed, maxFirstEqOp<label>());
Info<< "Min indexed: " << minIndexed << nl
<< "Max indexed: " << maxIndexed << nl;

View File

@ -1,7 +1,2 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,8 @@ Description
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "boundBox.H"
#include "line.H"
#include "Random.H"
#include "treeBoundBox.H"
#include "cellModel.H"
#include "bitSet.H"
@ -84,7 +85,20 @@ int main(int argc, char *argv[])
else
{
bb = cube(0, 1);
Info<<"starting box: " << bb << endl;
Info<< "starting box: " << bb << endl;
Info<< "corner: " << bb.hexCorner<0>() << nl
<< "corner: " << bb.hexCorner<7>() << nl
<< "corner: " << bb.hexCorner<6>() << endl;
linePoints ln1(bb.max(), bb.centre());
Info<< "line: " << ln1 << " box: " << ln1.box() << endl;
Info<< "box: " << boundBox(ln1.box()) << endl;
Info<< "corner: " << bb.hexCorner<0>() << nl
<< "corner: " << bb.hexCorner<7>() << nl
<< "corner: " << bb.hexCorner<6>() << endl;
point pt(Zero);
bb.add(pt);
@ -147,6 +161,25 @@ int main(int argc, char *argv[])
Info<< "box is now => " << box1 << endl;
}
List<boundBox> boxes(12);
{
Random rndGen(12345);
for (auto& bb : boxes)
{
bb = cube
(
rndGen.position<scalar>(-10, 10),
rndGen.position<scalar>(0, 5)
);
}
Info<< "boxes: " << boxes << endl;
Foam::sort(boxes);
Info<< "sorted: " << boxes << endl;
}
return 0;
}

View File

@ -59,11 +59,11 @@ void basicTests(const coordinateSystem& cs)
{
cs.writeEntry(cs.name(), Info);
if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
if ((const auto* cartptr = isA<coordSystem::cartesian>(cs)) != nullptr)
{
if (!cartptr->active())
if (!cartptr->valid())
{
Info<< "inactive cartesian = " << (*cartptr)
Info<< "invalid cartesian = " << (*cartptr)
<< " with: " << (*cartptr).R() << nl;
}
}
@ -106,7 +106,7 @@ void doTest(const dictionary& dict)
try
{
auto cs1ptr = coordinateSystem::New(dict, "");
auto cs1ptr = coordinateSystem::New(dict, word::null);
coordinateSystem& cs1 = *cs1ptr;
cs1.rename(dict.dictName());

View File

@ -51,11 +51,8 @@ cs4
{
type cylindrical;
origin (0 3 5);
rotation
{
type euler;
angles (90 0 0);
}
rotation euler;
angles (90 0 0);
}
cyl
@ -75,10 +72,7 @@ cyl
ident
{
origin (0 0 0);
rotation
{
type none;
}
rotation none;
}
)

View File

@ -26,7 +26,7 @@ rot_x90
rot_x90_axesRotation
{
origin (0 0 0);
coordinateRotation
rotation
{
type axesRotation;
e1 (1 0 0);
@ -37,7 +37,7 @@ rot_x90_axesRotation
rot_x90_axisAngle
{
origin (0 0 0);
coordinateRotation
rotation
{
type axisAngle;
axis (1 0 0); // non-unit also OK
@ -48,7 +48,7 @@ rot_x90_axisAngle
rot_x90_euler
{
origin (0 0 0);
coordinateRotation
rotation
{
type euler;
angles (0 90 0); // z-x'-z''
@ -61,7 +61,7 @@ rot_x90_euler
rot_z45_axesRotation
{
origin (0 0 0);
coordinateRotation
rotation
{
type axesRotation;
e1 (1 1 0);
@ -72,7 +72,7 @@ rot_z45_axesRotation
rot_z45_axisAngle
{
origin (0 0 0);
coordinateRotation
rotation
{
type axisAngle;
axis (0 0 10); // non-unit also OK
@ -83,7 +83,7 @@ rot_z45_axisAngle
rot_z45_euler
{
origin (0 0 0);
coordinateRotation
rotation
{
type euler;
angles (45 0 0); // z-x'-z''
@ -93,7 +93,7 @@ rot_z45_euler
rot_z45_starcd
{
origin (0 0 0);
coordinateRotation
rotation
{
type starcd;
angles (45 0 0); // z-x'-y''
@ -106,7 +106,7 @@ rot_z45_starcd
rot_zm45_axesRotation
{
origin (0 0 0);
coordinateRotation
rotation
{
type axesRotation;
e1 (1 -1 0);
@ -117,7 +117,7 @@ rot_zm45_axesRotation
rot_zm45_axisAngle
{
origin (0 0 0);
coordinateRotation
rotation
{
type axisAngle;
axis (0 0 10); // non-unit also OK
@ -128,7 +128,7 @@ rot_zm45_axisAngle
rot_zm45_euler
{
origin (0 0 0);
coordinateRotation
rotation
{
type euler;
angles (-45 0 0); // z-x'-z''
@ -141,7 +141,7 @@ rot_zm45_euler
null_axesRotation
{
origin (0 0 0);
coordinateRotation
rotation
{
type axesRotation;
e1 (1 0 0);
@ -152,7 +152,7 @@ null_axesRotation
null_axisAngle0
{
origin (0 0 0);
coordinateRotation
rotation
{
type axisAngle;
axis (0 0 0); // non-unit also OK
@ -163,7 +163,7 @@ null_axisAngle0
null_axisAngle1
{
origin (0 0 0);
coordinateRotation
rotation
{
type axisAngle;
axis (1 1 1); // non-unit also OK
@ -174,7 +174,7 @@ null_axisAngle1
null_euler
{
origin (0 0 0);
coordinateRotation
rotation
{
type euler;
angles (0 0 0); // z-x'-z''

View File

@ -60,7 +60,7 @@ int main(int argc, char *argv[])
Info<< "Reading " << file << nl << endl;
decomposedBlockData data
(
Pstream::worldComm,
UPstream::worldComm,
IOobject
(
file,
@ -79,7 +79,6 @@ int main(int argc, char *argv[])
(
objPath,
IOstreamOption::BINARY,
IOstreamOption::currentVersion,
runTime.writeCompression()
);
if (!os.good())

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,8 +65,7 @@ int main(int argc, char *argv[])
"tensor",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
{ IOobject::READ_IF_PRESENT, IOobject::NO_REGISTER }
),
mesh,
dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9))
@ -75,6 +74,47 @@ int main(int argc, char *argv[])
Info().beginBlock("transformed")
<< tensorfld.T() << nl;
Info().endBlock();
{
auto tfld =
DimensionedField<scalar, volMesh>::New
(
tensorfld,
"scalar",
dimensioned<scalar>(14)
);
Info().beginBlock(tfld().type())
<< tfld << nl;
Info().endBlock();
}
{
auto tfld =
volScalarField::New
(
"scalar",
tensorfld.mesh(),
dimensioned<scalar>(5)
);
Info().beginBlock(tfld().type())
<< tfld() << nl;
Info().endBlock();
// From dissimilar types
auto tfld2 =
volVectorField::New
(
tfld(),
"vector",
dimensioned<vector>(Zero)
);
Info().beginBlock(tfld2().type())
<< tfld2() << nl;
Info().endBlock();
}
}
#ifdef TEST_UINT8_FIELD

View File

@ -120,7 +120,8 @@ int main(int argc, char *argv[])
try
{
// Should not trigger any errors
expressions::exprString expr(str, dict, false);
auto expr = expressions::exprString::toExpr(str, dict);
Info<< "expr: " << expr << nl;
}
catch (const Foam::error& err)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,6 +48,14 @@ Description
using namespace Foam;
// Create named file with some dummy content
void touchFileContent(const fileName& file)
{
std::ofstream os(file);
os << "file=<" << file << ">" << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
unsigned testClean(std::initializer_list<Pair<std::string>> tests)
@ -260,7 +268,7 @@ int main(int argc, char *argv[])
"hello1",
"hello2",
"hello3",
"hello4.hmm"
"hello4.ext"
};
Info<< file1 << nl;
@ -270,7 +278,7 @@ int main(int argc, char *argv[])
{
file1,
"some",
"more/things.hmm"
"more/things.ext"
};
Info<< file2 << nl;
@ -281,7 +289,7 @@ int main(int argc, char *argv[])
{
std::string("ffO"),
"some",
"more/things.hmm"
"more/things.ext"
};
Info<< file3 << nl;
@ -295,7 +303,7 @@ int main(int argc, char *argv[])
{
"some",
file3,
"more/things.hmm",
"more/things.ext",
file1
};
Info<< "All ==> " << file4 << nl;
@ -328,26 +336,26 @@ int main(int argc, char *argv[])
fileName input1("path.to/media/image.png");
Info<<"File : " << input0 << " ext: "
<< Switch(input0.hasExt())
<< Switch(input0.has_ext())
<< " = " << input0.ext() << nl;
Info<<"File : " << input1 << " ext: "
<< Switch(input1.hasExt())
<< Switch(input1.has_ext())
<< " = " << input1.ext() << nl;
Info<<"File : " << endWithDot << " ext: "
<< Switch(endWithDot.hasExt())
<< Switch(endWithDot.has_ext())
<< " = " << endWithDot.ext() << " <-- perhaps return false?" << nl;
Info<<"File : " << endWithSlash << " ext: "
<< Switch(endWithSlash.hasExt())
<< Switch(endWithSlash.has_ext())
<< " = " << endWithSlash.ext() << nl;
Info<<"Remove extension " << (input0.removeExt());
Info<<"Remove extension " << (input0.remove_ext());
Info<< " now: " << input0 << nl;
Info<<"Remove extension " << (input1.removeExt());
Info<< " now: " << input1 << nl;
Info<<"Remove extension " << (endWithSlash.removeExt());
Info<<"Remove extension " << (endWithSlash.remove_ext());
Info<< " now: " << endWithSlash << nl;
wordList exts{ "jpg", "png", "txt", word::null };
@ -359,14 +367,14 @@ int main(int argc, char *argv[])
Info<< nl;
Info<<"Test hasExt(word)" << nl
Info<<"Test has_ext(word)" << nl
<<"~~~~~~~~~~~~~~~~~" << nl;
Info<<"Has extension(s):" << nl
<< "input: " << input1 << nl;
for (const word& e : exts)
{
Info<<" '" << e << "' -> "
<< Switch(input1.hasExt(e)) << nl;
<< Switch(input1.has_ext(e)) << nl;
}
Info<< nl;
@ -375,12 +383,12 @@ int main(int argc, char *argv[])
for (const word& e : exts)
{
Info<<" '" << e << "' -> "
<< Switch(endWithDot.hasExt(e)) << nl;
<< Switch(endWithDot.has_ext(e)) << nl;
}
Info<< nl;
Info<<"Test hasExt(wordRe)" << nl
Info<<"Test has_ext(wordRe)" << nl
<<"~~~~~~~~~~~~~~~~~~~" << nl;
// A regex with a zero length matcher doesn't work at all:
@ -393,25 +401,25 @@ int main(int argc, char *argv[])
Info<<"Has extension(s):" << nl
<< "input: " << endWithDot << nl;
Info<<" " << matcher0 << " -> "
<< Switch(endWithDot.hasExt(matcher0)) << nl;
<< Switch(endWithDot.has_ext(matcher0)) << nl;
Info<<" " << matcher1 << " -> "
<< Switch(endWithDot.hasExt(matcher1)) << nl;
<< Switch(endWithDot.has_ext(matcher1)) << nl;
Info<<" " << matcher2 << " -> "
<< Switch(endWithDot.hasExt(matcher2)) << nl;
<< Switch(endWithDot.has_ext(matcher2)) << nl;
Info<< "input: " << input1 << nl;
Info<<" " << matcher0 << " -> "
<< Switch(input1.hasExt(matcher0)) << nl;
<< Switch(input1.has_ext(matcher0)) << nl;
Info<<" " << matcher1 << " -> "
<< Switch(input1.hasExt(matcher1)) << nl;
<< Switch(input1.has_ext(matcher1)) << nl;
Info<<" " << matcher2 << " -> "
<< Switch(input1.hasExt(matcher2)) << nl;
<< Switch(input1.has_ext(matcher2)) << nl;
Info<< nl;
Info<<"Remove extension(s):" << nl << "input: " << input1 << nl;
while (!input1.empty())
{
if (input1.removeExt())
if (input1.remove_ext())
{
Info<< " -> " << input1 << nl;
}
@ -587,14 +595,54 @@ int main(int argc, char *argv[])
if (args.found("system"))
{
const fileName dirA("dirA");
const fileName dirB("dirB");
const fileName dirC("dirC");
const fileName dirD("dirD");
const fileName lnA("lnA");
const fileName lnB("lnB");
const fileName dirB("dirB");
Foam::rmDir(dirA);
// Purge anything existing
Foam::rmDir(dirA, true);
Foam::rmDir(dirB, true);
Foam::rmDir(dirC, true);
Foam::rmDir(dirD, true);
Foam::rm(lnA);
Foam::rm(lnB);
Foam::rmDir(dirB);
{
fileName name(dirA/dirB/dirC/"abc");
Foam::mkDir(name.path());
touchFileContent(name); // Create real file
Foam::mkDir(dirB/dirB/dirB/dirB);
Foam::ln("test", dirB/"linkB"); // Create dead link
Foam::mkDir(dirC);
Foam::ln("../dirD", dirC/"linkC"); // Create real link
Foam::mkDir(dirD);
for (const fileName& d : { dirA, dirB, dirC, dirD })
{
Info<< "Directory: " << d << " = "
<< readDir(d, fileName::UNDEFINED, false, false) << nl;
if (Foam::rmDir(d, false, true))
{
Info<< " Removed empty dir" << nl;
}
else
{
Info<< " Could not remove empty dir" << nl;
}
}
// Force removal before continuing
Foam::rmDir(dirA, true);
Foam::rmDir(dirB, true);
Foam::rmDir(dirC, true);
Foam::rmDir(dirD, true);
}
Info<< nl << "=========================" << nl
<< "Test some copying and deletion" << endl;
@ -618,9 +666,7 @@ int main(int argc, char *argv[])
);
Info<<" create: " << file << endl;
std::ofstream os(file);
os << "file=<" << file << ">" << nl;
touchFileContent(file);
}
const int oldDebug = POSIX::debug;
@ -708,7 +754,7 @@ int main(int argc, char *argv[])
"hello1",
"hello2",
"hello3",
"hello4.hmm"
"hello4.ext"
};
fileName pathName(wrdList);
@ -718,14 +764,28 @@ int main(int argc, char *argv[])
<< "pathName.name() = >" << pathName.name() << "<\n"
<< "pathName.path() = " << pathName.path() << nl
<< "pathName.ext() = >" << pathName.ext() << "<\n"
<< "pathName.nameLessExt= >" << pathName.nameLessExt() << "<\n";
<< "pathName.stem = >" << pathName.stem() << "<\n";
Info<< "pathName.components() = " << pathName.components() << nl
<< "pathName.component(2) = " << pathName.component(2) << nl
<< endl;
Info<< "hasPath = " << Switch(pathName.hasPath()) << nl;
pathName.removePath();
pathName.replace_name("newName.ext");
Info<< "new name = " << pathName << nl;
Info<< "has ext = " << Switch::name(pathName.has_ext()) << nl;
Info<< "has ext('') = " << Switch::name(pathName.has_ext("")) << nl;
Info<< "has ext(foo) = " << Switch::name(pathName.has_ext("foo")) << nl;
Info<< "has ext(ext) = " << Switch::name(pathName.has_ext("ext")) << nl;
pathName.replace_ext("png");
Info<< "new ext = " << pathName << nl;
pathName.replace_ext(""); // Same as remove_ext
Info<< "new ext = " << pathName << nl;
Info<< "has path = " << Switch::name(pathName.has_path()) << nl;
pathName.remove_path();
pathName.removePath(); // second type should be a no-op
Info<< "removed path = " << pathName << nl;
Info<< nl << nl;

View File

@ -64,13 +64,8 @@ int main(int argc, char *argv[])
// Slightly extended bb. Slightly off-centred just so on symmetric
// geometry there are less face/edge aligned items.
treeBoundBox bb
(
efem.points()
);
bb.min() -= point::uniform(ROOTVSMALL);
bb.max() += point::uniform(ROOTVSMALL);
treeBoundBox bb(efem.points());
bb.grow(ROOTVSMALL);
labelList allEdges(identity(efem.edges().size()));

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -61,10 +61,10 @@ int main(int argc, char *argv[])
InfoErr<< "output: " << outputName;
IOstreamOption::compressionType comp(IOstreamOption::UNCOMPRESSED);
if (outputName.hasExt("gz"))
if (outputName.has_ext("gz"))
{
comp = IOstreamOption::COMPRESSED;
outputName.removeExt();
outputName.remove_ext();
InfoErr<< " [compress]";
}

View File

@ -204,7 +204,7 @@ int main(int argc, char *argv[])
labelPair inOut;
pointField allCcs(globalNumbering.gather(mesh.cellCentres()));
inOut[0] = allCcs.size();
Pstream::scatter(allCcs);
Pstream::broadcast(allCcs);
inOut[1] = allCcs.size();
Pout<< " " << inOut << endl;

View File

@ -41,8 +41,8 @@ void printInfo(const labelRange& range)
<< "last " << range.last() << nl
<< "min " << range.min() << nl
<< "max " << range.max() << nl
<< "after " << range.after() << nl
<< "begin end " << *range.cbegin() << ' ' << *range.cend() << nl;
<< "end " << range.end_value() << nl
<< "begin/end " << *range.cbegin() << ' ' << *range.cend() << nl;
// Info<< "rbegin rend " << *range.rbegin() << ' ' << *range.rend() << nl;
}
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::noFunctionObjects();
argList::addArgument("start size .. startN sizeN");
argList::addVerbose("enable labelRange::debug");
argList::addVerboseOption("enable labelRange::debug");
argList::addNote
(
"The default is to add ranges, use 'add' and 'del' to toggle\n\n"

View File

@ -44,7 +44,7 @@ using namespace Foam;
template<class T>
Ostream& printInfo(const MinMax<T>& range)
{
Info<< range << " valid=" << range.valid() << " span=" << range.span();
Info<< range << " good=" << range.good() << " span=" << range.span();
return Info;
}
@ -234,11 +234,7 @@ int main(int argc, char *argv[])
Pout<< "hashed: " << hashed << nl;
Pstream::mapCombineGather
(
hashed,
plusEqOp<scalarMinMax>()
);
Pstream::mapCombineReduce(hashed, plusEqOp<scalarMinMax>());
Info<< "reduced: " << hashed << nl;

View File

@ -44,7 +44,7 @@ using namespace Foam;
template<class T>
Ostream& printInfo(const MinMax<T>& range)
{
Info<< range << " valid=" << range.valid();
Info<< range << " good=" << range.good();
return Info;
}

View File

@ -1,4 +1,4 @@
EXE_INC = $(COMP_OPENMP) /* -UUSE_OMP */
EXE_INC = $(COMP_OPENMP)
/* Mostly do not need to explicitly link openmp libraries */
/* EXE_LIBS = $(LINK_OPENMP) */

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,12 +41,6 @@ Description
int main(int argc, char *argv[])
{
#if USE_OMP
std::cout << "USE_OMP defined (" << USE_OMP << ")\n";
#else
std::cout << "USE_OMP undefined\n";
#endif
#if _OPENMP
std::cout << "_OPENMP = " << _OPENMP << "\n\n";

View File

@ -167,7 +167,7 @@ int main(int argc, char *argv[])
(
localValue,
sumOp<scalar>(),
Pstream::msgType(),
UPstream::msgType(),
comm
);
Pout<< "sum :" << sum << endl;

View File

@ -125,13 +125,13 @@ int main(int argc, char *argv[])
scalar data1 = 1.0;
label request1 = -1;
{
Foam::reduce(data1, sumOp<scalar>(), Pstream::msgType(), request1);
Foam::reduce(data1, sumOp<scalar>(), UPstream::msgType(), request1);
}
scalar data2 = 0.1;
label request2 = -1;
{
Foam::reduce(data2, sumOp<scalar>(), Pstream::msgType(), request2);
Foam::reduce(data2, sumOp<scalar>(), UPstream::msgType(), request2);
}

View File

@ -232,6 +232,7 @@ int main(int argc, char *argv[])
const labelListList& edgeFaces = pp.edgeFaces();
const labelListList& faceEdges = pp.faceEdges();
Pout<< "box: " << pp.box() << endl;
checkFaceEdges(localFaces, edges, faceEdges);

View File

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

View File

@ -0,0 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfileFormats \
-lsurfMesh \
-lmeshTools

View File

@ -0,0 +1,168 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 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/>.
Application
Test-rawIOField
Description
Reading rawIOField from disk
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "Switch.H"
#include "primitiveFields.H"
#include "pointField.H"
#include "rawIOField.H"
#include "exprTraits.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;
#undef USE_ROOT_CASE
//#define USE_ROOT_CASE
template<class Type>
tmp<Field<Type>> readRawField
(
const IOobject& io,
IOobjectOption::readOption withAverage
)
{
rawIOField<Type> raw(io, withAverage);
Info<< "File: " << io.objectPath() << nl
<< "Read: " << raw.size()
<< ' ' << pTraits<Type>::typeName << " entries" << nl
<< "Average: " << Switch::name(raw.hasAverage())
<< " = " << raw.average() << endl;
return tmp<Field<Type>>::New(std::move(static_cast<Field<Type>&>(raw)));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Test behaviour of rawIOField reading (writing?)"
);
argList::noCheckProcessorDirectories();
argList::addBoolOption("scalar", "Read scalar field");
argList::addBoolOption("vector", "Read vector field");
argList::addBoolOption("point", "Read point field");
argList::addBoolOption("average", "Require averaged value entry");
argList::addBoolOption("try-average", "Optional averaged value entry");
argList::addArgument("fileName");
#ifdef USE_ROOT_CASE
#include "setRootCase.H"
#include "createTime.H"
#else
// Without root case, or time
argList args(argc, argv);
#endif
fileName inputName = args.get<fileName>(1);
IOobjectOption::readOption withAverage = IOobjectOption::NO_READ;
if (args.found("average"))
{
withAverage = IOobjectOption::MUST_READ;
}
else if (args.found("try-average"))
{
withAverage = IOobjectOption::READ_IF_PRESENT;
}
Info<< "Using case: " << argList::envGlobalPath() << nl
<< "Read file: " << inputName << nl
<< "with average: " << int(withAverage) << nl
<< endl;
refPtr<Time> timePtr;
#ifdef USE_ROOT_CASE
timePtr.cref(runTime);
#endif
// Fallback (eg, no runTime)
if (!timePtr.good())
{
timePtr.reset(Time::New(argList::envGlobalPath()));
}
const auto& tm = timePtr();
fileName resolvedName(inputName);
resolvedName.toAbsolute();
IOobject io
(
resolvedName, // absolute path
tm,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER,
true // is global object (currently not used)
);
if (args.found("scalar"))
{
auto tfield = readRawField<scalar>(io, withAverage);
}
else if (args.found("point"))
{
auto tfield = readRawField<point>(io, withAverage);
}
else if (args.found("vector"))
{
auto tfield = readRawField<vector>(io, withAverage);
}
else
{
Info<< "no data type specified!\n";
}
Info<< nl << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -135,6 +135,7 @@ int main(int argc, char *argv[])
cout<<"string:" << sizeof(Foam::string) << nl;
}
cout<<"IOobjectOption:" << sizeof(Foam::IOobjectOption) << nl;
cout<<"IOobject:" << sizeof(Foam::IOobject) << nl;
cout<<"IOstream:" << sizeof(Foam::IOstream) << nl;
cout<<"PstreamBuffers:" << sizeof(Foam::PstreamBuffers) << nl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -91,15 +91,15 @@ int main(int argc, char *argv[])
const auto importName = args.get<fileName>(1);
word ext;
if (!args.readIfPresent("ext", ext))
{
ext = importName.ext();
if (ext == "gz")
{
ext = importName.lessExt().ext();
}
}
word ext =
(
importName.has_ext("gz")
? importName.stem().ext()
: importName.ext()
);
// Allow override of extension
args.readIfPresent("ext", ext);
args.readIfPresent("stl-parser", fileFormats::STLReader::parserType);

View File

@ -33,6 +33,7 @@ Description
#include "vectorField.H"
#include "IOstreams.H"
#include "Random.H"
#include <algorithm>
#include <random>
@ -74,8 +75,12 @@ void doTest(vector& vec1, vector& vec2)
printInfo(vec1);
printInfo(vec2);
Info<< "min of " << vec1 << " and " << vec2 << " = "
<< min(vec1, vec2) << nl << nl;
Info<< "vector: " << vec1 << nl
<< "vector: " << vec2 << nl
<< " min: " << min(vec1, vec2) << nl
<< " dist: " << vec1.dist(vec2) << ' ' << mag(vec1 - vec2) << nl
<< "dist^2: " << vec1.distSqr(vec2) << ' ' << magSqr(vec1 - vec2) << nl
<< nl;
}
@ -146,6 +151,46 @@ int main(int argc, char *argv[])
std::shuffle(vec2.begin(), vec2.end(), std::default_random_engine());
Info<< "shuffled: " << vec2 << nl;
// Vectors with some identical components
List<vector> vectors
({
{1.1, 2.2, 3.3 },
{2.2, 3.3, 4.4 },
{-1.1, 2.2, 3.3 },
{-2.2, 3.3, 4.4 },
{-1.1, -2.2, 3.3 },
{-2.2, -3.3, 4.4 },
{-1.1, -2.2, -3.3 },
{-2.2, -3.3, -4.4 },
{-3.3, 2.1, 12 },
{3.145, 1.6, 2 },
{0, 0, 0}
});
shuffle(vectors);
Info<< "initial vectors: ";
vectors.writeList(Info, 1) << nl;
Foam::sort(vectors);
Info<< "regular sort:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_xyz);
Info<< "sorted xyz:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_yzx);
Info<< "sorted yzx:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_zxy);
Info<< "sorted zxy:";
vectors.writeList(Info, 1) << nl;
}
// Basic tests for fields

View File

@ -585,7 +585,7 @@ void createBaffles
// Wrapper around find patch. Also makes sure same patch in parallel.
label findPatch(const polyBoundaryMesh& patches, const word& patchName)
{
label patchi = patches.findPatchID(patchName);
const label patchi = patches.findPatchID(patchName);
if (patchi == -1)
{
@ -597,16 +597,15 @@ label findPatch(const polyBoundaryMesh& patches, const word& patchName)
// Check same patch for all procs
{
label newPatch = patchi;
reduce(newPatch, minOp<label>());
const label newPatchi = returnReduce(patchi, minOp<label>());
if (newPatch != patchi)
if (newPatchi != patchi)
{
FatalErrorInFunction
<< "Patch " << patchName
<< " should have the same patch index on all processors." << nl
<< "On my processor it has index " << patchi
<< " ; on some other processor it has index " << newPatch
<< " ; on some other processor it has index " << newPatchi
<< exit(FatalError);
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -396,12 +397,11 @@ int main(int argc, char *argv[])
meshSearch queryMesh(mesh);
// Check all 'outside' points
forAll(outsidePts, outsideI)
for (const point& outsidePoint : outsidePts)
{
const point& outsidePoint = outsidePts[outsideI];
const label celli = queryMesh.findCell(outsidePoint, -1, false);
label celli = queryMesh.findCell(outsidePoint, -1, false);
if (returnReduce(celli, maxOp<label>()) == -1)
if (returnReduceAnd(celli < 0))
{
FatalErrorInFunction
<< "outsidePoint " << outsidePoint

View File

@ -142,26 +142,26 @@ scalar getEdgeStats(const primitiveMesh& mesh, const direction excludeCmpt)
if (mag(eVec & x) > 1-edgeTol)
{
minX = min(minX, eMag);
maxX = max(maxX, eMag);
minX = Foam::min(minX, eMag);
maxX = Foam::max(maxX, eMag);
nX++;
}
else if (mag(eVec & y) > 1-edgeTol)
{
minY = min(minY, eMag);
maxY = max(maxY, eMag);
minY = Foam::min(minY, eMag);
maxY = Foam::max(maxY, eMag);
nY++;
}
else if (mag(eVec & z) > 1-edgeTol)
{
minZ = min(minZ, eMag);
maxZ = max(maxZ, eMag);
minZ = Foam::min(minZ, eMag);
maxZ = Foam::max(maxZ, eMag);
nZ++;
}
else
{
minOther = min(minOther, eMag);
maxOther = max(maxOther, eMag);
minOther = Foam::min(minOther, eMag);
maxOther = Foam::max(maxOther, eMag);
}
}
@ -179,19 +179,19 @@ scalar getEdgeStats(const primitiveMesh& mesh, const direction excludeCmpt)
if (excludeCmpt == 0)
{
return min(minY, min(minZ, minOther));
return Foam::min(minY, Foam::min(minZ, minOther));
}
else if (excludeCmpt == 1)
{
return min(minX, min(minZ, minOther));
return Foam::min(minX, Foam::min(minZ, minOther));
}
else if (excludeCmpt == 2)
{
return min(minX, min(minY, minOther));
return Foam::min(minX, Foam::min(minY, minOther));
}
else
{
return min(minX, min(minY, min(minZ, minOther)));
return Foam::min(minX, Foam::min(minY, Foam::min(minZ, minOther)));
}
}
@ -771,7 +771,7 @@ int main(int argc, char *argv[])
{
Info<< "Read existing refinement level from file "
<< refLevel.objectPath() << nl
<< " min level : " << min(refLevel) << nl
<< " min level : " << Foam::min(refLevel) << nl
<< " max level : " << maxLevel << nl
<< endl;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -175,7 +175,7 @@ int main(int argc, char *argv[])
// strip erroneous extension (.ccm, .ccmg, .ccmp)
if (ext == "ccm" || ext == "ccmg" || ext == "ccmp")
{
exportName = exportName.lessExt();
exportName.remove_ext();
}
}
else if (args.found("export"))

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -137,7 +137,7 @@ int main(int argc, char *argv[])
// strip erroneous extension (.ccm, .ccmg, .ccmp)
if (ext == "ccm" || ext == "ccmg" || ext == "ccmp")
{
exportName = exportName.lessExt();
exportName.remove_ext();
}
}
else if (args.found("case"))

View File

@ -271,7 +271,7 @@ int main(int argc, char *argv[])
if (blockPFacePointi != blockPFacePointi2)
{
sqrMergeTol =
min
Foam::min
(
sqrMergeTol,
magSqr
@ -338,16 +338,16 @@ int main(int argc, char *argv[])
blockNFacePoints[blockNFacePointi]
+ blockOffsets[blockNlabel];
label minPN = min(PpointLabel, NpointLabel);
label minPN = Foam::min(PpointLabel, NpointLabel);
if (pointMergeList[PpointLabel] != -1)
{
minPN = min(minPN, pointMergeList[PpointLabel]);
minPN = Foam::min(minPN, pointMergeList[PpointLabel]);
}
if (pointMergeList[NpointLabel] != -1)
{
minPN = min(minPN, pointMergeList[NpointLabel]);
minPN = Foam::min(minPN, pointMergeList[NpointLabel]);
}
pointMergeList[PpointLabel]
@ -411,7 +411,7 @@ int main(int argc, char *argv[])
pointMergeList[PpointLabel]
= pointMergeList[NpointLabel]
= min
= Foam::min
(
pointMergeList[PpointLabel],
pointMergeList[NpointLabel]
@ -757,7 +757,7 @@ int main(int argc, char *argv[])
);
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
IOstream::defaultPrecision(Foam::max(10u, IOstream::defaultPrecision()));
Info<< "Writing polyMesh" << endl;
pShapeMesh.removeFiles();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,8 +87,8 @@ int main(int argc, char *argv[])
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 0);
const bool doTriangulate = args.found("tri");
fileName exportBase = exportName.lessExt();
word exportExt = exportName.ext();
const fileName exportBase = exportName.lessExt();
const word exportExt = exportName.ext();
if (!meshedSurface::canWriteType(exportExt, true))
{

View File

@ -350,7 +350,7 @@ mtype {space}"MTYPE:"{space}
// Find out how many labels are expected. If less or equal to
// seven, read them all and finish with it. If there is more,
// set read of the next line
label labelsToRead = min(8, nVertices);
label labelsToRead = Foam::min(8, nVertices);
label labelI = 0;
for (; labelI < labelsToRead; labelI++)
{
@ -387,7 +387,7 @@ mtype {space}"MTYPE:"{space}
labelList& curLabels = cellLabels[curNumberOfCells];
label labelsToRead = min
label labelsToRead = Foam::min
(
(nCellContinuationLines + 1)*7,
curLabels.size()
@ -869,7 +869,7 @@ int main(int argc, char *argv[])
);
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
IOstream::defaultPrecision(Foam::max(10u, IOstream::defaultPrecision()));
Info<< "Writing polyMesh" << endl;
pShapeMesh.removeFiles();

View File

@ -269,7 +269,7 @@ void readCells
label maxUnvPoint = 0;
forAll(unvPointID, pointi)
{
maxUnvPoint = max(maxUnvPoint, unvPointID[pointi]);
maxUnvPoint = Foam::max(maxUnvPoint, unvPointID[pointi]);
}
labelList unvToFoam(invert(maxUnvPoint+1, unvPointID));
@ -784,7 +784,7 @@ int main(int argc, char *argv[])
label maxUnvPoint = 0;
forAll(unvPointID, pointi)
{
maxUnvPoint = max(maxUnvPoint, unvPointID[pointi]);
maxUnvPoint = Foam::max(maxUnvPoint, unvPointID[pointi]);
}
labelList unvToFoam(invert(maxUnvPoint+1, unvPointID));
@ -1281,7 +1281,7 @@ int main(int argc, char *argv[])
}
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
IOstream::defaultPrecision(Foam::max(10u, IOstream::defaultPrecision()));
mesh.write();

View File

@ -8,10 +8,10 @@
{
if (kivaVersion == kiva3v)
{
regionIndex = max
regionIndex = Foam::max
(
max(idface[quadFace[0]], idface[quadFace[1]]),
max(idface[quadFace[2]], idface[quadFace[3]])
Foam::max(idface[quadFace[0]], idface[quadFace[1]]),
Foam::max(idface[quadFace[2]], idface[quadFace[3]])
);
if (regionIndex > 0)

View File

@ -148,7 +148,7 @@ for (label i=0; i<nPoints; i++)
end = pointMap[end];
}
label minLabel = min(start, end);
label minLabel = Foam::min(start, end);
pointMap[start] = pointMap[end] = minLabel;
}
@ -331,7 +331,7 @@ if
{
forAll(pf, pfi)
{
minz = min(minz, points[pf[pfi]].z());
minz = Foam::min(minz, points[pf[pfi]].z());
}
}
@ -344,7 +344,7 @@ if
scalar minfz = GREAT;
forAll(pf, pfi)
{
minfz = min(minfz, points[pf[pfi]].z());
minfz = Foam::min(minfz, points[pf[pfi]].z());
}
if (minfz > minz)
@ -371,7 +371,7 @@ if
scalar minfz = GREAT;
forAll(pf, pfi)
{
minfz = min(minfz, points[pf[pfi]].z());
minfz = Foam::min(minfz, points[pf[pfi]].z());
}
if (minfz < zHeadMin)
@ -570,7 +570,7 @@ polyMesh pShapeMesh
);
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
IOstream::defaultPrecision(Foam::max(10u, IOstream::defaultPrecision()));
Info << "Writing polyMesh" << endl;
pShapeMesh.removeFiles();

View File

@ -188,7 +188,7 @@ int main(int argc, char *argv[])
}
maxPatch = max(maxPatch, patchi);
maxPatch = Foam::max(maxPatch, patchi);
triFace tri(readLabel(str)-1, readLabel(str)-1, readLabel(str)-1);
@ -319,7 +319,7 @@ int main(int argc, char *argv[])
);
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
IOstream::defaultPrecision(Foam::max(10u, IOstream::defaultPrecision()));
Info<< "Writing mesh ..." << endl;
mesh.removeFiles();

View File

@ -538,8 +538,11 @@ int main(int argc, char *argv[])
// Add any patches.
label nAdded = nPatches - mesh.boundaryMesh().size();
reduce(nAdded, sumOp<label>());
const label nAdded = returnReduce
(
nPatches - mesh.boundaryMesh().size(),
sumOp<label>()
);
Info<< "Adding overall " << nAdded << " processor patches." << endl;
@ -946,9 +949,8 @@ int main(int argc, char *argv[])
// Put all modifications into meshMod
bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
reduce(anyChange, orOp<bool>());
if (anyChange)
if (returnReduceOr(anyChange))
{
// Construct new mesh from polyTopoChange.
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
@ -1118,8 +1120,7 @@ int main(int argc, char *argv[])
processorMeshes::removeFiles(mesh);
// Need writing cellSet
label nAdded = returnReduce(addedCellsSet.size(), sumOp<label>());
if (nAdded > 0)
if (returnReduceOr(addedCellsSet.size()))
{
cellSet addedCells(mesh, "addedCells", addedCellsSet);
Info<< "Writing added cells to cellSet " << addedCells.name()

View File

@ -345,7 +345,7 @@ void deleteEmptyPatches(fvMesh& mesh)
else
{
// Common patch.
if (returnReduce(patches[patchi].empty(), andOp<bool>()))
if (returnReduceAnd(patches[patchi].empty()))
{
Pout<< "Deleting patch " << patchi
<< " name:" << patches[patchi].name()
@ -556,8 +556,8 @@ void calcEdgeMinMaxZone
forAll(eFaces, i)
{
label zoneI = mappedZoneID[eFaces[i]];
minZoneID[edgeI] = min(minZoneID[edgeI], zoneI);
maxZoneID[edgeI] = max(maxZoneID[edgeI], zoneI);
minZoneID[edgeI] = Foam::min(minZoneID[edgeI], zoneI);
maxZoneID[edgeI] = Foam::max(maxZoneID[edgeI], zoneI);
}
}
}
@ -661,8 +661,8 @@ void countExtrudePatches
}
// Synchronise decision. Actual numbers are not important, just make
// sure that they're > 0 on all processors.
Pstream::listCombineAllGather(zoneSidePatch, plusEqOp<label>());
Pstream::listCombineAllGather(zoneZonePatch, plusEqOp<label>());
Pstream::listCombineReduce(zoneSidePatch, plusEqOp<label>());
Pstream::listCombineReduce(zoneZonePatch, plusEqOp<label>());
}
@ -813,8 +813,8 @@ void addCoupledPatches
forAll(eFaces, i)
{
label proci = procID[eFaces[i]];
minProcID[edgeI] = min(minProcID[edgeI], proci);
maxProcID[edgeI] = max(maxProcID[edgeI], proci);
minProcID[edgeI] = Foam::min(minProcID[edgeI], proci);
maxProcID[edgeI] = Foam::max(maxProcID[edgeI], proci);
}
}
}
@ -1291,7 +1291,7 @@ void extrudeGeometricProperties
label celli = regionMesh.faceOwner()[facei];
if (regionMesh.isInternalFace(facei))
{
celli = max(celli, regionMesh.faceNeighbour()[facei]);
celli = Foam::max(celli, regionMesh.faceNeighbour()[facei]);
}
// Calculate layer from cell numbering (see createShellMesh)
@ -1848,7 +1848,7 @@ int main(int argc, char *argv[])
const primitiveFacePatch extrudePatch(std::move(zoneFaces), mesh.points());
Pstream::listCombineAllGather(isInternal, orEqOp<bool>());
Pstream::listCombineReduce(isInternal, orEqOp<bool>());
// Check zone either all internal or all external faces
checkZoneInside(mesh, zoneNames, zoneID, extrudeMeshFaces, isInternal);
@ -2192,8 +2192,8 @@ int main(int argc, char *argv[])
if (zone0 != zone1) // || (cos(angle) > blabla))
{
label minZone = min(zone0,zone1);
label maxZone = max(zone0,zone1);
label minZone = Foam::min(zone0,zone1);
label maxZone = Foam::max(zone0,zone1);
label index = minZone*zoneNames.size()+maxZone;
ePatches.setSize(eFaces.size());
@ -2309,7 +2309,7 @@ int main(int argc, char *argv[])
}
// Reduce
Pstream::mapCombineAllGather(globalSum, plusEqOp<point>());
Pstream::mapCombineReduce(globalSum, plusEqOp<point>());
forAll(localToGlobalRegion, localRegionI)
{

View File

@ -588,9 +588,8 @@ Foam::label Foam::DistributedDelaunayMesh<Triangulation>::referVertices
reduce(preInsertionSize, sumOp<label>());
reduce(postInsertionSize, sumOp<label>());
label nTotalToInsert = referredVertices.size();
reduce(nTotalToInsert, sumOp<label>());
label nTotalToInsert =
returnReduce(referredVertices.size(), sumOp<label>());
if (preInsertionSize + nTotalToInsert != postInsertionSize)
{

View File

@ -167,14 +167,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
{
if (volumeStatus[celli] == volumeType::UNKNOWN)
{
treeBoundBox cellBb
(
mesh_.cells()[celli].points
(
mesh_.faces(),
mesh_.points()
)
);
treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_));
if (geometry.overlaps(cellBb))
{
@ -224,7 +217,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
);
}
if (returnReduce(newCellsToRefine.size(), sumOp<label>()) == 0)
if (returnReduceAnd(newCellsToRefine.empty()))
{
break;
}
@ -286,14 +279,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
{
if (volumeStatus[celli] == volumeType::UNKNOWN)
{
treeBoundBox cellBb
(
mesh_.cells()[celli].points
(
mesh_.faces(),
mesh_.points()
)
);
treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_));
if (geometry.overlaps(cellBb))
{
@ -512,14 +498,7 @@ bool Foam::backgroundMeshDecomposition::refineCell
// const conformationSurfaces& geometry = geometryToConformTo_;
treeBoundBox cellBb
(
mesh_.cells()[celli].points
(
mesh_.faces(),
mesh_.points()
)
);
treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_));
weightEstimate = 1.0;
@ -899,7 +878,7 @@ Foam::backgroundMeshDecomposition::distribute
}
}
if (returnReduce(cellsToRefine.size(), sumOp<label>()) == 0)
if (returnReduceAnd(cellsToRefine.empty()))
{
break;
}

View File

@ -153,7 +153,7 @@ public:
return name_;
}
const Switch& forceInitialPointInsertion() const
Switch forceInitialPointInsertion() const noexcept
{
return forceInitialPointInsertion_;
}

View File

@ -92,9 +92,7 @@ bool Foam::controlMeshRefinement::detectEdge
magSqr(a - b) < tolSqr
)
{
pointFound.setPoint(midPoint);
pointFound.setHit();
pointFound.hitPoint(midPoint);
return true;
}
@ -264,7 +262,7 @@ void Foam::controlMeshRefinement::initialMeshPopulation
const cellSizeAndAlignmentControl& controlFunction =
controlFunctions[fI];
const Switch& forceInsertion =
const Switch forceInsertion =
controlFunction.forceInitialPointInsertion();
Info<< "Inserting points from " << controlFunction.name()
@ -450,7 +448,7 @@ void Foam::controlMeshRefinement::initialMeshPopulation
const cellSizeAndAlignmentControl& controlFunction =
controlFunctions[fI];
const Switch& forceInsertion =
const Switch forceInsertion =
controlFunction.forceInitialPointInsertion();
Info<< "Inserting points from " << controlFunction.name()

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -298,7 +298,7 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
(
surface_.searchableSurface::time().constant()
/ "triSurface"
/ surfaceName_.nameLessExt() + "_cellSize"
/ surfaceName_.stem() + "_cellSize"
)
);

View File

@ -38,6 +38,7 @@ Description
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,23 +87,17 @@ void Foam::conformalVoronoiMesh::cellSizeMeshOverlapsBackground() const
boundBox cellSizeMeshBb = cellSizeMesh.bounds();
bool fullyContained = true;
bool fullyContained = cellSizeMeshBb.contains(bb);
if (!cellSizeMeshBb.contains(bb))
if (!fullyContained)
{
Pout<< "Triangulation not fully contained in cell size mesh."
<< endl;
Pout<< "Cell Size Mesh Bounds = " << cellSizeMesh.bounds() << endl;
Pout<< "foamyHexMesh Bounds = " << bb << endl;
fullyContained = false;
Pout<< "Triangulation not fully contained in cell size mesh." << endl
<< "Cell Size Mesh Bounds = " << cellSizeMeshBb << endl
<< "foamyHexMesh Bounds = " << bb << endl;
}
reduce(fullyContained, andOp<unsigned int>());
Info<< "Triangulation is "
<< (fullyContained ? "fully" : "not fully")
<< (returnReduceAnd(fullyContained) ? "fully" : "not fully")
<< " contained in the cell size mesh"
<< endl;
}
@ -115,12 +109,7 @@ void Foam::conformalVoronoiMesh::insertInternalPoints
bool distribute
)
{
label nPoints = points.size();
if (Pstream::parRun())
{
reduce(nPoints, sumOp<label>());
}
const label nPoints = returnReduce(points.size(), sumOp<label>());
Info<< " " << nPoints << " points to insert..." << endl;
@ -145,16 +134,15 @@ void Foam::conformalVoronoiMesh::insertInternalPoints
map().distribute(points);
}
label nVert = number_of_vertices();
label preReinsertionSize(number_of_vertices());
insert(points.begin(), points.end());
label nInserted(number_of_vertices() - nVert);
if (Pstream::parRun())
{
reduce(nInserted, sumOp<label>());
}
const label nInserted = returnReduce
(
label(number_of_vertices()) - preReinsertionSize,
sumOp<label>()
);
Info<< " " << nInserted << " points inserted"
<< ", failed to insert " << nPoints - nInserted

View File

@ -753,7 +753,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
forAll(patches, p)
{
label totalPatchSize = patchDicts[p].get<label>("nFaces");
label nPatchFaces = patchDicts[p].get<label>("nFaces");
if
(
@ -762,7 +762,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
)
{
// Do not create empty processor patches
if (totalPatchSize > 0)
if (nPatchFaces)
{
patchDicts[p].set("transform", "coincidentFullMatch");
@ -781,9 +781,8 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
else
{
// Check that the patch is not empty on every processor
reduce(totalPatchSize, sumOp<label>());
if (totalPatchSize > 0)
if (returnReduceOr(nPatchFaces))
{
patches[nValidPatches] = polyPatch::New
(

View File

@ -729,7 +729,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseSurfaceTrees
}
}
Pstream::listCombineAllGather(hits, plusEqOp<labelHashSet>());
Pstream::listCombineReduce(hits, plusEqOp<labelHashSet>());
forAll(surfaceHits, eI)
{
@ -816,7 +816,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseEdgeTrees
}
}
Pstream::listCombineAllGather(hits, plusEqOp<labelHashSet>());
Pstream::listCombineReduce(hits, plusEqOp<labelHashSet>());
forAll(featureEdgeHits, eI)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -707,9 +707,7 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
Info<< incrIndent << indent << "Faces matched." << endl;
reduce(anyChanged, orOp<bool>());
if (anyChanged)
if (returnReduceOr(anyChanged))
{
label nReorderedFaces = 0;

View File

@ -44,6 +44,7 @@ SourceFiles
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- //

View File

@ -45,6 +45,7 @@ SourceFiles
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- //

View File

@ -605,7 +605,7 @@ Foam::conformationSurfaces::conformationSurfaces
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::conformationSurfaces::overlaps(const treeBoundBox& bb) const
bool Foam::conformationSurfaces::overlaps(const boundBox& bb) const
{
forAll(surfaces_, s)
{

View File

@ -188,7 +188,7 @@ public:
//- Check if the supplied bound box overlaps any part of any of
// the surfaces
bool overlaps(const treeBoundBox& bb) const;
bool overlaps(const boundBox& bb) const;
//- Check if points are inside surfaces to conform to
Field<bool> inside(const pointField& samplePts) const;

View File

@ -84,16 +84,12 @@ Foam::searchableBoxFeatures::features() const
autoPtr<extendedFeatureEdgeMesh> features;
List<vector> faceNormalsList(treeBoundBox::faceNormals);
vectorField faceNormals(faceNormalsList);
vectorField faceNormals(std::move(faceNormalsList));
vectorField edgeDirections(12);
labelListList normalDirections(12);
labelListList normalDirections(12, labelList(2, Zero));
labelListList edgeNormals(12, labelList(2, Zero));
labelListList edgeNormals(12);
forAll(edgeNormals, eI)
{
edgeNormals[eI].setSize(2, 0);
}
edgeNormals[0][0] = 2; edgeNormals[0][1] = 4;
edgeNormals[1][0] = 1; edgeNormals[1][1] = 4;
edgeNormals[2][0] = 3; edgeNormals[2][1] = 4;
@ -116,7 +112,6 @@ Foam::searchableBoxFeatures::features() const
surfacePoints[treeBoundBox::edges[eI].end()]
- surfacePoints[treeBoundBox::edges[eI].start()];
normalDirections[eI] = labelList(2, Zero);
for (label j = 0; j < 2; ++j)
{
const vector cross =
@ -138,12 +133,12 @@ Foam::searchableBoxFeatures::features() const
}
}
labelListList featurePointNormals(8);
labelListList featurePointEdges(8);
labelListList featurePointNormals(8, labelList(3, Zero));
labelListList featurePointEdges(8, labelList(3, Zero));
forAll(featurePointNormals, pI)
{
labelList& ftPtEdges = featurePointEdges[pI];
ftPtEdges.setSize(3, 0);
label edgeI = 0;
forAll(treeBoundBox::edges, eI)
@ -161,7 +156,6 @@ Foam::searchableBoxFeatures::features() const
}
labelList& ftPtNormals = featurePointNormals[pI];
ftPtNormals.setSize(3, 0);
ftPtNormals[0] = edgeNormals[ftPtEdges[0]][0];
ftPtNormals[1] = edgeNormals[ftPtEdges[0]][1];

View File

@ -38,6 +38,7 @@ Description
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- //

View File

@ -40,6 +40,7 @@ Description
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- //

View File

@ -416,10 +416,12 @@ void extractSurface
// Allocate zone/patch for all patches
HashTable<label> compactZoneID(1024);
forAllConstIters(patchSize, iter)
if (Pstream::master())
{
label sz = compactZoneID.size();
compactZoneID.insert(iter.key(), sz);
forAllConstIters(patchSize, iter)
{
compactZoneID.insert(iter.key(), compactZoneID.size());
}
}
Pstream::broadcast(compactZoneID);
@ -431,7 +433,7 @@ void extractSurface
label patchi = bMesh.findPatchID(iter.key());
if (patchi != -1)
{
patchToCompactZone[patchi] = iter();
patchToCompactZone[patchi] = iter.val();
}
}
@ -663,7 +665,7 @@ void removeZeroSizedPatches(fvMesh& mesh)
if
(
isA<coupledPolyPatch>(pp)
|| returnReduce(pp.size(), sumOp<label>())
|| returnReduceOr(pp.size())
)
{
// Coupled (and unknown size) or uncoupled and used
@ -1889,11 +1891,8 @@ int main(int argc, char *argv[])
);
// Use the maxLocalCells from the refinement parameters
bool preBalance = returnReduce
(
(mesh.nCells() >= refineParams.maxLocalCells()),
orOp<bool>()
);
const bool preBalance =
returnReduceOr(mesh.nCells() >= refineParams.maxLocalCells());
if (!overwrite && !debugLevel)

View File

@ -104,9 +104,6 @@ void Foam::checkPatch
// << endl;
}
//DebugVar(globalEdgeFaces);
// Synchronise across coupled edges.
syncTools::syncEdgeList
(
@ -116,7 +113,6 @@ void Foam::checkPatch
labelList() // null value
);
//DebugVar(globalEdgeFaces);
label labelTyp = TopoType::MANIFOLD;
forAll(meshEdges, edgei)
@ -191,7 +187,7 @@ void Foam::checkPatch
{
const labelList& mp = pp.meshPoints();
if (returnReduce(mp.size(), sumOp<label>()) > 0)
if (returnReduceOr(mp.size()))
{
boundBox bb(pp.points(), mp, true); // reduce
Info<< ' ' << bb;
@ -200,6 +196,35 @@ void Foam::checkPatch
}
template<class Zone>
Foam::label Foam::checkZones
(
const polyMesh& mesh,
const ZoneMesh<Zone, polyMesh>& zones,
topoSet& set
)
{
labelList zoneID(set.maxSize(mesh), -1);
for (const auto& zone : zones)
{
for (const label elem : zone)
{
if
(
zoneID[elem] != -1
&& zoneID[elem] != zone.index()
)
{
set.insert(elem);
}
zoneID[elem] = zone.index();
}
}
return returnReduce(set.size(), sumOp<label>());
}
Foam::label Foam::checkTopology
(
const polyMesh& mesh,
@ -227,10 +252,10 @@ Foam::label Foam::checkTopology
}
}
reduce(nEmpty, sumOp<label>());
label nTotCells = returnReduce(mesh.cells().size(), sumOp<label>());
const label nCells = returnReduce(mesh.cells().size(), sumOp<label>());
// These are actually warnings, not errors.
if (nTotCells && (nEmpty % nTotCells))
if (nCells && (nEmpty % nCells))
{
Info<< " ***Total number of faces on empty patches"
<< " is not divisible by the number of cells in the mesh."
@ -310,7 +335,7 @@ Foam::label Foam::checkTopology
{
noFailedChecks++;
label nPoints = returnReduce(points.size(), sumOp<label>());
const label nPoints = returnReduce(points.size(), sumOp<label>());
Info<< " <<Writing " << nPoints
<< " unused points to set " << points.name() << endl;
@ -447,7 +472,7 @@ Foam::label Foam::checkTopology
}
}
label nOneCells = returnReduce(oneCells.size(), sumOp<label>());
const label nOneCells = returnReduce(oneCells.size(), sumOp<label>());
if (nOneCells > 0)
{
@ -463,7 +488,7 @@ Foam::label Foam::checkTopology
}
}
label nTwoCells = returnReduce(twoCells.size(), sumOp<label>());
const label nTwoCells = returnReduce(twoCells.size(), sumOp<label>());
if (nTwoCells > 0)
{
@ -563,11 +588,7 @@ Foam::label Foam::checkTopology
}
}
Pstream::listCombineAllGather
(
regionDisconnected,
andEqOp<bool>()
);
Pstream::listCombineReduce(regionDisconnected, andEqOp<bool>());
}
@ -614,7 +635,7 @@ Foam::label Foam::checkTopology
cellRegions[i].write();
}
label nPoints = returnReduce(points.size(), sumOp<label>());
const label nPoints = returnReduce(points.size(), sumOp<label>());
if (nPoints)
{
Info<< " <<Writing " << nPoints
@ -714,6 +735,25 @@ Foam::label Foam::checkTopology
);
Info<< endl;
}
// Check for duplicates
if (allTopology)
{
faceSet mzFaces(mesh, "multiZoneFaces", mesh.nFaces()/100);
const label nMulti = checkZones(mesh, faceZones, mzFaces);
if (nMulti)
{
Info<< " <<Writing " << nMulti
<< " faces that are in multiple zones"
<< " to set " << mzFaces.name() << endl;
mzFaces.instance() = mesh.pointsInstance();
mzFaces.write();
if (surfWriter && surfWriter->enabled())
{
mergeAndWrite(*surfWriter, mzFaces);
}
}
}
}
else
{
@ -791,6 +831,26 @@ Foam::label Foam::checkTopology
<< returnReduce(v, sumOp<scalar>())
<< ' ' << bb << endl;
}
// Check for duplicates
if (allTopology)
{
cellSet mzCells(mesh, "multiZoneCells", mesh.nCells()/100);
const label nMulti = checkZones(mesh, cellZones, mzCells);
if (nMulti)
{
Info<< " <<Writing " << nMulti
<< " cells that are in multiple zones"
<< " to set " << mzCells.name() << endl;
mzCells.instance() = mesh.pointsInstance();
mzCells.write();
if (surfWriter && surfWriter->enabled())
{
mergeAndWrite(*surfWriter, mzCells);
}
}
}
}
else
{
@ -798,6 +858,65 @@ Foam::label Foam::checkTopology
}
}
{
Info<< "\nChecking basic pointZone addressing..." << endl;
Pout.setf(ios_base::left);
const pointZoneMesh& pointZones = mesh.pointZones();
if (pointZones.size())
{
Info<< " "
<< setw(20) << "PointZone"
<< setw(8) << "Points"
<< "BoundingBox" << endl;
for (const auto& zone : pointZones)
{
boundBox bb;
for (const label pointi : zone)
{
bb.add(mesh.points()[pointi]);
}
bb.reduce(); // Global min/max
Info<< " "
<< setw(20) << zone.name()
<< setw(8)
<< returnReduce(zone.size(), sumOp<label>())
<< bb << endl;
}
// Check for duplicates
if (allTopology)
{
pointSet mzPoints(mesh, "multiZonePoints", mesh.nPoints()/100);
const label nMulti = checkZones(mesh, pointZones, mzPoints);
if (nMulti)
{
Info<< " <<Writing " << nMulti
<< " points that are in multiple zones"
<< " to set " << mzPoints.name() << endl;
mzPoints.instance() = mesh.pointsInstance();
mzPoints.write();
if (setWriter && setWriter->enabled())
{
mergeAndWrite(*setWriter, mzPoints);
}
}
}
}
else
{
Info<< " No pointZones found."<<endl;
}
}
// Force creation of all addressing if requested.
// Errors will be reported as required
if (allTopology)

View File

@ -1,5 +1,7 @@
#include "labelList.H"
#include "autoPtr.H"
#include "ZoneMesh.H"
#include "topoSet.H"
namespace Foam
{
@ -21,6 +23,14 @@ namespace Foam
pointSet& points
);
template<class Zone>
label checkZones
(
const polyMesh& mesh,
const ZoneMesh<Zone, polyMesh>& zones,
topoSet& set
);
label checkTopology
(
const polyMesh& mesh,

View File

@ -27,7 +27,7 @@ void maxFaceToCell
const cell& cFaces = cells[cellI];
forAll(cFaces, i)
{
cellFld[cellI] = max(cellFld[cellI], faceData[cFaces[i]]);
cellFld[cellI] = Foam::max(cellFld[cellI], faceData[cFaces[i]]);
}
}
@ -57,7 +57,7 @@ void minFaceToCell
const cell& cFaces = cells[cellI];
forAll(cFaces, i)
{
cellFld[cellI] = min(cellFld[cellI], faceData[cFaces[i]]);
cellFld[cellI] = Foam::min(cellFld[cellI], faceData[cFaces[i]]);
}
}
@ -88,8 +88,8 @@ void minFaceToCell
// Internal faces
forAll(own, facei)
{
cellFld[own[facei]] = min(cellFld[own[facei]], faceData[facei]);
cellFld[nei[facei]] = min(cellFld[nei[facei]], faceData[facei]);
cellFld[own[facei]] = Foam::min(cellFld[own[facei]], faceData[facei]);
cellFld[nei[facei]] = Foam::min(cellFld[nei[facei]], faceData[facei]);
}
// Patch faces
@ -100,7 +100,7 @@ void minFaceToCell
forAll(fc, i)
{
cellFld[fc[i]] = min(cellFld[fc[i]], fvp[i]);
cellFld[fc[i]] = Foam::min(cellFld[fc[i]], fvp[i]);
}
}
@ -180,7 +180,7 @@ void Foam::writeFields
(
radToDeg
(
Foam::acos(min(scalar(1), max(scalar(-1), faceOrthogonality)))
Foam::acos(Foam::min(scalar(1), Foam::max(scalar(-1), faceOrthogonality)))
)
);
@ -540,7 +540,7 @@ void Foam::writeFields
ownCc,
fc
).quality();
ownVol = min(ownVol, tetQual);
ownVol = Foam::min(ownVol, tetQual);
}
}
if (mesh.isInternalFace(facei))
@ -556,7 +556,7 @@ void Foam::writeFields
fc,
neiCc
).quality();
neiVol = min(neiVol, tetQual);
neiVol = Foam::min(neiVol, tetQual);
}
}
}
@ -608,8 +608,8 @@ void Foam::writeFields
// Internal faces
forAll(own, facei)
{
cellFld[own[facei]] = min(cellFld[own[facei]], ownPyrVol[facei]);
cellFld[nei[facei]] = min(cellFld[nei[facei]], neiPyrVol[facei]);
cellFld[own[facei]] = Foam::min(cellFld[own[facei]], ownPyrVol[facei]);
cellFld[nei[facei]] = Foam::min(cellFld[nei[facei]], neiPyrVol[facei]);
}
// Patch faces
@ -620,7 +620,7 @@ void Foam::writeFields
forAll(fc, i)
{
const label meshFacei = fvp.patch().start();
cellFld[fc[i]] = min(cellFld[fc[i]], ownPyrVol[meshFacei]);
cellFld[fc[i]] = Foam::min(cellFld[fc[i]], ownPyrVol[meshFacei]);
}
}
@ -631,7 +631,7 @@ void Foam::writeFields
if (writeFaceFields)
{
scalarField minFacePyrVol(neiPyrVol);
minFacePyrVol = min
minFacePyrVol = Foam::min
(
minFacePyrVol,
SubField<scalar>(ownPyrVol, mesh.nInternalFaces())

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -138,7 +138,7 @@ void filterPatches(fvMesh& mesh, const wordHashSet& addedPatchNames)
if
(
isA<coupledPolyPatch>(pp)
|| returnReduce(pp.size(), sumOp<label>())
|| returnReduceOr(pp.size())
|| addedPatchNames.found(pp.name())
)
{

View File

@ -686,7 +686,7 @@ void syncPoints
//- Note: hasTransformation is only used for warning messages so
// reduction not strictly necessary.
//reduce(hasTransformation, orOp<bool>());
//Pstream::reduceOr(hasTransformation);
// Synchronize multiple shared points.
const globalMeshData& pd = mesh.globalData();
@ -714,7 +714,7 @@ void syncPoints
}
// Combine - globally consistent
Pstream::listCombineAllGather(sharedPts, cop);
Pstream::listCombineReduce(sharedPts, cop);
// Now we will all have the same information. Merge it back with
// my local information.

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -272,7 +273,7 @@ int main(int argc, char *argv[])
}
if (returnReduce(changedEdges.size(), sumOp<label>()) == 0)
if (returnReduceAnd(changedEdges.empty()))
{
break;
}

View File

@ -100,26 +100,26 @@ void printEdgeStats(const polyMesh& mesh)
if (mag(eVec & x) > 1-edgeTol)
{
minX = min(minX, eMag);
maxX = max(maxX, eMag);
minX = Foam::min(minX, eMag);
maxX = Foam::max(maxX, eMag);
nX++;
}
else if (mag(eVec & y) > 1-edgeTol)
{
minY = min(minY, eMag);
maxY = max(maxY, eMag);
minY = Foam::min(minY, eMag);
maxY = Foam::max(maxY, eMag);
nY++;
}
else if (mag(eVec & z) > 1-edgeTol)
{
minZ = min(minZ, eMag);
maxZ = max(maxZ, eMag);
minZ = Foam::min(minZ, eMag);
maxZ = Foam::max(maxZ, eMag);
nZ++;
}
else
{
minOther = min(minOther, eMag);
maxOther = max(maxOther, eMag);
minOther = Foam::min(minOther, eMag);
maxOther = Foam::max(maxOther, eMag);
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -145,10 +145,10 @@ void getBand
// Note: mag not necessary for correct (upper-triangular) ordering.
label diff = nei-own;
cellBandwidth[nei] = max(cellBandwidth[nei], diff);
cellBandwidth[nei] = Foam::max(cellBandwidth[nei], diff);
}
bandwidth = max(cellBandwidth);
bandwidth = Foam::max(cellBandwidth);
// Do not use field algebra because of conversion label to scalar
profile = 0.0;
@ -340,7 +340,7 @@ labelList getRegionFaceOrder
}
// Do region interfaces
label nRegions = max(cellToRegion)+1;
label nRegions = Foam::max(cellToRegion)+1;
{
// Sort in increasing region
SortableList<label> sortKey(mesh.nFaces(), labelMax);
@ -353,8 +353,8 @@ labelList getRegionFaceOrder
if (ownRegion != neiRegion)
{
sortKey[facei] =
min(ownRegion, neiRegion)*nRegions
+max(ownRegion, neiRegion);
Foam::min(ownRegion, neiRegion)*nRegions
+Foam::max(ownRegion, neiRegion);
}
}
sortKey.sort();
@ -566,7 +566,7 @@ labelList regionRenumber
labelList cellOrder(cellToRegion.size());
label nRegions = max(cellToRegion)+1;
label nRegions = Foam::max(cellToRegion)+1;
labelListList regionToCells(invertOneToMany(nRegions, cellToRegion));
@ -1103,9 +1103,7 @@ int main(int argc, char *argv[])
// Update proc maps
if (cellProcAddressing.headerOk())
{
bool localOk = (cellProcAddressing.size() == mesh.nCells());
if (returnReduce(localOk, andOp<bool>()))
if (returnReduceAnd(cellProcAddressing.size() == mesh.nCells()))
{
Info<< "Renumbering processor cell decomposition map "
<< cellProcAddressing.name() << endl;
@ -1129,9 +1127,7 @@ int main(int argc, char *argv[])
if (faceProcAddressing.headerOk())
{
bool localOk = (faceProcAddressing.size() == mesh.nFaces());
if (returnReduce(localOk, andOp<bool>()))
if (returnReduceAnd(faceProcAddressing.size() == mesh.nFaces()))
{
Info<< "Renumbering processor face decomposition map "
<< faceProcAddressing.name() << endl;
@ -1171,9 +1167,7 @@ int main(int argc, char *argv[])
if (pointProcAddressing.headerOk())
{
bool localOk = (pointProcAddressing.size() == mesh.nPoints());
if (returnReduce(localOk, andOp<bool>()))
if (returnReduceAnd(pointProcAddressing.size() == mesh.nPoints()))
{
Info<< "Renumbering processor point decomposition map "
<< pointProcAddressing.name() << endl;
@ -1197,12 +1191,13 @@ int main(int argc, char *argv[])
if (boundaryProcAddressing.headerOk())
{
bool localOk =
if
(
boundaryProcAddressing.size()
== mesh.boundaryMesh().size()
);
if (returnReduce(localOk, andOp<bool>()))
returnReduceAnd
(
boundaryProcAddressing.size() == mesh.boundaryMesh().size()
)
)
{
// No renumbering needed
}

View File

@ -320,10 +320,10 @@ bool doCommand
const globalMeshData& parData = mesh.globalData();
label typSize =
max
Foam::max
(
parData.nTotalCells(),
max
Foam::max
(
parData.nTotalFaces(),
parData.nTotalPoints()
@ -375,7 +375,7 @@ bool doCommand
topoSet& currentSet = currentSetPtr();
// Presize it according to current mesh data.
currentSet.resize(max(currentSet.size(), typSize));
currentSet.resize(Foam::max(currentSet.size(), typSize));
}
}

View File

@ -286,8 +286,8 @@ void addToInterface
{
edge interface
(
min(ownRegion, neiRegion),
max(ownRegion, neiRegion)
Foam::min(ownRegion, neiRegion),
Foam::max(ownRegion, neiRegion)
);
auto iter = regionsToSize.find(interface);
@ -544,8 +544,8 @@ void getInterfaceSizes
edge interface
(
min(ownRegion, neiRegion),
max(ownRegion, neiRegion)
Foam::min(ownRegion, neiRegion),
Foam::max(ownRegion, neiRegion)
);
faceToInterface[facei] = regionsToInterface[interface][zoneID];
@ -567,8 +567,8 @@ void getInterfaceSizes
edge interface
(
min(ownRegion, neiRegion),
max(ownRegion, neiRegion)
Foam::min(ownRegion, neiRegion),
Foam::max(ownRegion, neiRegion)
);
faceToInterface[facei] = regionsToInterface[interface][zoneID];
@ -847,7 +847,7 @@ void createAndWriteRegion
if (!isA<processorPolyPatch>(pp))
{
if (returnReduce(pp.size(), sumOp<label>()) > 0)
if (returnReduceOr(pp.size()))
{
oldToNew[patchi] = newI;
if (!addedPatches.found(patchi))
@ -1114,7 +1114,7 @@ label findCorrespondingRegion
}
}
Pstream::listCombineAllGather(cellsInZone, plusEqOp<label>());
Pstream::listCombineReduce(cellsInZone, plusEqOp<label>());
// Pick region with largest overlap of zoneI
label regionI = findMax(cellsInZone);

View File

@ -345,7 +345,7 @@ void subsetTopoSets
Info<< "Subsetting " << set.type() << " " << set.name() << endl;
labelHashSet subset(2*min(set.size(), map.size()));
labelHashSet subset(2*Foam::min(set.size(), map.size()));
forAll(map, i)
{

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