Compare commits

...

63 Commits

Author SHA1 Message Date
54dcde5f9a INT: compressibleInterFoam: assimilate DyM solver
Based on changes from openfoam.org
2024-05-01 16:44:42 +01:00
7dc9ccdcaa Merge branch 'update-Pstream-message-count' into 'develop'
Use MPI Get_elements_x() for message sizes

See merge request Development/openfoam!681
2024-04-29 10:25:30 +00:00
b2bbc15463 ENH: use MPI Get_elements_x() for message sizes (#3152)
- ensures more accurate values for message sizes than using
  MPI Get_count(), which trucates at INT_MAX

- add more/better error messages when trying to receive messages
  that exceed INT_MAX or the char buffer lengths
2024-04-29 10:22:24 +02:00
7b38b148fa STYLE: use PstreamBuffers default construct
- PstreamBuffers are nonBlocking by default, so no need to re-specify
2024-04-29 10:21:25 +02:00
7f355ba343 STYLE: communication name "buffered" instead of "blocking"
- "buffered" corresponds to MPI_Bsend (buffered send),
  whereas the old name "blocking" is misleading since the
  regular MPI_Send also blocks until completion
  (ie, buffer can be reused).

ENH: IPstream::read() returns std::streamsize instead of label (#3152)

- previously returned a 'label' but std::streamsize is consistent with
  the input parameter and will help with later adjustments.

- use <label> instead of <int> for internal accounting of the message
  size, for consistency with the underyling List<char> buffers used.

- improve handling for corner case of IPstream receive with
  non-blocking, although this combination is not used anywhere
2024-04-29 10:19:40 +02:00
e1d45ec26e ENH: snappyHexMesh: more parallel consistency. See #2331 2024-04-25 15:52:41 +01:00
690d02f9e8 ENH: snappyHexMesh: more parallel consistency. See #2331 2024-04-24 17:10:27 +01:00
31b74cd627 Merge branch 'update-fvsPatchFields-mappers' into 'develop'
Fix fvsPatchFields reading/writing the "value" entry

See merge request Development/openfoam!679
2024-04-24 12:35:11 +00:00
f04ccef588 ENH: improve code consistency for {cell,face,point}Mapper (#3147)
- robuster and more reliable determination of inserted objects
  (previous code could produce false positives).

  Now also determine the number of inserted objects within the
  constructor (instead of simply storing a bool). This allows reuse
  in the address calculations to reduce overheads there.

BUG: dodgy short-circuit logic for insertedObjectLabels()

- as a quick short-circuit it previously created as demand-driven
  pointer with a zero elements. However, this meant that if this code
  was called first (before any other addressing), subsequent calls to
  the addressing would fail.

BUG: bad logic and lookup for faAreaMapper (#3147)

- was using labelHashSet but returning a bool and set using the
  addressing using the unfiltered objects!
  This is a latent bug since interpolated/inserted faces not
  currently supported anyhow.

ENH: use std::unique_ptr for demand-driven data
2024-04-24 14:03:11 +02:00
8a8b5db977 BUG: fvsPatchFields reading/writing the "value" entry (fixes #3144)
- manual revert for 44d0fbd594.

  Unless required for post-processing the "value" entry should not
  written if it is not mandatory for reading.

  This is especially crucial with an 'empty' patch field where the
  field (size 0) has a different size from the patch.

- the changes made align fvsPatchField behaviour with fvPatchField
2024-04-24 14:03:02 +02:00
5fb1181bb2 SUBMODULE: update avalanche tutorials (for new finite-area locations) 2024-04-23 16:57:17 +02:00
411ac5fcfa ENH: adjust return type for token compound factory method
- return autoPtr<token::compound> instead of the derived type,
  otherwise cannot easily construct a token from it

ENH: additional typed version of refCompoundToken()

- symmetric with typed version of transferCompoundToken()
  and isCompound()

- add ITstream::findCompound<Type>() method.
  Useful for searching within token streams
2024-04-23 16:51:38 +02:00
880215e8e6 STYLE: use intermediate variable in openFoamTableReader 2024-04-23 12:16:52 +02:00
3874c1312e Merge branch 'update-argList-mpi-startup' into 'develop'
reduce communication argList at startup

See merge request Development/openfoam!678
2024-04-23 09:20:19 +00:00
09377471a3 ENH: stricter handling when freeing communicator components
- previously automatically skipped the first communicator (which was
  assumed to be MPI_COMM_WORLD), but now simply rely on the
  internal pendingMPIFree_ to track which communicators have actually
  been allocated.
2024-04-23 10:58:41 +02:00
2889dc7248 ENH: add wrapped accessor for MPI_Comm
- UPstream::Communicator is similar to UPstream::Request to
  wrap/unwrap MPI_Comm. Provides a 'lookup' method to transcribe
  the internal OpenFOAM communicator tracking to the opaque wrapped
  version.

- provide an 'openfoam_mpi.H' interfacing file, which includes
  the <mpi.h> as well as casting routines.

  Example (caution: ugly!)

     MPI_Comm myComm =
         PstreamUtils::Cast::to_mpi
         (
             UPstream::Communicator::lookup(UPstream::worldComm)
         );
2024-04-23 10:58:38 +02:00
d75c60d8ae ENH: reduce communication argList at startup (#3142)
- replace point-to-point transmission of the argList args/options with
  a broadcast. This is sufficient for most cases (without distributed
  roots).

  For "normal" cases (non-distributed roots) this will replace the
  nProcs-1 messages with a single broadcast.

- for cases with distributed roots, distinguish between a single,
  identical root and different roots.  An identical root can also be
  subsequently handled with a broadcast. Different roots will still
  require individual point-to-point communication.

  For cases with distributed roots, it will add the overhead of an
  additional broadcast.
2024-04-23 10:55:44 +02:00
582b613d5f ENH: add send/recv static methods for broadcast streams
- adds consistency with regular point-to-point parallel streams.

ENH: add ITstream::tokens() methods

- useful, for example, to disambiguate constructing tokenList from
  a ITstream.

  ITstream& is = otherDict.lookup("original");

  tokenList deepCopy(is);  // Error: from Istream or tokenList??
  tokenList deepCopy(is.tokens());  // OK: from tokenList
2024-04-22 11:46:27 +02:00
6cce1cdc8b STYLE: add push_back() method to dlLibraryTable, cellTable, boundaryRegion
- same as append() did, but with more consistent names

STYLE: replace special purpose append() with container method

STYLE: update code style
2024-04-22 11:46:24 +02:00
b6203a7de5 BUG: overlapping zones: incorrect sizing 2024-04-19 20:19:45 +01:00
701c916764 Merge branch 'update-finiteArea' into 'develop'
update to internal accounting for finite-area

See merge request Development/openfoam!675
2024-04-19 15:52:41 +00:00
d1c4a225a2 CONFIG: increment API level to 2402 (finite-area API changes) 2024-04-19 17:20:09 +02:00
4cfa2ea304 TUT: update for new finite-area location (with foamUpgradeFiniteArea) 2024-04-19 17:20:09 +02:00
b5435cc83e ENH: separate registry and revised file locations for finite-area
- The internal storage location of finite-area changes from being
  piggybacked on the polyMesh registry to a having its own dedicated
  registry:

  * allows a clearer separation of field types without name clashes.
  * prerequisite for supporting multiple finite-area regions (future)

Old Locations:
```
   0/Us
   constant/faMesh
   system/faMeshDefinition
   system/faSchemes
   system/faSolution
```

New Locations:
```
   0/finite-area/Us
   constant/finite-area/faMesh
   system/finite-area/faMeshDefinition  (or system/faMeshDefinition)
   system/finite-area/faSchemes
   system/finite-area/faSolution
```

NOTES:
    The new locations represent a hard change (breaking change) that
    is normally to be avoided, but seamless compatibility handling
    within the code was found to be unworkable.

    The `foamUpgradeFiniteArea` script provides assistance with migration.

    As a convenience, the system/faMeshDefinition location continues
    to be supported (may be deprecated in the future).
2024-04-19 17:20:09 +02:00
1d5b95b5fe BUG: redistributePar: Distributing refinement data. Fixes #3137.
- was using blocking (=buffered) comms
- was running out of MPI_COMM_SIZE buffer space
- now using PstreamBuffers to have non-blocing comms
2024-04-18 11:52:34 +01:00
31aadc5c4d ENH: prefer objectRegistry sorted to lookupClass
- lower memory overhead, consistent access pattern
2024-04-16 10:18:08 +02:00
a803516b16 ENH: use typedef for MeshObject within derived classes
- use an internal 'typedef MeshObject<...> MeshObject_type' within
  derived classes. Reduces clutter and eases any updates.
2024-04-16 10:18:08 +02:00
1b212789e5 ENH: add MeshObject Release() static method
- Delete() will perform a 'checkOut()' which does the following:
  * remove the object from the registry
  * delete the pointer (if owned by the registry)

- Release() does the following:
  * transfer ownership of the pointer (if owned by the registry)

- Store() does the following:
  * transfer ownership of the pointer to the registry

ENH: use UPtrList of sorted objects for MeshObject updates

- few allocations and lower overhead than using a HashTable,
  ensures the same walk order over the objects (in parallel)

STYLE: adjust meshObject debug statements
2024-04-16 10:18:08 +02:00
688fd5f3f1 ENH: add separate handling for clearing mesh phi
STYLE: update code style for phi modification (engine motion)

ENH: pass isMeshUpdate param in fvMesh/polyMesh clearOut() methods

- top-level use of isMeshUpdate parameter to clearOut and
  clearAddressing was being inadvertently filtered out
2024-04-16 10:18:08 +02:00
75e19c3116 REGRESSION: distributedTriSurfaceMesh:::findLocalInstance failure (#3135)
- after the modification of d578d48a4f, the parent was now actually
  searched. However, should be returning "constant" and not trigger a
  FatalError if the file/directory is not found.
2024-04-16 10:18:08 +02:00
16dd92b38e ENH: reduce reliance on stringListOps functions
- findStrings, findMatchingStrings now mostly covered by matching
  intrinsics in wordRe and wordRes.

  Add static wordRes match() and matching() variants

COMP: remove stringListOps include from objectRegistry.H

- was already noted for removal (NOV-2018)
2024-04-16 10:18:08 +02:00
92c329a8a9 ENH: add const_cast variants for isA<> and refCast<>
- an example of the new, more succinct refConstCast version:

      auto& abc = refConstCast<adjointVectorBoundaryCondition>(Uab);

  older:
      adjointVectorBoundaryCondition& abc =
          refCast<adjointVectorBoundaryCondition>
          (
              const_cast<fvPatchVectorField&>(Uab)
          );
  or:
      adjointVectorBoundaryCondition& abc =
          const_cast<adjointVectorBoundaryCondition&>
          (
              refCast<const adjointVectorBoundaryCondition>(Uab)
          );

- an example of the new, more succinct isA_constCast version:

      auto* acapPtr = isA_constCast<fieldType>(abf[patchi]);

      if (acapPtr)
      {
          auto& acap = *acapPtr;
          ...
      }

  older:
      if (isA<fieldType>(abf[patchi]))
      {
          fieldType& acap =
              const_cast<fieldType&>
              (
                  refCast<const fieldType>(abf[patchi])
              );
          ...
      }

STYLE: remove spurious 'const' qualifier from isA<> use
2024-04-16 10:18:08 +02:00
6546dd3f5b BUG: redistributePar: bypassing reading remote file. See #3137.
- NewIFstream would read complete remote file to decide if
  was collated.
- This limits files to 31bit size
- Instead now have master-only opening of file.
- Still has problem with refinement history/cellLevel etc.
2024-04-15 16:49:45 +01:00
752ab418c9 COMP: avoid ambiguous type conversion in Clang (fixes #3138) 2024-04-11 09:33:51 +01:00
d578d48a4f ENH: improve findInstance handling for optional files
- previously would always return "constant" as the instance for
  an optional dir/file that wasn't found.
  However, this meant retesting to screen out false positives.
  Now support an additional parameter
      'bool constant_fallback = ...'
  to return "constant" or an empty word.

  The method signature changes slightly with a new optional bool
  parameter:

      //! Return \c "constant" instead of \c "" if the search failed
      const bool constant_fallback = true

ENH: code consolidation for findInstancePath

- relocate from Time to TimePaths and provide an additional static
  version that is reused in fileOperations

BUG: distributedTriSurfaceMesh:::findLocalInstance broken (#3135)

- was not checking the parent at all.

COMP: remove unused findInstancePath(const fileName&, ..) method
2024-04-10 15:55:29 +02:00
85771c8985 ENH: simpler topoSet handling of zone/set
- support construct faceZoneSet from faceSet (#3126)

ENH: support unregistered loading of cell/face/point sets
2024-04-10 15:55:29 +02:00
68c5d90ad0 STYLE: rename readContents -> readIOcontents for private/protected method
- leave 'readContents' method name for exposed (public) methods.
  Generally not a problem, but can confuse the compiler when various
  public/private versions are available with the same number of
  parameters.

STYLE: adjust meshObject debug statements
2024-04-10 15:55:29 +02:00
0dcc53ab03 ENH: additional std::unique_ptr support for regIOobject and IOobjectList
- regIOobject::store(std::unique_ptr<...>&& ptr)
- IOobjectList::add(std::unique_ptr<...>&& ptr)

STYLE: io.globalCaseName() instead of io.time().globalCaseName() [#3007]
2024-04-10 15:55:29 +02:00
6ac572a179 BUG: masterUncollatedFileOperation::read() masked return value (#3135)
ENH: combine broadcasts for uncollated master-only handling
2024-04-10 15:55:29 +02:00
7fd962926d ENH: simplify Pstream broadcast stream construction
- the rootProcNo is usually == UPstream::masterNo()
2024-04-10 15:55:29 +02:00
bca093d89c SUBMODULE: update OpenQBMM (compilation change only) 2024-04-08 19:21:12 +01:00
0ef981adbc BUG: cached ensight type not a word (fixes #3133)
- the type/name for field caching were saved as word, but ensight has
  things like "tensor symm" etc, which do not parse very well as
  'word'. Now save as 'string' type.

  Backwards compatibility is OK since a word token will also be
  readable as string etc.
2024-04-05 14:06:36 +02:00
2d61127606 ENH: accept reading unquoted string (ie, word)
- makes string reading consistent with fileName reading.

  Related to #3133 to also allow compatibility when reading existing
  dictionaries written with unquoted string contents.
2024-04-05 14:05:36 +02:00
e099e98b8b STYLE: remove defunct restore0Dir expand of #include [collated]
- used defunct "processors/" directory naming, and includes are now
  addressed by the file-handler anyhow.

ENH: support 'tutorials/Alltest -init'

- for copying/creating test directory without running
2024-04-03 19:00:39 +02:00
2ff67f8ce4 BUG: overlapping zones: incorrect indexing 2024-03-30 16:29:23 +00:00
13f66313d1 BUG: redistributePar: restore. Fix AMIInterpolation. fixes #3125
Problem was that the zero fvMeshSubset constructed did not reset
the distributed flag.
2024-03-28 14:52:28 +00:00
483075b4aa BUG: KinematicCloud: remove hard-coded debug condition 2024-03-27 19:47:32 +00:00
1668519996 BUG: redistributePar: disable parallel when redistributing. Fixes #3125 2024-03-27 11:52:38 +00:00
5091c79e96 BUG: topoSet: allow use of 'set' as input for zones. Fixes #3126 2024-03-27 10:32:16 +00:00
6bd1486a38 ENH: solution: allow Function1 with database 2024-03-27 09:17:18 +00:00
93f6cae46a DOC: topoSet: add zones instead of sets 2024-03-27 09:17:18 +00:00
68e36946fd BUG: externalWallHeatFluxTemperature: prevent FPE in mixedEnergy condition (fixes #3123) 2024-03-21 16:36:22 +00:00
c6ecf3113a COMP: syncTools: move attribute 2024-03-20 09:32:43 +00:00
46e1b00c34 ENH: handle sub-mesh connectivity by subsetting of adjacency matrix
- in renumberMesh replace calculation of a subMesh connectivity
  with calculation of the full mesh connectivity followed by subsetting
  of the full adjacency matrix. This should reduce the overall number of
  operations. (MR !669)
2024-03-19 14:09:22 +01:00
a431e0fe9a ENH: additional parRun selection/protection on syncTools
- allow more control over using parallel communication or not.
2024-03-18 20:59:21 +01:00
6d69506294 STYLE: adjust comments and iterator de-reference
STYLE: replace PackedListCore.H with in-file definition
2024-03-18 20:59:21 +01:00
77ec7ab679 Merge branch 'feature-topoSet-with-zone' into 'develop'
topoSet: allow use of 'zone' instead 'set', 'zones' instead of 'sets' in all set sources

See merge request Development/openfoam!674
2024-03-18 19:58:07 +00:00
6692ecfbbc topoSet: allow use of 'zone' instead 'set', 'zones' instead of 'sets' in all set sources 2024-03-18 19:58:06 +00:00
3ef892b980 Merge branch 'feature-topoSet' into 'develop'
Feature topo set

See merge request Development/openfoam!668
2024-03-18 16:13:52 +00:00
a7d6f2720f ENH: add for geometric transformation properties for topoSet
- added solidBodyMotionFunctions to topoSet which allows things like
  moving cellSet selection for fvOptions etc.

COMP: relocate solidBodyMotionFunctions to meshTools

Co-authored-by: Kutalmis Bercin <>
2024-03-18 16:50:16 +01:00
4a0a63999e BUG: cyclicAMI: start without 'value'. Fixes #3119 2024-03-18 12:14:36 +00:00
b1eb3e8746 BUG: fileHandler: disable parallel side effects. Fixes #3105 2024-03-18 11:54:40 +00:00
bc03a538cf ENH: mapDistribute: improved error message 2024-03-18 10:44:54 +00:00
766 changed files with 10694 additions and 6276 deletions

View File

@ -1,2 +1,2 @@
api=2401
api=2402
patch=240220

View File

@ -7,7 +7,6 @@ wclean libso surfaceTensionModels
wclean libso VoFphaseCompressibleTurbulenceModels
wclean
wclean compressibleInterDyMFoam
wclean compressibleInterFilmFoam
wclean compressibleInterIsoFoam

View File

@ -8,7 +8,6 @@ wmake $targetType surfaceTensionModels
wmake $targetType VoFphaseCompressibleTurbulenceModels
wmake $targetType
wmake $targetType compressibleInterDyMFoam
wmake $targetType compressibleInterFilmFoam
wmake $targetType compressibleInterIsoFoam
wmake $targetType overCompressibleInterDyMFoam

View File

@ -1,21 +1,25 @@
EXE_INC = \
-I../VoF \
-ItwoPhaseMixtureThermo \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-IVoFphaseCompressibleTurbulenceModels/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-IVoFphaseCompressibleTurbulenceModels/lnInclude
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-ldynamicMesh \
-ldynamicFvMesh \
-ltwoPhaseMixtureThermo \
-ltwoPhaseSurfaceTension \
-lcompressibleTransportModels \

View File

@ -1,3 +0,0 @@
compressibleInterDyMFoam.C
EXE = $(FOAM_APPBIN)/compressibleInterDyMFoam

View File

@ -1,35 +0,0 @@
EXE_INC = \
-I.. \
-I../../VoF \
-I../twoPhaseMixtureThermo \
-I../VoFphaseCompressibleTurbulenceModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-ltwoPhaseMixtureThermo \
-ltwoPhaseSurfaceTension \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-ltwoPhaseMixture \
-ltwoPhaseProperties \
-linterfaceProperties \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lthermoTools \
-lVoFphaseCompressibleTurbulenceModels \
-ldynamicMesh \
-ldynamicFvMesh

View File

@ -1,43 +0,0 @@
volScalarField::Internal Sp
(
IOobject
(
"Sp",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(dgdt.dimensions(), Zero)
);
volScalarField::Internal Su
(
IOobject
(
"Su",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(dgdt.dimensions(), Zero)
);
forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0 && alpha1[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]*alpha1[celli];
Su[celli] += dgdt[celli]*alpha1[celli];
}
else if (dgdt[celli] < 0.0 && alpha1[celli] < 1.0)
{
Sp[celli] += dgdt[celli]*(1.0 - alpha1[celli]);
}
}
volScalarField::Internal divU
(
mesh.moving()
? fvc::div(phiCN() + mesh.phi())
: fvc::div(phiCN())
);

View File

@ -1,190 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 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
compressibleInterDyMFoam
Description
Solver for two compressible, non-isothermal immiscible fluids using a VOF
(volume of fluid) phase-fraction based interface capturing approach,
with optional mesh motion and mesh topology changes including adaptive
re-meshing.
The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.
Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "CMULES.H"
#include "EulerDdtScheme.H"
#include "localEulerDdtScheme.H"
#include "CrankNicolsonDdtScheme.H"
#include "subCycle.H"
#include "compressibleInterPhaseTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "fvcSmooth.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Solver for two compressible, non-isothermal immiscible fluids"
" using VOF phase-fraction based interface capturing.\n"
"With optional mesh motion and mesh topology changes including"
" adaptive re-meshing."
);
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "initContinuityErrs.H"
#include "createDyMControls.H"
#include "createFields.H"
#include "createUf.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
volScalarField& p = mixture.p();
volScalarField& T = mixture.T();
const volScalarField& psi1 = mixture.thermo1().psi();
const volScalarField& psi2 = mixture.thermo2().psi();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readDyMControls.H"
// Store divU and divUp from the previous mesh so that it can be mapped
// and used in correctPhi to ensure the corrected phi has the
// same divergence
volScalarField divU("divU0", fvc::div(fvc::absolute(phi, U)));
volScalarField divUp("divUp", fvc::div(fvc::absolute(phi, U), p));
if (LTS)
{
#include "setRDeltaT.H"
}
else
{
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
}
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
if (pimple.firstIter() || moveMeshOuterCorrectors)
{
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
mesh.update();
if (mesh.changing())
{
MRF.update();
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
}
if ((mesh.changing() && correctPhi))
{
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf;
#include "correctPhi.H"
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
mixture.correct();
}
if (mesh.changing() && checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
#include "alphaControls.H"
#include "compressibleAlphaEqnSubCycle.H"
turbulence.correctPhasePhi();
#include "UEqn.H"
#include "TEqn.H"
// --- Pressure corrector loop
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence.correct();
}
}
rho = alpha1*rho1 + alpha2*rho2;
// Correct p_rgh for consistency with p and the updated densities
p_rgh = p - rho*gh;
p_rgh.correctBoundaryConditions();
runTime.write();
runTime.printExecutionTime(Info);
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,145 +0,0 @@
{
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, Uf))
);
MRF.makeRelative(phiHbyA);
surfaceScalarField phig
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phiHbyA, U);
tmp<fvScalarMatrix> p_rghEqnComp1;
tmp<fvScalarMatrix> p_rghEqnComp2;
if (pimple.transonic())
{
#include "rhofs.H"
surfaceScalarField phid1("phid1", fvc::interpolate(psi1)*phi);
surfaceScalarField phid2("phid2", fvc::interpolate(psi2)*phi);
p_rghEqnComp1 =
pos(alpha1)
*(
(
fvc::ddt(alpha1, rho1) + fvc::div(alphaPhi1*rho1f)
- (fvOptions(alpha1, mixture.thermo1().rho())&rho1)
)/rho1
- fvc::ddt(alpha1) - fvc::div(alphaPhi1)
+ (alpha1/rho1)
*correction
(
psi1*fvm::ddt(p_rgh)
+ fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
)
);
p_rghEqnComp1.ref().relax();
p_rghEqnComp2 =
pos(alpha2)
*(
(
fvc::ddt(alpha2, rho2) + fvc::div(alphaPhi2*rho2f)
- (fvOptions(alpha2, mixture.thermo2().rho())&rho2)
)/rho2
- fvc::ddt(alpha2) - fvc::div(alphaPhi2)
+ (alpha2/rho2)
*correction
(
psi2*fvm::ddt(p_rgh)
+ fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
)
);
p_rghEqnComp2.ref().relax();
}
else
{
p_rghEqnComp1 =
fvc::ddt(rho1) + psi1*correction(fvm::ddt(p_rgh))
+ fvc::div(phi, rho1) - fvc::Sp(fvc::div(phi), rho1);
p_rghEqnComp2 =
fvc::ddt(rho2) + psi2*correction(fvm::ddt(p_rgh))
+ fvc::div(phi, rho2) - fvc::Sp(fvc::div(phi), rho2);
}
// Cache p_rgh prior to solve for density update
volScalarField p_rgh_0(p_rgh);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqnIncomp
(
fvc::div(phiHbyA)
- fvm::laplacian(rAUf, p_rgh)
);
solve
(
(
(max(alpha1, scalar(0))/rho1)*p_rghEqnComp1()
+ (max(alpha2, scalar(0))/rho2)*p_rghEqnComp2()
)
+ p_rghEqnIncomp,
p_rgh.select(pimple.finalInnerIter())
);
if (pimple.finalNonOrthogonalIter())
{
p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin);
p_rgh = p - (alpha1*rho1 + alpha2*rho2)*gh;
dgdt =
(
pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2
- pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1
);
phi = phiHbyA + p_rghEqnIncomp.flux();
U = HbyA
+ rAU*fvc::reconstruct((phig + p_rghEqnIncomp.flux())/rAUf);
U.correctBoundaryConditions();
fvOptions.correct(U);
}
}
{
Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += n*(fvc::absolute(phi, U)/mesh.magSf() - (n & Uf));
}
// Update densities from change in p_rgh
mixture.thermo1().correctRho(psi1*(p_rgh - p_rgh_0));
mixture.thermo2().correctRho(psi2*(p_rgh - p_rgh_0));
rho = alpha1*rho1 + alpha2*rho2;
// Correct p_rgh for consistency with p and the updated densities
p = max(p_rgh + rho*gh, pMin);
p_rgh = p - rho*gh;
p_rgh.correctBoundaryConditions();
K = 0.5*magSqr(U);
}

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) OpenCFD OpenCFD Ltd.
Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,7 +32,9 @@ Group
Description
Solver for two compressible, non-isothermal immiscible fluids using a VOF
(volume of fluid) phase-fraction based interface capturing approach.
(volume of fluid) phase-fraction based interface capturing approach,
with optional mesh motion and mesh topology changes including adaptive
re-meshing.
The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.
@ -45,6 +47,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "CMULES.H"
#include "EulerDdtScheme.H"
#include "localEulerDdtScheme.H"
@ -53,6 +56,7 @@ Description
#include "compressibleInterPhaseTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "fvcSmooth.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,30 +74,31 @@ int main(int argc, char *argv[])
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createTimeControls.H"
#include "createDynamicFvMesh.H"
#include "initContinuityErrs.H"
#include "createDyMControls.H"
#include "createFields.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
#include "createUfIfPresent.H"
volScalarField& p = mixture.p();
volScalarField& T = mixture.T();
const volScalarField& psi1 = mixture.thermo1().psi();
const volScalarField& psi2 = mixture.thermo2().psi();
if (!LTS)
{
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readTimeControls.H"
#include "readDyMControls.H"
// Store divU from the previous mesh so that it can be mapped
// and used in correctPhi to ensure the corrected phi has the
// same divergence
volScalarField divU("divU0", fvc::div(fvc::absolute(phi, U)));
if (LTS)
{
@ -113,6 +118,44 @@ int main(int argc, char *argv[])
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
if (pimple.firstIter() || moveMeshOuterCorrectors)
{
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
mesh.update();
if (mesh.changing())
{
MRF.update();
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
if (correctPhi)
{
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
#include "correctPhi.H"
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
mixture.correct();
}
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
}
#include "alphaControls.H"
#include "compressibleAlphaEqnSubCycle.H"

View File

@ -8,6 +8,4 @@ CorrectPhi
pimple
);
//***HGW phi.oldTime() = phi;
#include "continuityErrs.H"

View File

@ -6,7 +6,7 @@
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi))
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi, Uf))
);
MRF.makeRelative(phiHbyA);
@ -23,6 +23,9 @@
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phiHbyA, U);
tmp<fvScalarMatrix> p_rghEqnComp1;
tmp<fvScalarMatrix> p_rghEqnComp2;
@ -34,8 +37,7 @@
surfaceScalarField phid2("phid2", fvc::interpolate(psi2)*phi);
p_rghEqnComp1 =
pos(alpha1)
*(
(
(
fvc::ddt(alpha1, rho1) + fvc::div(alphaPhi1*rho1f)
- (fvOptions(alpha1, mixture.thermo1().rho())&rho1)
@ -48,11 +50,9 @@
+ fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
)
);
p_rghEqnComp1.ref().relax();
p_rghEqnComp2 =
pos(alpha2)
*(
(
(
fvc::ddt(alpha2, rho2) + fvc::div(alphaPhi2*rho2f)
- (fvOptions(alpha2, mixture.thermo2().rho())&rho2)
@ -65,7 +65,6 @@
+ fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
)
);
p_rghEqnComp2.ref().relax();
}
else
{
@ -94,6 +93,21 @@
);
}
if (mesh.moving())
{
p_rghEqnComp1.ref() += fvc::div(mesh.phi())*alpha1;
p_rghEqnComp2.ref() += fvc::div(mesh.phi())*alpha2;
}
p_rghEqnComp1.ref() *= pos(alpha1);
p_rghEqnComp2.ref() *= pos(alpha2);
if (pimple.transonic())
{
p_rghEqnComp1.ref().relax();
p_rghEqnComp2.ref().relax();
}
// Cache p_rgh prior to solve for density update
volScalarField p_rgh_0(p_rgh);
@ -131,6 +145,9 @@
}
}
// Correct Uf if the mesh is moving
fvc::correctUf(Uf, U, fvc::absolute(phi, U));
// Update densities from change in p_rgh
mixture.thermo1().correctRho(psi1*(p_rgh - p_rgh_0));
mixture.thermo2().correctRho(psi2*(p_rgh - p_rgh_0));

View File

@ -53,46 +53,37 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
fileName coherentInst;
word coherentInst;
coherentInst =
(
runTime.findInstance
(
polyMesh::meshSubDir,
"coherent",
IOobject::READ_IF_PRESENT
IOobject::READ_IF_PRESENT,
word::null, // No stop instance
false // No "constant" fallback (word::null instead)
)
);
// Unfortunately with READ_IF_PRESENT, cannot tell if the file
// was actually found or not
Info<< "check: " << (coherentInst/polyMesh::meshSubDir/"coherent") << nl;
if (!Foam::isFile(coherentInst/polyMesh::meshSubDir/"coherent"))
{
coherentInst.clear();
}
Info<< "found coherent: " << coherentInst << nl;
Info<< "Found coherent \"" << coherentInst << '"' << nl;
PtrList<entry> entries;
if (!coherentInst.empty())
{
IOdictionary coherent
(
IOobject
dictionary coherent =
IOdictionary::readContents
(
"coherent",
coherentInst,
polyMesh::meshSubDir,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
)
);
IOobject
(
"coherent",
coherentInst,
polyMesh::meshSubDir,
runTime,
IOobject::MUST_READ
)
);
ITstream& is = coherent.lookup("boundary");
is >> entries;
@ -105,7 +96,7 @@ int main(int argc, char *argv[])
Info<< "size: " << polyBoundaryMeshEntries::patchSizes(entries) << nl;
Info<< nl;
fileName boundaryInst;
word boundaryInst;
boundaryInst =
(
runTime.findInstance
@ -116,7 +107,7 @@ int main(int argc, char *argv[])
)
);
Info<< "found boundary: " << boundaryInst << nl;
Info<< "Found boundary: \"" << boundaryInst << '"' << nl;
polyBoundaryMeshEntries pbm
(

View File

@ -0,0 +1,3 @@
Test-faMesh-try.cxx
EXE = $(FOAM_USER_APPBIN)/Test-faMesh-try

View File

@ -0,0 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lmeshTools

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 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-faMesh-try
Description
Test for loading of faMesh
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "faMesh.H"
#include "polyMesh.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "addRegionOption.H"
#include "addFaRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedPolyMesh.H"
#include "getFaRegionOption.H"
autoPtr<faMesh> aMeshPtr = faMesh::TryNew(areaRegionName, mesh);
Info<< "area-mesh: " << Switch::name(aMeshPtr) << nl;
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //

View File

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

View File

@ -0,0 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lmeshTools

View File

@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 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-faMeshesRegistry
Description
Basic tests for faMeshesRegistry
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "faMesh.H"
#include "faMeshesRegistry.H"
#include "polyMesh.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
Info<< "mesh 0: " << mesh.sortedNames() << nl;
faMeshesRegistry& reg =
const_cast<faMeshesRegistry&>(faMeshesRegistry::New(mesh));
// faMeshesRegistry faReg = faMeshesRegistry(mesh);
faMesh mesh1(mesh, Foam::zero{});
faMesh mesh2("mesh2", mesh, Foam::zero{});
reg.write();
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
Copyright (C) 2023-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,6 +50,9 @@ void printInfo(const meshObjects::gravity& g)
int main(int argc, char *argv[])
{
argList::addBoolOption("checkout", "Test checkout with release");
argList::addBoolOption("release", "Test release instead of delete");
#include "setRootCase.H"
#include "createTime.H"
@ -70,14 +73,81 @@ int main(int argc, char *argv[])
printInfo(g);
}
Pout<< "registered:" << flatOutput(runTime.sortedToc()) << nl << endl;
Pout<< "registered:"
<< flatOutput(runTime.sortedToc()) << nl << endl;
}
meshObjects::gravity::Delete("g", runTime);
meshObjects::gravity::Delete("something-not-in-registry", runTime);
std::unique_ptr<meshObjects::gravity> release1;
std::unique_ptr<meshObjects::gravity> release2;
Info<< "after Delete" << nl;
Pout<< "registered:" << flatOutput(runTime.sortedToc()) << endl;
if (args.found("release"))
{
// Ugly!
typedef
MeshObject<Time, TopologicalMeshObject, meshObjects::gravity>
parent_type;
release1 = meshObjects::gravity::Release("g", runTime);
release2 = meshObjects::gravity::Release("#none#", runTime);
Info<< "release: " << Switch::name(bool(release1))
<< ", " << Switch::name(bool(release2)) << nl;
Info<< "after Release: "
<< flatOutput(runTime.sortedToc()) << endl;
// Do checkout by hand (ugly)
if (args.found("checkout"))
{
if (release1)
{
release1->parent_type::checkOut();
}
if (release2)
{
release2->parent_type::checkOut();
}
Info<< "after checkout: "
<< flatOutput(runTime.sortedToc()) << endl;
}
}
else if (args.found("checkout"))
{
// Do checkout as part of release
release1 = meshObjects::gravity::Release("g", runTime, true);
release2 = meshObjects::gravity::Release("#none#", runTime, true);
Info<< "release: " << Switch::name(bool(release1))
<< ", " << Switch::name(bool(release2)) << nl;
Info<< "after Release/Checkout(true) : "
<< flatOutput(runTime.sortedToc()) << endl;
}
else
{
meshObjects::gravity::Delete("g", runTime);
meshObjects::gravity::Delete("#none#", runTime);
Info<< "after Delete: "
<< flatOutput(runTime.sortedToc()) << endl;
}
if (meshObjects::gravity::Store(std::move(release1)))
{
Info<< "Store pointer" << endl;
}
if (release2)
{
release2.reset();
Info<< "Clear pointer" << endl;
}
Info<< "Before exit: "
<< flatOutput(runTime.sortedToc()) << endl;
Info<< "\nEnd\n" << endl;

View File

@ -62,7 +62,7 @@ scalar sumReduce
scalar procValue;
UIPstream::read
(
UPstream::commsTypes::blocking,
UPstream::commsTypes::buffered,
proci,
reinterpret_cast<char*>(&procValue),
sizeof(scalar),
@ -79,7 +79,7 @@ scalar sumReduce
{
UOPstream::write
(
UPstream::commsTypes::blocking,
UPstream::commsTypes::buffered,
proci,
reinterpret_cast<const char*>(&sum),
sizeof(scalar),
@ -93,7 +93,7 @@ scalar sumReduce
{
UOPstream::write
(
UPstream::commsTypes::blocking,
UPstream::commsTypes::buffered,
UPstream::masterNo(),
reinterpret_cast<const char*>(&localValue),
sizeof(scalar),
@ -105,7 +105,7 @@ scalar sumReduce
{
UIPstream::read
(
UPstream::commsTypes::blocking,
UPstream::commsTypes::buffered,
UPstream::masterNo(),
reinterpret_cast<char*>(&sum),
sizeof(scalar),

View File

@ -41,14 +41,7 @@ Description
#include "PstreamReduceOps.H"
#include "SHA1.H"
// Include MPI without any C++ bindings
#ifndef MPICH_SKIP_MPICXX
#define MPICH_SKIP_MPICXX
#endif
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
#include <mpi.h>
#include "openfoam_mpi.H"
using namespace Foam;

View File

@ -41,14 +41,7 @@ Description
#include "StringStream.H"
#include "Random.H"
// Include MPI without any C++ bindings
#ifndef MPICH_SKIP_MPICXX
#define MPICH_SKIP_MPICXX
#endif
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
#include <mpi.h>
#include "openfoam_mpi.H"
using namespace Foam;

View File

@ -40,14 +40,7 @@ Description
#include "Pstream.H"
#include <iostream>
// Include MPI without any C++ bindings
#ifndef MPICH_SKIP_MPICXX
#define MPICH_SKIP_MPICXX
#endif
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
#include <mpi.h>
#include "openfoam_mpi.H"
using namespace Foam;

View File

@ -66,7 +66,7 @@ int main(int argc, char *argv[])
Pstream::myProcNo()
);
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
PstreamBuffers pBufs;
if (!Pstream::master())
{
@ -150,7 +150,7 @@ int main(int argc, char *argv[])
// Do a non-blocking send inbetween
{
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
PstreamBuffers pBufs;
for (const int proci : Pstream::allProcs())
{

View File

@ -131,7 +131,7 @@ void testTransfer(const T& input)
for (const int proci : UPstream::subProcs())
{
Perr<< "master sending to proc:" << proci << endl;
OPstream os(UPstream::commsTypes::blocking, proci);
OPstream os(UPstream::commsTypes::buffered, proci);
os << data;
}
}
@ -139,7 +139,7 @@ void testTransfer(const T& input)
{
{
Perr<< "proc sending to master" << endl;
OPstream os(UPstream::commsTypes::blocking, UPstream::masterNo());
OPstream os(UPstream::commsTypes::buffered, UPstream::masterNo());
os << data;
}
@ -169,7 +169,7 @@ void testTokenized(const T& data)
for (const int proci : UPstream::subProcs())
{
Perr<< "master sending to proc:" << proci << endl;
OPstream os(UPstream::commsTypes::blocking, proci);
OPstream os(UPstream::commsTypes::buffered, proci);
os << tok;
}
}
@ -177,7 +177,7 @@ void testTokenized(const T& data)
{
{
Perr<< "proc sending to master" << endl;
OPstream os(UPstream::commsTypes::blocking, UPstream::masterNo());
OPstream os(UPstream::commsTypes::buffered, UPstream::masterNo());
os << tok;
}

View File

@ -34,14 +34,7 @@ Description
#include "globalMeshData.H"
#include "OFstream.H"
// Include MPI without any C++ bindings
#ifndef MPICH_SKIP_MPICXX
#define MPICH_SKIP_MPICXX
#endif
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
#include <mpi.h>
#include "openfoam_mpi.H"
using namespace Foam;

View File

@ -44,7 +44,7 @@ Description
Format options:
\table
Property | Description | Required | Default
commsType | blocking/nonBlocking/scheduled | no | scheduled
commsType | scheduled/nonBlocking/buffered | no | scheduled
merge | Enable geometry/field merging | no | true
write | Write file(s) | no | false
narrow | Communicate with narrowed values | no | false

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd.
Copyright (C) 2017-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,6 +35,9 @@ Description
#include "labelList.H"
#include "scalarList.H"
#include "DynamicList.H"
#include "labelField.H"
#include "scalarField.H"
#include "SubField.H"
#include "SpanStream.H"
#include "formattingEntry.H"
@ -90,7 +93,7 @@ int main(int argc, char *argv[])
{
// This also works, but not actually using the autoPtr directly
autoPtr<token::Compound<labelList>> ptr
autoPtr<token::compound> ptr
(
new token::Compound<labelList>(identity(10, -9))
);
@ -131,44 +134,50 @@ int main(int argc, char *argv[])
Info<< "resized: "
<< ctok1.info() << nl << ctok1 << endl;
const scalarList* listptr = ctok1.compoundToken().isA<scalarList>();
if (listptr)
{
for (scalar& val : const_cast<scalarList&>(*listptr))
// Using isA<> on compoundToken()
const auto* listptr = ctok1.compoundToken().isA<scalarList>();
if (listptr)
{
val *= 5;
}
// sneaky, SubField bypasses const!
scalarField::subField fld(*listptr);
fld *= 5;
Info<< "multiplied List<scalar>: "
<< ctok1.info() << nl << ctok1 << endl;
Info<< "multiplied List<scalar>: "
<< ctok1.info() << nl << ctok1 << endl;
}
}
listptr = ctok1.isCompound<scalarList>();
if (listptr)
{
for (scalar& val : const_cast<scalarList&>(*listptr))
{
val /= 2;
}
// Using isCompound<...> - combined check
Info<< "divided List<scalar>: "
<< ctok1.info() << nl << ctok1 << endl;
const auto* listptr = ctok1.isCompound<scalarList>();
if (listptr)
{
scalarField::subField fld(*listptr);
fld /= 2;
Info<< "divided List<scalar>: "
<< ctok1.info() << nl << ctok1 << endl;
}
}
const labelList* listptr2 = ctok1.isCompound<labelList>();
if (listptr2)
{
for (label& val : const_cast<labelList&>(*listptr2))
{
val /= 2;
}
// Using isCompound<...> - combined check
Info<< "divided List<label>: "
<< ctok1.info() << nl << ctok1 << endl;
}
else
{
Info<< "compound is not List<label>" << nl;
const auto* listptr = ctok1.isCompound<labelList>();
if (listptr)
{
labelField::subField fld(*listptr);
fld /= 2;
Info<< "divided List<label>: "
<< ctok1.info() << nl << ctok1 << endl;
}
else
{
Info<< "compound is not List<label>" << nl;
}
}
Info<< "Before fill_zero: " << ctok1 << endl;
@ -183,57 +192,33 @@ int main(int argc, char *argv[])
auto& ct = ctok1.refCompoundToken();
ct.resize(20);
bool handled = true;
bool handled = false;
switch (ct.typeCode())
{
case token::tokenType::BOOL :
{
UList<bool> cmpts
(
reinterpret_cast<bool*>(ct.data_bytes()),
label(ct.size_bytes() / sizeof(bool))
);
cmpts = false;
#undef doLocalCode
#define doLocalCode(TokenType, cmptType, cmptValue) \
\
case TokenType : \
{ \
UList<cmptType> cmpts \
( \
reinterpret_cast<cmptType*>(ct.data_bytes()), \
label(ct.size_bytes() / sizeof(cmptType)) \
); \
cmpts = cmptValue; \
handled = true; \
break; \
}
break;
case token::tokenType::LABEL :
{
UList<label> cmpts
(
reinterpret_cast<label*>(ct.data_bytes()),
label(ct.size_bytes() / sizeof(label))
);
cmpts = 123;
}
break;
doLocalCode(token::tokenType::BOOL, bool, false);
doLocalCode(token::tokenType::LABEL, label, 123);
doLocalCode(token::tokenType::FLOAT, float, 2.7);
doLocalCode(token::tokenType::DOUBLE, double, 3.1415);
case token::tokenType::FLOAT :
{
UList<float> cmpts
(
reinterpret_cast<float*>(ct.data_bytes()),
label(ct.size_bytes() / sizeof(float))
);
cmpts = 2.7;
}
break;
#undef doLocalCode
case token::tokenType::DOUBLE :
{
UList<double> cmpts
(
reinterpret_cast<double*>(ct.data_bytes()),
label(ct.size_bytes() / sizeof(double))
);
cmpts = 3.1415;
}
break;
default:
handled = false;
break;
default : break;
}
@ -241,6 +226,10 @@ int main(int argc, char *argv[])
{
Info<< "assigned: " << ctok1 << nl;
}
else
{
Info<< "Warning: not handled!" << nl;
}
}
}
@ -327,6 +316,65 @@ int main(int argc, char *argv[])
Info<< "content" << nl << entry3 << nl;
}
{
primitiveEntry entry0("entry");
Info<< "empty: " << entry0 << nl;
// populate
{
tokenList& toks = entry0.stream();
toks.resize(2);
toks[0] = word("nonuniform");
toks[1] = token::Compound<scalarList>::New(10, scalar(1));
}
Info<< entry0 << nl;
// Modify contents
for (auto& tok : entry0.stream())
{
if (tok.isCompound<scalarList>())
{
tok.refCompoundToken<scalarList>() = 2;
}
}
Info<< entry0 << nl;
// Find and 'capture' contents
{
typedef List<scalar> ListType;
auto* inputDataPtr =
const_cast<ListType*>(entry0.stream().findCompound<ListType>());
if (inputDataPtr)
{
Info<< "found input data" << nl;
Info<< entry0 << nl;
ListType inputData(std::move(*inputDataPtr));
Info<< "input data, after move" << nl;
Info<< entry0 << nl;
ListType replaceData(5, scalar(3.145));
// some manipulation
replaceData.back() = scalar(1.414);
inputDataPtr->swap(replaceData);
Info<< "with replaced values" << nl;
}
}
Info<< entry0 << nl;
}
return 0;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -77,6 +77,7 @@ int main(int argc, char *argv[])
);
#include "addRegionOption.H"
#include "addFaRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedPolyMesh.H"
@ -90,8 +91,7 @@ int main(int argc, char *argv[])
faMesh::geometryOrder(geometryOrder);
}
// Create
faMesh aMesh(mesh);
#include "createNamedFaMesh.H"
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -55,7 +55,7 @@ do
bitSet haveMeshOnProc;
std::unique_ptr<faMeshSubset> subsetter;
IOobjectList objects(0);
IOobjectList objects;
refPtr<fileOperation> newHandler(fileOperation::NewUncollated());
@ -70,7 +70,13 @@ do
const bool oldParRun = UPstream::parRun(false);
objects = IOobjectList(serialMesh.time(), runTime.timeName());
objects = IOobjectList
(
serialMesh.time(),
runTime.timeName(),
serialMesh.dbDir(),
IOobjectOption::NO_REGISTER
);
UPstream::parRun(oldParRun);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -18,7 +18,8 @@ Required Classes
- Foam::IOdictionary
Required Variables
- regionName [word]
- regionName [word] (the polyMesh region)
- areaRegionName [word] (the areaMesh region)
- args [argList]
- runTime [Time]
@ -35,6 +36,7 @@ autoPtr<IOdictionary> meshDictPtr;
{
fileName dictPath;
const word& regionDir = Foam::polyMesh::regionName(regionName);
const word& areaRegionDir = Foam::polyMesh::regionName(areaRegionName);
if (args.readIfPresent("dict", dictPath))
{
@ -47,38 +49,30 @@ autoPtr<IOdictionary> meshDictPtr;
}
else if
(
// Check global location
exists
// Dictionary under system/faMeshDefinition ?
// (v2312 and earlier)
areaRegionDir.empty()
&& exists
(
runTime.path()/runTime.caseConstant()
runTime.path()/runTime.caseSystem()
/ regionDir/faMesh::meshSubDir/dictName
)
)
{
// Dictionary present in constant faMesh directory (old-style)
// Dictionary present directly in system/ (v2312 and earlier)
dictPath =
(
runTime.constant()
/ regionDir/faMesh::meshSubDir/dictName
);
// Warn that constant/faMesh/faMeshDefinition was used
// instead of system/faMeshDefinition
#if 0
WarningIn(args.executable())
<< "Using the old faMeshDefinition location: "
<< dictPath << nl
<< " instead of default location: "
<< runTime.system()/regionDir/dictName << nl
<< endl;
#endif
dictPath = runTime.system()/regionDir/dictName;
}
else
{
// Assume dictionary is in the system directory
// Use system/finite-area/ directory, with region qualifications
dictPath = runTime.system()/regionDir/dictName;
dictPath =
(
runTime.system()/regionDir
/ faMesh::prefix()/areaRegionDir/dictName
);
}
IOobject meshDictIO

View File

@ -104,10 +104,13 @@ int main(int argc, char *argv[])
);
#include "addRegionOption.H"
#include "addFaRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedPolyMesh.H"
#include "getFaRegionOption.H"
const bool doDecompose = !args.found("no-decompose");
const bool doDecompFields = !args.found("no-fields");
@ -133,8 +136,15 @@ int main(int argc, char *argv[])
// Preliminary checks
#include "checkPatchTopology.H"
Info << "Create areaMesh";
if (!Foam::polyMesh::regionName(areaRegionName).empty())
{
Foam::Info << ' ' << areaRegionName;
}
Info << " for polyMesh at time = " << runTime.timeName() << nl;
// Create
faMesh aMesh(mesh, meshDefDict);
faMesh aMesh(areaRegionName, mesh, meshDefDict);
// Mesh information (less verbose)
faMeshTools::printMeshChecks(aMesh, 0);

View File

@ -618,7 +618,7 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
labelList rotation(faces.size(), Zero);
labelList faceMap(faces.size(), label(-1));
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
PstreamBuffers pBufs;
// Send ordering
forAll(sortMesh.boundaryMesh(), patchi)

View File

@ -568,10 +568,9 @@ void syncPoints
}
}
// buffered send
OPstream toNbr
(
UPstream::commsTypes::blocking,
UPstream::commsTypes::buffered,
procPatch.neighbProcNo()
);
toNbr << patchInfo;

View File

@ -145,6 +145,7 @@ Usage
#include "hexRef8Data.H"
#include "regionProperties.H"
#include "polyMeshTools.H"
#include "subsetAdjacency.H"
using namespace Foam;
@ -194,21 +195,56 @@ tmp<volScalarField> createScalarField
}
// Calculate band of matrix
label getBand(const labelList& owner, const labelList& neighbour)
// Calculate band of mesh
// label getBand(const labelUList& owner, const labelUList& neighbour)
// {
// label bandwidth = 0;
//
// forAll(neighbour, facei)
// {
// const label width = neighbour[facei] - owner[facei];
//
// if (bandwidth < width)
// {
// bandwidth = width;
// }
// }
// return bandwidth;
// }
// Calculate band and profile of matrix. Profile is scalar to avoid overflow
Tuple2<label, scalar> getBand
(
const CompactListList<label>& mat
)
{
label band = 0;
Tuple2<label, scalar> metrics(0, 0);
forAll(neighbour, facei)
auto& bandwidth = metrics.first();
auto& profile = metrics.second();
forAll(mat, celli)
{
label diff = neighbour[facei] - owner[facei];
const auto& neighbours = mat[celli];
if (diff > band)
const label nNbr = neighbours.size();
if (nNbr)
{
band = diff;
// Max distance
const label width = (neighbours[nNbr-1] - celli);
if (bandwidth < width)
{
bandwidth = width;
}
profile += scalar(width);
}
}
return band;
return metrics;
}
@ -217,27 +253,35 @@ void getBand
(
const bool calculateIntersect,
const label nCells,
const labelList& owner,
const labelList& neighbour,
const labelUList& owner,
const labelUList& neighbour,
label& bandwidth,
scalar& profile, // scalar to avoid overflow
scalar& sumSqrIntersect // scalar to avoid overflow
)
{
labelList cellBandwidth(nCells, Foam::zero{});
scalarField nIntersect(nCells, Foam::zero{});
bandwidth = 0;
forAll(neighbour, facei)
{
label own = owner[facei];
label nei = neighbour[facei];
const label own = owner[facei];
const label nei = neighbour[facei];
// Note: mag not necessary for correct (upper-triangular) ordering.
label diff = nei-own;
cellBandwidth[nei] = max(cellBandwidth[nei], diff);
}
const label width = nei - own;
bandwidth = max(cellBandwidth);
if (cellBandwidth[nei] < width)
{
cellBandwidth[nei] = width;
if (bandwidth < width)
{
bandwidth = width;
}
}
}
// Do not use field algebra because of conversion label to scalar
profile = 0;
@ -246,14 +290,16 @@ void getBand
profile += scalar(width);
}
sumSqrIntersect = 0.0;
sumSqrIntersect = 0;
if (calculateIntersect)
{
scalarField nIntersect(nCells, Foam::zero{});
forAll(nIntersect, celli)
{
for (label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
{
nIntersect[colI] += 1.0;
nIntersect[colI] += scalar(1);
}
}
@ -675,9 +721,8 @@ CompactListList<label> regionRenumber
forAll(regionCellOrder, regioni)
{
// Info<< " region " << regioni
// << " starts at " << regionCellOrder.localStart(regioni)
// << nl;
// Info<< " region " << regioni << " starts at "
// << regionCellOrder.localStart(regioni) << nl;
// No parallel communication
const bool oldParRun = UPstream::parRun(false);
@ -703,27 +748,42 @@ CompactListList<label> regionRenumber
{
timer.resetTimeIncrement();
// Create adjacency matrix of the full mesh and subset subsequently.
// This is more efficient than creating adjacency matrices of
// sub-meshes.
// No parallel communication
const bool oldParRun = UPstream::parRun(false);
// The local connectivity of the full (non-subsetted) mesh
CompactListList<label> meshCellCells;
globalMeshData::calcCellCells(mesh, meshCellCells);
UPstream::parRun(oldParRun); // Restore parallel state
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
// For the respective subMesh selections
bitSet subsetCells(mesh.nCells());
forAll(regionCellOrder, regioni)
{
// Info<< " region " << regioni
// << " starts at " << regionCellOrder.localStart(regioni)
// << nl;
// Info<< " region " << regioni << " starts at "
// << regionCellOrder.localStart(regioni) << nl;
subsetCells = false;
subsetCells.set(regionCellOrder[regioni]);
// Connectivity of local sub-mesh
labelList cellMap;
CompactListList<label> subCellCells =
subsetAdjacency(subsetCells, meshCellCells, cellMap);
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
// No parallel communication
const bool oldParRun = UPstream::parRun(false);
// Connectivity of local sub-mesh
CompactListList<label> cellCells;
labelList cellMap = globalMeshData::calcCellCells
(
mesh,
regionCellOrder[regioni],
cellCells
);
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
labelList subCellOrder = method.renumber(cellCells);
labelList subCellOrder = method.renumber(subCellCells);
UPstream::parRun(oldParRun); // Restore parallel state
@ -835,10 +895,10 @@ int main(int argc, char *argv[])
const bool dryrun = args.dryRun();
const bool readDict = args.found("dict");
const bool doFrontWidth = args.found("frontWidth");
const bool doDecompose = args.found("decompose");
const bool overwrite = args.found("overwrite");
const bool doFields = !args.found("no-fields");
const bool doDecompose = args.found("decompose");
const bool doFrontWidth = args.found("frontWidth") && !doDecompose;
word renumberMethodName;
args.readIfPresent("renumber-method", renumberMethodName);
@ -846,8 +906,7 @@ int main(int argc, char *argv[])
if (doDecompose && UPstream::parRun())
{
FatalErrorIn(args.executable())
<< "Cannot use -decompose option in parallel"
<< " ... giving up" << nl
<< "Cannot use -decompose option in parallel ... giving up" << nl
<< exit(FatalError);
}
@ -908,21 +967,21 @@ int main(int argc, char *argv[])
reduce(band, maxOp<label>());
reduce(profile, sumOp<scalar>());
reduce(sumSqrIntersect, sumOp<scalar>());
scalar rmsFrontwidth = Foam::sqrt
(
sumSqrIntersect/mesh.globalData().nTotalCells()
);
Info<< "Mesh " << mesh.name()
<< " size: " << mesh.globalData().nTotalCells() << nl
<< "Before renumbering :" << nl
<< "Before renumbering" << nl
<< " band : " << band << nl
<< " profile : " << profile << nl;
if (doFrontWidth)
{
reduce(sumSqrIntersect, sumOp<scalar>());
scalar rmsFrontwidth = Foam::sqrt
(
sumSqrIntersect/mesh.globalData().nTotalCells()
);
Info<< " rms frontwidth : " << rmsFrontwidth << nl;
}
@ -1091,10 +1150,7 @@ int main(int argc, char *argv[])
);
// List of objects read from time directory
// List of stored objects to clear from mesh
IOobjectList objects;
// List of stored objects to clear from mesh (after reading)
DynamicList<regIOobject*> storedObjects;
if (!dryrun && doFields)
@ -1103,55 +1159,60 @@ int main(int argc, char *argv[])
timer.resetTimeIncrement();
objects = IOobjectList(mesh, runTime.timeName());
IOobjectList objects(mesh, runTime.timeName());
storedObjects.reserve(objects.size());
const predicates::always nameMatcher;
// Read GeometricFields
#undef ReadFields
#define ReadFields(FieldType) \
#undef doLocalCode
#define doLocalCode(FieldType) \
readFields<FieldType>(mesh, objects, nameMatcher, storedObjects);
// Read volume fields
ReadFields(volScalarField);
ReadFields(volVectorField);
ReadFields(volSphericalTensorField);
ReadFields(volSymmTensorField);
ReadFields(volTensorField);
doLocalCode(volScalarField);
doLocalCode(volVectorField);
doLocalCode(volSphericalTensorField);
doLocalCode(volSymmTensorField);
doLocalCode(volTensorField);
// Read internal fields
ReadFields(volScalarField::Internal);
ReadFields(volVectorField::Internal);
ReadFields(volSphericalTensorField::Internal);
ReadFields(volSymmTensorField::Internal);
ReadFields(volTensorField::Internal);
doLocalCode(volScalarField::Internal);
doLocalCode(volVectorField::Internal);
doLocalCode(volSphericalTensorField::Internal);
doLocalCode(volSymmTensorField::Internal);
doLocalCode(volTensorField::Internal);
// Read surface fields
ReadFields(surfaceScalarField);
ReadFields(surfaceVectorField);
ReadFields(surfaceSphericalTensorField);
ReadFields(surfaceSymmTensorField);
ReadFields(surfaceTensorField);
doLocalCode(surfaceScalarField);
doLocalCode(surfaceVectorField);
doLocalCode(surfaceSphericalTensorField);
doLocalCode(surfaceSymmTensorField);
doLocalCode(surfaceTensorField);
// Read point fields
const pointMesh& pMesh = pointMesh::New(mesh);
#undef ReadPointFields
#define ReadPointFields(FieldType) \
#undef doLocalCode
#define doLocalCode(FieldType) \
readFields<FieldType>(pMesh, objects, nameMatcher, storedObjects);
ReadPointFields(pointScalarField);
ReadPointFields(pointVectorField);
ReadPointFields(pointSphericalTensorField);
ReadPointFields(pointSymmTensorField);
ReadPointFields(pointTensorField);
doLocalCode(pointScalarField);
doLocalCode(pointVectorField);
doLocalCode(pointSphericalTensorField);
doLocalCode(pointSymmTensorField);
doLocalCode(pointTensorField);
#undef ReadFields
#undef ReadPointFields
#undef doLocalCode
timings[TimingType::READ_FIELDS] += timer.timeIncrement();
// Write loaded fields when mesh.write() is called
for (auto* fldptr : storedObjects)
{
fldptr->writeOpt(IOobject::AUTO_WRITE);
}
}
@ -1224,7 +1285,13 @@ int main(int argc, char *argv[])
CompactListList<label> regionCellOrder =
regionRenumber(renumberPtr(), mesh, cellToRegion);
regionRenumber
(
renumberPtr(),
mesh,
cellToRegion,
decomposePtr().nDomains()
);
cellOrder = regionCellOrder.values();
@ -1586,19 +1653,25 @@ int main(int argc, char *argv[])
);
reduce(band, maxOp<label>());
reduce(profile, sumOp<scalar>());
reduce(sumSqrIntersect, sumOp<scalar>());
scalar rmsFrontwidth = Foam::sqrt
(
sumSqrIntersect/mesh.globalData().nTotalCells()
);
Info<< "After renumbering";
if (doDecompose)
{
Info<< " [values are misleading with -decompose option]";
}
Info<< "After renumbering :" << nl
Info<< nl
<< " band : " << band << nl
<< " profile : " << profile << nl;
if (doFrontWidth)
{
reduce(sumSqrIntersect, sumOp<scalar>());
scalar rmsFrontwidth = Foam::sqrt
(
sumSqrIntersect/mesh.globalData().nTotalCells()
);
Info<< " rms frontwidth : " << rmsFrontwidth << nl;
}

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) 2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Subsetting of an adjacency matrix (as CompactListList).
Can be relocated elsewhere.
\*---------------------------------------------------------------------------*/
#include "CompactListList.H"
#include "bitSet.H"
#include "ListOps.H"
#include "Map.H"
namespace Foam
{
// Perform a subset of the adjacency matrix
CompactListList<label> subsetAdjacency
(
const bitSet& select, // could also be labelHashSet
const CompactListList<label>& input,
labelList& subMap
)
{
// Corresponds to cellMap etc (the original selection)
subMap = select.sortedToc();
// Ensure that the subMap corresponds to a valid subset
{
label validSize = 0;
const label nTotal = input.size();
forAllReverse(subMap, i)
{
if (subMap[i] < nTotal)
{
validSize = i + 1;
break;
}
}
subMap.resize(validSize);
}
// Assumed to be sparse - use Map for reverse lookup
const Map<label> reverseMap(invertToMap(subMap));
// Pass 1: determine the selected sub-sizes
labelList sizes(subMap.size(), Foam::zero{});
forAll(subMap, idx)
{
for (const label nbr : input[subMap[idx]])
{
if
(
select.test(nbr)
&& reverseMap.contains(nbr) // extra consistency (paranoid)
)
{
++sizes[idx];
}
}
}
CompactListList<label> output(sizes);
// Reuse sizes as output offset into output.values()
sizes = labelList::subList(output.offsets(), output.size());
labelList& values = output.values();
// Pass 2: extract sub-adjacent matrix
label newNbr = -1;
forAll(subMap, idx)
{
for (const label nbr : input[subMap[idx]])
{
if
(
select.test(nbr)
&& (newNbr = reverseMap.lookup(nbr, -1)) >= 0
)
{
values[sizes[idx]++] = newNbr;
}
}
}
return output;
}
// Perform a subset of the adjacency matrix
CompactListList<label> subsetAdjacency
(
const labelRange& slice,
const CompactListList<label>& input,
labelList& subMap
)
{
// Ensure that the selection corresponds to a valid subset
const labelRange select = slice.subset0(input.size());
// Corresponds to cellMap etc (the original selection)
subMap = Foam::identity(select);
// Pass 1: determine the selected sub-sizes
labelList sizes(subMap.size(), Foam::zero{});
forAll(subMap, idx)
{
for (const label nbr : input[subMap[idx]])
{
if (select.contains(nbr))
{
++sizes[idx];
}
}
}
CompactListList<label> output(sizes);
// Reuse sizes as output offset into output.values()
sizes = labelList::subList(output.offsets(), output.size());
labelList& values = output.values();
// Pass 2: extract sub-adjacent matrix
const label localOffset = select.start();
forAll(subMap, idx)
{
for (const label nbr : input[subMap[idx]])
{
if (select.contains(nbr))
{
values[sizes[idx]++] = nbr - localOffset;
}
}
}
return output;
}
} // End namespace Foam
// ************************************************************************* //

View File

@ -173,7 +173,7 @@ namespace Foam
// Uses polyMesh/fvMesh meshSubDir by default
autoPtr<labelIOList> procAddressing
(
const fvMesh& procMesh,
const objectRegistry& procRegistry,
const word& name,
const word& instance,
const word& local = fvMesh::meshSubDir
@ -186,7 +186,7 @@ autoPtr<labelIOList> procAddressing
name,
instance,
local,
procMesh,
procRegistry,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
@ -199,13 +199,13 @@ autoPtr<labelIOList> procAddressing
// Uses the finiteArea meshSubDir
autoPtr<labelIOList> faProcAddressing
(
const fvMesh& procMesh,
const objectRegistry& procRegistry,
const word& name,
const word& instance,
const word& local = faMesh::meshSubDir
)
{
return procAddressing(procMesh, name, instance, local);
return procAddressing(procRegistry, name, instance, local);
}
@ -797,11 +797,22 @@ int main(int argc, char *argv[])
// Field objects at this time
IOobjectList objects;
IOobjectList faObjects;
if (doDecompFields)
{
// List of volume mesh objects for this instance
objects = IOobjectList(mesh, runTime.timeName());
// List of area mesh objects (assuming single region)
faObjects = IOobjectList
(
mesh.time(),
runTime.timeName(),
faMesh::dbDir(mesh, word::null),
IOobjectOption::NO_REGISTER
);
// Ignore generated fields: (cellDist)
objects.remove("cellDist");
}
@ -810,12 +821,15 @@ int main(int argc, char *argv[])
autoPtr<faMeshDecomposition> faMeshDecompPtr;
if (doFiniteArea)
{
const word boundaryInst =
mesh.time().findInstance(mesh.meshDir(), "boundary");
IOobject io
(
"faBoundary",
mesh.time().findInstance(mesh.meshDir(), "boundary"),
faMesh::meshSubDir,
mesh,
boundaryInst,
faMesh::meshDir(mesh, word::null),
mesh.time(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
@ -1225,7 +1239,7 @@ int main(int argc, char *argv[])
if (doDecompFields)
{
areaFieldCache.readAllFields(aMesh, objects);
areaFieldCache.readAllFields(aMesh, faObjects);
}
const label nAreaFields = areaFieldCache.size();
@ -1293,7 +1307,7 @@ int main(int argc, char *argv[])
autoPtr<labelIOList> tfaceProcAddr =
faProcAddressing
(
procFvMesh,
procMesh,
"faceProcAddressing",
runTime.constant()
);
@ -1302,7 +1316,7 @@ int main(int argc, char *argv[])
autoPtr<labelIOList> tboundaryProcAddr =
faProcAddressing
(
procFvMesh,
procMesh,
"boundaryProcAddressing",
runTime.constant()
);
@ -1311,7 +1325,7 @@ int main(int argc, char *argv[])
autoPtr<labelIOList> tedgeProcAddr =
faProcAddressing
(
procFvMesh,
procMesh,
"edgeProcAddressing",
runTime.constant()
);

View File

@ -132,9 +132,6 @@ class domainDecomposition
labelList& elementToZone
);
//- Append single element to list
static void append(labelList&, const label);
//- Add face to inter-processor patch
void addInterProcFace
(

View File

@ -39,14 +39,6 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::domainDecomposition::append(labelList& lst, const label elem)
{
label sz = lst.size();
lst.setSize(sz+1);
lst[sz] = elem;
}
void Foam::domainDecomposition::addInterProcFace
(
const label facei,
@ -354,9 +346,8 @@ void Foam::domainDecomposition::decomposeMesh()
procFaceAddressing_[proci].size();
// Add size as last element to substarts and transfer
append
subPatchStarts[proci][interPatch].append
(
subPatchStarts[proci][interPatch],
curInterPatchFaces[interPatch].size()
);
procProcessorPatchSubPatchIDs_[proci][i].transfer

View File

@ -103,8 +103,8 @@ void Foam::domainDecomposition::processInterCyclics
if (interPatchFaces[proci][interI].size() > oldSz)
{
// Added faces to this interface. Add an entry
append(subPatchIDs[proci][interI], patchi);
append(subPatchStarts[proci][interI], oldSz);
subPatchIDs[proci][interI].append(patchi);
subPatchStarts[proci][interI].append(oldSz);
}
}
}

View File

@ -382,9 +382,25 @@ int main(int argc, char *argv[])
IOobjectList objects
(
procMeshes.meshes()[0],
databases[0].timeName()
databases[0].timeName(),
IOobjectOption::NO_REGISTER
);
IOobjectList faObjects;
if (doFiniteArea && doFields)
{
// List of area mesh objects (assuming single region)
// - scan on processor0
faObjects = IOobjectList
(
procMeshes.meshes()[0],
databases[0].timeName(),
faMesh::dbDir(word::null), // local relative to mesh
IOobjectOption::NO_REGISTER
);
}
if (doFields)
{
// If there are any FV fields, reconstruct them
@ -545,12 +561,12 @@ int main(int argc, char *argv[])
}
else if
(
objects.count<areaScalarField>()
|| objects.count<areaVectorField>()
|| objects.count<areaSphericalTensorField>()
|| objects.count<areaSymmTensorField>()
|| objects.count<areaTensorField>()
|| objects.count<edgeScalarField>()
faObjects.count<areaScalarField>()
|| faObjects.count<areaVectorField>()
|| faObjects.count<areaSphericalTensorField>()
|| faObjects.count<areaSymmTensorField>()
|| faObjects.count<areaTensorField>()
|| faObjects.count<edgeScalarField>()
)
{
Info << "Reconstructing FA fields" << nl << endl;
@ -568,7 +584,7 @@ int main(int argc, char *argv[])
procFaMeshes.boundaryProcAddressing()
);
reconstructor.reconstructAllFields(objects);
reconstructor.reconstructAllFields(faObjects);
}
else
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -314,11 +314,7 @@ boundBox procBounds
{
fileName pointsInstance
(
procDb.findInstance
(
polyMesh::meshDir(regionName),
"points"
)
procDb.findInstance(polyMesh::meshDir(regionName), "points")
);
if (pointsInstance != procDb.timeName())
@ -343,11 +339,7 @@ boundBox procBounds
IOobject
(
"points",
procDb.findInstance
(
polyMesh::meshDir(regionName),
"points"
),
pointsInstance,
polyMesh::meshDir(regionName),
procDb,
IOobject::MUST_READ,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2023 OpenCFD Ltd.
Copyright (C) 2015-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,6 +31,7 @@ License
#include "Pstream.H"
#include "OSspecific.H"
#include "decomposedBlockData.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
@ -161,19 +162,54 @@ Foam::boolList Foam::haveMeshFile
(
handler.filePath(runTime.path()/meshPath/meshFile)
);
bool found = handler.isFile(fName);
if (returnReduceAnd(found)) // worldComm
{
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(fName));
if (isPtr && isPtr->good())
// Bit tricky: avoid having all slaves open file since this involves
// reading it on master and broadcasting it. This fails if file > 2G.
// So instead only read on master
bool isCollated = false;
// Note: can test only world-master. Since even host-collated will have
// same file format type for all processors
if (UPstream::master(UPstream::worldComm))
{
auto& is = *isPtr;
const bool oldParRun = UPstream::parRun(false);
IOobject io(meshFile, meshPath, runTime);
io.readHeader(is);
IFstream is(fName);
if (is.good())
{
IOobject io(meshFile, meshPath, runTime);
io.readHeader(is);
if (decomposedBlockData::isCollatedType(io))
isCollated = decomposedBlockData::isCollatedType(io);
}
UPstream::parRun(oldParRun);
}
Pstream::broadcast(isCollated); //UPstream::worldComm
// Collect block-number in individual filenames (might differ
// on different processors)
if (isCollated)
{
const label nProcs = UPstream::nProcs(fileHandler().comm());
const label myProcNo = UPstream::myProcNo(fileHandler().comm());
// Collect file names on master of local communicator
const fileNameList fNames
(
Pstream::listGatherValues
(
fName,
fileHandler().comm(),
UPstream::msgType()
)
);
// Collect local block number
label myBlockNumber = -1;
{
fileName path, pDir, local;
procRangeType group;
@ -188,7 +224,6 @@ Foam::boolList Foam::haveMeshFile
numProcs
);
label myBlockNumber = 0;
if (proci == -1 && group.empty())
{
// 'processorsXXX' format so contains all ranks
@ -199,12 +234,53 @@ Foam::boolList Foam::haveMeshFile
{
// 'processorsXXX_n-m' format so check for the
// relative rank
myBlockNumber = UPstream::myProcNo(fileHandler().comm());
myBlockNumber = myProcNo;
}
// Check if block for the local rank is inside file
found = decomposedBlockData::hasBlock(is, myBlockNumber);
}
const labelList myBlockNumbers
(
Pstream::listGatherValues
(
myBlockNumber,
fileHandler().comm(),
UPstream::msgType()
)
);
// Determine for all whether the filename exists in the collated
// file.
boolList allFound(nProcs, false);
if (UPstream::master(fileHandler().comm()))
{
// Store nBlocks and index of file that was used for nBlocks
label nBlocks = -1;
label blockRanki = -1;
forAll(fNames, ranki)
{
if
(
blockRanki == -1
|| (fNames[ranki] != fNames[blockRanki])
)
{
blockRanki = ranki;
IFstream is(fNames[ranki]);
nBlocks = decomposedBlockData::getNumBlocks(is);
}
allFound[ranki] = (myBlockNumbers[ranki] < nBlocks);
}
}
found = Pstream::listScatterValues
(
allFound,
fileHandler().comm(),
UPstream::msgType()
);
}
}
#endif

View File

@ -184,7 +184,7 @@ Foam::parLagrangianDistributor::distributeLagrangianPositions
labelListList sendMap;
// Transfer buffers
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
PstreamBuffers pBufs;
{
// List of lists of particles to be transferred for all of the

View File

@ -102,6 +102,7 @@ Usage
#include "faMeshSubset.H"
#include "faMeshTools.H"
#include "faMeshDistributor.H"
#include "faMeshesRegistry.H"
#include "parFaFieldDistributorCache.H"
#include "redistributeLagrangian.H"
@ -906,12 +907,26 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
}
// If faMeshesRegistry exists, it is also owned by the polyMesh and will
// be destroyed by clearGeom() in fvMeshDistribute::distribute()
//
// Rescue faMeshesRegistry from destruction by temporarily moving
// it to be locally owned.
std::unique_ptr<faMeshesRegistry> faMeshesRegistry_saved
(
faMeshesRegistry::Release(mesh)
);
// Mesh distribution engine
fvMeshDistribute distributor(mesh);
// Do all the distribution of mesh and fields
autoPtr<mapDistributePolyMesh> distMap = distributor.distribute(decomp);
// Restore ownership onto the polyMesh
faMeshesRegistry::Store(std::move(faMeshesRegistry_saved));
// Print some statistics
InfoOrPout<< "After distribution:" << endl;
printMeshData(mesh);
@ -1598,7 +1613,8 @@ int main(int argc, char *argv[])
);
const fileName areaMeshSubDir
(
polyMesh::regionName(regionName) / faMesh::meshSubDir
// Assume single-region area mesh
faMesh::meshDir(regionName, word::null)
);
InfoOrPout
@ -2501,7 +2517,8 @@ int main(int argc, char *argv[])
);
const fileName areaMeshSubDir
(
polyMesh::regionName(regionName) / faMesh::meshSubDir
// Assume single-region area mesh
faMesh::meshDir(regionName, word::null)
);
InfoOrPout

View File

@ -21,29 +21,38 @@ Requires
// Initially all possible objects that are available at the final time
List<wordHashSet> availableRegionObjectNames(meshes.size());
List<wordHashSet> availableFaRegionObjectNames(meshes.size());
forAll(meshes, regioni)
{
const auto& mesh = meshes[regioni];
IOobjectList objects(0);
IOobjectList objects;
IOobjectList faObjects;
if (doConvertFields && !timeDirs.empty())
{
// List of volume mesh objects for this instance
objects = IOobjectList(mesh, timeDirs.back().name());
if (fieldSelector && !fieldSelector().empty())
{
objects.filterObjects(fieldSelector());
}
// List of area mesh objects (assuming single region)
faObjects = IOobjectList
(
mesh.time(),
timeDirs.back().name(),
faMesh::dbDir(mesh, word::null),
IOobjectOption::NO_REGISTER
);
if (fieldSelector && !fieldSelector().empty())
{
objects.filterObjects(fieldSelector());
faObjects.filterObjects(fieldSelector());
}
// Remove "*_0" restart fields
objects.prune_0();
faObjects.prune_0();
if (!doPointValues)
{
@ -59,12 +68,38 @@ forAll(meshes, regioni)
}
}
wordList objectNames(objects.sortedNames());
// Volume fields
if (!objects.empty())
{
wordList objectNames(objects.sortedNames());
// Check availability for all times...
checkData(mesh, timeDirs, objectNames);
// Check availability for all times...
checkData
(
mesh.thisDb(),
timeDirs,
objectNames
);
availableRegionObjectNames[regioni] = objectNames;
availableRegionObjectNames[regioni] = objectNames;
}
// Area fields
if (!faObjects.empty())
{
wordList objectNames(faObjects.sortedNames());
// Check availability for all times... (assuming single region)
checkData
(
mesh.time(),
timeDirs,
objectNames,
faMesh::dbDir(mesh, word::null)
);
availableFaRegionObjectNames[regioni] = objectNames;
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -14,6 +14,8 @@ Description
Code chunk for converting area fields
included by foamToEnsight.
Possible objects to convert are given in faObjects
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -23,7 +25,7 @@ if (doFiniteArea && ensFaCasePtr && ensFaMeshPtr)
{
Info<< " area field (";
writeAllAreaFields(*ensFaCasePtr, *ensFaMeshPtr, objects);
writeAllAreaFields(*ensFaCasePtr, *ensFaMeshPtr, faObjects);
Info<< " )" << nl;
}

View File

@ -577,6 +577,20 @@ int main(int argc, char *argv[])
// Volume, internal, point fields
#include "convertVolumeFields.H"
// The finite-area objects at this time
IOobjectList faObjects;
if (ensFaMeshPtr)
{
faObjects =
IOobjectList(ensFaMeshPtr->mesh(), runTime.timeName());
faObjects.filterObjects
(
availableFaRegionObjectNames[regioni]
);
}
// The finiteArea fields
#include "convertAreaFields.H"

View File

@ -55,7 +55,7 @@ label timeIndex = 0;
else
{
goodTimeIndex = false;
Info<< "skip ... missing entry " << io.objectPath() << endl;
Info<< "skip ... missing file: " << io.objectRelPath() << endl;
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,9 +32,10 @@ License
Foam::label Foam::checkData
(
const fvMesh& mesh,
const objectRegistry& obr,
const instantList& timeDirs,
wordList& objectNames
wordList& objectNames,
const fileName& local
)
{
// Assume prune_0() was used prior to calling this
@ -43,6 +44,9 @@ Foam::label Foam::checkData
for (const word& fieldName : objectNames)
{
// // If prune_0() not previously used...
// if (objectNames.ends_with("_0")) continue;
bool good = false;
for (const instant& inst : timeDirs)
@ -52,7 +56,8 @@ Foam::label Foam::checkData
(
fieldName,
inst.name(),
mesh,
local,
obr,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER

View File

@ -164,9 +164,10 @@ tmp<VolumeField<Type>> makeZeroGradientField
// ignore fields that are not available for all time-steps
label checkData
(
const fvMesh& mesh,
const objectRegistry& obr,
const instantList& timeDirs,
wordList& objectNames
wordList& objectNames,
const fileName& local = fileName::null
);

View File

@ -29,7 +29,7 @@ if (doFiniteArea)
autoPtr<faMesh> faMeshPtr;
const label nAreaFields =
objects.count(stringListOps::foundOp<word>(fieldTypes::area));
faObjects.count(stringListOps::foundOp<word>(fieldTypes::area));
if (nAreaFields || withMeshIds)
{
@ -40,7 +40,7 @@ if (doFiniteArea)
{
const faMesh& areaMesh = faMeshPtr();
reportFields::area(Info, objects);
reportFields::area(Info, faObjects);
const auto& pp = faMeshPtr->patch();
@ -97,7 +97,7 @@ if (doFiniteArea)
(
writer,
areaMesh,
objects,
faObjects,
true // syncPar
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -141,7 +141,7 @@ Note
#include "pointSet.H"
#include "HashOps.H"
#include "regionProperties.H"
#include "stringListOps.H"
#include "stringListOps.H" // For stringListOps::findMatching()
#include "Cloud.H"
#include "readFields.H"
@ -780,21 +780,34 @@ int main(int argc, char *argv[])
}
}
IOobjectList objects(0);
IOobjectList objects;
IOobjectList faObjects;
if (doConvertFields)
{
// List of objects for this time
// List of volume mesh objects for this instance
objects =
IOobjectList(meshProxy.baseMesh(), runTime.timeName());
// List of area mesh objects (assuming single region)
faObjects =
IOobjectList
(
runTime,
runTime.timeName(),
faMesh::dbDir(meshProxy.baseMesh(), word::null),
IOobjectOption::NO_REGISTER
);
if (fieldSelector && !fieldSelector().empty())
{
objects.filterObjects(fieldSelector());
faObjects.filterObjects(fieldSelector());
}
// Remove "*_0" restart fields
objects.prune_0();
faObjects.prune_0();
if (!doPointValues)
{

View File

@ -80,7 +80,6 @@ Usage
#include "IOobjectList.H"
#include "IOPtrList.H"
#include "volFields.H"
#include "stringListOps.H"
#include "timeSelector.H"
using namespace Foam;
@ -189,7 +188,7 @@ labelList findMatches
const HashTable<wordList>& shortcuts,
const wordList& shortcutNames,
const wordList& thisKeys,
const keyType& key
const wordRe& key
)
{
labelList matches;
@ -197,20 +196,20 @@ labelList findMatches
if (key.isPattern())
{
// Wildcard match
matches = findStrings(key, thisKeys);
matches = wordRes::matching(key, thisKeys);
}
else if (shortcuts.size())
{
// See if patchGroups expand to valid thisKeys
labelList indices = findStrings(key, shortcutNames);
labelList indices = wordRes::matching(key, shortcutNames);
for (const label idx : indices)
{
const word& name = shortcutNames[idx];
const wordList& keys = shortcuts[name];
forAll(keys, j)
for (const word& k : keys)
{
const label index = thisKeys.find(keys[j]);
const label index = thisKeys.find(k);
if (index != -1)
{
matches.append(index);

View File

@ -48,7 +48,7 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
if
(
commsType == UPstream::commsTypes::blocking
commsType == UPstream::commsTypes::buffered
|| commsType == UPstream::commsTypes::nonBlocking
)
{

View File

@ -51,6 +51,7 @@ Description
#include "emptyPolyPatch.H"
#include "processorPolyPatch.H"
#include "ListListOps.H"
#include "stringListOps.H" // For stringListOps::findMatching()
#include "indirectPrimitivePatch.H"
#include "globalMeshData.H"
#include "globalIndex.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -294,7 +294,7 @@ bool Foam::searchableSurfaceModifiers::cut::modify
// Find the surfaces to cut with
for (const wordRe& cutterName : cutterNames_)
{
labelList geomIDs = findStrings(cutterName, geometry_.names());
labelList geomIDs = wordRes::matching(cutterName, geometry_.names());
for (const label geomI : geomIDs)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -130,9 +130,14 @@ int main(int argc, char *argv[])
for (const entry& e : regionsDict)
{
const keyType& regionName = e.keyword();
const wordRe regionName(e.keyword());
const dictionary& regionDict = e.dict();
labelList regionIDs
(
wordRes::matching(regionName, surf.regions())
);
autoPtr<searchableSurfaceModifier> modifier
(
searchableSurfaceModifier::New
@ -143,9 +148,6 @@ int main(int argc, char *argv[])
)
);
labelList regionIDs =
findStrings(regionName, surf.regions());
if (modifier().modify(regionIDs, surf))
{
changed = true;

View File

@ -56,7 +56,7 @@ Usage
#include "argList.H"
#include "MeshedSurfaces.H"
#include "stringListOps.H"
#include "stringListOps.H" // For stringListOps::findMatching()
#include "geometricSurfacePatch.H"
using namespace Foam;

322
bin/foamUpgradeFiniteArea Executable file
View File

@ -0,0 +1,322 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2023-2024 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamUpgradeFiniteArea
#
# Description
# Relocate finite-area files to new sub-directory locations
#
#------------------------------------------------------------------------------
printHelp() {
cat <<USAGE
Usage: ${0##*/} [OPTION]
options:
-case=DIR Specify starting directory, default is cwd
-dry-run | -n Test without performing actions
-verbose | -v Additional verbosity
-force (currently ignored)
-link-back Link back from new finite-area/ to old locations
-no-mesh Do not move system/faMeshDefinition
-git Use 'git mv' when making changes
-help Print help and exit
Relocate finite-area files to new sub-directory locations
Equivalent options:
| -case=DIR | -case DIR |
USAGE
exit 0 # A clean exit
}
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
#------------------------------------------------------------------------------
# Parse options
unset caseDir optDryRun optGit optVerbose optLink optMeshDef hadError
while [ "$#" -gt 0 ]
do
case "$1" in
(- | --)
shift
break # Stop option parsing
;;
(-h | -help*) printHelp ;;
(-n | -dry-run) optDryRun="(dry-run) " ;;
(-v | -verbose) optVerbose=true ;;
(-f | -force) echo "Ignored option: ${1%%=*}" 1>&2 ;;
(-link-back) optLink=back ;;
# (-link-only) optLink=forward ;;
(-no-mesh) optMeshDef=false ;;
(-git) optGit=true ;;
(-case=*)
caseDir="${1#*=}"
;;
(-case)
caseDir="$2"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
shift
;;
(-*) die "unknown option: $1" ;;
(*) die "unknown argument: $1" ;;
esac
shift
done
if [ -n "$caseDir" ]
then
cd "$caseDir" 2>/dev/null || {
echo "${0##*/}: No such directory $caseDir" 1>&2
exit 2
}
fi
#------------------------------------------------------------------------------
# Proper umask
umask 022
# The commands
copy_cmd="cp -a${optVerbose:+ -v}"
move_cmd="mv${optVerbose:+ -v}"
link_cmd="ln -sf${optVerbose:+ -v}"
mkdir_cmd="mkdir -p"
if [ -n "$optDryRun" ]
then
if [ -n "$optVerbose" ]
then
copy_cmd="echo cp -a"
move_cmd="echo mv"
link_cmd="echo ln -sf"
mkdir_cmd="echo mkdir -p"
else
copy_cmd=true
move_cmd=true
link_cmd=true
mkdir_cmd=true
fi
elif [ -n "$optGit" ]
then
move_cmd="git mv"
link_cmd="echo no symlink for git:"
fi
regionDir="finite-area"
#------------------------------------------------------------------------------
# Various script parts
#
# awk : scan file for FoamFile { ... class NAME; }
read -d '' getClass_awk << 'AWK_CONTENT'
BEGIN { state = 0 } # 0=begin, 1=header, 2=done
/FoamFile/ { if (!state) { state = 1; next; } exit; }
# FoamFile begin contents
/\{/ { if (state == 1) state = 2; next; }
# FoamFile end contents
/\}/ { if (state == 2) exit; next; }
/^[ ]*class[ ]/ {
if (state == 2)
{
sub("^[ ]*class[ ]+", "")
sub("[ ;]*$", "")
print
exit
}
next
}
AWK_CONTENT
# Check for FoamFile and return extracted 'class'
getFoamFile_class()
{
local file="$1"
local class
if grep -q FoamFile "$file" 2>/dev/null
then
# class="$(foamDictionary -disableFunctionEntries -entry FoamFile/class -value "$file" 2> stderr)"
class="$(awk -- "$getClass_awk" "$file")"
fi
echo "$class"
}
# Check if class corresponds to an finite-area field
# eg, areaScalarField, ... edgeVectorField
isAreaFieldClass()
{
case "$1" in
(area*Field | edge*Field) return 0 ;;
esac
return 1
}
#------------------------------------------------------------------------------
#Debug# getFoamFile_class "system/faSchemes"
#------------------------------------------------------------------------------
# Link back from the local finite-area/ directory to the current directory
# variables
# - regionDir = "finite-area"
#
performLinkBack()
{
local file
if [ -d "$regionDir" ]
then
find "$regionDir" -maxdepth 1 -type f 2>/dev/null | while read file
do
file="${file#*/}"
if [ -f "$regionDir/$file" ] && [ ! -f "$file" ]
then
echo "${optDryRun} ln -s $regionDir/$file $file" 1>&2
$link_cmd "$regionDir/$file" "$file"
fi
done
fi
}
# Move from current directory to local finite-area/ directory
# variables
# - regionDir = "finite-area"
#
performMove()
{
local file="$1"
if [ -f "$regionDir/$file" ]
then
echo "${optDryRun} already: $regionDir/$file" 1>&2
elif [ -f "$file" ]
then
$mkdir_cmd "$regionDir"
echo "${optDryRun} mv $file -> $regionDir/" 1>&2
$move_cmd "$file" "$regionDir/$file"
elif [ -n "$file" ]
then
echo "${optDryRun} no $file" 1>&2
fi
}
#------------------------------------------------------------------------------
# system
# ----
if [ -d system ]
then
(
cd system || exit
currDir="system"
echo "${optDryRun}Examining files in $currDir/" 1>&2
performMove faSchemes
performMove faSolution
if [ "$optMeshDef" = false ]
then
echo "${optDryRun} ignore: faMeshDefinition" 1>&2
else
performMove faMeshDefinition
fi
if [ -d "$regionDir" ] && [ "$optLink" = back ]
then
performLinkBack
fi
)
else
echo "${optDryRun}No system/ directory..." 1>&2
fi
#------------------------------------------------------------------------------
# time dirs (initial conditions)
# ----
for timeDir in 0 0.orig
do
if [ -d "$timeDir" ]
then
(
cd "$timeDir" || exit
currDir="$timeDir"
echo "${optDryRun}Examining $currDir/" 1>&2
find . -maxdepth 1 -type f | while read file
do
file="${file#*/}"
case "$file" in
(*.gz)
echo "${optDryRun} ignoring compressed file: $file" 1>&2
continue
;;
esac
className="$(getFoamFile_class "$file")"
if isAreaFieldClass "$className"
then
performMove "$file"
fi
done
if [ -d "$regionDir" ] && [ "$optLink" = back ]
then
performLinkBack
fi
)
else
echo "${optDryRun}No $timeDir/ directory..." 1>&2
fi
done
#------------------------------------------------------------------------------

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2015-2023 OpenCFD Ltd.
# Copyright (C) 2015-2024 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -501,9 +501,9 @@ cloneParallelCase()
}
# Overwrite 0/ with the contents of 0.orig/ if it exists.
# The -processor option to do the processor directories instead
#
# If 0.orig/ exists, copy (overwrite) into 0/ [ie, serial case]
# * -processor : copy into processor directories instead
# * -all : copy into serial and processor directories
restore0Dir()
{
if [ ! -d 0.orig ]
@ -513,35 +513,27 @@ restore0Dir()
fi
case "$1" in
-proc | -processor | -processors)
echo "Restore 0/ from 0.orig/ [processor directories]"
(-all | -proc | -processor*)
if [ "$1" = "-all" ]
then
echo "Restore 0/ from 0.orig/ [serial/processor dirs]" 1>&2
\rm -rf 0
\cp -r 0.orig 0 2>/dev/null
else
echo "Restore 0/ from 0.orig/ [processor dirs]" 1>&2
fi
\ls -d processor* | xargs -I {} \rm -rf ./{}/0
\ls -d processor* | xargs -I {} \cp -r 0.orig ./{}/0 > /dev/null 2>&1
# Remove '#include' directives from field dictionaries
# for collated format
if [ "$1" = "-processors" ]
then
(
echo "Filter #include directives in processors/0:"
\cd processors/0 2>/dev/null || exit 0
for file in $(grep -l "#include" * 2>/dev/null)
do
foamDictionary "$file" > "$file.$$." && mv "$file.$$." "$file"
echo " $file"
done | tr -d '\n'
echo
)
fi
;;
*)
echo "Restore 0/ from 0.orig/"
(*)
echo "Restore 0/ from 0.orig/" 1>&2
\rm -rf 0
\cp -r 0.orig 0 2>/dev/null
;;
esac
return 0
}

View File

@ -43,6 +43,10 @@ cellSet_doc
sets (c1 c2);
// or
set c1;
// or
zones (c1Zone c2Zone);
// or
zone c1Zone;
}
@ -62,6 +66,10 @@ cellSet_doc
sets (f0 f1);
// or
set f0; // Name of faceSet
// or
zones (f0Zone f1Zone);
// or
zone f0Zone;
//- selection option (mandatory)
option any; // cell with any face in faceSet
@ -127,6 +135,10 @@ cellSet_doc
sets (p0 p1);
// or
sets p0;
// or
zones (p0Zone p1Zone);
// or
zone p0Zone;
option any; // cell with any point in pointSet
//option edge; // cell with an edge with both points in pointSet
@ -254,6 +266,10 @@ faceSet_doc
sets (c0 c1);
// or
set c0; // Name of cellSet
// or
zones (c0Zone c1Zone);
// or
zone c0Zone;
option all; // All faces of cells
//option both; // Only faces with owner+neighbour in cellSet
@ -310,6 +326,10 @@ faceSet_doc
sets (p0 p1);
// or
set p0; // Name of pointSet
// or
zones (p0Zone p1Zone);
// or
zone p0Zone;
option any; // Faces using any point in pointSet
//option all // Faces with all points in pointSet
@ -399,6 +419,10 @@ pointSet_doc
sets (c1 c2);
// or
set c1;
// or
zones (c1Zone c2Zone);
// or
zone c1Zone;
option all; // all points of cell
}
@ -421,6 +445,10 @@ pointSet_doc
sets (f1 f2);
// or
set f1;
// or
zones (f1Zone f2Zone);
// or
zone f1Zone;
option all; // all points of face
}
@ -446,6 +474,10 @@ pointSet_doc
sets (p1 p2);
// or
set p1;
// or
zones (p1Zone p2Zone);
// or
zone p1Zone;
}

View File

@ -132,7 +132,7 @@ OptimisationSwitches
// MPI/Parallel settings
// =====================
// Default communication type (nonBlocking | scheduled | blocking);
// Default communication type (nonBlocking | scheduled | buffered)
commsType nonBlocking;
// Transfer double as float for processor boundaries. Mostly defunct.

View File

@ -83,8 +83,9 @@ See also
Foam::DynamicList
SourceFiles
PackedListI.H
PackedList.C
PackedListCore.C
PackedListI.H
PackedListIO.C
\*---------------------------------------------------------------------------*/
@ -92,11 +93,11 @@ SourceFiles
#ifndef Foam_PackedList_H
#define Foam_PackedList_H
#include "className.H"
#include "BitOps.H"
#include "labelList.H"
#include "IndirectListBase.H"
#include "InfoProxy.H"
#include "PackedListCore.H"
#include <type_traits>
@ -119,6 +120,23 @@ template<unsigned Width>
Ostream& operator<<(Ostream& os, const InfoProxy<PackedList<Width>>& info);
/*---------------------------------------------------------------------------*\
Class Detail::PackedListCore Declaration
\*---------------------------------------------------------------------------*/
namespace Detail
{
//- Template-invariant parts for PackedList
struct PackedListCore
{
//- Define template name
ClassNameNoDebug("PackedList");
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class PackedList Declaration
\*---------------------------------------------------------------------------*/

View File

@ -25,7 +25,7 @@ License
\*---------------------------------------------------------------------------*/
#include "PackedListCore.H"
#include "PackedList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -1,69 +1 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 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/>.
Class
Foam::Detail::PackedListCore
Description
Implementation of template-invariant details for Foam::PackedList
SourceFiles
PackedListCore.C
\*---------------------------------------------------------------------------*/
#ifndef PackedListCore_H
#define PackedListCore_H
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::PackedListCore Declaration
\*---------------------------------------------------------------------------*/
//- Template-invariant parts for PackedList
struct PackedListCore
{
//- Define template name
ClassNameNoDebug("PackedList");
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Detail
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
#warning File removed - left for old dependency check only

View File

@ -115,7 +115,7 @@ void Foam::ParSortableList<Type>::checkAndSend
}
{
OPstream toProc(UPstream::commsTypes::blocking, destProci);
OPstream toProc(UPstream::commsTypes::buffered, destProci);
toProc << values << indices;
}
}
@ -309,7 +309,7 @@ void Foam::ParSortableList<Type>::sort()
Pout<< "Receiving from " << proci << endl;
}
IPstream fromProc(UPstream::commsTypes::blocking, proci);
IPstream fromProc(UPstream::commsTypes::buffered, proci);
fromProc >> recValues >> recIndices;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -228,6 +228,9 @@ public:
// Basic methods
//- Move insert IOobject into the list
inline bool add(std::unique_ptr<IOobject>&& objectPtr);
//- Move insert IOobject into the list
inline bool add(autoPtr<IOobject>& objectPtr);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2023 OpenCFD Ltd.
Copyright (C) 2022-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -109,6 +109,17 @@ inline Foam::IOobjectList::IOobjectList
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::IOobjectList::add(std::unique_ptr<IOobject>&& objectPtr)
{
if (objectPtr)
{
return insert(objectPtr->name(), std::move(objectPtr));
}
return false;
}
inline bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr)
{
if (objectPtr)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,8 +32,26 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T, class BaseType>
void Foam::CompactIOField<T, BaseType>::readFromStream(const bool readOnProc)
bool Foam::CompactIOField<T, BaseType>::readIOcontents(bool readOnProc)
{
if (readOpt() == IOobject::MUST_READ)
{
// Reading
}
else if (isReadOptional())
{
if (!headerOk())
{
readOnProc = false;
}
}
else
{
return false;
}
// Do reading
Istream& is = readStream(word::null, readOnProc);
if (readOnProc)
@ -58,23 +76,8 @@ void Foam::CompactIOField<T, BaseType>::readFromStream(const bool readOnProc)
<< exit(FatalIOError);
}
}
}
template<class T, class BaseType>
bool Foam::CompactIOField<T, BaseType>::readContents()
{
if
(
readOpt() == IOobject::MUST_READ
|| (isReadOptional() && headerOk())
)
{
readFromStream();
return true;
}
return false;
return true;
}
@ -85,7 +88,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField(const IOobject& io)
:
regIOobject(io)
{
readContents();
readIOcontents();
}
@ -98,15 +101,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
if (readOpt() == IOobject::MUST_READ)
{
readFromStream(readOnProc);
}
else if (isReadOptional())
{
const bool haveFile = headerOk();
readFromStream(readOnProc && haveFile);
}
readIOcontents(readOnProc);
}
@ -119,7 +114,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
readContents();
readIOcontents();
}
@ -132,7 +127,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
if (!readContents())
if (!readIOcontents())
{
Field<T>::resize(len);
}
@ -148,7 +143,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
if (!readContents())
if (!readIOcontents())
{
Field<T>::operator=(content);
}
@ -166,7 +161,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
{
Field<T>::transfer(content);
readContents();
readIOcontents();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020-2022 OpenCFD Ltd.
Copyright (C) 2020-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -76,13 +76,10 @@ class CompactIOField
{
// Private Member Functions
//- Read according to header type, with optional 'on-proc' value
void readFromStream(const bool readOnProc = true);
//- Read if IOobject flags set. Return true if read.
// Reads according to the header type
bool readContents();
//- Read if IOobject flags set and 'on-proc' is true.
//- Reads according to the header type.
// Return true if read (only accurate when readOnProc == true).
bool readIOcontents(bool readOnProc = true);
public:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,34 +32,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T, class BaseType>
void Foam::CompactIOList<T, BaseType>::readFromStream()
{
Istream& is = readStream(word::null);
if (headerClassName() == IOList<T>::typeName)
{
is >> static_cast<List<T>&>(*this);
close();
}
else if (headerClassName() == typeName)
{
is >> *this;
close();
}
else
{
FatalIOErrorInFunction(is)
<< "unexpected class name " << headerClassName()
<< " expected " << typeName
<< " or " << IOList<T>::typeName << endl
<< " while reading object " << name()
<< exit(FatalIOError);
}
}
template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::readContents()
bool Foam::CompactIOList<T, BaseType>::readIOcontents()
{
if
(
@ -67,7 +40,28 @@ bool Foam::CompactIOList<T, BaseType>::readContents()
|| (isReadOptional() && headerOk())
)
{
readFromStream();
Istream& is = readStream(word::null);
if (headerClassName() == IOList<T>::typeName)
{
is >> static_cast<List<T>&>(*this);
close();
}
else if (headerClassName() == typeName)
{
is >> *this;
close();
}
else
{
FatalIOErrorInFunction(is)
<< "Unexpected class name " << headerClassName()
<< " expected " << typeName
<< " or " << IOList<T>::typeName << endl
<< " while reading object " << name()
<< exit(FatalIOError);
}
return true;
}
@ -78,12 +72,14 @@ bool Foam::CompactIOList<T, BaseType>::readContents()
template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::overflows() const
{
label size = 0;
forAll(*this, i)
const List<T>& lists = *this;
label total = 0;
for (const auto& sublist : lists)
{
const label oldSize = size;
size += this->operator[](i).size();
if (size < oldSize)
const label prev = total;
total += sublist.size();
if (total < prev)
{
return true;
}
@ -99,7 +95,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList(const IOobject& io)
:
regIOobject(io)
{
readContents();
readIOcontents();
}
@ -112,7 +108,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
:
regIOobject(io)
{
readContents();
readIOcontents();
}
@ -125,7 +121,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
:
regIOobject(io)
{
if (!readContents())
if (!readIOcontents())
{
List<T>::resize(len);
}
@ -141,7 +137,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
:
regIOobject(io)
{
if (!readContents())
if (!readIOcontents())
{
List<T>::operator=(content);
}
@ -159,7 +155,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
{
List<T>::transfer(content);
readContents();
readIOcontents();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,7 +43,6 @@ SourceFiles
#define Foam_CompactIOList_H
#include "IOList.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -76,12 +75,10 @@ class CompactIOList
{
// Private Member Functions
//- Read according to header type
void readFromStream();
//- Read if IOobject flags set. Return true if read.
// Reads according to the header type
bool readContents();
//- Reads according to the header type.
// Return true if read.
bool readIOcontents();
//- Has too many elements in it?
bool overflows() const;
@ -130,7 +127,7 @@ public:
const bool writeOnProc
) const;
virtual bool writeData(Ostream&) const;
virtual bool writeData(Ostream& os) const;
// Member Operators
@ -140,23 +137,6 @@ public:
//- Copy or move assignment of entries
using List<T>::operator=;
// IOstream operators
//- Read List from Istream, discarding contents of existing List.
friend Istream& operator>> <T, BaseType>
(
Istream&,
CompactIOList<T, BaseType>&
);
// Write List to Ostream.
friend Ostream& operator<< <T, BaseType>
(
Ostream&,
const CompactIOList<T, BaseType>&
);
};

View File

@ -91,14 +91,14 @@ public:
// Member Functions
//- Is object global
//- This object is global
virtual bool global() const
{
return true;
}
//- Return complete path + object name if the file exists
// either in the case/processor or case otherwise null
//- either in the case/processor or case otherwise null
virtual fileName filePath() const
{
return globalFilePath(type());

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,8 +31,26 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::IOField<Type>::readFromStream(const bool readOnProc)
bool Foam::IOField<Type>::readIOcontents(bool readOnProc)
{
if (isReadRequired())
{
// Reading
}
else if (isReadOptional())
{
if (!headerOk())
{
readOnProc = false;
}
}
else
{
return false;
}
// Do reading
Istream& is = readStream(typeName, readOnProc);
if (readOnProc)
@ -40,19 +58,7 @@ void Foam::IOField<Type>::readFromStream(const bool readOnProc)
is >> *this;
}
close();
}
template<class Type>
bool Foam::IOField<Type>::readContents()
{
if (isReadRequired() || (isReadOptional() && headerOk()))
{
readFromStream();
return true;
}
return false;
return true;
}
@ -66,7 +72,7 @@ Foam::IOField<Type>::IOField(const IOobject& io)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
readContents();
readIOcontents();
}
@ -78,15 +84,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const bool readOnProc)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
if (isReadRequired())
{
readFromStream(readOnProc);
}
else if (isReadOptional())
{
const bool haveFile = headerOk();
readFromStream(readOnProc && haveFile);
}
readIOcontents(readOnProc);
}
@ -98,7 +96,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, Foam::zero)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
readContents();
readIOcontents();
}
@ -110,7 +108,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const label len)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
if (!readContents())
if (!readIOcontents())
{
Field<Type>::resize(len);
}
@ -125,7 +123,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const UList<Type>& content)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
if (!readContents())
if (!readIOcontents())
{
Field<Type>::operator=(content);
}
@ -142,7 +140,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, Field<Type>&& content)
Field<Type>::transfer(content);
readContents();
readIOcontents();
}
@ -158,7 +156,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const tmp<Field<Type>>& tfld)
Field<Type>::transfer(tfld.ref());
}
if (!readContents() && !reuse)
if (!readIOcontents() && !reuse)
{
Field<Type>::operator=(tfld());
}
@ -185,7 +183,7 @@ template<class Type>
Foam::Field<Type> Foam::IOField<Type>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,11 +58,9 @@ class IOField
{
// Private Member Functions
//- Read with optional 'on-proc' value
void readFromStream(const bool readOnProc = true);
//- Read if IOobject flags set. Return true if read.
bool readContents();
//- Read if IOobject flags set and 'on-proc' is true.
// Return true if read (only accurate when readOnProc == true).
bool readIOcontents(bool readOnProc = true);
public:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
bool Foam::IOList<T>::readContents()
bool Foam::IOList<T>::readIOcontents()
{
if (isReadRequired() || (isReadOptional() && headerOk()))
{
@ -54,7 +54,7 @@ Foam::IOList<T>::IOList(const IOobject& io)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>();
readContents();
readIOcontents();
}
@ -66,7 +66,7 @@ Foam::IOList<T>::IOList(const IOobject& io, Foam::zero)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>();
readContents();
readIOcontents();
}
@ -78,7 +78,7 @@ Foam::IOList<T>::IOList(const IOobject& io, const label len)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>();
if (!readContents())
if (!readIOcontents())
{
List<T>::resize(len);
}
@ -93,7 +93,7 @@ Foam::IOList<T>::IOList(const IOobject& io, const UList<T>& content)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>();
if (!readContents())
if (!readIOcontents())
{
List<T>::operator=(content);
}
@ -110,7 +110,7 @@ Foam::IOList<T>::IOList(const IOobject& io, List<T>&& content)
List<T>::transfer(content);
readContents();
readIOcontents();
}
@ -132,7 +132,7 @@ template<class T>
Foam::List<T> Foam::IOList<T>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,7 +59,7 @@ class IOList
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readContents();
bool readIOcontents();
public:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
bool Foam::IOMap<T>::readContents()
bool Foam::IOMap<T>::readIOcontents()
{
if (isReadRequired() || (isReadOptional() && headerOk()))
{
@ -55,7 +55,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io)
:
regIOobject(io)
{
readContents();
readIOcontents();
}
@ -64,7 +64,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, const label size)
:
regIOobject(io)
{
if (!readContents())
if (!readIOcontents())
{
Map<T>::resize(size);
}
@ -76,7 +76,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& content)
:
regIOobject(io)
{
if (!readContents())
if (!readIOcontents())
{
Map<T>::operator=(content);
}
@ -90,7 +90,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, Map<T>&& content)
{
Map<T>::transfer(content);
readContents();
readIOcontents();
}
@ -100,7 +100,7 @@ template<class T>
Foam::Map<T> Foam::IOMap<T>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,7 +60,7 @@ class IOMap
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readContents();
bool readIOcontents();
public:

View File

@ -122,7 +122,7 @@ template<class T>
Foam::PtrList<T> Foam::IOPtrList<T>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -96,7 +96,7 @@ Foam::IOdictionary::IOdictionary
Foam::dictionary Foam::IOdictionary::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -93,7 +93,7 @@ Foam::localIOdictionary::localIOdictionary
Foam::dictionary Foam::localIOdictionary::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -97,7 +97,7 @@ Foam::label Foam::unwatchedIOdictionary::addWatch(const fileName& f)
{
label index = -1;
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
if (readOpt() == IOobjectOption::READ_MODIFIED)
{
index = files_.find(f);
@ -113,7 +113,7 @@ Foam::label Foam::unwatchedIOdictionary::addWatch(const fileName& f)
void Foam::unwatchedIOdictionary::addWatch()
{
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
if (readOpt() == IOobjectOption::READ_MODIFIED)
{
fileName f = filePath();
if (f.empty())

View File

@ -545,7 +545,7 @@ bool Foam::decomposedBlockData::readBlocks
}
else
{
PstreamBuffers pBufs(comm, UPstream::commsTypes::nonBlocking);
PstreamBuffers pBufs(comm);
if (UPstream::master(comm))
{
@ -667,7 +667,7 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
}
else
{
PstreamBuffers pBufs(comm, UPstream::commsTypes::nonBlocking);
PstreamBuffers pBufs(comm);
if (UPstream::master(comm))
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::rawIOField<Type>::readContents
void Foam::rawIOField<Type>::readIOcontents
(
Istream& is,
IOobjectOption::readOption readAverage
@ -65,7 +65,7 @@ void Foam::rawIOField<Type>::readContents
template<class Type>
bool Foam::rawIOField<Type>::readContents
bool Foam::rawIOField<Type>::readIOcontents
(
IOobjectOption::readOption readAverage
)
@ -111,7 +111,7 @@ bool Foam::rawIOField<Type>::readContents
if (is.good())
{
readContents(is, readAverage);
readIOcontents(is, readAverage);
close();
}
}
@ -122,7 +122,7 @@ bool Foam::rawIOField<Type>::readContents
if (isPtr && isPtr->good())
{
readContents(*isPtr, readAverage);
readIOcontents(*isPtr, readAverage);
}
else
{
@ -165,7 +165,7 @@ Foam::rawIOField<Type>::rawIOField
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<rawIOField<Type>>();
readContents(readAverage);
readIOcontents(readAverage);
}
@ -194,7 +194,7 @@ template<class Type>
Foam::Field<Type> Foam::rawIOField<Type>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -67,10 +67,10 @@ class rawIOField
// Private Member Functions
//- Read contents and average
void readContents(Istream&, IOobjectOption::readOption readAverage);
void readIOcontents(Istream&, IOobjectOption::readOption readAverage);
//- Read if IOobject flags set. Return true if read.
bool readContents(IOobjectOption::readOption readAverage);
bool readIOcontents(IOobjectOption::readOption readAverage);
public:

View File

@ -115,7 +115,7 @@ void Foam::masterOFstream::commit()
}
// Different files
PstreamBuffers pBufs(comm_, UPstream::commsTypes::nonBlocking);
PstreamBuffers pBufs(comm_);
if (!UPstream::master(comm_))
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2023 OpenCFD Ltd.
Copyright (C) 2022-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,7 +34,7 @@ License
Foam::UIPBstream::UIPBstream
(
const UPstream::commsTypes commsType,
const int fromProcNo,
const int rootProcNo,
DynamicList<char>& receiveBuf,
label& receiveBufPosition,
const int tag,
@ -45,11 +45,11 @@ Foam::UIPBstream::UIPBstream
:
UIPstreamBase
(
commsType,
fromProcNo,
commsType, // irrelevant
rootProcNo, // normally UPstream::masterNo()
receiveBuf,
receiveBufPosition,
tag,
tag, // irrelevant
comm,
clearAtEnd,
fmt
@ -62,7 +62,7 @@ Foam::UIPBstream::UIPBstream
Foam::IPBstream::IPBstream
(
const UPstream::commsTypes commsType,
const int fromProcNo,
const int rootProcNo,
const label bufSize,
const int tag,
const label comm,
@ -72,11 +72,11 @@ Foam::IPBstream::IPBstream
Pstream(commsType, bufSize),
UIPBstream
(
commsType,
fromProcNo,
commsType, // irrelevant
rootProcNo, // normally UPstream::masterNo()
Pstream::transferBuf_,
UIPstreamBase::storedRecvBufPos_, // Internal only
tag,
tag, // irrelevant
comm,
false, // Do not clear Pstream::transferBuf_ if at end
fmt
@ -86,7 +86,7 @@ Foam::IPBstream::IPBstream
Foam::IPBstream::IPBstream
(
const int fromProcNo,
const int rootProcNo,
const label comm,
IOstreamOption::streamFormat fmt
)
@ -94,7 +94,25 @@ Foam::IPBstream::IPBstream
IPBstream
(
UPstream::commsTypes::scheduled, // irrelevant
fromProcNo,
rootProcNo,
label(0), // bufSize
UPstream::msgType(), // irrelevant
comm,
fmt
)
{}
Foam::IPBstream::IPBstream
(
const label comm,
IOstreamOption::streamFormat fmt
)
:
IPBstream
(
UPstream::commsTypes::scheduled, // irrelevant
UPstream::masterNo(), // rootProcNo
label(0), // bufSize
UPstream::msgType(), // irrelevant
comm,

View File

@ -127,14 +127,40 @@ public:
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
//- Construct for broadcast root with optional communicator,
//- write format
explicit IPBstream
//- Construct for broadcast root and communicator,
//- with optional read format
IPBstream
(
const int rootProcNo, //!< normally UPstream::masterNo()
const label comm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
//- Construct with optional communicator and read format.
//- Uses UPstream::masterNo() root
explicit IPBstream
(
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
// Static Functions
//- Receive (from broadcast, root == UPstream::masterNo())
//- and deserialize a value.
//- Uses \c operator>> for de-serialization
template<class Type>
static void recv
(
Type& value,
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
)
{
IPBstream is(comm, fmt);
is >> value;
}
};

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2023 OpenCFD Ltd.
Copyright (C) 2022-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,7 +34,7 @@ License
Foam::UOPBstream::UOPBstream
(
const UPstream::commsTypes commsType,
const int toProcNo,
const int rootProcNo,
DynamicList<char>& sendBuf,
const int tag,
const label comm,
@ -42,14 +42,23 @@ Foam::UOPBstream::UOPBstream
IOstreamOption::streamFormat fmt
)
:
UOPstreamBase(commsType, toProcNo, sendBuf, tag, comm, sendAtDestruct, fmt)
UOPstreamBase
(
commsType, // irrelevant
rootProcNo, // normally UPstream::masterNo()
sendBuf,
tag, // irrelevant
comm,
sendAtDestruct,
fmt
)
{}
Foam::OPBstream::OPBstream
(
const UPstream::commsTypes commsType,
const int toProcNo,
const int rootProcNo,
const label bufSize,
const int tag,
const label comm,
@ -59,10 +68,10 @@ Foam::OPBstream::OPBstream
Pstream(commsType, bufSize),
UOPBstream
(
commsType,
toProcNo,
commsType, // irrelevant
rootProcNo, // normally UPstream::masterNo()
Pstream::transferBuf_,
tag,
tag, // irrelevant
comm,
true, // sendAtDestruct
fmt
@ -72,7 +81,7 @@ Foam::OPBstream::OPBstream
Foam::OPBstream::OPBstream
(
const int toProcNo,
const int rootProcNo,
const label comm,
IOstreamOption::streamFormat fmt
)
@ -80,7 +89,25 @@ Foam::OPBstream::OPBstream
OPBstream
(
UPstream::commsTypes::scheduled, // irrelevant
toProcNo,
rootProcNo,
label(0), // bufSize
UPstream::msgType(), // irrelevant
comm,
fmt
)
{}
Foam::OPBstream::OPBstream
(
const label comm,
IOstreamOption::streamFormat fmt
)
:
OPBstream
(
UPstream::commsTypes::scheduled, // irrelevant
UPstream::masterNo(), // rootProcNo
label(0), // bufSize
UPstream::msgType(), // irrelevant
comm,

View File

@ -144,14 +144,39 @@ public:
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
//- Construct for broadcast root with optional communicator,
//- write format
explicit OPBstream
//- Construct for broadcast root and communicator,
//- with optional write format
OPBstream
(
const int rootProcNo, //!< normally UPstream::masterNo()
const label comm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
//- Construct with optional communicator and write format.
//- Uses UPstream::masterNo() root
explicit OPBstream
(
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
// Static Functions
//- Serialize a value and broadcast (root == UPstream::masterNo()).
//- Uses \c operator<< for serialization
template<class Type>
static void send
(
const Type& value,
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
)
{
OPBstream os(comm, fmt);
os << value;
}
};

View File

@ -101,6 +101,12 @@ Foam::UOPstream::~UOPstream()
{
if (sendAtDestruct_)
{
// Note: sendAtDestruct_ and nonBlocking is a questionable combination
// since the transfer buffer will be destroyed before
// the non-blocking send completes!
//
// Could flag as an error, but not actually used anywhere.
if (!bufferIPCsend())
{
FatalErrorInFunction

View File

@ -41,20 +41,19 @@ void Foam::Pstream::broadcast(Type& value, const label comm)
(
reinterpret_cast<char*>(&value),
sizeof(Type),
comm,
UPstream::masterNo()
comm
);
}
else if (UPstream::is_parallel(comm))
{
if (UPstream::master(comm))
{
OPBstream os(UPstream::masterNo(), comm);
OPBstream os(comm);
os << value;
}
else // UPstream::is_subrank(comm)
{
IPBstream is(UPstream::masterNo(), comm);
IPBstream is(comm);
is >> value;
}
}
@ -68,12 +67,12 @@ void Foam::Pstream::broadcasts(const label comm, Type& arg1, Args&&... args)
{
if (UPstream::master(comm))
{
OPBstream os(UPstream::masterNo(), comm);
OPBstream os(comm);
Detail::outputLoop(os, arg1, std::forward<Args>(args)...);
}
else // UPstream::is_subrank(comm)
{
IPBstream is(UPstream::masterNo(), comm);
IPBstream is(comm);
Detail::inputLoop(is, arg1, std::forward<Args>(args)...);
}
}
@ -98,8 +97,7 @@ void Foam::Pstream::broadcastList(ListType& list, const label comm)
(
reinterpret_cast<char*>(&len),
sizeof(label),
comm,
UPstream::masterNo()
comm
);
if (UPstream::is_subrank(comm))
@ -113,8 +111,7 @@ void Foam::Pstream::broadcastList(ListType& list, const label comm)
(
list.data_bytes(),
list.size_bytes(),
comm,
UPstream::masterNo()
comm
);
}
}
@ -125,12 +122,12 @@ void Foam::Pstream::broadcastList(ListType& list, const label comm)
if (UPstream::master(comm))
{
OPBstream os(UPstream::masterNo(), comm);
OPBstream os(comm);
os << list;
}
else // UPstream::is_subrank(comm)
{
IPBstream is(UPstream::masterNo(), comm);
IPBstream is(comm);
is >> list;
}
}

View File

@ -32,13 +32,13 @@ Description
Use UOPstream to stream data into buffers, call finishedSends() to
notify that data is in buffers and then use IUPstream to get data out
of received buffers. Works with both blocking and non-blocking. Does
of received buffers. Works with both buffered and non-blocking. Does
not make much sense with scheduled since there you would not need these
explicit buffers.
Example usage:
\code
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
PstreamBuffers pBufs;
for (const int proci : UPstream::allProcs())
{
@ -51,7 +51,7 @@ Description
}
}
pBufs.finishedSends(); // no-op for blocking
pBufs.finishedSends(); // no-op for buffered
for (const int proci : UPstream::allProcs())
{
@ -68,7 +68,7 @@ Description
one-to-all and all-to-one communication patterns.
For example,
\code
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
PstreamBuffers pBufs;
if (UPstream::master())
{
@ -96,7 +96,7 @@ Description
For example,
\code
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
PstreamBuffers pBufs;
pBufs.initRegisterSend();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd.
Copyright (C) 2017-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -96,7 +96,7 @@ protected:
const int comm_;
//- The message size, read on bufferIPCrecv or set directly
int messageSize_;
label messageSize_;
//- Receive position in buffer data, if ony
//- If there is no external location for recvBufPos_
@ -279,8 +279,8 @@ public:
// Static Functions
//- Read buffer contents from given processor.
// \return the message size (bytes read)
static label read
// \return the message size (bytes read). May change in the future
static std::streamsize read
(
const UPstream::commsTypes commsType,
const int fromProcNo,
@ -293,8 +293,8 @@ public:
);
//- Read buffer contents (non-blocking) from given processor.
// \return the message size (bytes read)
inline static label read
// \return the message size (bytes read). May change in the future
inline static std::streamsize read
(
//! [out] request information
UPstream::Request& req,
@ -321,7 +321,7 @@ public:
// Only valid for contiguous data types.
// \return the message size (bytes read). May change in the future
template<class Type>
inline static label read
inline static std::streamsize read
(
const UPstream::commsTypes commsType,
const int fromProcNo,
@ -348,7 +348,7 @@ public:
// Only valid for contiguous data types.
// \return the message size (bytes read). May change in the future
template<class Type>
inline static label read
inline static std::streamsize read
(
const UPstream::commsTypes commsType,
const int fromProcNo,
@ -375,7 +375,7 @@ public:
// Only valid for contiguous data types.
// \return the message size (bytes read). May change in the future
template<class Type>
inline static label read
inline static std::streamsize read
(
//! [out] request information
UPstream::Request& req,
@ -401,7 +401,7 @@ public:
// Only valid for contiguous data types.
// \return the message size (bytes read). May change in the future
template<class Type>
inline static label read
inline static std::streamsize read
(
//! [out] request information
UPstream::Request& req,
@ -474,8 +474,8 @@ public:
// Static Functions
//- Wrapped version of UPstream::broadcast
// \return the message size (bytes read)
static label read
// \return the message size (bytes read). May change in the future
static std::streamsize read
(
const int rootProcNo, //!< normally UPstream::masterNo()
char* buf,

View File

@ -50,9 +50,11 @@ const Foam::Enum
>
Foam::UPstream::commsTypeNames
({
{ commsTypes::blocking, "blocking" }, // "buffered"
{ commsTypes::buffered, "buffered" }, // "buffered"
{ commsTypes::scheduled, "scheduled" },
{ commsTypes::nonBlocking, "nonBlocking" }, // "immediate"
// compatibility names
{ commsTypes::buffered, "blocking" },
});

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