Compare commits

..

30 Commits

Author SHA1 Message Date
d3a079b4da COMP: g++11: suppress optimisation. See #3024 2024-01-19 20:52:34 +01:00
177176c5ff BUG: particle: use correct celli. Fixes #1992
Was checking the old celli instead of the result of
re-finding the position. See also Foundation commit 50a965f8866683a81d79cbc7811af7333baf9d10.
2023-10-10 15:40:47 +01:00
53feaf2560 BUG: mapFields: incorrect patches. Fixes #2944. 2023-08-30 16:39:16 +02:00
d189f95c7d BUG: UPstream::shutdown misbehaves with external initialisation (fixes #2808)
- freeCommmunicatorComponents needs an additional bounds check.
  When MPI is initialized outside of OpenFOAM, there are no
  UPstream communicator equivalents
2023-06-20 09:33:13 +02:00
bc7053dbf9 Revert "BUG: Fixing ray dAve and omega for 1D and 2D cases"
This reverts commit 5848b0afd5.
2023-05-22 09:37:50 +01:00
b087bc52de BUG: VTK write pointSet fails in parallel (fixes #2773)
- de-referenced autoPtr with () instead of ref() will fail on
  non-master ranks.
2023-05-05 16:01:37 +02:00
69f2c34e5f COMP: code adjustments for gcc-13 (#2714) 2023-02-28 16:24:06 +01:00
4dda01f161 CONFIG: improve handling of empty/non-empty ThirdParty directory 2023-02-28 16:10:00 +01:00
a7e464a70a CONFIG: foamConfigurePaths support for sys-openmpi major version 2023-02-28 16:09:59 +01:00
f40d60aa78 CONFIG: accept module-prefix 'none' as equivalent to 'false' (ie, disabled) 2023-02-28 16:09:59 +01:00
12e7bba017 BUG: solidIsothermalReactionRate: redefine the latent energy (fixes #2646) 2022-11-30 10:17:12 +00:00
ee66a09a72 ENH: solidIsothermalReactionRate: new solid reaction rate model
STYLE: solidArrheniusReactionRate: modernise code
2022-11-29 14:39:26 +00:00
f1ac837448 ENH: makeSolidReaction: modify macros to allow new models 2022-11-28 11:43:12 +00:00
7dcab65ffd BUG: related to #1676 - avoid recalculating map multiple times on topo changes 2022-11-02 20:32:14 +00:00
ff8cdfa7de ENH: use local ref to map() to avoid excessive rebuilding during topo changes 2022-10-25 14:41:56 +01:00
da5048fd70 BUG: totalFlowRateAdvectiveDiffusive: missing autoMap. Fixes #2475 2022-09-28 16:41:32 +01:00
555d76bb7b BUG: Fixing pyrolysis region motion. 2022-09-10 10:01:33 +01:00
546e2c0243 BUG: incorrect order for output scaling (transformPoints, ...)
- the output write scaling should be applied *after* undoing the
  effects of the specified rotation centre. Fixes #2566

ENH: update option names for transformPoints and surfaceTransformPoints

- prefer  '-auto-centre' and '-centre', but also accept the previous
  options '-auto-origin' and '-origin' as aliases.

  Changing to '-centre' avoids possible confusion with
  coordinate system origin().
2022-08-18 13:35:09 +02:00
b4324b1297 COMP: missing std::array include (searchable sphere) 2022-06-27 10:05:31 +02:00
b12839ffc3 CONFIG: bump patch level 2022-06-23 09:51:24 +02:00
3f5c240cdb COMP: Gcc 11+ potential fix - see #2434 2022-06-23 09:51:24 +02:00
50420f755c COMP: references to temporaries
COMP: include <limits>
2022-06-23 09:51:24 +02:00
2d8870a878 COMP: gcc-12 buffer check bypasses xsputn (#2481, #2496)
- add overflow() method to the SHA1 streambuf. Previously could rely
  on xsputn for adding to sha1 content, but streams now check pptr()
  first to test for the buffering range and thus overflow() is needed.
2022-06-23 09:51:24 +02:00
8221721d44 BUG: sample/store surface field triggers dimension check (fixes #2361)
- when used for example with wallShearStress, the stress field is
  initially created as incompressible but later updated with the
  correct compressible/incompressible dimensions.

  If this field is sampled as a surface and stored on the registry
  the dimensions should be reset() and not '=' assigned, since that
  causes a dimension check which will obviously fail.
2022-02-11 14:35:06 +01:00
f4ccdec894 BUG: error with empty distributed roots specification (fixes #2196) 2021-09-08 10:21:02 +02:00
0f7277fd5e BUG: ParticleCollector - corrected and simplified parallel reductions. See #2184 2021-09-06 16:29:50 +02:00
2f5da5af4b BUG: Curle - added missing division by r. See #2169 2021-09-06 16:29:49 +02:00
e95f8b1a8d BUG: boundaryData output incorrect when no fields are sampled (fixes #2163)
- add "point data" or "face data" note to the boundaryData output
  for easier diagnositics in the future.
2021-07-20 17:04:02 +02:00
5d8e43e86e BUG: noise did not set num of output fields (VTK legacy) [fixes #2133] 2021-06-25 10:35:36 +02:00
f53c9dd6da BUG: liquidProperties - corrected read scalar (was label). See #2142 2021-06-25 10:33:37 +02:00
11790 changed files with 2936870 additions and 140501 deletions

View File

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

View File

@ -1,6 +1,6 @@
# Contributors to OpenFOAM
The following is a list of known contributors to OpenFOAM.
The following is an list of known contributors to OpenFOAM.
It is likely incomplete...
## Contributors (alphabetical by surname)
@ -24,7 +24,6 @@ It is likely incomplete...
- Hrvoje Jasak
- Alexander Kabat vel Job
- Thilo Knacke
- Shannon Leakey
- Tommaso Lucchini
- Graham Macpherson
- Alexey Matveichev
@ -51,7 +50,7 @@ It is likely incomplete...
- Norbert Weber
- Henry Weller
- Niklas Wikstrom
- Guanyang Xue
- Thorsten Zirwes
<!----------------------------------------------------------------------------->

View File

@ -3,9 +3,8 @@
Meta-information is generally for OpenFOAM internal use only.
The format, content and meaning may be changed at anytime without
prior notice.
If any of these are changed, these are some of places that will need
to be updated accordingly:
notice. If any of these are changed, these are some of places that
will need to be updated accordingly:
- bin/foamEtcFile
- bin/tools/foamConfigurePaths
@ -39,7 +38,7 @@ Format: `date +%y%m`
- 4-digit year-month (YYMM) integer corresponding to the major
release or in unusual cases an intermediate release.
Example, `2106` for the June-2021 release.
Example, `1712` for the Dec-2017 release.
#### patch
@ -79,9 +78,9 @@ the saved information needs synchronization. The command
### Notes
The saved information is split into two separate files.
The `api-info` file contains more permanent information,
whereas the `build-info` is more transient in nature.
The saved information is split into two separate files. The `api-info`
contains more permanent information, whereas the `build-info` is more
transient in nature.
----
2021-06-09
2020-06-23

View File

@ -1,2 +1,2 @@
api=2106
api=2012
patch=220610

View File

@ -11,7 +11,7 @@ individual and group contributors, integrations
[governance guided activities](https://www.openfoam.com/governance/).
## License
## Copyright
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
@ -27,11 +27,10 @@ may redistribute files.
OpenCFD Ltd grants use of its OpenFOAM trademark by Third Parties on a
licence basis. ESI Group and OpenFOAM Foundation Ltd are currently
permitted to use the Name and agreed Domain Name. For information on
trademark use, please refer to the
[trademark policy guidelines][link trademark].
trademark use, please refer to the [trademark policy guidelines](http://www.openfoam.com/legal/trademark-policy.php).
Please [contact OpenCFD](http://www.openfoam.com/contact) if you have
any questions about the use of the OpenFOAM trademark.
any questions on the use of the OpenFOAM trademark.
Violations of the Trademark are monitored, and will be duly prosecuted.
@ -40,9 +39,9 @@ Violations of the Trademark are monitored, and will be duly prosecuted.
If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
For example, for the OpenFOAM-v2106 version:
For example, for the OpenFOAM-v1912 version:
```
source /installation/path/OpenFOAM-v2106/etc/bashrc
source /installation/path/OpenFOAM-v1912/etc/bashrc
```
## Compiling OpenFOAM
@ -56,11 +55,6 @@ guides:
| [ThirdParty][repo third] | [readme][link third-readme] | [system requirements][link third-require] | [build][link third-build] |
If you need to modify the versions or locations of ThirdParty
software, please read how the
[OpenFOAM configuration][wiki-config] is structured.
## How do I know which version I am currently using?
The value of the `$WM_PROJECT_DIR` or even `$WM_PROJECT_VERSION` are
@ -69,19 +63,19 @@ not guaranteed to have any correspondence to the OpenFOAM release
information is embedded into each application. For example, as
displayed from `blockMesh -help`:
```
Using: OpenFOAM-com (2012) - visit www.openfoam.com
Build: b830beb5ea-20210429 (patch=210414)
Using: OpenFOAM-v1812.local (1812) - visit www.openfoam.com
Build: 65d6551ff7-20190530 (patch=190531)
Arch: LSB;label=32;scalar=64
```
This output contains all of the more interesting information that we need:
| item | value |
|-----------------------|---------------|
| version | com (eg, local development branch) |
| api | 2012 |
| commit | b830beb5ea |
| author date | 20210429 |
| patch-level | (20)210414 |
| version | v1812.local |
| api | 1812 |
| commit | 65d6551ff7 |
| author date | 20190530 |
| patch-level | (20)190531 |
| label/scalar size | 32/64 bits |
The Arch information may also include the `solveScalar` size
@ -96,19 +90,19 @@ when OpenFOAM has not yet been compiled:
```
$ wmake -build-info
make
api = 2012
patch = 210414
api = 1812
patch = 190531
branch = master
build = 308af39136-20210426
build = 65d6551ff7-20190530
```
Similar information is available with `foamEtcFile`, using the
`-show-api` or `-show-patch` options. For example,
```
$ foamEtcFile -show-api
2012
1812
$ foamEtcFile -show-patch
210414
190531
```
This output will generally be the easiest to parse for scripts.
The `$FOAM_API` convenience environment variable may not reflect the
@ -127,8 +121,8 @@ These 3rd-party sources are normally located in a directory parallel
to the OpenFOAM directory. For example,
```
/path/parent
|-- OpenFOAM-v2106
\-- ThirdParty-v2106
|-- OpenFOAM-v1912
\-- ThirdParty-v1912
```
There are, however, many cases where this simple convention is inadequate:
@ -136,7 +130,7 @@ There are, however, many cases where this simple convention is inadequate:
operating system or cluster installation provides it)
* When we have changed the OpenFOAM directory name to some arbitrary
directory name, e.g. openfoam-sandbox2106, etc..
directory name, e.g. openfoam-sandbox1912, etc..
* When we would like any additional 3rd party software to be located
inside of the OpenFOAM directory to ensure that the installation is
@ -156,14 +150,17 @@ when locating the ThirdParty directory with the following precedence:
2. PREFIX/ThirdParty-VERSION
* this corresponds to the traditional approach
3. PREFIX/ThirdParty-vAPI
* allows for an updated value of VERSION, *eg*, `v2106-myCustom`,
* allows for an updated value of VERSION, *eg*, `v1912-myCustom`,
without requiring a renamed ThirdParty. The API value would still
be `2106` and the original `ThirdParty-v2106/` would be found.
be `1912` and the original `ThirdParty-v1912/` would be found.
4. PREFIX/ThirdParty-API
* same as the previous example, but using an unadorned API value.
* this is the same as the previous example, but using an unadorned
API value. This also makes sense if the chosen version name also
uses the unadorned API value in its naming, *eg*,
`1912-patch190131`, `1912.19W03`
5. PREFIX/ThirdParty-common
* permits maximum reuse for various versions, for experienced
users who are aware of potential version incompatibilities
* permits maximum reuse for various versions, for experienced user
who are aware of potential version incompatibilities
If none of these directories are found to be suitable, it reverts to
using PROJECT/ThirdParty as a dummy location (even if the directory
@ -187,21 +184,18 @@ ThirdParty directory will contain either an `Allwmake` file or a
<!-- OpenFOAM -->
[link trademark]: https://www.openfoam.com/opencfd-limited-trade-mark-policy
[repo openfoam]: https://develop.openfoam.com/Development/openfoam/
[repo third]: https://develop.openfoam.com/Development/ThirdParty-common/
[link openfoam-readme]: https://develop.openfoam.com/Development/openfoam/blob/develop/README.md
[link openfoam-issues]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/BuildIssues.md
[link openfoam-config]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Config.md
[link openfoam-build]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Build.md
[link openfoam-require]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Requirements.md
[link third-readme]: https://develop.openfoam.com/Development/ThirdParty-common/blob/develop/README.md
[link third-build]: https://develop.openfoam.com/Development/ThirdParty-common/blob/develop/BUILD.md
[link third-require]: https://develop.openfoam.com/Development/ThirdParty-common/blob/develop/Requirements.md
[wiki-config]: https://develop.openfoam.com/Development/openfoam/-/wikis/configuring
## Useful Links
@ -209,8 +203,8 @@ ThirdParty directory will contain either an `Allwmake` file or a
- [Documentation](http://www.openfoam.com/documentation)
- [Reporting bugs/issues/feature requests](http://www.openfoam.com/code/bug-reporting.php)
- [Issue tracker](https://develop.openfoam.com/Development/openfoam/-/issues)
- [Code wiki](https://develop.openfoam.com/Development/openfoam/-/wikis/) and [General wiki](http://wiki.openfoam.com/)
- [Governance](http://www.openfoam.com/governance/), [Governance Projects](https://www.openfoam.com/governance/projects)
- [Code wiki](https://develop.openfoam.com/Development/openfoam/-/wikis/) and [general wiki](http://wiki.openfoam.com/)
- [Community](http://www.openfoam.com/community/), [Governance](http://www.openfoam.com/governance/)
- [Contacting OpenCFD](http://www.openfoam.com/contact/)
Copyright 2016-2021 OpenCFD Ltd
Copyright 2016-2020 OpenCFD Ltd

View File

@ -160,7 +160,7 @@ int main(int argc, char *argv[])
runTime.printExecutionTime(Info);
}
Info<< "End\n";
Info<< "\n end\n";
return 0;
}

View File

@ -207,7 +207,7 @@ int main(int argc, char *argv[])
runTime.printExecutionTime(Info);
}
Info<< "End\n";
Info<< "\n end\n";
return 0;
}

View File

@ -6,13 +6,11 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lfluidThermophysicalModels \
-lreactionThermophysicalModels \
-lchemistryModel \
-lthermophysicalProperties
-lchemistryModel

View File

@ -7,7 +7,7 @@
(
IOobject
(
polyMesh::defaultRegion,
dynamicFvMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ

View File

@ -44,7 +44,11 @@ SourceFiles
namespace Foam
{
// Forward Declarations
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class magnet;
Istream& operator>>(Istream&, magnet&);
Ostream& operator<<(Ostream&, const magnet&);

View File

@ -7,7 +7,7 @@
(
IOobject
(
polyMesh::defaultRegion,
dynamicFvMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ

View File

@ -23,7 +23,6 @@ surfaceScalarField phiHbyA
+ phig
);
fvc::makeRelative(phiHbyA, rho, U);
MRF.makeRelative(fvc::interpolate(rho), phiHbyA);
// Update the pressure BCs to ensure flux consistency

View File

@ -11,6 +11,5 @@ wmake $targetType
wmake $targetType compressibleInterDyMFoam
wmake $targetType compressibleInterFilmFoam
wmake $targetType compressibleInterIsoFoam
wmake $targetType overCompressibleInterDyMFoam
#------------------------------------------------------------------------------

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -83,7 +83,7 @@ VoFPatchTransfer::VoFPatchTransfer
pbm.size() - film.regionMesh().globalData().processorPatches().size()
);
wordRes patchNames;
wordReList patchNames;
if (coeffDict_.readIfPresent("patches", patchNames))
{
patchIDs_ = pbm.patchSet(patchNames).sortedToc();

View File

@ -144,11 +144,10 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
),
curTimeIndex_(-1)
{
fieldNames_.resize(2);
fieldNames_.setSize(2);
fieldNames_[0] = "U";
fieldNames_[1] = "T";
fv::option::resetApplied();
applied_.setSize(fieldNames_.size(), false);
}

View File

@ -41,6 +41,10 @@ bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict)
return true;
}
else
{
return false;
}
return false;
}

View File

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

View File

@ -1,40 +0,0 @@
EXE_INC = \
-I.. \
-I../../VoF \
-I../../interFoam/overInterDyMFoam \
-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 \
-I$(FOAM_SOLVERS)/incompressible/pimpleFoam/overPimpleDyMFoam \
-I$(LIB_SRC)/overset/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-ltwoPhaseMixtureThermo \
-ltwoPhaseSurfaceTension \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-ltwoPhaseMixture \
-ltwoPhaseProperties \
-linterfaceProperties \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lVoFphaseCompressibleTurbulenceModels \
-ldynamicMesh \
-ldynamicFvMesh \
-ltopoChangerFvMesh \
-loverset \
-lwaveModels

View File

@ -1,28 +0,0 @@
{
fvScalarMatrix TEqn
(
fvm::ddt(rho, T) + fvm::div(rhoPhi, T) - fvm::Sp(contErr, T)
- fvm::laplacian(turbulence.alphaEff(), T)
+ (
divUp()// - contErr/rho*p
+ (fvc::ddt(rho, K) + fvc::div(rhoPhi, K))() - contErr*K
)
*(
alpha1()/mixture.thermo1().Cv()()
+ alpha2()/mixture.thermo2().Cv()()
)
==
fvOptions(rho, T)
);
TEqn.relax();
fvOptions.constrain(TEqn);
TEqn.solve();
fvOptions.correct(T);
mixture.correctThermo();
mixture.correct();
}

View File

@ -1,36 +0,0 @@
MRF.correctBoundaryVelocity(U);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U) + fvm::div(rhoPhi, U)
- fvm::Sp(contErr, U)
+ MRF.DDt(rho, U)
+ turbulence.divDevRhoReff(U)
==
fvOptions(rho, U)
);
UEqn.relax();
fvOptions.constrain(UEqn);
if (pimple.momentumPredictor())
{
solve
(
UEqn
==
cellMask*fvc::reconstruct
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
- fvc::snGrad(p_rgh)
) * mesh.magSf()
)
);
fvOptions.correct(U);
K = 0.5*magSqr(U);
}

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)
{
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
}
else if (dgdt[celli] < 0.0)
{
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
}
}
volScalarField::Internal divU
(
mesh.moving()
? fvc::div(phi + mesh.phi())
: fvc::div(phi)
);

View File

@ -1,138 +0,0 @@
#include "createRDeltaT.H"
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
(
IOobject
(
"p_rgh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
#include "createPhi.H"
Info<< "Constructing twoPhaseMixtureThermo\n" << endl;
twoPhaseMixtureThermo mixture(U, phi);
volScalarField& alpha1(mixture.alpha1());
volScalarField& alpha2(mixture.alpha2());
Info<< "Reading thermophysical properties\n" << endl;
const volScalarField& rho1 = mixture.thermo1().rho();
const volScalarField& rho2 = mixture.thermo2().rho();
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
alpha1*rho1 + alpha2*rho2
);
dimensionedScalar pMin
(
"pMin",
dimPressure,
mixture
);
mesh.setFluxRequired(p_rgh.name());
mesh.setFluxRequired(alpha1.name());
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"
// Mass flux
// Initialisation does not matter because rhoPhi is reset after the
// alpha1 solution before it is used in the U equation.
surfaceScalarField rhoPhi
(
IOobject
(
"rhoPhi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
fvc::interpolate(rho)*phi
);
volScalarField dgdt(alpha1*fvc::div(phi));
#include "createAlphaFluxes.H"
// Construct compressible turbulence model
compressibleInterPhaseTransportModel turbulence
(
rho,
U,
phi,
rhoPhi,
alphaPhi10,
mixture
);
#include "createK.H"
#include "createMRF.H"
#include "createFvOptions.H"
// Overset specific
// Add solver-specific interpolations
{
wordHashSet& nonInt =
const_cast<wordHashSet&>(Stencil::New(mesh).nonInterpolatedFields());
nonInt.insert("HbyA");
nonInt.insert("grad(p_rgh)");
nonInt.insert("nHat");
nonInt.insert("surfaceIntegrate(phi)");
nonInt.insert("surfaceIntegrate(phiHbyA)");
nonInt.insert("cellMask");
nonInt.insert("cellDisplacement");
nonInt.insert("interpolatedCells");
nonInt.insert("cellInterpolationWeight");
nonInt.insert("pcorr");
}
// Mask field for zeroing out contributions on hole cells
#include "createCellMask.H"
surfaceScalarField faceMask
(
localMin<scalar>(mesh).interpolate(cellMask)
);
// Create bool field with interpolated cells
#include "createInterpolatedCells.H"

View File

@ -1,240 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
overCompressibleInterDyMFoam
Group
grpMultiphaseSolvers
Description
Solver for two compressible, non-isothermal, immiscible fluids using VOF
(i.e. volume of fluid) phase-fraction based interface capturing approach.
This solver supports dynamic mesh motions including overset cases.
The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.
Either mixture or two-phase transport modelling may be selected. In the
mixture approach, a single laminar, RAS or LES model is selected to model
the momentum stress. In the Euler-Euler two-phase approach separate
laminar, RAS or LES selected models are selected for each of the phases.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "CMULES.H"
#include "EulerDdtScheme.H"
#include "CrankNicolsonDdtScheme.H"
#include "subCycle.H"
#include "compressibleInterPhaseTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "fvcSmooth.H"
#include "cellCellStencilObject.H"
#include "localMin.H"
#include "interpolationCellPoint.H"
#include "transform.H"
#include "fvMeshSubset.H"
#include "oversetAdjustPhi.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Solver for two compressible, non-isothermal, immiscible fluids"
" using VOF phase-fraction based interface capturing approach.\n"
"Supports dynamic mesh motions including overset cases."
);
#include "postProcess.H"
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
pimpleControl pimple(mesh);
#include "createTimeControls.H"
#include "createDyMControls.H"
#include "createFields.H"
volScalarField& p = mixture.p();
volScalarField& T = mixture.T();
const volScalarField& psi1 = mixture.thermo1().psi();
const volScalarField& psi2 = mixture.thermo2().psi();
#include "correctPhi.H"
#include "createUf.H"
if (!LTS)
{
#include "CourantNo.H"
#include "setInitialDeltaT.H"
}
#include "setCellMask.H"
#include "setInterpolatedCells.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readControls.H"
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())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
// Do not apply previous time-step mesh compression flux
// if the mesh topology changed
if (mesh.topoChanging())
{
talphaPhi1Corr0.clear();
}
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
// Update cellMask field for blocking out hole cells
#include "setCellMask.H"
#include "setInterpolatedCells.H"
faceMask =
localMin<scalar>(mesh).interpolate(cellMask.oldTime());
// Zero Uf on old faceMask (H-I)
Uf *= faceMask;
const surfaceVectorField Uint(fvc::interpolate(U));
// Update Uf and phi on new C-I faces
Uf += (1-faceMask)*Uint;
// Update Uf boundary
forAll(Uf.boundaryField(), patchI)
{
Uf.boundaryFieldRef()[patchI] =
Uint.boundaryField()[patchI];
}
phi = mesh.Sf() & Uf;
// Correct phi on individual regions
if (correctPhi)
{
#include "correctPhi.H"
}
mixture.correct();
// Zero phi on current H-I
faceMask = localMin<scalar>(mesh).interpolate(cellMask);
phi *= faceMask;
U *= cellMask;
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);
}
if (mesh.changing() && checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
#include "alphaControls.H"
#include "compressibleAlphaEqnSubCycle.H"
const surfaceScalarField faceMask
(
localMin<scalar>(mesh).interpolate(cellMask)
);
rhoPhi *= faceMask;
turbulence.correctPhasePhi();
#include "UEqn.H"
volScalarField divUp("divUp", fvc::div(fvc::absolute(phi, U), p));
#include "TEqn.H"
// --- Pressure corrector loop
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence.correct();
}
}
runTime.write();
runTime.printExecutionTime(Info);
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,177 +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)
);
if (ddtCorr)
{
surfaceScalarField faceMaskOld
(
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
);
phiHbyA +=
MRF.zeroFilter
(
fvc::interpolate(rho*rAU)*faceMaskOld*fvc::ddtCorr(U, Uf)
);
}
MRF.makeRelative(phiHbyA);
surfaceScalarField phig
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*faceMask*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
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
{
#include "rhofs.H"
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*psi1/rho1)*correction(fvm::ddt(p_rgh))
);
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*psi2/rho2)*correction(fvm::ddt(p_rgh))
);
}
// 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
(
p_rghEqnComp1() + p_rghEqnComp2() + p_rghEqnIncomp,
mesh.solver(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 =
(
alpha1*(p_rghEqnComp2 & p_rgh)
- alpha2*(p_rghEqnComp1 & p_rgh)
);
phi = phiHbyA + p_rghEqnIncomp.flux();
U =
cellMask*
(
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));
}
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
// Zero faces H-I for transport Eq after pEq
phi *= faceMask;
// 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_rgh = p - rho*gh;
p_rgh.correctBoundaryConditions();
K = 0.5*magSqr(U);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,23 +59,24 @@ class multiphaseMixtureThermo
{
public:
//- Symmetric pair of interface names
class interfacePair
:
public Pair<word>
{
public:
// Always use symmetric hashing
using hasher = Pair<word>::symmHasher;
// Always use symmetric hashing (alias)
using hash = Pair<word>::symmHasher;
struct hash
{
label operator()(const interfacePair& key) const
{
return word::hash()(key.first()) + word::hash()(key.second());
}
};
// Constructors
interfacePair() = default;
interfacePair() {} // = default
interfacePair(const word& alpha1Name, const word& alpha2Name)
:
@ -96,7 +97,11 @@ public:
const interfacePair& b
)
{
return (0 != Pair<word>::compare(a, b));
return
(
((a.first() == b.first()) && (a.second() == b.second()))
|| ((a.first() == b.second()) && (a.second() == b.first()))
);
}
friend bool operator!=
@ -112,7 +117,7 @@ public:
private:
// Private Data
// Private data
//- Dictionary of phases
PtrDictionary<phaseModel> phases_;
@ -135,7 +140,7 @@ private:
const dimensionedScalar deltaN_;
// Private Member Functions
// Private member functions
void calcAlphas();

View File

@ -7,7 +7,6 @@ EXE_INC = \
-I$(LIB_SRC)/fvOptions/lnInclude\
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
@ -15,15 +14,13 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(FOAM_SOLVERS)/multiphase/interFoam
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-lsampling \
-ldynamicFvMesh \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lcompressibleTransportModels \

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,14 +42,16 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "subCycle.H"
#include "multiphaseSystem.H"
#include "turbulentFluidThermoModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "fixedFluxPressureFvPatchScalarField.H"
#include "radiationModel.H"
#include "CorrectPhi.H"
#include "HashPtrTable.H"
#include "fvcDDt.H"
#include "zeroField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -68,18 +70,14 @@ int main(int argc, char *argv[])
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "createMesh.H"
#include "initContinuityErrs.H"
#include "createDyMControls.H"
pimpleControl pimple(mesh);
#include "createFields.H"
#include "createFieldRefs.H"
#include "initCorrectPhi.H"
#include "createUfIfPresent.H"
#include "createFvOptions.H"
#include "createTimeControls.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
@ -91,8 +89,7 @@ int main(int argc, char *argv[])
while (runTime.run())
{
#include "readDyMControls.H"
#include "readTimeControls.H"
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
@ -108,28 +105,6 @@ int main(int argc, char *argv[])
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
if (pimple.firstIter() || moveMeshOuterCorrectors)
{
mesh.update();
if (mesh.changing())
{
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 flux relative to the mesh motion
fvc::makeRelative(phi, U);
}
}
}
#include "UEqn.H"
#include "YEqns.H"
#include "TEqn.H"

View File

@ -1,31 +1,17 @@
{
if (correctPhi)
{
rAU.ref() = 1.0/UEqn.A();
}
else
{
rAU = 1.0/UEqn.A();
}
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU()));
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
volVectorField HbyA("HbyA", U);
HbyA = rAU()*UEqn.H();
HbyA = rAU*UEqn.H();
surfaceScalarField phiHbyA
(
"phiHbyA",
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::interpolate(rho*rAU())*fvc::ddtCorr(U, phi)
+ fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi)
);
if (p_rgh.needReference())
{
fvc::makeRelative(phiHbyA, U);
adjustPhi(phiHbyA, U, p_rgh);
fvc::makeAbsolute(phiHbyA, U);
}
adjustPhi(phiHbyA, U, p_rgh);
surfaceScalarField phig
(
@ -64,7 +50,7 @@
p_rgh.relax();
U = HbyA + rAU()*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf);
U = HbyA + rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
fvOptions.correct(U);
@ -72,14 +58,6 @@
}
}
#include "continuityErrs.H"
// Correct Uf if the mesh is moving
fvc::correctUf(Uf, U, phi);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
p == p_rgh + rho*gh;
if (p_rgh.needReference())
@ -92,9 +70,4 @@
);
p_rgh = p - rho*gh;
}
if (!correctPhi)
{
rAU.clear();
}
}

View File

@ -97,15 +97,9 @@ int main(int argc, char *argv[])
dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0)
);
if (correctPhi)
{
#include "correctPhi.H"
}
#include "correctPhi.H"
#include "createUf.H"
#include "setCellMask.H"
#include "setInterpolatedCells.H"
turbulence->validate();
if (!LTS)
@ -114,6 +108,9 @@ int main(int argc, char *argv[])
#include "setInitialDeltaT.H"
}
#include "setCellMask.H"
#include "setInterpolatedCells.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;

View File

@ -4,9 +4,7 @@ cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
wmake $targetType phaseChangeTwoPhaseMixtures
wmake $targetType
wmake $targetType interPhaseChangeDyMFoam
wmake $targetType overInterPhaseChangeDyMFoam
#------------------------------------------------------------------------------

View File

@ -9,12 +9,7 @@
phic += (interface.cAlpha()*icAlpha)*fvc::interpolate(mag(U));
}
volScalarField divU
(
mesh.moving()
? fvc::div(phi + mesh.phi())
: fvc::div(phi)
);
volScalarField divU(fvc::div(phi));
if (nAlphaSubCycles > 1)
{

View File

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

View File

@ -1,35 +0,0 @@
EXE_INC = \
-I.. \
-I../../interFoam/overInterDyMFoam \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I../phaseChangeTwoPhaseMixtures/lnInclude \
-I$(FOAM_SOLVERS)/incompressible/pimpleFoam/overPimpleDyMFoam \
-I$(LIB_SRC)/overset/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-lsampling \
-lphaseChangeTwoPhaseMixtures \
-ltwoPhaseMixture \
-linterfaceProperties \
-ltwoPhaseProperties \
-lincompressibleTransportModels \
-lturbulenceModels \
-lincompressibleTurbulenceModels \
-ldynamicMesh \
-ldynamicFvMesh \
-ltopoChangerFvMesh \
-loverset \
-lwaveModels

View File

@ -1,31 +0,0 @@
fvVectorMatrix UEqn
(
fvm::ddt(rho, U) + fvm::div(rhoPhi, U)
- fvm::Sp(fvc::ddt(rho) + fvc::div(rhoPhi), U)
+ turbulence->divDevRhoReff(rho, U)
==
fvOptions(rho, U)
);
UEqn.relax();
fvOptions.constrain(UEqn);
if (pimple.momentumPredictor())
{
solve
(
UEqn
==
cellMask*fvc::reconstruct
(
(
interface.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
- fvc::snGrad(p_rgh)
) * mesh.magSf()
)
);
fvOptions.correct(U);
}

View File

@ -1,11 +0,0 @@
CorrectPhi
(
U,
phi,
p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU)),
divU,
pimple
);
#include "continuityErrs.H"

View File

@ -1,158 +0,0 @@
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
(
IOobject
(
"p_rgh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
#include "createPhi.H"
Info<< "Creating phaseChangeTwoPhaseMixture\n" << endl;
autoPtr<phaseChangeTwoPhaseMixture> mixture =
phaseChangeTwoPhaseMixture::New(U, phi);
volScalarField& alpha1(mixture->alpha1());
volScalarField& alpha2(mixture->alpha2());
const dimensionedScalar& rho1 = mixture->rho1();
const dimensionedScalar& rho2 = mixture->rho2();
// Need to store rho for ddt(rho, U)
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT
),
alpha1*rho1 + alpha2*rho2
);
rho.oldTime();
// Construct interface from alpha1 distribution
interfaceProperties interface(alpha1, U, mixture());
// Construct incompressible turbulence model
autoPtr<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, mixture())
);
#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p_rgh + rho*gh
);
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
p_rgh,
pimple.dict(),
pRefCell,
pRefValue
);
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
mesh.setFluxRequired(p_rgh.name());
mesh.setFluxRequired(alpha1.name());
#include "createFvOptions.H"
IOobject alphaPhi10Header
(
IOobject::groupName("alphaPhi0", alpha1.group()),
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
);
// MULES flux from previous time-step
surfaceScalarField alphaPhi10
(
alphaPhi10Header,
phi*fvc::interpolate(alpha1)
);
// Overset specific
// Add solver-specific interpolations
{
wordHashSet& nonInt =
const_cast<wordHashSet&>(Stencil::New(mesh).nonInterpolatedFields());
nonInt.insert("HbyA");
nonInt.insert("grad(p_rgh)");
nonInt.insert("nHat");
nonInt.insert("surfaceIntegrate(phi)");
nonInt.insert("surfaceIntegrate(phiHbyA)");
nonInt.insert("cellMask");
nonInt.insert("cellDisplacement");
nonInt.insert("interpolatedCells");
nonInt.insert("cellInterpolationWeight");
nonInt.insert("pcorr");
}
// Mask field for zeroing out contributions on hole cells
#include "createCellMask.H"
surfaceScalarField faceMask
(
localMin<scalar>(mesh).interpolate(cellMask)
);
// Create bool field with interpolated cells
#include "createInterpolatedCells.H"

View File

@ -1,250 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD 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
overInterPhaseChangeDyMFoam
Group
grpMultiphaseSolvers grpMovingMeshSolvers
Description
Solver for two incompressible, isothermal, immiscible fluids with
phase-change (e.g. cavitation) using VOF (i.e. volume of fluid)
phase-fraction based interface capturing, with optional dynamic mesh
motion (including overset) 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.
The set of phase-change models provided are designed to simulate cavitation
but other mechanisms of phase-change are supported within this solver
framework.
Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "CMULES.H"
#include "subCycle.H"
#include "interfaceProperties.H"
#include "phaseChangeTwoPhaseMixture.H"
#include "turbulentTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "cellCellStencilObject.H"
#include "localMin.H"
#include "interpolationCellPoint.H"
#include "transform.H"
#include "oversetAdjustPhi.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Solver for two incompressible, isothermal, immiscible fluids with"
" phase-change\n"
"using VOF (volume of fluid) phase-fraction based interface capturing,"
" with optional dynamic mesh motion (including overset)\n"
"and mesh topology changes including adaptive re-meshing."
);
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
pimpleControl pimple(mesh);
#include "createTimeControls.H"
#include "createDyMControls.H"
#include "initContinuityErrs.H"
#include "createFields.H"
volScalarField rAU
(
IOobject
(
"rAU",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0)
);
#include "createUf.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
turbulence->validate();
#include "setCellMask.H"
#include "setInterpolatedCells.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readControls.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)));
#include "CourantNo.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())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
// Update cellMask field for blocking out hole cells
#include "setCellMask.H"
#include "setInterpolatedCells.H"
faceMask =
localMin<scalar>(mesh).interpolate(cellMask.oldTime());
// Zero Uf on old faceMask (H-I)
Uf *= faceMask;
const surfaceVectorField Uint(fvc::interpolate(U));
// Update Uf and phi on new C-I faces
Uf += (1-faceMask)*Uint;
// Update Uf boundary
forAll(Uf.boundaryField(), patchI)
{
Uf.boundaryFieldRef()[patchI] =
Uint.boundaryField()[patchI];
}
phi = mesh.Sf() & Uf;
if (correctPhi)
{
#include "correctPhi.H"
}
mixture->correct();
// Zero phi on current H-I
faceMask = localMin<scalar>(mesh).interpolate(cellMask);
phi *= faceMask;
U *= cellMask;
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);
}
if (mesh.changing() && checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
#include "alphaControls.H"
surfaceScalarField rhoPhi
(
IOobject
(
"rhoPhi",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(dimMass/dimTime, Zero)
);
mixture->correct();
#include "alphaEqnSubCycle.H"
const surfaceScalarField faceMask
(
localMin<scalar>(mesh).interpolate(cellMask)
);
rhoPhi *= faceMask;
interface.correct();
#include "UEqn.H"
// --- Pressure corrector loop
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence->correct();
}
}
runTime.write();
runTime.printExecutionTime(Info);
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,101 +0,0 @@
{
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)
);
if (ddtCorr)
{
surfaceScalarField faceMaskOld
(
localMin<scalar>(mesh).interpolate(cellMask.oldTime())
);
phiHbyA += faceMaskOld*fvc::ddtCorr(U, Uf);
}
if (p_rgh.needReference())
{
fvc::makeRelative(phiHbyA, U);
adjustPhi(phiHbyA, U, p_rgh);
fvc::makeAbsolute(phiHbyA, U);
}
surfaceScalarField phig
(
(
interface.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*faceMask*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf);
Pair<tmp<volScalarField>> vDotP = mixture->vDotP();
const volScalarField& vDotcP = vDotP[0]();
const volScalarField& vDotvP = vDotP[1]();
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh)
- (vDotvP - vDotcP)*(mixture->pSat() - rho*gh)
+ fvm::Sp(vDotvP - vDotcP, p_rgh)
);
//p_rghEqn.setReference(pRefCell, pRefValue);
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));
if (pimple.finalNonOrthogonalIter())
{
phi = phiHbyA + p_rghEqn.flux();
p_rgh.relax();
U =
cellMask
*(HbyA + rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf));
U.correctBoundaryConditions();
fvOptions.correct(U);
}
}
#include "continuityErrs.H"
{
Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += n*(phi/mesh.magSf() - (n & Uf));
}
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
// Zero faces H-I for transport Eq after pEq
phi *= faceMask;
p == p_rgh + rho*gh;
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
}

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,23 +67,24 @@ class multiphaseMixture
{
public:
//- Symmetric pair of interface names
class interfacePair
:
public Pair<word>
{
public:
// Always use symmetric hashing
using hasher = Pair<word>::symmHasher;
// Always use symmetric hashing (alias)
using hash = Pair<word>::symmHasher;
struct hash
{
label operator()(const interfacePair& key) const
{
return word::hash()(key.first()) + word::hash()(key.second());
}
};
// Constructors
interfacePair() = default;
interfacePair() {} // = default
interfacePair(const word& alpha1Name, const word& alpha2Name)
:
@ -105,7 +105,11 @@ public:
const interfacePair& b
)
{
return (0 != Pair<word>::compare(a, b));
return
(
((a.first() == b.first()) && (a.second() == b.second()))
|| ((a.first() == b.second()) && (a.second() == b.first()))
);
}
friend bool operator!=

View File

@ -47,7 +47,7 @@
}
else if (rhoType == "field")
{
rhoIO.readOpt(IOobject::MUST_READ);
rhoIO.readOpt() = IOobject::MUST_READ;
rhoPtr.reset
(
@ -102,7 +102,7 @@
}
else if (EType == "field")
{
EHeader.readOpt(IOobject::MUST_READ);
EHeader.readOpt() = IOobject::MUST_READ;
EPtr.reset
(
@ -156,7 +156,7 @@
}
else if (nuType == "field")
{
nuIO.readOpt(IOobject::MUST_READ);
nuIO.readOpt() = IOobject::MUST_READ;
nuPtr.reset
(
new volScalarField

View File

@ -81,7 +81,7 @@ if (thermalStress)
}
else if (CType == "field")
{
CIO.readOpt(IOobject::MUST_READ);
CIO.readOpt() = IOobject::MUST_READ;
CPtr.reset
(
@ -136,7 +136,7 @@ if (thermalStress)
}
else if (kType == "field")
{
rhoKIO.readOpt(IOobject::MUST_READ);
rhoKIO.readOpt() = IOobject::MUST_READ;
rhoKPtr.reset
(
@ -191,7 +191,7 @@ if (thermalStress)
}
else if (alphaType == "field")
{
alphaIO.readOpt(IOobject::MUST_READ);
alphaIO.readOpt() = IOobject::MUST_READ;
alphaPtr.reset
(

View File

@ -1,6 +0,0 @@
/* Disable normal project defaults */
PROJECT_INC =
PROJECT_LIBS =
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -186,14 +186,14 @@ int main(int argc, char *argv[])
FixedList<label, 4> list1{2, 3, 4, 5};
Info<< "list1:" << list1
<< " hash:" << FixedList<label, 4>::hasher()(list1) << nl
<< " hash:" << FixedList<label, 4>::Hash<>()(list1) << nl
<< " hash:" << Hash<FixedList<label, 4>>()(list1) << nl;
label a[4] = {0, 1, 2, 3};
FixedList<label, 4> list2(a);
Info<< "list2:" << list2
<< " hash:" << FixedList<label, 4>::hasher()(list2) << nl
<< " hash:" << FixedList<label, 4>::Hash<>()(list2) << nl
<< " hash:" << Hash<FixedList<label, 4>>()(list2) << nl;

View File

@ -1,6 +1,15 @@
EXE_INC = \
-DFULLDEBUG -g \
-DFULLDEBUG -g -O0 \
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lmeshTools
-llagrangianIntermediate \
-lradiationModels \
-lregionModels \
-lfiniteVolume \
-lmeshTools \
-lsampling

View File

@ -32,8 +32,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IOstreams.H"
#include "fvCFD.H"
#include "Function1.H"
#include "scalarIndList.H"
#include "scalarField.H"
@ -41,8 +40,6 @@ Description
#include "linearInterpolationWeights.H"
#include "splineInterpolationWeights.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -26,44 +26,11 @@ x
);
constant1 constant 100;
table1 table
function1 table
(
(0 0)(10 1)
);
table2
{
type table;
values
(
(0 0)(10 1)
);
}
table3
{
type table;
file "<constant>/table-values";
}
poly1 polynomial
(
(0 1)
(1 1)
);
poly2
{
type polynomial;
coeffs
(
(0 1)
(1 1)
);
}
function2
{
type expression;

View File

@ -1,9 +0,0 @@
// -*- C++ -*-
// Some table values
(
(0 0)
(20 1)
);
// ************************************************************************* //

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -125,39 +125,28 @@ int main()
myTable.set("pi", new double(3.14159));
myTable.set("natlog", new double(2.718282));
myTable.insert("sqrt2", autoPtr<double>::New(1.414214));
myTable.insert("euler", autoPtr<double>::New(0.577216));
HashTable<std::unique_ptr<double>> myTable1;
HashTable<std::unique_ptr<double>, word, string::hash> myTable1;
myTable1.set("abc", std::unique_ptr<double>(new double(42.1)));
myTable1.set("pi", std::unique_ptr<double>(new double(3.14159)));
myTable1.set("natlog", std::unique_ptr<double>(new double(2.718282)));
HashTable<autoPtr<double>> myTable2;
HashTable<autoPtr<double>, word, string::hash> myTable2;
myTable2.set("abc", autoPtr<double>(new double(42.1)));
myTable2.set("pi", autoPtr<double>(new double(3.14159)));
myTable2.set("natlog", autoPtr<double>(new double(2.718282)));
myTable2.insert("sqrt2", autoPtr<double>::New(1.414214));
Info<< "Initial table" << nl;
// Info<< myTable << endl;
printTable(myTable);
Info<< "print" << nl;
Info<< myTable2 << nl;
{
auto iter2 = myTable2.find("pi");
Info<< nl << "Got pi=";
if (iter2.good())
{
Info<< **iter2 << nl;
}
else
{
Info<< "not-found" << nl;
}
}
auto iter2 = myTable2.find("pi");
Info<<"PI: " << **iter2 << nl;
HashPtrTable<double> copy(myTable);
@ -176,9 +165,6 @@ int main()
myTable.erase("abc");
myTable.erase("unknownKey");
myTable.release("euler");
Info<< "After erasure" << nl;
printTable(myTable);
HashPtrTable<double> moved(std::move(copy));

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -80,11 +80,6 @@ void printMinMax(const HashSet<Key, Hash>& set)
int main(int argc, char *argv[])
{
Info<< "labelHashSet hasher: "
<< typeid(labelHashSet::hasher).name() << nl
<< "HashSet<label> hasher: "
<< typeid(HashSet<label>::hasher).name() << nl << nl;
hashedWordList words
{
"abc",

View File

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

View File

@ -0,0 +1,346 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 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
testHashing
Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "stringList.H"
#include "labelList.H"
#include "labelPair.H"
#include "wordPair.H"
#include "edgeList.H"
#include "faceList.H"
#include "triFaceList.H"
#include "Hash.H"
using namespace Foam;
void infoHashString
(
unsigned modulus,
std::initializer_list<std::string> lst
)
{
if (modulus)
{
Info<< "basic string hashing (mod " << label(modulus) << ")" << nl;
for (const auto& str : lst)
{
Info<<"hash(" << str.c_str() << ")="
<< (Hash<string>()(str) % modulus) << nl;
}
}
else
{
Info<< "basic string hashing" << nl;
for (const auto& str : lst)
{
Info<<"hash(" << str.c_str() << ")="
<< Hash<string>()(str) << nl;
}
}
}
void reportHashList(const UList<string>& list)
{
Info<< "contiguous = " << is_contiguous<string>::value << nl << nl;
for (const string& val : list)
{
unsigned hash1 = string::hash()(val);
Info<< hex << hash1 << ": " << val << nl;
}
}
void reportHashList(const UList<label>& list)
{
Info<<"contiguous = " << is_contiguous<label>::value << nl << nl;
for (const label val : list)
{
// Direct value
unsigned hash1 = Hash<label>()(val);
// Hashed byte-wise
unsigned hash2 = Hash<label>()(val, 0);
Info<< hex << hash1
<< " (seeded: " << hash2 << ")"
<< ": " << dec << val << nl;
}
}
void reportHashList(const UList<face>& list)
{
Info<<"contiguous = " << is_contiguous<label>::value << nl << nl;
for (const face& f : list)
{
// Direct value
unsigned hash1 = face::Hash<>()(f);
unsigned hash2 = Hash<face>()(f);
Info<< hex << "face::Hash<> " << hash1
<< " Hash<face> " << hash2
<< ": " << dec << flatOutput(f) << nl;
}
}
void reportHashList(const UList<labelList>& list)
{
for (const labelList& val : list)
{
unsigned hash1 = Hasher
(
val.cdata(),
val.size() * sizeof(label)
);
unsigned hash2 = Hash<labelList>()(val);
unsigned hash2b = labelList::Hash<>()(val);
Info<< hex << hash1 << " or " << hash2
<< "(" << hash2b << ") "
<< ": " << dec << val << nl;
}
unsigned hash2 = Hash<labelListList>()(list);
unsigned hash2bad = HasherT(list);
Info<< hex << hash2 << " : " << dec << flatOutput(list) << nl
<< hex << hash2bad << " as direct hash would be wrong"
<< dec << nl;
}
void reportHashList(const UList<wordPair>& list)
{
Info<<"contiguous = " << is_contiguous<wordPair>::value << nl << nl;
for (const wordPair& pr : list)
{
unsigned hash1 = Hash<wordPair>()(pr);
// as FixedList
unsigned hash2 = wordPair::Hash<>()(pr);
// as FixedList
unsigned hash2sym = wordPair::SymmHash<>()(pr);
// as FixedList
unsigned hash3 = Hash<FixedList<word,2>>()(pr);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< ") or " << hash3
<< " symm-hash:" << hash2sym
<< " : "<< dec << flatOutput(pr) << nl;
}
}
void reportHashList(const UList<labelPair>& list)
{
Info<<"contiguous = " << is_contiguous<labelPair>::value << nl << nl;
for (const labelPair& pr : list)
{
unsigned hash1 = Hash<labelPair>()(pr);
// as FixedList
unsigned hash2 = labelPair::Hash<>()(pr);
// as FixedList
unsigned hash3 = Hash<labelPair>()(pr);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< ") or " << hash3
<< " : "<< dec << pr << nl;
}
}
void reportHashList(const UList<labelPairPair>& list)
{
Info<<"contiguous = " << is_contiguous<labelPairPair>::value << nl << nl;
for (const labelPairPair& pr : list)
{
unsigned hash1 = Hash<labelPairPair>()(pr);
// as FixedList
unsigned hash2 = labelPairPair::Hash<>()(pr);
// as FixedList
unsigned hash3 = Hash<labelPairPair>()(pr);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< ") or " << hash3
<< " : "<< dec << pr << nl;
}
}
void reportHashList(const UList<edge>& list)
{
Info<<"contiguous = " << is_contiguous<edge>::value << nl << nl;
for (const edge& e : list)
{
unsigned hash1 = Hash<edge>()(e);
// as FixedList
unsigned hash2 = labelPair::Hash<>()(e);
// as FixedList
unsigned hash3 = Hash<labelPair>()(e);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< ") or " << hash3
<< " : "<< dec << e << nl;
}
}
void reportHashList(const UList<triFace>& list)
{
Info<<"contiguous = " << is_contiguous<triFace>::value << nl << nl;
for (const triFace& f : list)
{
// direct value
unsigned hash1 = Hash<triFace>()(f);
unsigned hash2 = FixedList<label, 3>::Hash<>()(f);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< "): " << dec << f << nl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
infoHashString(8, {"asdathis1", "adsxf", "hij", "klmpq"});
IFstream is("hashingTests");
if (is.good())
{
Info<< nl << "Process " << is.name() << " file ..." << nl;
}
else
{
Info<< nl << "No " << is.name() << " file found ..." << nl;
}
token tok;
while (is.good() && is.read(tok) && tok.good())
{
const word listType(tok.wordToken());
Info<< nl;
IOobject::writeDivider(Info) << listType << nl;
if (listType == "stringList")
{
stringList list(is);
reportHashList(list);
}
else if (listType == "labelList")
{
labelList list(is);
reportHashList(list);
}
else if (listType == "faceList")
{
faceList list(is);
reportHashList(list);
}
else if (listType == "labelListList")
{
List<labelList> list(is);
reportHashList(list);
}
else if (listType == "wordPairList")
{
List<wordPair> list(is);
reportHashList(list);
}
else if (listType == "labelPairList")
{
labelPairList list(is);
reportHashList(list);
}
else if (listType == "labelPairPairList")
{
List<labelPairPair> list(is);
reportHashList(list);
}
else if (listType == "edgeList")
{
edgeList list(is);
reportHashList(list);
}
else if (listType == "triFaceList")
{
triFaceList list(is);
reportHashList(list);
}
else
{
Info<< "unknown type: " << listType << nl;
}
}
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,224 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::HashFunction
Description
Hash function class.
Verify that template overloads are properly resolved
Note
The second template parameter (bool) is used for SFINAE overloading,
\*---------------------------------------------------------------------------*/
#ifndef HashFunction_H
#define HashFunction_H
#include "Hash.H"
#ifdef FULLDEBUG
#define HashTypeInfo(Args) void info() { std::cerr<< "" Args << "\n"; }
#else
#define HashTypeInfo(Args) void info() {}
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class Hash Declaration
\*---------------------------------------------------------------------------*/
template<class T, class SFINAEType=bool>
struct HashFun
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "default"; }
#endif
HashTypeInfo("plain hash")
unsigned operator()(const T& obj, unsigned seed=0) const
{
return Foam::Hasher(&obj, sizeof(obj), seed);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hashing for label
template<> struct HashFun<Foam::label> : Hash<label>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "label"; }
#endif
HashTypeInfo("hash label")
};
//- Hashing for pointers, interpret pointer as a integer type
template<> struct HashFun<void*> : Hash<void *>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "pointer"; }
#endif
HashTypeInfo("hash ptr")
};
//- Hashing for string types
template<class StringType>
struct HashFun
<
StringType,
typename std::enable_if
<
std::is_base_of<std::string, StringType>::value, bool
>::type
>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "string"; }
#endif
HashTypeInfo("hash string")
unsigned operator()(const std::string& obj, unsigned seed=0) const
{
return Foam::Hasher(obj.data(), obj.size(), seed);
}
};
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Various
#include "edge.H"
#include "face.H"
#include "triFace.H"
#include "Pair.H"
#include "Tuple2.H"
#include "DynamicList.H"
#include "FixedList.H"
namespace Foam
{
template<> struct HashFun<edge> : Hash<edge>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "edge"; }
#endif
HashTypeInfo("hash edge")
};
template<> struct HashFun<face> : Hash<face>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "face"; }
#endif
HashTypeInfo("hash face")
};
template<> struct HashFun<triFace> : Hash<triFace>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "triFace"; }
#endif
HashTypeInfo("hash triFace")
};
template<class T>
struct HashFun<Pair<T>> : Hash<Pair<T>>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "Pair"; }
#endif
HashTypeInfo("hash Pair")
};
template<class T1, class T2>
struct HashFun<Tuple2<T1, T2>> : Hash<Tuple2<T1, T2>>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "Tuple2"; }
#endif
HashTypeInfo("hash Tuple2")
};
template<class T>
struct HashFun<List<T>> : Hash<List<T>>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "List"; }
#endif
HashTypeInfo("hash List")
};
template<class T> struct HashFun<UList<T>> : Hash<UList<T>>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "UList"; }
#endif
HashTypeInfo("hash UList")
};
template<class T, int SizeMin>
struct HashFun<DynamicList<T, SizeMin>> : Hash<DynamicList<T, SizeMin>>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "DynamicList"; }
#endif
HashTypeInfo("hash DynamicList")
};
template<class T, unsigned N>
struct HashFun<FixedList<T, N>> : Hash<FixedList<T, N>>
{
#ifdef FULLDEBUG
static constexpr const char* name() noexcept { return "FixedList"; }
#endif
HashTypeInfo("hash FixedList")
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

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

View File

@ -1,163 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-Hashing1
Description
Test/verify overloads of Hash function
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "stringList.H"
#include "labelList.H"
#include "labelPair.H"
#include "wordPair.H"
#include "edgeList.H"
#include "faceList.H"
#include "triFaceList.H"
#define FULLDEBUG
#include "HashFunction.H"
using namespace Foam;
template<class T>
unsigned rawHasher(const T& obj)
{
return Foam::Hasher(&obj, sizeof(T), 0u);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
{
typedef unsigned Type;
Type value = 100;
Info<< "hash " << typeid(value).name() << " of " << value << nl;
Info<< " Hasher: " << rawHasher(value) << nl;
Info<< " Hash<>: " << Hash<Type>()(value) << nl;
}
{
typedef int32_t Type;
Type value = 100;
Info<< "hash " << typeid(value).name() << " of " << value << nl;
Info<< " Hasher: " << rawHasher(value) << nl;
Info<< " Hash<>: " << Hash<Type>()(value) << nl;
}
{
typedef int64_t Type;
Type value = 100;
Info<< "hash " << typeid(value).name() << " of " << value << nl;
Info<< " Hasher: " << rawHasher(value) << nl;
Info<< " Hash<>: " << Hash<Type>()(value) << nl;
}
HashFun<std::string>().info();
HashFun<string>().info();
HashFun<Foam::word>().info();
HashFun<Foam::keyType>().info();
HashFun<int>().info();
HashFun<label>().info();
HashFun<float>().info();
HashFun<double>().info();
{
float value = 15.f;
Info<< "hash of " << Foam::name(&value)
<< " = " << HashFun<void*>()(&value) << nl;
}
HashFun<labelList>().info();
HashFun<wordUList>().info();
HashFun<edge>().info();
HashFun<Pair<label>>().info();
HashFun<labelPair>().info();
HashFun<labelPairPair>().info();
HashFun<Tuple2<label, word>>().info();
{
typedef Tuple2<label, word> Type;
Type obj(10, "test");
Info<< obj << " hash=" << Hash<Type>()(obj) << nl;
}
{
typedef Tuple2<label, label> Type;
Type obj(10, 12);
Info<< obj << " hash=" << Hash<Type>()(obj) << nl;
}
{
typedef Pair<label> Type;
Type obj(10, 12);
Info<< obj << " hash=" << Hash<Type>()(obj) << nl;
}
{
typedef std::pair<label, label> Type;
Type obj(10, 12);
Info<< obj << " hash=" << Hash<Type>()(obj) << nl;
HashSet<Type> hs;
hs.insert(obj);
hs.erase(obj);
}
{
Pair<label>::hasher op;
Info<< "hasher: " << op(Pair<label>(10, 12)) << nl;
}
// Not supported
#if 0
{
Tuple2<label, label>::hasher op;
Info<< "hasher: " << op(Tuple2<label>(10, 12)) << nl;
}
#endif
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //

View File

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

View File

@ -1,3 +0,0 @@
EXE_INC = ${c++LESSWARN}
/* EXE_LIBS = */

View File

@ -1,343 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-Hashing2
Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "stringList.H"
#include "labelList.H"
#include "labelPair.H"
#include "wordPair.H"
#include "edgeList.H"
#include "faceList.H"
#include "triFaceList.H"
#include "Hash.H"
#include "HashSet.H"
using namespace Foam;
void infoHashString
(
unsigned modulus,
std::initializer_list<std::string> lst
)
{
if (modulus)
{
Info<< "basic string hashing (mod " << label(modulus) << ")" << nl;
for (const auto& str : lst)
{
Info<<"hash(" << str.c_str() << ")="
<< (Hash<string>()(str) % modulus) << nl;
}
}
else
{
Info<< "basic string hashing" << nl;
for (const auto& str : lst)
{
Info<<"hash(" << str.c_str() << ")="
<< Hash<string>()(str) << nl;
}
}
}
void reportHashList(const UList<string>& list)
{
Info<< "contiguous = " << is_contiguous<string>::value << nl << nl;
for (const string& val : list)
{
unsigned hash1 = string::hasher()(val);
Info<< hex << hash1 << ": " << val << nl;
}
}
void reportHashList(const UList<label>& list)
{
Info<<"contiguous = " << is_contiguous<label>::value << nl << nl;
for (const label val : list)
{
// Direct value
unsigned hash1 = Hash<label>()(val);
// Hashed byte-wise
unsigned hash2 = Hash<label>()(val, 0);
Info<< hex << hash1
<< " (seeded: " << hash2 << ")"
<< ": " << dec << val << nl;
}
}
void reportHashList(const UList<face>& list)
{
Info<<"contiguous = " << is_contiguous<label>::value << nl << nl;
for (const face& f : list)
{
// Direct value
unsigned hash1 = face::hasher()(f);
unsigned hash2 = Hash<face>()(f);
Info<< hex << "face hash " << hash1
<< " Hash<face> " << hash2
<< ": " << dec << flatOutput(f) << nl;
}
}
void reportHashList(const UList<labelList>& list)
{
for (const labelList& val : list)
{
unsigned hash1 = Foam::Hasher(val.cdata(), val.size_bytes());
unsigned hash2 = Hash<labelList>()(val);
unsigned hash2b = labelList::hasher()(val);
Info<< hex << hash1 << " or " << hash2
<< "(" << hash2b << ") "
<< ": " << dec << val << nl;
}
unsigned hash2 = Hash<labelListList>()(list);
unsigned hash2bad = Foam::Hasher(&list, sizeof(list));
Info<< hex << hash2 << " : " << dec << flatOutput(list) << nl
<< hex << hash2bad << " as direct hash would be wrong"
<< dec << nl;
}
void reportHashList(const UList<wordPair>& list)
{
Info<<"contiguous = " << is_contiguous<wordPair>::value << nl << nl;
for (const wordPair& pr : list)
{
unsigned hash1 = Hash<wordPair>()(pr);
// as FixedList
unsigned hash2 = wordPair::hasher()(pr);
// as FixedList
unsigned hash2sym = wordPair::symmHasher()(pr);
// as FixedList
unsigned hash3 = Hash<FixedList<word,2>>()(pr);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< ") or " << hash3
<< " symm-hash:" << hash2sym
<< " : "<< dec << flatOutput(pr) << nl;
}
}
void reportHashList(const UList<labelPair>& list)
{
Info<<"contiguous = " << is_contiguous<labelPair>::value << nl << nl;
for (const labelPair& pr : list)
{
unsigned hash1 = Hash<labelPair>()(pr);
// as FixedList
unsigned hash2 = labelPair::hasher()(pr);
// as FixedList
unsigned hash3 = Hash<labelPair>()(pr);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< ") or " << hash3
<< " : "<< dec << pr << nl;
}
}
void reportHashList(const UList<labelPairPair>& list)
{
Info<<"contiguous = " << is_contiguous<labelPairPair>::value << nl << nl;
for (const labelPairPair& pr : list)
{
unsigned hash1 = Hash<labelPairPair>()(pr);
// as FixedList
unsigned hash2 = labelPairPair::hasher()(pr);
// as FixedList
unsigned hash3 = Hash<labelPairPair>()(pr);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< ") or " << hash3
<< " : "<< dec << pr << nl;
}
}
void reportHashList(const UList<edge>& list)
{
Info<<"contiguous = " << is_contiguous<edge>::value << nl << nl;
for (const edge& e : list)
{
unsigned hash1 = Hash<edge>()(e);
// as FixedList
unsigned hash2 = labelPair::hasher()(e);
// as FixedList
unsigned hash3 = Hash<labelPair>()(e);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< ") or " << hash3
<< " : "<< dec << e << nl;
}
}
void reportHashList(const UList<triFace>& list)
{
Info<<"contiguous = " << is_contiguous<triFace>::value << nl << nl;
for (const triFace& f : list)
{
// direct value
unsigned hash1 = Hash<triFace>()(f);
unsigned hash2 = FixedList<label, 3>::hasher()(f);
Info<< hex << hash1 << " (as FixedList: " << hash2
<< "): " << dec << f << nl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
infoHashString(8, {"asdathis1", "adsxf", "hij", "klmpq"});
IFstream is("hashingTests");
if (is.good())
{
Info<< nl << "Process " << is.name() << " file ..." << nl;
}
else
{
Info<< nl << "No " << is.name() << " file found ..." << nl;
}
token tok;
while (is.good() && is.read(tok) && tok.good())
{
const word listType(tok.wordToken());
Info<< nl;
IOobject::writeDivider(Info) << listType << nl;
if (listType == "stringList")
{
stringList list(is);
reportHashList(list);
}
else if (listType == "labelList")
{
labelList list(is);
reportHashList(list);
}
else if (listType == "faceList")
{
faceList list(is);
reportHashList(list);
}
else if (listType == "labelListList")
{
List<labelList> list(is);
reportHashList(list);
}
else if (listType == "wordPairList")
{
List<wordPair> list(is);
reportHashList(list);
}
else if (listType == "labelPairList")
{
labelPairList list(is);
reportHashList(list);
}
else if (listType == "labelPairPairList")
{
List<labelPairPair> list(is);
reportHashList(list);
}
else if (listType == "edgeList")
{
edgeList list(is);
reportHashList(list);
}
else if (listType == "triFaceList")
{
triFaceList list(is);
reportHashList(list);
}
else
{
Info<< "unknown type: " << listType << nl;
}
}
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //

View File

@ -3,8 +3,8 @@
#include "Hasher.H"
#include "int.H"
#include <cstdio>
#include <ctime>
#include <stdio.h>
#include <time.h>
#ifndef CLOCKS_PER_SEC
#ifdef CLK_TCK
@ -1048,7 +1048,7 @@ int32_t i;
struct tagtest {
double res;
const char * name;
char * name;
hashFn hash;
} tests[] = {
// { 0.0, "CRC32\t\t", GetCRC32 },

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -89,15 +89,15 @@ void writeAndRead
const IOobject& io,
const label sz,
const word& writeType,
const IOobject::readOption rOpt,
const IOobject::readOption readOpt,
const word& readType
)
{
Pout<< "** Writing:" << writeType
<< " Reading:" << readType << endl;
// The write handler
fileHandler(fileOperation::New(writeType, true));
autoPtr<fileOperation> writeHandler(fileOperation::New(writeType, true));
fileHandler(writeHandler);
// Delete
Pout<< "Deleting:" << fileHandler().filePath(io.objectPath()) << endl;
@ -107,12 +107,12 @@ void writeAndRead
Pout<< "Writing:" << fileHandler().objectPath(io, io.name()) << endl;
doWrite<Type>(io, sz);
// The read handler
fileHandler(fileOperation::New(readType, true));
autoPtr<fileOperation> readHandler(fileOperation::New(readType, true));
fileHandler(readHandler);
// Read
IOobject readIO(io);
readIO.readOpt(rOpt);
readIO.readOpt() = readOpt;
Pout<< "Reading:"
<< fileHandler().filePath(readIO.objectPath()) << endl;
doRead<Type>(readIO, sz);
@ -130,11 +130,12 @@ void readIfPresent
const word& readType
)
{
fileHandler(fileOperation::New(readType, true));
autoPtr<fileOperation> readHandler(fileOperation::New(readType, true));
fileHandler(readHandler);
// Read
Pout<< "Reading:" << fileHandler().filePath(io.objectPath()) << endl;
io.readOpt(IOobject::READ_IF_PRESENT);
io.readOpt() = IOobject::READ_IF_PRESENT;
doRead<Type>(io, sz);
}
@ -177,7 +178,6 @@ void doTests(IOobject& io, const label sz)
int main(int argc, char *argv[])
{
argList::noBanner();
argList::addBoolOption("bool", "Use bool for tests");
argList::addBoolOption("scalar", "Use scalar for tests");
argList::addBoolOption("label", "Use label for tests (default)");
@ -209,11 +209,6 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
);
{
dictionary headerDict;
io.writeHeader(headerDict, "anything", IOstreamOption());
Info<< "IOobjectHeader" << headerDict << nl;
}
label tested = 0;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -78,7 +78,7 @@ void printTokens(Istream& is)
if (t.good())
{
++count;
Info<< "token: " << t << endl;
Info<<"token: " << t << endl;
}
}
@ -86,28 +86,14 @@ void printTokens(Istream& is)
}
Ostream& reportPeek(const ITstream& is)
{
Info<< " index : " << is.tokenIndex() << nl
<< " peek : " << is.peek().info() << nl;
return Info;
}
template<class BUF>
void doTest
(
const string& name,
const BUF& input,
bool verbose = false,
bool testskip = false
)
void doTest(const string& name, const BUF& input, bool verbose=false)
{
Info<< "test " << name.c_str() << ":" << nl
<< "====" << nl;
Info<<"test " << name.c_str() << ":" << nl
<<"====" << nl;
toString(Info, input)
<< nl
<< "====" << nl << endl;
<<"====" << nl << endl;
ITstream its(name, input);
Info<< "got " << its.size() << " tokens - index at "
@ -121,35 +107,6 @@ void doTest
}
Info<< nl;
}
if (testskip)
{
Info<< " first : " << its.peekFirst().info() << nl
<< " last : " << its.peekLast().info() << nl;
Info<< "rewind():" << nl;
reportPeek(its);
its.skip(3);
Info<< "skip(3):" << nl;
reportPeek(its);
its.skip(2);
Info<< "skip(2):" << nl;
reportPeek(its);
its.skip(-2);
Info<< "skip(-2):" << nl;
reportPeek(its);
its.skip(100);
Info<< "skip(100):" << nl;
reportPeek(its);
its.skip(-1000);
Info<< "skip(-1000):" << nl;
reportPeek(its);
}
}
@ -159,16 +116,14 @@ void doTest
int main(int argc, char *argv[])
{
const char* charInput =
"( const char input \"string\" to tokenize )\n"
"( const char input \"string\" to tokenize )"
"List<label> 5(0 1 2 3 4);";
string stringInput("( string ; input \"string\" to tokenize )");
List<char> listInput(stringInput.cbegin(), stringInput.cend());
doTest("empty", "", true, true);
doTest("char*", charInput, true, true);
doTest("char*", charInput, true);
doTest("string", stringInput, true);
doTest("List<char>", listInput, true);

View File

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

View File

@ -1,74 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Test LabelledItem (formerly 'Keyed', but that was never used)
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "edge.H"
#include "LabelledItem.H"
#include "List.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
typedef LabelledItem<edge> labelledEdge;
List<labelledEdge> edges(10);
forAll(edges, edgei)
{
auto& e = edges[edgei];
e.insert(20-edgei);
e.insert(edgei);
if (!(edgei % 3))
{
e.setIndex(edgei);
}
}
Info<< "edges: " << edges << nl;
Foam::sort(edges);
Info<< "sorted: " << edges << nl;
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,9 +55,6 @@ See also
#include <numeric>
#include <functional>
// see issue #2083
#undef Foam_constructList_from_iterators
namespace Foam
{
@ -257,12 +254,8 @@ int main(int argc, char *argv[])
Info<< "list4: " << list4 << nl
<< "list5: " << list5 << endl;
#ifdef Foam_constructList_from_iterators
List<vector> list6(list4.begin(), list4.end());
Info<< "list6: " << list6 << endl;
#else
Info<< "NOTE: no construction from two iterators" << endl;
#endif
// Subset
const labelList map{0, 2};
@ -280,13 +273,9 @@ int main(int argc, char *argv[])
// scalarList slist = identity(15);
//
// More writing, but does work:
#ifdef Foam_constructList_from_iterators
scalarList slist(labelRange().begin(), labelRange(15).end());
Info<<"scalar identity:" << flatOutput(slist) << endl;
#else
Info<<"No iterator means of creating a scalar identity list" << endl;
#endif
printListOutputType<label>("labels") << nl;
@ -395,7 +384,6 @@ int main(int argc, char *argv[])
}
Info<< "sub-sorted: " << flatOutput(longLabelList) << nl;
#ifdef Foam_constructList_from_iterators
// Construct from a label-range
labelRange range(25,15);
@ -418,10 +406,6 @@ int main(int argc, char *argv[])
// Even weird things like this
List<scalar> sident4(labelRange().begin(), labelRange(8).end());
Info<<"range-list (scalar)=" << sident4 << nl;
#else
Info<< "NOTE: no construction of labelList from range pair" << nl
<< "use identity(...) instead" << endl;
#endif
}
wordReList reLst;
@ -674,11 +658,11 @@ int main(int argc, char *argv[])
Info<<"hash of " << flatOutput(list1)
<< " = " << Hash<labelList>()(list1) << " or "
<< labelList::hasher()(list1) << nl;
<< labelList::Hash<>()(list1) << nl;
Info<<"hash of " << flatOutput(list2) << " = "
<< Hash<labelList>()(list2) << " or "
<< labelList::hasher()(list2) << nl;
<< labelList::Hash<>()(list2) << nl;
}
return 0;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,7 +101,7 @@ int main(int argc, char *argv[])
{
if (true)
{
IFstream is(args.get<fileName>(argi));
IFstream is(args[argi]);
Info<< nl << nl
<< "read from " << is.name() << nl << endl;
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
if (true)
{
IFstream is(args.get<fileName>(argi));
IFstream is(args[argi]);
Info<< nl << nl
<< "read from " << is.name() << nl << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2013 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
std::for_each(test6.begin(), test6.end(), [](label& x){ x *= 3; });
// Randomize the list
Foam::shuffle(test6);
std::random_shuffle(test6.begin(), test6.end());
Info<< "randomized input list: " << flatOutput(test6) << nl;
@ -160,7 +160,7 @@ int main(int argc, char *argv[])
// List reorder
labelList oldToNew(identity(40));
Foam::shuffle(oldToNew);
std::random_shuffle(oldToNew.begin(), oldToNew.end());
// Force a few -1:
oldToNew[4] = oldToNew[8] = -1;
@ -192,9 +192,9 @@ int main(int argc, char *argv[])
)
);
Info<< "packed input: " << packed << nl;
Info<<"packed input: " << flatOutput(packed) << nl;
inplaceReorder(oldToNew, packed);
Info<<" reorder: " << packed << nl << nl;
Info<<" reorder: " << flatOutput(packed) << nl << nl;
Info<< "\nEnd\n" << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,7 +57,7 @@ Ostream& operator<<
);
template<class T, class Key, class Hash=Foam::Hash<Key>>
template<class T, class Key, class Hash>
class HashSorter
{
const HashTable<T, Key, Hash>& table;
@ -219,8 +219,8 @@ int main(int argc, char *argv[])
Info<< nl << "Test inplaceMapValue" << nl << nl;
HashTable<label> input;
typedef HashSorter<label, label> Mapper;
typedef HashSorter<label, word> Sorter;
typedef HashSorter<label, label, Hash<label>> Mapper;
typedef HashSorter<label, word, string::hash> Sorter;
for (label i=0; i < 10; ++i)
{

View File

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

View File

@ -1 +0,0 @@
EXE_INC = -I../TestTools

View File

@ -1,179 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-MathFunctions
Description
Tests for \c Math namespace member functions
using \c doubleScalar base type.
\*---------------------------------------------------------------------------*/
#include "MathFunctions.H"
#include "mathematicalConstants.H"
#include "IOmanip.H"
#include "TestTools.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Execute each member functions of Foam::Math::, and print output
template<class Type>
void test_member_funcs(Type)
{
Random rndGen(1234);
const label numberOfTests = 10000;
const scalar tolerance = 1e-3;
for (label i = 0; i < numberOfTests; ++i)
{
Info<< "# Inverse error functions:" << endl;
const Type x1 = rndGen.sample01<Type>();
const Type x2 = rndGen.sample01<Type>();
Info<< " # Operands:" << nl
<< " x1 = " << x1 << nl
<< " x2 = " << x2 << endl;
cmp
(
" # erf(erfinv(x1)) = x1 = ",
x1,
Foam::erf(Foam::Math::erfInv(x1)),
tolerance
);
cmp
(
" # erf(erfinv(-x2)) = -x2 = ",
x2,
Foam::erf(Foam::Math::erfInv(x2)),
tolerance
);
Info<< "# Incomplete gamma functions:" << endl;
const Type a = rndGen.position(SMALL, Type(100));
const Type x = rndGen.position(Type(0), Type(100));
Info<< " # Operands:" << nl
<< " a = " << a << nl
<< " x = " << x << endl;
cmp
(
" # incGammaRatio_Q(a,x) + incGammaRatio_P(a,x) = 1 = ",
Foam::Math::incGammaRatio_Q(a,x) + Foam::Math::incGammaRatio_P(a,x),
scalar(1),
tolerance
);
cmp
(
" # incGamma_Q(1, x) = exp(-x) = ",
Foam::Math::incGamma_Q(1, x),
Foam::exp(-x),
tolerance
);
cmp
(
" # incGamma_Q(0.5, x) = sqrt(pi)*erfc(sqrt(x)) = ",
Foam::Math::incGamma_Q(0.5, x),
Foam::sqrt(Foam::constant::mathematical::pi)
*Foam::erfc(Foam::sqrt(x)),
tolerance
);
cmp
(
" # incGamma_P(1,x) = 1 - exp(x) = ",
Foam::Math::incGamma_P(1, x),
1 - Foam::exp(-x),
tolerance
);
cmp
(
" # incGamma_P(0.5, x) = sqrt(pi)*erf(sqrt(x)) = ",
Foam::Math::incGamma_P(0.5, x),
Foam::sqrt(Foam::constant::mathematical::pi)
*Foam::erf(Foam::sqrt(x)),
tolerance
);
}
}
// Do compile-time recursion over the given types
template<std::size_t I = 0, typename... Tp>
inline typename std::enable_if<I == sizeof...(Tp), void>::type
run_tests(const std::tuple<Tp...>& types, const List<word>& typeID){}
template<std::size_t I = 0, typename... Tp>
inline typename std::enable_if<I < sizeof...(Tp), void>::type
run_tests(const std::tuple<Tp...>& types, const List<word>& typeID)
{
Info<< nl << " ## Test member functions: "<< typeID[I] <<" ##" << nl;
test_member_funcs(std::get<I>(types));
run_tests<I + 1, Tp...>(types, typeID);
}
// * * * * * * * * * * * * * * * Main Program * * * * * * * * * * * * * * * //
int main()
{
Info<< setprecision(15);
const std::tuple<doubleScalar> types
(
std::make_tuple(Zero)
);
const List<word> typeID
({
"doubleScalar"
});
run_tests(types, typeID);
if (nFail_)
{
Info<< nl << " #### "
<< "Failed in " << nFail_ << " tests "
<< "out of total " << nTest_ << " tests "
<< "####\n" << endl;
return 1;
}
Info<< nl << " #### Passed all " << nTest_ <<" tests ####\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -105,18 +105,6 @@ int main(int argc, char *argv[])
printInfo(os1);
printInfo(os2);
printInfo(os3);
// Rewind and test single output
os1.rewind(); generateOutput(os1);
os2.rewind(); generateOutput(os2);
os3.rewind(); generateOutput(os3);
Info<< nl
<< "single output" << nl;
printInfo(os1);
printInfo(os2);
printInfo(os3);
}
Info<< "\nEnd\n" << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -214,7 +214,7 @@ int main(int argc, char *argv[])
{
OListStream os2;
os2.indentSize(0);
os2.indentSize() = 0;
outputDict(os2);

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -126,9 +125,9 @@ int main(int argc, char *argv[])
}
for (label argi=1; argi < args.size(); ++argi)
for (label argI=1; argI < args.size(); ++argI)
{
const auto srcFile = args.get<fileName>(argi);
const string& srcFile = args[argI];
Info<< nl << "reading " << srcFile << nl;
IFstream ifs(srcFile);

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,13 +49,11 @@ int main(int argc, char *argv[])
#include "createTime.H"
#include "createPolyMesh.H"
const wordRes patchSelection(args.getList<wordRe>(1));
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
labelList patchIDs
(
pbm.patchSet(patchSelection).sortedToc()
pbm.patchSet(args.getList<wordRe>(1)).sortedToc()
);
Info<< "Starting walk from patches "

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,10 +30,6 @@ Description
using namespace Foam;
#include "floatScalar.H"
#include "doubleScalar.H"
#include "complex.H"
#include "Matrix.H"
#include "Random.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -62,9 +62,7 @@ void testFind(const T& val, const ListType& lst)
int main(int argc, char *argv[])
{
labelList completeList(20);
labelList scratch(20);
scratch = -1;
List<label> completeList(20);
forAll(completeList, i)
{
@ -73,24 +71,12 @@ int main(int argc, char *argv[])
Info<< "raw : " << flatOutput(completeList) << nl << endl;
List<label> addresses({ 1, 0, 3, 7, 4, 8, 5, 1, 0, 3, 7, 4, 8, 5 });
List<label> addresses{1, 0, 3, 7, 4, 8, 5, 1, 0, 3, 7, 4, 8, 5, };
labelUIndList idl1(completeList, addresses);
printInfo(idl1);
labelList::subList slice(scratch, idl1.size());
slice = idl1;
Info<< "sliced: " << flatOutput(slice) << nl;
Info<< "scratch: " << flatOutput(scratch) << nl;
// Again, but offset and using intermediate only
scratch = -1;
labelList::subList(scratch, idl1.size(), 5) = idl1;
Info<< "offset: " << flatOutput(scratch) << nl;
for (const label val : { 10, 30, 40, 50, 90, 80, 120 } )
{
testFind(val, idl1);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,8 +37,6 @@ Description
#include "HashSet.H"
#include "ListOps.H"
#include "cpuTime.H"
#include "StringStream.H"
#include "FlatOutput.H"
#include <vector>
#include <unordered_set>
@ -67,28 +65,6 @@ inline Ostream& report
}
// Create equivalent to flat output
inline void undecorated
(
Ostream& os,
const bitSet& list
)
{
const label len = list.size();
os << token::BEGIN_LIST;
// Contents
for (label i=0; i < len; ++i)
{
if (i) os << token::SPACE;
os << label(list.get(i));
}
os << token::END_LIST;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
@ -121,28 +97,6 @@ int main(int argc, char *argv[])
Info<<"bits used: " << flatOutput(set3b.toc()) << nl;
Info<<"inverted: " << flatOutput(invert(set3b)) << nl;
Info<< "Test read/write (ASCII)" << nl;
OStringStream ostr;
undecorated(ostr, set3a); // like flatOutput
ostr << bitSet();
set3a.flip();
undecorated(ostr, set3a); // like flatOutput
{
IStringStream istr(ostr.str());
Info<< "parse: " << istr.str() << nl;
bitSet bset1(istr);
bitSet bset2(istr);
bitSet bset3(istr);
Info<< "got: " << bset1 << nl
<< "and: " << bset2 << nl
<< "and: " << bset3 << nl;
}
}
Info<< "End\n" << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -370,6 +370,7 @@ int main(int argc, char *argv[])
(
ITstream
(
"input",
"(1 n 1 n 1 n 1 1 off 0 0 f f 0 y yes y true y false on t)"
)()
);

View File

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

View File

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

View File

@ -1,87 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-charList
Description
Some test of UList, List for characters
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "argList.H"
#include "IOstreams.H"
#include "messageStream.H"
#include "charList.H"
#include "labelList.H"
#include "StringStream.H"
#include "ListOps.H"
#include "SubList.H"
#include "FlatOutput.H"
#include <numeric>
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::noFunctionObjects();
#include "setRootCase.H"
Info<< "Known compound tokens: "
<< token::compound::IstreamConstructorTablePtr_->sortedToc() << nl;
OStringStream ostr;
{
List<char> alphabet(64);
std::iota(alphabet.begin(), alphabet.end(), '@');
alphabet.writeEntry("alphabet", Info);
ostr << alphabet;
Info<< "wrote: " << ostr.str() << nl;
}
{
IStringStream istr(ostr.str());
List<char> alphabet(istr);
Info<< "re-read: " << alphabet << nl;
}
return 0;
}
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,8 +55,12 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::noBanner();
#include "addAllRegionOptions.H"
#include "addRegionOption.H"
argList::addBoolOption
(
"allRegions",
"operate on all regions in regionProperties"
);
argList::addBoolOption
(
"verbose",
@ -70,12 +74,14 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const auto decompFile = args.get<fileName>(1);
const fileName decompFile = args[1];
const bool region = args.found("region");
const bool allRegions = args.found("allRegions");
const bool verbose = args.found("verbose");
// Set time from database
#include "createTime.H"
// Allow override of time
instantList times = timeSelector::selectIfPresent(runTime, args);
@ -83,20 +89,42 @@ int main(int argc, char *argv[])
const fileName decompDictFile =
args.getOrDefault<fileName>("decomposeParDict", "");
// Get region names
#include "getAllRegionOptions.H"
wordList regionNames;
wordList regionDirs;
if (allRegions)
{
Info<< "Decomposing all regions in regionProperties" << nl << endl;
regionProperties rp(runTime);
forAllConstIters(rp, iter)
{
const wordList& regions = iter();
forAll(regions, i)
{
if (!regionNames.found(regions[i]))
{
regionNames.append(regions[i]);
}
}
}
regionDirs = regionNames;
}
else
{
regionNames.resize(1, fvMesh::defaultRegion);
regionDirs.resize(1, word::null);
if (args.readIfPresent("region", regionNames.first()))
{
regionDirs.first() = regionNames.first();
}
}
labelList cellToProc;
forAll(regionNames, regioni)
{
const word& regionName = regionNames[regioni];
// const word& regionDir =
// (
// regionName != polyMesh::defaultRegion
// ? regionName
// : word::null
// );
const word& regionDir = regionDirs[regioni];
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
Info<< "Create mesh..." << flush;

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,9 +59,9 @@ int main(int argc, char *argv[])
else
{
IOobject::writeDivider(Info);
for (label argi=1; argi < args.size(); ++argi)
for (label argI=1; argI < args.size(); ++argI)
{
const auto dictFile = args.get<fileName>(argi);
const string& dictFile = args[argI];
IFstream is(dictFile);
dictionary dict(is);

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -179,7 +179,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi)
{
const auto dictFile = args.get<fileName>(argi);
const string& dictFile = args[argi];
IFstream is(dictFile);
dictionary inputDict(is);
@ -201,7 +201,7 @@ int main(int argc, char *argv[])
{
for (label argi=1; argi < args.size(); ++argi)
{
const auto dictFile = args.get<fileName>(argi);
const string& dictFile = args[argi];
IFstream is(dictFile);
dictionary inputDict(is);

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2106 |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -135,8 +135,8 @@ int main(int argc, char *argv[])
args.readIfPresent("maxPath", maxPath);
#endif
const auto srcFile = args.get<fileName>(1);
const auto dstFile = args.get<fileName>(2);
const fileName srcFile(fileName::validate(args[1]));
const fileName dstFile(fileName::validate(args[2]));
const fileName tmpFile(dstFile + Foam::name(pid()));
Info<< "src : " << srcFile << nl

View File

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

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