Compare commits
317 Commits
wip-develo
...
feature-st
| Author | SHA1 | Date | |
|---|---|---|---|
| 798a9dd9b1 | |||
| fe1e056196 | |||
| 9d291ab4cc | |||
| 0e11f47f74 | |||
| 698e05eeb3 | |||
| 2395e493d1 | |||
| 12916cd7a3 | |||
| b66369fb37 | |||
| b236e1493c | |||
| a6744d0814 | |||
| 1e2858e8cb | |||
| 09d86dc02b | |||
| 36f8542e01 | |||
| 886ba89ddb | |||
| 778796853d | |||
| 224c3199aa | |||
| e4f2efec18 | |||
| 3630333526 | |||
| 97668eab26 | |||
| b620152191 | |||
| 03ca52b036 | |||
| 11a1f78338 | |||
| 268de43afc | |||
| 43f8b477b7 | |||
| bbbab8a9c2 | |||
| 2422e6f061 | |||
| eeb9d144e3 | |||
| fabd3f4e0c | |||
| 7828067ef6 | |||
| 53b3fff7d5 | |||
| 066a5a997a | |||
| 4daaf6dd2a | |||
| 944840f8d6 | |||
| 1340bc50bd | |||
| 97a42df7ba | |||
| 5eacd8257b | |||
| aad4c2222e | |||
| 14f7d44ca0 | |||
| db39f196cc | |||
| 2fc2d1f95f | |||
| db16d80840 | |||
| d65e2d89b5 | |||
| dc95242cd2 | |||
| ed314b2740 | |||
| 5397c9ac04 | |||
| 129b738136 | |||
| 0eb4354ee0 | |||
| f18a29a742 | |||
| 36161e682a | |||
| a3ec19c344 | |||
| 4dfafc3c36 | |||
| 945e3e41b1 | |||
| 76efcba4c7 | |||
| 7cae3b9660 | |||
| 8117cde596 | |||
| 63258d0b33 | |||
| 5e334c0686 | |||
| 32903d337e | |||
| f717f79833 | |||
| 3430ab3aa8 | |||
| 779c3fe11e | |||
| 8562f4d7a4 | |||
| 65cddb6120 | |||
| 95b820368c | |||
| ab0d4d95ff | |||
| a8df552998 | |||
| edb455ca97 | |||
| ae6de092d5 | |||
| 69dae2e008 | |||
| 63753605a0 | |||
| 7a29eb9b3b | |||
| 4db98e5de4 | |||
| 115bbd2699 | |||
| 8ee4b52560 | |||
| f398d7b313 | |||
| a1e34bb251 | |||
| 0d456a4c66 | |||
| 728527a345 | |||
| 5635e14f81 | |||
| fc2760ab9c | |||
| f8987e64ed | |||
| a215f94ec4 | |||
| d5a0eaeeee | |||
| 7a857b318a | |||
| 763bf4674d | |||
| 2d145e070e | |||
| beb0c910a0 | |||
| 664e8e0060 | |||
| 7b20e888a8 | |||
| c4b4d1e03e | |||
| 4d7c827bd7 | |||
| d6d319d95a | |||
| f93b4338d5 | |||
| c9645e61a6 | |||
| b264d2e913 | |||
| c3660b4123 | |||
| 642d8a9dfa | |||
| 2afd2320ce | |||
| 7edacd3ab0 | |||
| 6a1e56e6e9 | |||
| 360aad19dc | |||
| a3e6af8fcf | |||
| 183e9511e5 | |||
| c5c7f2b7fe | |||
| d5ed01dc70 | |||
| 3dee3438d5 | |||
| 0411a75e24 | |||
| 4a5f542cb4 | |||
| d3419e4e56 | |||
| da98104a79 | |||
| aaf1fcf460 | |||
| c6741f5073 | |||
| 09edb23c1d | |||
| 32386d0b39 | |||
| 3de090e602 | |||
| 67bd9119ee | |||
| 97459771ad | |||
| fc86e52451 | |||
| e54ead28e8 | |||
| 34f12219bd | |||
| f9d0895707 | |||
| 4412566c58 | |||
| b2217d5e6b | |||
| 66a2894da8 | |||
| 979b5a20cd | |||
| 41cb168649 | |||
| 5894e6ee8b | |||
| 0f2bbbcbbe | |||
| 4c86664aba | |||
| ee26a36add | |||
| 8f46e47931 | |||
| 40d6ba19b1 | |||
| f1f797a815 | |||
| f4cc4d7652 | |||
| d2e8c75dc9 | |||
| 67c5e63819 | |||
| 789db1d554 | |||
| bfcf3b2ac4 | |||
| 246d927573 | |||
| 188c303a27 | |||
| 528c5ed8eb | |||
| f584ec97d0 | |||
| 83b1ebee6f | |||
| ffbd05f72a | |||
| 9489a5a101 | |||
| a8cec219c3 | |||
| f4df00a4e9 | |||
| 1cdba9b269 | |||
| b87db82c05 | |||
| dbba89fc92 | |||
| e92975075a | |||
| f096c34a80 | |||
| 57c50bda79 | |||
| b13c2c042f | |||
| 1c9ea038d0 | |||
| 60fc3906dc | |||
| 2ac4e5f4d6 | |||
| 3455d67d7f | |||
| 7bc3bc9194 | |||
| 68c44f3219 | |||
| 9b5b5ecc75 | |||
| f55adf6c5d | |||
| c8e224b598 | |||
| ddf96afdfe | |||
| 2eb2de5f8e | |||
| c177637db2 | |||
| f0fca75726 | |||
| e566142f8a | |||
| 6a66a15b8f | |||
| 0680d0c553 | |||
| adc38d55ac | |||
| 113fe48d0e | |||
| d94744e9f7 | |||
| dcf005508b | |||
| fcbfa40b0b | |||
| 30dc465615 | |||
| 4984153d2d | |||
| 8d2bf3fc2e | |||
| 8a060e87cb | |||
| d34dfbe0b7 | |||
| a34262966b | |||
| 5284bc3019 | |||
| 73f6c7fe28 | |||
| 401c6646be | |||
| 821d395259 | |||
| 06147dabe7 | |||
| 336422e00b | |||
| abc60d4d20 | |||
| 19254d0cf2 | |||
| 8320a1e421 | |||
| 11742301f1 | |||
| 1abea53d1a | |||
| 16064b60e2 | |||
| 505704d290 | |||
| 9cd14bc8b0 | |||
| f15e58d3d5 | |||
| 5eebc75845 | |||
| b687c4927c | |||
| b45ea8c2aa | |||
| a64357983c | |||
| 302eb7b560 | |||
| 6d76b31f29 | |||
| bc51caac32 | |||
| 28ac15f933 | |||
| f41d1879b9 | |||
| bdd384c767 | |||
| 87cb811db2 | |||
| a5d9ad3a5c | |||
| a0005c3a54 | |||
| f7a7f1c14c | |||
| a581a8cb8d | |||
| 521043094e | |||
| 687a9528b0 | |||
| 5aeb02e23d | |||
| 59b1cf080e | |||
| f98ecb38dc | |||
| fe50b745ae | |||
| 8dee603193 | |||
| c7e5e7f4a2 | |||
| efe8220a26 | |||
| 7269cc1d3b | |||
| d92583f4b6 | |||
| e9160673a1 | |||
| d069ffa16a | |||
| c7fc4891ae | |||
| 62a68eeea0 | |||
| 139a8fc6ff | |||
| e8bcf4cb1b | |||
| 3d091a0d6a | |||
| b3fa59db92 | |||
| b62e4b06fa | |||
| 783934ccad | |||
| 1bef57d018 | |||
| 31600c96d4 | |||
| f462a850ce | |||
| dfa5c05a16 | |||
| 1685e8e418 | |||
| 2df90880d6 | |||
| 8e32db2b5f | |||
| 16591012e9 | |||
| bddda09a08 | |||
| 98c42479f6 | |||
| 52b225b6d5 | |||
| c6f528588b | |||
| 2eb1f5678d | |||
| 50f4d0444c | |||
| 639b800049 | |||
| 9d2ae3da67 | |||
| d22c206226 | |||
| fd1a70f933 | |||
| 868d6dd778 | |||
| 3e382aadea | |||
| 964cb140e2 | |||
| b0b3ec0d8e | |||
| 0ae31d4c00 | |||
| 4f7aa70ad6 | |||
| 47bb79cb75 | |||
| b664eea712 | |||
| 287025d2df | |||
| e967305ef2 | |||
| 09ce87135b | |||
| 7a5ecd70b8 | |||
| ee39e3d276 | |||
| d9533e561b | |||
| ce282dfbbf | |||
| a7c4c184b8 | |||
| 5042d1296f | |||
| 1d39cdaa17 | |||
| 2b1061420c | |||
| 7bef18a274 | |||
| 35c2b4b603 | |||
| 424f913fdd | |||
| 32df7c2e92 | |||
| 8434931c29 | |||
| b12e47d9ab | |||
| 66a7f0c9db | |||
| 80bc1db5b7 | |||
| 9d3427e0b4 | |||
| b277b913cf | |||
| 74db18a9c3 | |||
| 2cf200aef4 | |||
| a96dcf706b | |||
| 3947f3c441 | |||
| 09dd913077 | |||
| 6b16a614ca | |||
| 3d2df7cdf6 | |||
| 89e1d8c269 | |||
| 1f5cf3958b | |||
| e1cb12509e | |||
| 9fbc484cdf | |||
| 11065bb029 | |||
| aa002122c2 | |||
| 700156b4c5 | |||
| d826f9259f | |||
| d51967d728 | |||
| 5de59417f8 | |||
| 9577a0f6b5 | |||
| 475ed5cc32 | |||
| 188e61af16 | |||
| f8e05934f1 | |||
| e5e1440020 | |||
| 87eed5e3b8 | |||
| bd1e1ec9c7 | |||
| ddf9d528e2 | |||
| b339be2459 | |||
| ed89d97627 | |||
| f903707e4a | |||
| 66cae2b9d1 | |||
| 4994456a28 | |||
| 726787b0d2 | |||
| f6969631a6 | |||
| 81807646ca | |||
| 80a416d253 | |||
| e68acbe314 | |||
| 13bd644cf4 | |||
| 5614a571f2 | |||
| 4136b686ba |
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Providing details of your set-up can help us identify any issues, e.g.
|
Providing details of your set-up can help us identify any issues, e.g.
|
||||||
OpenFOAM version : v2212|v2206|v2112|v2106|v2012 etc
|
OpenFOAM version : v2306|v2212|v2206|v2112|v2106 etc
|
||||||
Operating system : ubuntu|openSUSE|centos etc
|
Operating system : ubuntu|openSUSE|centos etc
|
||||||
Hardware info : any info that may help?
|
Hardware info : any info that may help?
|
||||||
Compiler : gcc|intel|clang etc
|
Compiler : gcc|intel|clang etc
|
||||||
|
|||||||
10
Allwmake
10
Allwmake
@ -96,10 +96,12 @@ echo " ${WM_PROJECT_DIR##*/}"
|
|||||||
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
|
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
|
||||||
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
|
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
|
||||||
echo
|
echo
|
||||||
echo " api = $(etc/openfoam -show-api 2>/dev/null)"
|
|
||||||
echo " patch = $(etc/openfoam -show-patch 2>/dev/null)"
|
# The api/patch information
|
||||||
echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
|
sed -e 's/^/ /; s/=/ = /' ./META-INFO/api-info 2>/dev/null || true
|
||||||
echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
|
|
||||||
|
echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
|
||||||
|
echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
|
||||||
echo
|
echo
|
||||||
echo ========================================
|
echo ========================================
|
||||||
|
|
||||||
|
|||||||
@ -5,17 +5,22 @@ It is likely incomplete...
|
|||||||
|
|
||||||
## Contributors (alphabetical by surname)
|
## Contributors (alphabetical by surname)
|
||||||
|
|
||||||
|
- Horacio Aguerre
|
||||||
|
- Yu Ankun
|
||||||
- Tetsuo Aoyagi
|
- Tetsuo Aoyagi
|
||||||
- Akira Azami
|
- Akira Azami
|
||||||
- William Bainbridge
|
- William Bainbridge
|
||||||
- Gabriel Barajas
|
- Gabriel Barajas
|
||||||
- Kutalmis Bercin
|
- Kutalmis Bercin
|
||||||
|
- Julius Bergmann
|
||||||
- Ivor Clifford
|
- Ivor Clifford
|
||||||
- Greg Collecutt
|
- Greg Collecutt
|
||||||
- Jonathan Cranford
|
- Jonathan Cranford
|
||||||
|
- Santiago Marquez Damian
|
||||||
- Sergio Ferraris
|
- Sergio Ferraris
|
||||||
- Matej Forman
|
- Matej Forman
|
||||||
- Marian Fuchs
|
- Marian Fuchs
|
||||||
|
- Gabriel Gerlero
|
||||||
- Pawan Ghildiyal
|
- Pawan Ghildiyal
|
||||||
- Chris Greenshields
|
- Chris Greenshields
|
||||||
- Bernhard Gschaider
|
- Bernhard Gschaider
|
||||||
@ -50,8 +55,11 @@ It is likely incomplete...
|
|||||||
- Gavin Tabor
|
- Gavin Tabor
|
||||||
- Zeljko Tukovic
|
- Zeljko Tukovic
|
||||||
- Eugene De Villiers
|
- Eugene De Villiers
|
||||||
|
- Louis Vittoz
|
||||||
|
- Vuko Vukcevic
|
||||||
- Yi Wang
|
- Yi Wang
|
||||||
- Norbert Weber
|
- Norbert Weber
|
||||||
|
- Volker Weissmann
|
||||||
- Henry Weller
|
- Henry Weller
|
||||||
- Niklas Wikstrom
|
- Niklas Wikstrom
|
||||||
- Guanyang Xue
|
- Guanyang Xue
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
api=2301
|
api=2306
|
||||||
patch=230110
|
patch=0
|
||||||
|
|||||||
14
README.md
14
README.md
@ -40,9 +40,9 @@ Violations of the Trademark are monitored, and will be duly prosecuted.
|
|||||||
|
|
||||||
If OpenFOAM has already been compiled on your system, simply source
|
If OpenFOAM has already been compiled on your system, simply source
|
||||||
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
|
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
|
||||||
For example, for the OpenFOAM-v2212 version:
|
For example, for the OpenFOAM-v2306 version:
|
||||||
```
|
```
|
||||||
source /installation/path/OpenFOAM-v2212/etc/bashrc
|
source /installation/path/OpenFOAM-v2306/etc/bashrc
|
||||||
```
|
```
|
||||||
|
|
||||||
## Compiling OpenFOAM
|
## Compiling OpenFOAM
|
||||||
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
|
|||||||
to the OpenFOAM directory. For example,
|
to the OpenFOAM directory. For example,
|
||||||
```
|
```
|
||||||
/path/parent
|
/path/parent
|
||||||
|-- OpenFOAM-v2212
|
|-- OpenFOAM-v2306
|
||||||
\-- ThirdParty-v2212
|
\-- ThirdParty-v2306
|
||||||
```
|
```
|
||||||
There are, however, many cases where this simple convention is inadequate:
|
There are, however, many cases where this simple convention is inadequate:
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ There are, however, many cases where this simple convention is inadequate:
|
|||||||
operating system or cluster installation provides it)
|
operating system or cluster installation provides it)
|
||||||
|
|
||||||
* When we have changed the OpenFOAM directory name to some arbitrary
|
* When we have changed the OpenFOAM directory name to some arbitrary
|
||||||
directory name, e.g. openfoam-sandbox2212, etc..
|
directory name, e.g. openfoam-sandbox2306, etc..
|
||||||
|
|
||||||
* When we would like any additional 3rd party software to be located
|
* When we would like any additional 3rd party software to be located
|
||||||
inside of the OpenFOAM directory to ensure that the installation is
|
inside of the OpenFOAM directory to ensure that the installation is
|
||||||
@ -156,9 +156,9 @@ when locating the ThirdParty directory with the following precedence:
|
|||||||
2. PREFIX/ThirdParty-VERSION
|
2. PREFIX/ThirdParty-VERSION
|
||||||
* this corresponds to the traditional approach
|
* this corresponds to the traditional approach
|
||||||
3. PREFIX/ThirdParty-vAPI
|
3. PREFIX/ThirdParty-vAPI
|
||||||
* allows for an updated value of VERSION, *eg*, `v2212-myCustom`,
|
* allows for an updated value of VERSION, *eg*, `v2306-myCustom`,
|
||||||
without requiring a renamed ThirdParty. The API value would still
|
without requiring a renamed ThirdParty. The API value would still
|
||||||
be `2212` and the original `ThirdParty-v2212/` would be found.
|
be `2306` and the original `ThirdParty-v2306/` would be found.
|
||||||
4. PREFIX/ThirdParty-API
|
4. PREFIX/ThirdParty-API
|
||||||
* same as the previous example, but using an unadorned API value.
|
* same as the previous example, but using an unadorned API value.
|
||||||
5. PREFIX/ThirdParty-common
|
5. PREFIX/ThirdParty-common
|
||||||
|
|||||||
@ -18,6 +18,6 @@ dimensionedScalar rho("rho", dimDensity, transportProperties);
|
|||||||
|
|
||||||
scalar MaxCo =
|
scalar MaxCo =
|
||||||
max(mesh.surfaceInterpolation::deltaCoeffs()*c0).value()
|
max(mesh.surfaceInterpolation::deltaCoeffs()*c0).value()
|
||||||
*runTime.deltaT().value();
|
*runTime.deltaTValue();
|
||||||
|
|
||||||
Info<< "Max acoustic Courant Number = " << MaxCo << endl;
|
Info<< "Max acoustic Courant Number = " << MaxCo << endl;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2020,2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -132,6 +132,11 @@ void PDRkEpsilon::correct()
|
|||||||
|
|
||||||
// Update epsilon and G at the wall
|
// Update epsilon and G at the wall
|
||||||
epsilon_.boundaryFieldRef().updateCoeffs();
|
epsilon_.boundaryFieldRef().updateCoeffs();
|
||||||
|
// Push new cell values to
|
||||||
|
// coupled neighbours. Note that we want to avoid the re-updateCoeffs
|
||||||
|
// of the wallFunctions so make sure to bypass the evaluate on
|
||||||
|
// those patches and only do the coupled ones.
|
||||||
|
epsilon_.boundaryFieldRef().evaluateCoupled<coupledFvPatch>();
|
||||||
|
|
||||||
// Add the blockage generation term so that it is included consistently
|
// Add the blockage generation term so that it is included consistently
|
||||||
// in both the k and epsilon equations
|
// in both the k and epsilon equations
|
||||||
|
|||||||
@ -223,7 +223,7 @@ if (ign.ignited())
|
|||||||
volScalarField R(Gstar*XiEqStar/(XiEqStar - scalar(1)));
|
volScalarField R(Gstar*XiEqStar/(XiEqStar - scalar(1)));
|
||||||
volScalarField G(R*(XiEq - scalar(1.001))/XiEq);
|
volScalarField G(R*(XiEq - scalar(1.001))/XiEq);
|
||||||
|
|
||||||
//R *= (Gstar + 2*mag(dev(symm(fvc::grad(U)))))/Gstar;
|
//R *= (Gstar + 2*mag(devSymm(fvc::grad(U))))/Gstar;
|
||||||
|
|
||||||
// Solve for the flame wrinkling
|
// Solve for the flame wrinkling
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
if (adjustTimeStep)
|
if (adjustTimeStep)
|
||||||
{
|
{
|
||||||
runTime.setDeltaT(min(dtChem, maxDeltaT));
|
runTime.setDeltaT(min(dtChem, maxDeltaT));
|
||||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
dtChem = chemistry.solve(runTime.deltaT().value());
|
dtChem = chemistry.solve(runTime.deltaTValue());
|
||||||
scalar Qdot = chemistry.Qdot()()[0]/rho[0];
|
scalar Qdot = chemistry.Qdot()()[0]/rho[0];
|
||||||
integratedHeat += Qdot*runTime.deltaT().value();
|
integratedHeat += Qdot*runTime.deltaTValue();
|
||||||
|
|||||||
@ -105,7 +105,8 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
|||||||
|
|
||||||
if (!this->readValueEntry(dict))
|
if (!this->readValueEntry(dict))
|
||||||
{
|
{
|
||||||
fvPatchField<scalar>::operator=(patchInternalField());
|
// Fallback: set to the internal field
|
||||||
|
fvPatchField<scalar>::patchInternalField(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
refValue() = *this;
|
refValue() = *this;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> interpolate
|
|||||||
vf,
|
vf,
|
||||||
dir,
|
dir,
|
||||||
"reconstruct("
|
"reconstruct("
|
||||||
+ (reconFieldName != word::null ? reconFieldName : vf.name())
|
+ (reconFieldName.empty() ? vf.name() : reconFieldName)
|
||||||
+ ')'
|
+ ')'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ if (mesh.changing())
|
|||||||
wordList pcorrTypes
|
wordList pcorrTypes
|
||||||
(
|
(
|
||||||
p.boundaryField().size(),
|
p.boundaryField().size(),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
*mag(aMesh.edgeInterpolation::deltaCoeffs())
|
*mag(aMesh.edgeInterpolation::deltaCoeffs())
|
||||||
/rhol
|
/rhol
|
||||||
)
|
)
|
||||||
).value()*runTime.deltaT().value();
|
).value()*runTime.deltaTValue();
|
||||||
|
|
||||||
Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl;
|
Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,13 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
fam::ddt(h, Us)
|
fam::ddt(h, Us)
|
||||||
+ fam::div(phi2s, Us)
|
+ fam::div(phi2s, Us)
|
||||||
+ fam::Sp(0.0125*frictionFactor*mag(Us), Us)
|
+ fam::Sp
|
||||||
|
(
|
||||||
|
0.0125
|
||||||
|
*frictionFactor.internalField()
|
||||||
|
*mag(Us.internalField()),
|
||||||
|
Us
|
||||||
|
)
|
||||||
==
|
==
|
||||||
Gs*h
|
Gs*h
|
||||||
- fam::Sp(Sd, Us)
|
- fam::Sp(Sd, Us)
|
||||||
|
|||||||
@ -47,10 +47,10 @@ if (aMesh.nInternalEdges())
|
|||||||
);
|
);
|
||||||
|
|
||||||
CoNum = max(SfUfbyDelta/aMesh.magLe())
|
CoNum = max(SfUfbyDelta/aMesh.magLe())
|
||||||
.value()*runTime.deltaT().value();
|
.value()*runTime.deltaTValue();
|
||||||
|
|
||||||
meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe()))
|
meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe()))
|
||||||
.value()*runTime.deltaT().value();
|
.value()*runTime.deltaTValue();
|
||||||
|
|
||||||
velMag = max(mag(phis)/aMesh.magLe()).value();
|
velMag = max(mag(phis)/aMesh.magLe()).value();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,6 +47,7 @@ forAll(Us, faceI)
|
|||||||
Us[faceI].z() =
|
Us[faceI].z() =
|
||||||
Uinf.value()*0.25*R[faceI].x()*R[faceI].z()/sqr(mag(R[faceI]));
|
Uinf.value()*0.25*R[faceI].x()*R[faceI].z()/sqr(mag(R[faceI]));
|
||||||
}
|
}
|
||||||
|
Us.boundaryFieldRef().evaluateCoupled<coupledFaPatch>();
|
||||||
|
|
||||||
Us -= aMesh.faceAreaNormals()*(aMesh.faceAreaNormals() & Us);
|
Us -= aMesh.faceAreaNormals()*(aMesh.faceAreaNormals() & Us);
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ if (mesh.changing())
|
|||||||
wordList pcorrTypes
|
wordList pcorrTypes
|
||||||
(
|
(
|
||||||
p.boundaryField().size(),
|
p.boundaryField().size(),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
||||||
|
|||||||
@ -108,7 +108,7 @@ forAll(fluidRegions, i)
|
|||||||
IOobject::READ_IF_PRESENT,
|
IOobject::READ_IF_PRESENT,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
),
|
),
|
||||||
dimensionedScalar("hRef", dimLength, Zero) // uses name
|
dimensionedScalar(word::null, dimLength, Zero)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C
|
derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C
|
||||||
../solid/solidRegionDiffNo.C
|
solid/solidRegionDiffNo.C
|
||||||
chtMultiRegionTwoPhaseEulerFoam.C
|
chtMultiRegionTwoPhaseEulerFoam.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/chtMultiRegionTwoPhaseEulerFoam
|
EXE = $(FOAM_APPBIN)/chtMultiRegionTwoPhaseEulerFoam
|
||||||
|
|||||||
@ -292,8 +292,7 @@ updateCoeffs()
|
|||||||
|
|
||||||
// Since we're inside initEvaluate/evaluate there might be processor
|
// Since we're inside initEvaluate/evaluate there might be processor
|
||||||
// comms underway. Change the tag we use.
|
// comms underway. Change the tag we use.
|
||||||
int oldTag = UPstream::msgType();
|
const int oldTag = UPstream::incrMsgType();
|
||||||
UPstream::msgType() = oldTag+1;
|
|
||||||
|
|
||||||
// Get the coupling information from the mappedPatchBase
|
// Get the coupling information from the mappedPatchBase
|
||||||
const label patchi = patch().index();
|
const label patchi = patch().index();
|
||||||
@ -471,10 +470,9 @@ updateCoeffs()
|
|||||||
<< regionTypeNames_ << nl << exit(FatalError);
|
<< regionTypeNames_ << nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
mixedFvPatchScalarField::updateCoeffs();
|
UPstream::msgType(oldTag); // Restore tag
|
||||||
|
|
||||||
// Restore tag
|
mixedFvPatchScalarField::updateCoeffs();
|
||||||
UPstream::msgType() = oldTag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -221,7 +221,7 @@ forAll(fluidRegions, i)
|
|||||||
IOobject::READ_IF_PRESENT,
|
IOobject::READ_IF_PRESENT,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
),
|
),
|
||||||
dimensionedScalar("hRef", dimLength, Zero)
|
dimensionedScalar(word::null, dimLength, Zero)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -13,11 +13,11 @@ forAll(cumulativeContErrIO, i)
|
|||||||
"cumulativeContErr",
|
"cumulativeContErr",
|
||||||
runTime.timeName(),
|
runTime.timeName(),
|
||||||
"uniform",
|
"uniform",
|
||||||
mesh,
|
mesh.thisDb(),
|
||||||
IOobject::READ_IF_PRESENT,
|
IOobject::READ_IF_PRESENT,
|
||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
dimensionedScalar(dimless, Zero)
|
dimensionedScalar(word::null, dimless, Zero)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
../../solid/solidRegionDiffNo.C
|
||||||
@ -112,7 +112,7 @@ forAll(fluidRegions, i)
|
|||||||
IOobject::READ_IF_PRESENT,
|
IOobject::READ_IF_PRESENT,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
),
|
),
|
||||||
dimensionedScalar("hRef", dimLength, Zero) // uses name
|
dimensionedScalar(word::null, dimLength, Zero)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -13,11 +13,11 @@ forAll(cumulativeContErrIO, i)
|
|||||||
"cumulativeContErr",
|
"cumulativeContErr",
|
||||||
runTime.timeName(),
|
runTime.timeName(),
|
||||||
"uniform",
|
"uniform",
|
||||||
mesh,
|
mesh.thisDb(),
|
||||||
IOobject::READ_IF_PRESENT,
|
IOobject::READ_IF_PRESENT,
|
||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
dimensionedScalar(dimless, Zero)
|
dimensionedScalar(word::null, dimless, Zero)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,11 +49,11 @@ if (adjustTimeStep)
|
|||||||
(
|
(
|
||||||
min
|
min
|
||||||
(
|
(
|
||||||
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaT().value(),
|
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
|
||||||
min(runTime.deltaTValue(), maxDeltaT)
|
min(runTime.deltaTValue(), maxDeltaT)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,12 +59,12 @@ if (adjustTimeStep)
|
|||||||
(
|
(
|
||||||
min
|
min
|
||||||
(
|
(
|
||||||
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaT().value(),
|
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -57,7 +57,7 @@
|
|||||||
),
|
),
|
||||||
solidRegions[i],
|
solidRegions[i],
|
||||||
dimensionedSymmTensor(tkappaByCp().dimensions(), Zero),
|
dimensionedSymmTensor(tkappaByCp().dimensions(), Zero),
|
||||||
zeroGradientFvPatchSymmTensorField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ if (!thermo.isotropic())
|
|||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedSymmTensor(tkappaByCp().dimensions(), Zero),
|
dimensionedSymmTensor(tkappaByCp().dimensions(), Zero),
|
||||||
zeroGradientFvPatchSymmTensorField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
volSymmTensorField& aniAlpha = *taniAlpha;
|
volSymmTensorField& aniAlpha = *taniAlpha;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ if (mesh.changing())
|
|||||||
wordList pcorrTypes
|
wordList pcorrTypes
|
||||||
(
|
(
|
||||||
p.boundaryField().size(),
|
p.boundaryField().size(),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
||||||
|
|||||||
@ -130,7 +130,7 @@ int main(int argc, char *argv[])
|
|||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
||||||
zeroGradientFvPatchVectorField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
|
|
||||||
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
||||||
|
|||||||
@ -111,7 +111,7 @@ int main(int argc, char *argv[])
|
|||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
||||||
zeroGradientFvPatchVectorField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
|
|
||||||
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
||||||
|
|||||||
@ -141,7 +141,7 @@ int main(int argc, char *argv[])
|
|||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
||||||
zeroGradientFvPatchVectorField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
|
|
||||||
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
||||||
|
|||||||
@ -64,8 +64,7 @@ volScalarField mu
|
|||||||
mesh,
|
mesh,
|
||||||
IOobject::READ_IF_PRESENT
|
IOobject::READ_IF_PRESENT
|
||||||
),
|
),
|
||||||
mixture.mu(),
|
mixture.mu()
|
||||||
calculatedFvPatchScalarField::typeName
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -139,7 +138,7 @@ volScalarField alphac
|
|||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedScalar(dimless, Zero),
|
dimensionedScalar(dimless, Zero),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
alphac.oldTime();
|
alphac.oldTime();
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
wordList pcorrTypes
|
wordList pcorrTypes
|
||||||
(
|
(
|
||||||
p.boundaryField().size(),
|
p.boundaryField().size(),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
|
|
||||||
for (label i=0; i<p.boundaryField().size(); i++)
|
for (label i=0; i<p.boundaryField().size(); i++)
|
||||||
|
|||||||
@ -86,6 +86,7 @@ VoFPatchTransfer::VoFPatchTransfer
|
|||||||
wordRes patchNames;
|
wordRes patchNames;
|
||||||
if (coeffDict_.readIfPresent("patches", patchNames))
|
if (coeffDict_.readIfPresent("patches", patchNames))
|
||||||
{
|
{
|
||||||
|
// Can also use pbm.indices(), but no warnings...
|
||||||
patchIDs_ = pbm.patchSet(patchNames).sortedToc();
|
patchIDs_ = pbm.patchSet(patchNames).sortedToc();
|
||||||
|
|
||||||
Info<< " applying to " << patchIDs_.size() << " patches:" << nl;
|
Info<< " applying to " << patchIDs_.size() << " patches:" << nl;
|
||||||
|
|||||||
@ -140,7 +140,7 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
|
|||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedScalar(dimless, Zero),
|
dimensionedScalar(dimless, Zero),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
),
|
),
|
||||||
curTimeIndex_(-1)
|
curTimeIndex_(-1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1075,7 +1075,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
|
|||||||
|
|
||||||
MULES::limit
|
MULES::limit
|
||||||
(
|
(
|
||||||
1.0/mesh_.time().deltaT().value(),
|
1.0/mesh_.time().deltaTValue(),
|
||||||
geometricOneField(),
|
geometricOneField(),
|
||||||
alpha,
|
alpha,
|
||||||
phi_,
|
phi_,
|
||||||
|
|||||||
@ -105,8 +105,7 @@ incompressibleTwoPhaseInteractingMixture
|
|||||||
U_.db()
|
U_.db()
|
||||||
),
|
),
|
||||||
U_.mesh(),
|
U_.mesh(),
|
||||||
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero),
|
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero)
|
||||||
calculatedFvPatchScalarField::typeName
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
correct();
|
correct();
|
||||||
|
|||||||
@ -48,7 +48,7 @@ Foam::wordList Foam::relativeVelocityModel::UdmPatchFieldTypes() const
|
|||||||
wordList UdmTypes
|
wordList UdmTypes
|
||||||
(
|
(
|
||||||
U.boundaryField().size(),
|
U.boundaryField().size(),
|
||||||
calculatedFvPatchScalarField::typeName
|
fvPatchFieldBase::calculatedType()
|
||||||
);
|
);
|
||||||
|
|
||||||
forAll(U.boundaryField(), i)
|
forAll(U.boundaryField(), i)
|
||||||
|
|||||||
@ -699,7 +699,7 @@ void Foam::radiation::laserDTRM::calculate()
|
|||||||
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
|
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
|
||||||
Info << "Total energy absorbed [W]: " << totalQ << endl;
|
Info << "Total energy absorbed [W]: " << totalQ << endl;
|
||||||
|
|
||||||
if (mesh_.time().outputTime())
|
if (mesh_.time().writeTime())
|
||||||
{
|
{
|
||||||
reflectingCellsVol.write();
|
reflectingCellsVol.write();
|
||||||
nHat.write();
|
nHat.write();
|
||||||
|
|||||||
@ -52,7 +52,9 @@ namespace Foam
|
|||||||
const Foam::volScalarField&
|
const Foam::volScalarField&
|
||||||
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
||||||
{
|
{
|
||||||
if (!mesh_.foundObject<volScalarField>(alphaName))
|
const volScalarField* ptr = mesh_.cfindObject<volScalarField>(alphaName);
|
||||||
|
|
||||||
|
if (!ptr)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unable to retrieve density field " << alphaName << " from "
|
<< "Unable to retrieve density field " << alphaName << " from "
|
||||||
@ -60,7 +62,7 @@ Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mesh_.lookupObject<volScalarField>(alphaName);
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -124,7 +124,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
|||||||
* max(TSat - T, T0)
|
* max(TSat - T, T0)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mesh_.time().outputTime())
|
if (mesh_.time().writeTime())
|
||||||
{
|
{
|
||||||
mDotC.write();
|
mDotC.write();
|
||||||
mDotE.write();
|
mDotE.write();
|
||||||
|
|||||||
@ -96,7 +96,7 @@
|
|||||||
MULES::limiter
|
MULES::limiter
|
||||||
(
|
(
|
||||||
allLambda,
|
allLambda,
|
||||||
1.0/runTime.deltaT().value(),
|
1.0/runTime.deltaTValue(),
|
||||||
geometricOneField(),
|
geometricOneField(),
|
||||||
alpha1,
|
alpha1,
|
||||||
alphaPhi1BD,
|
alphaPhi1BD,
|
||||||
@ -164,7 +164,7 @@
|
|||||||
MULES::limiter
|
MULES::limiter
|
||||||
(
|
(
|
||||||
allLambda,
|
allLambda,
|
||||||
1.0/runTime.deltaT().value(),
|
1.0/runTime.deltaTValue(),
|
||||||
geometricOneField(),
|
geometricOneField(),
|
||||||
alpha2,
|
alpha2,
|
||||||
alphaPhi2BD,
|
alphaPhi2BD,
|
||||||
|
|||||||
@ -119,8 +119,7 @@ Foam::incompressibleThreePhaseMixture::incompressibleThreePhaseMixture
|
|||||||
U.db()
|
U.db()
|
||||||
),
|
),
|
||||||
U.mesh(),
|
U.mesh(),
|
||||||
dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero),
|
dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero)
|
||||||
calculatedFvPatchScalarField::typeName
|
|
||||||
),
|
),
|
||||||
|
|
||||||
nuModel1_
|
nuModel1_
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
wordList pcorrTypes
|
wordList pcorrTypes
|
||||||
(
|
(
|
||||||
p_rgh.boundaryField().size(),
|
p_rgh.boundaryField().size(),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
|
|
||||||
for (label i=0; i<p_rgh.boundaryField().size(); i++)
|
for (label i=0; i<p_rgh.boundaryField().size(); i++)
|
||||||
|
|||||||
@ -76,7 +76,7 @@
|
|||||||
mesh
|
mesh
|
||||||
),
|
),
|
||||||
fluid.dragCoeff(phase, dragCoeffs())/phase.rho(),
|
fluid.dragCoeff(phase, dragCoeffs())/phase.rho(),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
fvPatchFieldBase::zeroGradientType()
|
||||||
);
|
);
|
||||||
dragCoeffi.correctBoundaryConditions();
|
dragCoeffi.correctBoundaryConditions();
|
||||||
|
|
||||||
|
|||||||
@ -628,7 +628,7 @@ void Foam::multiphaseMixture::solveAlphas
|
|||||||
|
|
||||||
MULES::limit
|
MULES::limit
|
||||||
(
|
(
|
||||||
1.0/mesh_.time().deltaT().value(),
|
1.0/mesh_.time().deltaTValue(),
|
||||||
geometricOneField(),
|
geometricOneField(),
|
||||||
alpha,
|
alpha,
|
||||||
phi_,
|
phi_,
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
IOobject rhoIO
|
IOobject rhoIO
|
||||||
(
|
(
|
||||||
"rho",
|
"rho",
|
||||||
runTime.timeName(0),
|
Time::timeName(0),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
@ -75,7 +75,7 @@
|
|||||||
IOobject EHeader
|
IOobject EHeader
|
||||||
(
|
(
|
||||||
"E",
|
"E",
|
||||||
runTime.timeName(0),
|
Time::timeName(0),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
@ -127,7 +127,7 @@
|
|||||||
IOobject nuIO
|
IOobject nuIO
|
||||||
(
|
(
|
||||||
"nu",
|
"nu",
|
||||||
runTime.timeName(0),
|
Time::timeName(0),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
|
|||||||
@ -51,7 +51,7 @@ if (thermalStress)
|
|||||||
IOobject CIO
|
IOobject CIO
|
||||||
(
|
(
|
||||||
"C",
|
"C",
|
||||||
runTime.timeName(0),
|
Time::timeName(0),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
@ -106,7 +106,7 @@ if (thermalStress)
|
|||||||
IOobject rhoKIO
|
IOobject rhoKIO
|
||||||
(
|
(
|
||||||
"k",
|
"k",
|
||||||
runTime.timeName(0),
|
Time::timeName(0),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
@ -161,7 +161,7 @@ if (thermalStress)
|
|||||||
IOobject alphaIO
|
IOobject alphaIO
|
||||||
(
|
(
|
||||||
"alpha",
|
"alpha",
|
||||||
runTime.timeName(0),
|
Time::timeName(0),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
|
|||||||
@ -47,7 +47,7 @@ tractionDisplacementFvPatchVectorField
|
|||||||
traction_(p.size(), Zero),
|
traction_(p.size(), Zero),
|
||||||
pressure_(p.size(), Zero)
|
pressure_(p.size(), Zero)
|
||||||
{
|
{
|
||||||
fvPatchVectorField::operator=(patchInternalField());
|
extrapolateInternal();
|
||||||
gradient() = Zero;
|
gradient() = Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ tractionDisplacementFvPatchVectorField
|
|||||||
traction_("traction", dict, p.size()),
|
traction_("traction", dict, p.size()),
|
||||||
pressure_("pressure", dict, p.size())
|
pressure_("pressure", dict, p.size())
|
||||||
{
|
{
|
||||||
fvPatchVectorField::operator=(patchInternalField());
|
extrapolateInternal();
|
||||||
gradient() = Zero;
|
gradient() = Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ tractionDisplacementCorrectionFvPatchVectorField
|
|||||||
traction_(p.size(), Zero),
|
traction_(p.size(), Zero),
|
||||||
pressure_(p.size(), Zero)
|
pressure_(p.size(), Zero)
|
||||||
{
|
{
|
||||||
fvPatchVectorField::operator=(patchInternalField());
|
extrapolateInternal();
|
||||||
gradient() = Zero;
|
gradient() = Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ tractionDisplacementCorrectionFvPatchVectorField
|
|||||||
traction_("traction", dict, p.size()),
|
traction_("traction", dict, p.size()),
|
||||||
pressure_("pressure", dict, p.size())
|
pressure_("pressure", dict, p.size())
|
||||||
{
|
{
|
||||||
fvPatchVectorField::operator=(patchInternalField());
|
extrapolateInternal();
|
||||||
gradient() = Zero;
|
gradient() = Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,14 @@ License
|
|||||||
|
|
||||||
#include "dummyLib.H"
|
#include "dummyLib.H"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
// Include MPI without any C++ bindings
|
||||||
|
#ifndef MPICH_SKIP_MPICXX
|
||||||
|
#define MPICH_SKIP_MPICXX
|
||||||
|
#endif
|
||||||
|
#ifndef OMPI_SKIP_MPICXX
|
||||||
|
#define OMPI_SKIP_MPICXX
|
||||||
|
#endif
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -92,7 +92,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
report(buf1);
|
report(buf1);
|
||||||
|
|
||||||
buf1.push_back(identity(5)); report(buf1);
|
buf1.push_back(identity(5));
|
||||||
|
buf1.emplace_front(-1000);
|
||||||
|
buf1.emplace_back(1000);
|
||||||
|
report(buf1);
|
||||||
|
|
||||||
buf1.info(Info);
|
buf1.info(Info);
|
||||||
Info<< buf1 << nl;
|
Info<< buf1 << nl;
|
||||||
|
|||||||
@ -55,10 +55,7 @@ public:
|
|||||||
i_(i)
|
i_(i)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const word& keyword() const
|
const word& keyword() const noexcept { return keyword_; }
|
||||||
{
|
|
||||||
return keyword_;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const ent& e)
|
friend Ostream& operator<<(Ostream& os, const ent& e)
|
||||||
{
|
{
|
||||||
@ -74,28 +71,27 @@ class Scalar
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalar()
|
static bool verbose;
|
||||||
:
|
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar val)
|
constexpr Scalar() noexcept : data_(0) {}
|
||||||
:
|
Scalar(scalar val) noexcept : data_(val) {}
|
||||||
data_(val)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Scalar()
|
~Scalar()
|
||||||
{
|
{
|
||||||
Info<<"delete Scalar: " << data_ << endl;
|
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
scalar value() const noexcept { return data_; }
|
||||||
|
scalar& value() noexcept { return data_; }
|
||||||
|
|
||||||
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
os << val.data_;
|
os << item.value();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -117,7 +113,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
dict.swapDown(dict.first());
|
dict.swapDown(dict.first());
|
||||||
|
|
||||||
forAllConstIter(Dictionary<ent>, dict, iter)
|
forAllConstIters(dict, iter)
|
||||||
{
|
{
|
||||||
Info<< "element : " << *iter;
|
Info<< "element : " << *iter;
|
||||||
}
|
}
|
||||||
@ -157,9 +153,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl << "scalarDict1: " << endl;
|
Info<< nl << "scalarDict1: " << endl;
|
||||||
forAllConstIter(PtrDictionary<Scalar>, scalarDict, iter)
|
forAllConstIters(scalarDict, iter)
|
||||||
{
|
{
|
||||||
Info<< " = " << iter() << endl;
|
Info<< " = " << *iter << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
PtrDictionary<Scalar> scalarDict2;
|
PtrDictionary<Scalar> scalarDict2;
|
||||||
@ -169,7 +165,7 @@ int main(int argc, char *argv[])
|
|||||||
scalarDict2.insert(key, new Scalar(1.3*i));
|
scalarDict2.insert(key, new Scalar(1.3*i));
|
||||||
}
|
}
|
||||||
Info<< nl << "scalarDict2: " << endl;
|
Info<< nl << "scalarDict2: " << endl;
|
||||||
forAllConstIter(PtrDictionary<Scalar>, scalarDict2, iter)
|
forAllConstIters(scalarDict2, iter)
|
||||||
{
|
{
|
||||||
std::cout<< "iter: " << typeid(*iter).name() << '\n';
|
std::cout<< "iter: " << typeid(*iter).name() << '\n';
|
||||||
|
|
||||||
|
|||||||
@ -85,7 +85,7 @@ Description
|
|||||||
|
|
||||||
fileNameList procDirs
|
fileNameList procDirs
|
||||||
(
|
(
|
||||||
DirLister::dirs(".").sorted<fileName>(matchProcs)
|
DirLister::dirs(".").csorted<fileName>(matchProcs)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
@ -206,11 +206,11 @@ public:
|
|||||||
|
|
||||||
//- Return a complete list of names, sorted in natural order
|
//- Return a complete list of names, sorted in natural order
|
||||||
template<class StringType=Foam::word>
|
template<class StringType=Foam::word>
|
||||||
List<StringType> sorted() const;
|
List<StringType> csorted() const;
|
||||||
|
|
||||||
//- Return complete list of names, sorted in natural order
|
//- Return complete list of names, sorted in natural order
|
||||||
template<class StringType=Foam::word, class UnaryPredicate>
|
template<class StringType=Foam::word, class UnaryPredicate>
|
||||||
List<StringType> sorted
|
List<StringType> csorted
|
||||||
(
|
(
|
||||||
const UnaryPredicate& pred,
|
const UnaryPredicate& pred,
|
||||||
const bool prune = false
|
const bool prune = false
|
||||||
|
|||||||
@ -70,23 +70,23 @@ Foam::List<StringType> Foam::DirLister::list() const
|
|||||||
|
|
||||||
|
|
||||||
template<class StringType, class UnaryPredicate>
|
template<class StringType, class UnaryPredicate>
|
||||||
Foam::List<StringType> Foam::DirLister::sorted
|
Foam::List<StringType> Foam::DirLister::csorted
|
||||||
(
|
(
|
||||||
const UnaryPredicate& pred,
|
const UnaryPredicate& pred,
|
||||||
const bool prune
|
const bool prune
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
List<StringType> lst(list<StringType>(pred, prune));
|
List<StringType> list(list<StringType>(pred, prune));
|
||||||
sort(lst, stringOps::natural_sort());
|
Foam::sort(list, stringOps::natural_sort());
|
||||||
|
|
||||||
return lst;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
Foam::List<StringType> Foam::DirLister::sorted() const
|
Foam::List<StringType> Foam::DirLister::csorted() const
|
||||||
{
|
{
|
||||||
return sorted<StringType>(predicates::always());
|
return csorted<StringType>(predicates::always());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -162,7 +162,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "dirList: "
|
Info<< "dirList: "
|
||||||
<< flatOutput
|
<< flatOutput
|
||||||
(
|
(
|
||||||
DirLister::dirs(".").sorted<fileName>(relist)
|
DirLister::dirs(".").csorted<fileName>(relist)
|
||||||
) << nl;
|
) << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -112,13 +112,20 @@ int main(int argc, char *argv[])
|
|||||||
argList::addBoolOption("iter");
|
argList::addBoolOption("iter");
|
||||||
argList::addBoolOption("swap");
|
argList::addBoolOption("swap");
|
||||||
argList::addBoolOption("default", "reinstate default tests");
|
argList::addBoolOption("default", "reinstate default tests");
|
||||||
|
argList::addBoolOption("no-wait", "test with skipping request waits");
|
||||||
argList::addNote("runs default tests or specified ones only");
|
argList::addNote("runs default tests or specified ones only");
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
const bool optNowaiting = args.found("no-wait");
|
||||||
|
|
||||||
// Run default tests, unless only specific tests are requested
|
// Run default tests, unless only specific tests are requested
|
||||||
const bool defaultTests =
|
const bool defaultTests =
|
||||||
args.found("default") || args.options().empty();
|
(
|
||||||
|
args.found("default")
|
||||||
|
|| args.options().empty()
|
||||||
|
|| (optNowaiting && args.options().size())
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
typedef FixedList<scalar,2> scalar2Type;
|
typedef FixedList<scalar,2> scalar2Type;
|
||||||
@ -195,14 +202,31 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "get<3>: " << list1.get<3>() << nl;
|
Info<< "get<3>: " << list1.get<3>() << nl;
|
||||||
// Will not compile: Info<< "get<4>: " << list1.get<4>() << nl;
|
// Will not compile: Info<< "get<4>: " << list1.get<4>() << nl;
|
||||||
|
|
||||||
label a[4] = {0, 1, 2, 3};
|
// Test deprecated form
|
||||||
FixedList<label, 4> list2(a);
|
label array2[4] = {0, 1, 2, 3};
|
||||||
|
FixedList<label, 4> list2(array2);
|
||||||
|
|
||||||
Info<< "list2:" << list2
|
Info<< "list2:" << list2
|
||||||
<< " hash:" << FixedList<label, 4>::hasher()(list2) << nl
|
<< " hash:" << FixedList<label, 4>::hasher()(list2) << nl
|
||||||
<< " hash:" << Hash<FixedList<label, 4>>()(list2) << nl;
|
<< " hash:" << Hash<FixedList<label, 4>>()(list2) << nl;
|
||||||
|
|
||||||
|
|
||||||
|
// Test deprecated form
|
||||||
|
SLList<label> sllist3;
|
||||||
|
{
|
||||||
|
sllist3.push_back(0);
|
||||||
|
sllist3.push_back(1);
|
||||||
|
sllist3.push_back(2);
|
||||||
|
sllist3.push_back(3);
|
||||||
|
}
|
||||||
|
FixedList<label, 4> list3(sllist3);
|
||||||
|
|
||||||
|
Info<< "list3:" << list3 << nl;
|
||||||
|
// Test deprecated forms
|
||||||
|
list3 = array2;
|
||||||
|
list2 = sllist3;
|
||||||
|
|
||||||
|
|
||||||
// Using FixedList for content too
|
// Using FixedList for content too
|
||||||
{
|
{
|
||||||
List<FixedList<label, 4>> twolists{list1, list2};
|
List<FixedList<label, 4>> twolists{list1, list2};
|
||||||
@ -230,8 +254,8 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "mem: "
|
Info<< "mem: "
|
||||||
<< name(list1.data()) << " " << name(list2.data()) << nl;
|
<< name(list1.data()) << " " << name(list2.data()) << nl;
|
||||||
|
|
||||||
Swap(list1, list2);
|
Foam::Swap(list1, list2);
|
||||||
Info<< "The Swap() function" << nl;
|
Info<< "Foam::Swap() function" << nl;
|
||||||
Info<< "list1: " << list1 << nl
|
Info<< "list1: " << list1 << nl
|
||||||
<< "list2: " << list2 << nl;
|
<< "list2: " << list2 << nl;
|
||||||
|
|
||||||
@ -307,27 +331,53 @@ int main(int argc, char *argv[])
|
|||||||
List<FixedList<label, 2>> list6{{0, 1}, {2, 3}};
|
List<FixedList<label, 2>> list6{{0, 1}, {2, 3}};
|
||||||
Info<< "list6: " << list6 << nl;
|
Info<< "list6: " << list6 << nl;
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (UPstream::parRun())
|
||||||
{
|
{
|
||||||
// Fixed buffer would also work, but want to test using UList
|
// Fixed buffer would also work, but want to test using UList
|
||||||
List<labelPair> buffer;
|
List<labelPair> buffer;
|
||||||
|
|
||||||
|
DynamicList<UPstream::Request> requests;
|
||||||
|
|
||||||
|
const label numProcs = UPstream::nProcs();
|
||||||
const label startOfRequests = UPstream::nRequests();
|
const label startOfRequests = UPstream::nRequests();
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
|
// NOTE: also test a mix of local and global requests...
|
||||||
|
UPstream::Request singleRequest;
|
||||||
|
|
||||||
|
if (UPstream::master())
|
||||||
{
|
{
|
||||||
buffer.resize(UPstream::nProcs());
|
// Use local requests here
|
||||||
|
requests.reserve(numProcs);
|
||||||
|
|
||||||
|
buffer.resize(numProcs);
|
||||||
buffer[0] = labelPair(0, UPstream::myProcNo());
|
buffer[0] = labelPair(0, UPstream::myProcNo());
|
||||||
|
|
||||||
for (const int proci : Pstream::subProcs())
|
for (const int proci : UPstream::subProcs())
|
||||||
{
|
{
|
||||||
UIPstream::read
|
UIPstream::read
|
||||||
(
|
(
|
||||||
UPstream::commsTypes::nonBlocking,
|
requests.emplace_back(),
|
||||||
proci,
|
proci,
|
||||||
buffer.slice(proci, 1)
|
buffer.slice(proci, 1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requests.size() > 1)
|
||||||
|
{
|
||||||
|
// Or just wait for as a single request...
|
||||||
|
singleRequest = requests.back();
|
||||||
|
requests.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requests.size() > 2)
|
||||||
|
{
|
||||||
|
// Peel off a few from local -> global
|
||||||
|
// the order will not matter (is MPI_Waitall)
|
||||||
|
|
||||||
|
UPstream::addRequest(requests.back()); requests.pop_back();
|
||||||
|
UPstream::addRequest(requests.back()); requests.pop_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -336,16 +386,34 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Perr<< "Sending to master: " << buffer << endl;
|
Perr<< "Sending to master: " << buffer << endl;
|
||||||
|
|
||||||
|
// Capture the request and transfer to the global list
|
||||||
|
// (for testing)
|
||||||
|
|
||||||
UOPstream::write
|
UOPstream::write
|
||||||
(
|
(
|
||||||
UPstream::commsTypes::nonBlocking,
|
singleRequest,
|
||||||
UPstream::masterNo(),
|
UPstream::masterNo(),
|
||||||
buffer.slice(0, 1) // OK
|
buffer.slice(0, 1) // OK
|
||||||
/// buffer // Also OK
|
/// buffer // Also OK
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// if (singleRequest.good())
|
||||||
|
{
|
||||||
|
UPstream::addRequest(singleRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UPstream::waitRequests(startOfRequests);
|
Pout<< "Pending requests [" << numProcs << " procs] global="
|
||||||
|
<< (UPstream::nRequests() - startOfRequests)
|
||||||
|
<< " local=" << requests.size()
|
||||||
|
<< " single=" << singleRequest.good() << nl;
|
||||||
|
|
||||||
|
if (!optNowaiting)
|
||||||
|
{
|
||||||
|
UPstream::waitRequests(startOfRequests);
|
||||||
|
}
|
||||||
|
UPstream::waitRequests(requests);
|
||||||
|
UPstream::waitRequest(singleRequest);
|
||||||
|
|
||||||
Info<< "Gathered: " << buffer << endl;
|
Info<< "Gathered: " << buffer << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,7 @@ void runSwapTest
|
|||||||
|
|
||||||
for (label iLoop = 0; iLoop < nLoops; ++iLoop)
|
for (label iLoop = 0; iLoop < nLoops; ++iLoop)
|
||||||
{
|
{
|
||||||
Swap(list1, list2);
|
Foam::Swap(list1, list2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "output 1: " << list1.first() << nl;
|
Info<< "output 1: " << list1.first() << nl;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -44,38 +44,28 @@ class Scalar
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalar()
|
static bool verbose;
|
||||||
:
|
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar val)
|
constexpr Scalar() noexcept : data_(0) {}
|
||||||
:
|
Scalar(scalar val) noexcept : data_(val) {}
|
||||||
data_(val)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Scalar()
|
~Scalar()
|
||||||
{
|
{
|
||||||
Info<<"delete Scalar: " << data_ << endl;
|
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const scalar& value() const
|
const scalar& value() const noexcept { return data_; }
|
||||||
{
|
scalar& value() noexcept { return data_; }
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar& value()
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
return data_;
|
os << item.value();
|
||||||
}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
|
||||||
{
|
|
||||||
os << val.data_;
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void printTable(const HashPtrTable<T>& table)
|
void printTable(const HashPtrTable<T>& table)
|
||||||
@ -129,6 +119,9 @@ int main()
|
|||||||
myTable.set("natlog", new double(2.718282));
|
myTable.set("natlog", new double(2.718282));
|
||||||
myTable.insert("sqrt2", autoPtr<double>::New(1.414214));
|
myTable.insert("sqrt2", autoPtr<double>::New(1.414214));
|
||||||
myTable.insert("euler", autoPtr<double>::New(0.577216));
|
myTable.insert("euler", autoPtr<double>::New(0.577216));
|
||||||
|
myTable.set("def_0", nullptr);
|
||||||
|
myTable.emplace_set("def_1", 123);
|
||||||
|
myTable.emplace_set("def_2", 456);
|
||||||
|
|
||||||
HashTable<std::unique_ptr<double>> myTable1;
|
HashTable<std::unique_ptr<double>> myTable1;
|
||||||
|
|
||||||
@ -146,6 +139,14 @@ int main()
|
|||||||
Info<< "Initial table" << nl;
|
Info<< "Initial table" << nl;
|
||||||
printTable(myTable);
|
printTable(myTable);
|
||||||
|
|
||||||
|
myTable.try_emplace("def_0", 1000); // was nullptr, now value
|
||||||
|
myTable.try_emplace("def_1", 1001); // no-op
|
||||||
|
myTable.try_emplace("def_2", 1002); // no-op;
|
||||||
|
myTable.try_emplace("def_3", 1003); // was non-existent, now value
|
||||||
|
|
||||||
|
Info<< "after try_emplace" << nl;
|
||||||
|
printTable(myTable);
|
||||||
|
|
||||||
Info<< "print" << nl;
|
Info<< "print" << nl;
|
||||||
Info<< myTable2 << nl;
|
Info<< myTable2 << nl;
|
||||||
|
|
||||||
|
|||||||
@ -75,8 +75,8 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Info<< "\ntable1 sorted() :" << endl;
|
Info<< "\ntable1 csorted() :" << endl;
|
||||||
for (const auto& iter : table1.sorted())
|
for (const auto& iter : table1.csorted())
|
||||||
{
|
{
|
||||||
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Info<< "\nInplace modified - via sorted() access :" << endl;
|
Info<< "\nInplace modified - via sorted() access :" << endl;
|
||||||
for (const auto& iter : table1.sorted())
|
for (const auto& iter : table1.csorted())
|
||||||
{
|
{
|
||||||
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
||||||
}
|
}
|
||||||
@ -366,8 +366,8 @@ int main()
|
|||||||
Info<< nl << "input values" << nl;
|
Info<< nl << "input values" << nl;
|
||||||
Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl;
|
Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl;
|
||||||
|
|
||||||
Info<<"global Swap function" << nl;
|
Info<<"std::swap function" << nl;
|
||||||
Swap(table1, table2);
|
std::swap(table1, table2);
|
||||||
Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl;
|
Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl;
|
||||||
|
|
||||||
Info<<"swap method" << nl;
|
Info<<"swap method" << nl;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -290,14 +290,14 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Time: " << runTime.timeName() << nl;
|
Info<< "Time: " << runTime.timeName() << nl;
|
||||||
|
|
||||||
report(objects);
|
report(objects);
|
||||||
report(objects.sorted());
|
report(objects.csorted());
|
||||||
|
|
||||||
report(objects.sorted<volScalarField>());
|
report(objects.csorted<volScalarField>());
|
||||||
report(objects.sorted<volVectorField>());
|
report(objects.csorted<volVectorField>());
|
||||||
|
|
||||||
// Extra checks
|
// Extra checks
|
||||||
report<volScalarField>(objects.sorted<volScalarField>());
|
report<volScalarField>(objects.csorted<volScalarField>());
|
||||||
report<volScalarField>(objects.sorted<volVectorField>());
|
report<volScalarField>(objects.csorted<volVectorField>());
|
||||||
|
|
||||||
|
|
||||||
findObjectTest(objects);
|
findObjectTest(objects);
|
||||||
|
|||||||
@ -46,26 +46,27 @@ class Scalar
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// static bool verbose;
|
||||||
|
|
||||||
scalar data_;
|
scalar data_;
|
||||||
|
|
||||||
Scalar()
|
Scalar() : data_(0) {}
|
||||||
:
|
Scalar(scalar val) : data_(val) {}
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar s)
|
// ~Scalar() {}
|
||||||
:
|
|
||||||
data_(s)
|
|
||||||
{}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& s)
|
scalar value() const noexcept { return data_; }
|
||||||
|
scalar& value() noexcept { return data_; }
|
||||||
|
|
||||||
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
os << s.data_;
|
os << item.value();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,6 +27,7 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
#include "ListStream.H"
|
#include "ListStream.H"
|
||||||
#include "UListStream.H"
|
#include "UListStream.H"
|
||||||
#include "wordList.H"
|
#include "wordList.H"
|
||||||
@ -155,35 +156,378 @@ void doTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void printToken(const label index, const token& tok)
|
||||||
|
{
|
||||||
|
Info<< " " << index << " " << tok.name();
|
||||||
|
if (tok.good())
|
||||||
|
{
|
||||||
|
Info<< " : " << tok;
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class BUF>
|
||||||
|
void testWalk1
|
||||||
|
(
|
||||||
|
const std::string& name,
|
||||||
|
const BUF& input,
|
||||||
|
const int verbose
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< "tokenized " << name.c_str() << ":" << nl
|
||||||
|
<< "====" << nl;
|
||||||
|
toString(Info, input)
|
||||||
|
<< nl
|
||||||
|
<< "====" << endl;
|
||||||
|
|
||||||
|
ITstream is(input);
|
||||||
|
Info<< is.size() << " tokens" << endl;
|
||||||
|
for (is.rewind(); !is.eof(); is.skip())
|
||||||
|
{
|
||||||
|
printToken(is.tokenIndex(), is.currentToken());
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
|
||||||
|
Info<< "every other token:" << nl;
|
||||||
|
for (is.seek(1); is.nRemainingTokens(); is.skip(2))
|
||||||
|
{
|
||||||
|
printToken(is.tokenIndex(), is.currentToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i : { 3, 7, 11, 20 })
|
||||||
|
{
|
||||||
|
Info<< "peekToken: ";
|
||||||
|
printToken(i, is.peekToken(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
labelRange range(is.size()-2, 2);
|
||||||
|
Info<< nl
|
||||||
|
<< "remove: " << range << " of 0/" << is.size() << " tokens" << endl;
|
||||||
|
is.remove(range);
|
||||||
|
|
||||||
|
Info<< "Now " << is.size() << " tokens" << endl;
|
||||||
|
for (is.rewind(); !is.eof(); is.skip())
|
||||||
|
{
|
||||||
|
printToken(is.tokenIndex(), is.currentToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
range.reset(10, 3);
|
||||||
|
Info<< nl
|
||||||
|
<< "remove: " << range << " of 0/" << is.size() << " tokens" << endl;
|
||||||
|
is.remove(range);
|
||||||
|
|
||||||
|
Info<< "Now " << is.size() << " tokens" << endl;
|
||||||
|
for (is.rewind(); !is.eof(); is.skip())
|
||||||
|
{
|
||||||
|
printToken(is.tokenIndex(), is.currentToken());
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void testRewrite(const std::string& input, const int verbose)
|
||||||
|
{
|
||||||
|
Info<< "tokens" << nl
|
||||||
|
<< "====" << nl;
|
||||||
|
toString(Info, input)
|
||||||
|
<< nl
|
||||||
|
<< "====" << endl;
|
||||||
|
|
||||||
|
ITstream is(input);
|
||||||
|
Info<< is.size() << " tokens" << endl;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
for (is.rewind(); !is.eof(); is.skip())
|
||||||
|
{
|
||||||
|
printToken(is.tokenIndex(), is.currentToken());
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "==>";
|
||||||
|
for (const token& tok : is)
|
||||||
|
{
|
||||||
|
Info<< ' ' << tok;
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "removing sub-dictionary tokens" << nl;
|
||||||
|
|
||||||
|
for (is.rewind(); !is.eof(); is.skip())
|
||||||
|
{
|
||||||
|
if (is.currentToken().isPunctuation(token::BEGIN_BLOCK))
|
||||||
|
{
|
||||||
|
labelRange slice(is.tokenIndex(), 0);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// This is a bad way to remove things since we lose the parse
|
||||||
|
// point!
|
||||||
|
for (/*nil*/; !is.eof(); is.skip())
|
||||||
|
{
|
||||||
|
if (is.currentToken().isPunctuation(token::END_BLOCK))
|
||||||
|
{
|
||||||
|
slice.size() = (is.tokenIndex() - slice.start()) + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
for (label toki = is.tokenIndex()+1; toki < is.size(); ++toki)
|
||||||
|
{
|
||||||
|
if (is.peekToken(toki).isPunctuation(token::END_BLOCK))
|
||||||
|
{
|
||||||
|
slice.size() = (toki - slice.start()) + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Info<< "remove range: " << slice
|
||||||
|
<< " currentIndex: " << is.tokenIndex() << '/' << is.size()
|
||||||
|
// NB peekToken handles out-of-range
|
||||||
|
<< " token: " << is.peekToken(is.tokenIndex()) << nl;
|
||||||
|
|
||||||
|
const label nRemoved = is.remove(slice);
|
||||||
|
|
||||||
|
Info<< "remove " << nRemoved
|
||||||
|
<< " new current: " << is.tokenIndex() << '/' << is.size()
|
||||||
|
// NB peekToken handles out-of-range
|
||||||
|
<< " token: " << is.peekToken(is.tokenIndex()) << nl;
|
||||||
|
|
||||||
|
Info<< "==>";
|
||||||
|
for (const token& tok : is)
|
||||||
|
{
|
||||||
|
Info<< ' ' << tok;
|
||||||
|
}
|
||||||
|
Info<< nl << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void testRemoveDict(const std::string& input, const int verbose)
|
||||||
|
{
|
||||||
|
Info<< "tokens" << nl
|
||||||
|
<< "====" << nl;
|
||||||
|
toString(Info, input)
|
||||||
|
<< nl
|
||||||
|
<< "====" << endl;
|
||||||
|
|
||||||
|
ITstream is(input);
|
||||||
|
Info<< is.size() << " tokens" << endl;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
for (is.rewind(); !is.eof(); is.skip())
|
||||||
|
{
|
||||||
|
printToken(is.tokenIndex(), is.currentToken());
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "==>";
|
||||||
|
for (const token& tok : is)
|
||||||
|
{
|
||||||
|
Info<< ' ' << tok;
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (label pos = 0; pos < is.size(); /*nil*/)
|
||||||
|
{
|
||||||
|
labelRange slice
|
||||||
|
(
|
||||||
|
is.find(token::BEGIN_BLOCK, token::END_BLOCK, pos)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (slice.good())
|
||||||
|
{
|
||||||
|
pos = slice.end_value();
|
||||||
|
|
||||||
|
tokenList::subList substream(is.slice(slice));
|
||||||
|
|
||||||
|
Info<< " dict " << slice << " ==>";
|
||||||
|
for (const token& tok : substream)
|
||||||
|
{
|
||||||
|
Info<< ' ' << tok;
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "removing sub-dictionary tokens" << nl;
|
||||||
|
|
||||||
|
for (is.rewind(); !is.eof(); is.skip())
|
||||||
|
{
|
||||||
|
if (is.currentToken().isPunctuation(token::BEGIN_BLOCK))
|
||||||
|
{
|
||||||
|
labelRange slice
|
||||||
|
(
|
||||||
|
is.find(token::BEGIN_BLOCK, token::END_BLOCK, is.tokenIndex())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (slice.good())
|
||||||
|
{
|
||||||
|
ITstream substream(is.extract(slice));
|
||||||
|
|
||||||
|
Info<< "got " << slice << " ==>";
|
||||||
|
for (const token& tok : substream)
|
||||||
|
{
|
||||||
|
Info<< ' ' << tok;
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
|
||||||
|
dictionary dict(substream);
|
||||||
|
|
||||||
|
Info<< "tokenIndex: " << is.tokenIndex() << nl;
|
||||||
|
Info<< "sub-dict " << dict << nl;
|
||||||
|
|
||||||
|
Info<< "remove range: " << slice
|
||||||
|
<< " currentIndex: " << is.tokenIndex() << '/' << is.size()
|
||||||
|
<< " token: " << is.peekToken(is.tokenIndex()) << nl;
|
||||||
|
|
||||||
|
const label nRemoved = is.remove(slice);
|
||||||
|
|
||||||
|
Info<< "remove " << nRemoved
|
||||||
|
<< " new current: " << is.tokenIndex() << '/' << is.size()
|
||||||
|
<< " token: " << is.peekToken(is.tokenIndex()) << nl;
|
||||||
|
|
||||||
|
Info<< "==>";
|
||||||
|
for (const token& tok : is)
|
||||||
|
{
|
||||||
|
Info<< ' ' << tok;
|
||||||
|
}
|
||||||
|
Info<< nl << nl;
|
||||||
|
|
||||||
|
// Reposition the parse point
|
||||||
|
is.seek(slice.start());
|
||||||
|
is.skip(-1);
|
||||||
|
|
||||||
|
Info<< "continue after " << is.tokenIndex()
|
||||||
|
<< " : " << is.peekToken(is.tokenIndex()) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char* charInput =
|
argList::noBanner();
|
||||||
"( const char input \"string\" to tokenize )\n"
|
argList::noParallel();
|
||||||
"List<label> 5(0 1 2 3 4);";
|
argList::addVerboseOption("additional verbosity");
|
||||||
|
argList::addBoolOption("basic", "basic tests");
|
||||||
|
argList::addBoolOption("rewrite", "test rewriting only");
|
||||||
|
argList::addBoolOption("remove-dict", "test rewriting only");
|
||||||
|
|
||||||
string stringInput("( string ; input \"string\" to tokenize )");
|
argList args(argc, argv);
|
||||||
|
|
||||||
List<char> listInput
|
if
|
||||||
(
|
(
|
||||||
ListOps::create<char>
|
!args.found("basic")
|
||||||
|
&& !args.found("rewrite")
|
||||||
|
&& !args.found("remove-dict")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< "No test options specified!" << nl << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.found("basic"))
|
||||||
|
{
|
||||||
|
const char* charInput =
|
||||||
|
"( const char input \"string\" to tokenize )\n"
|
||||||
|
"List<label> 5(0 1 2 3 4);";
|
||||||
|
|
||||||
|
string stringInput("( string ; input \"string\" to tokenize )");
|
||||||
|
|
||||||
|
List<char> listInput
|
||||||
(
|
(
|
||||||
stringInput.cbegin(),
|
ListOps::create<char>
|
||||||
stringInput.cend(),
|
(
|
||||||
Foam::identityOp{}
|
stringInput.cbegin(),
|
||||||
)
|
stringInput.cend(),
|
||||||
);
|
Foam::identityOp{}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
doTest("empty", "", true, true);
|
doTest("empty", "", true, true);
|
||||||
|
|
||||||
doTest("char*", charInput, true, true);
|
doTest("char*", charInput, true, true);
|
||||||
doTest("string", stringInput, true);
|
doTest("string", stringInput, true);
|
||||||
doTest("List<char>", listInput, true);
|
doTest("List<char>", listInput, true);
|
||||||
|
|
||||||
reverse(listInput);
|
reverse(listInput);
|
||||||
doTest("List<char>", listInput, true);
|
doTest("List<char>", listInput, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.found("rewrite"))
|
||||||
|
{
|
||||||
|
testWalk1
|
||||||
|
(
|
||||||
|
"std::string",
|
||||||
|
"( string ; input \"string\" to tokenize )"
|
||||||
|
"{ other entry; value 100; value2 200; }"
|
||||||
|
, args.verbose()
|
||||||
|
);
|
||||||
|
|
||||||
|
testRewrite
|
||||||
|
(
|
||||||
|
"some entry ( string1 ; )"
|
||||||
|
"{ sub dict1; value 100; value2 200; }"
|
||||||
|
"other entry ( string2 ; )"
|
||||||
|
"{ sub dict2; value 100; value2 200; }"
|
||||||
|
"{ sub dict3; value 100; value2 200; }"
|
||||||
|
"trailing entry"
|
||||||
|
, args.verbose()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.found("remove-dict"))
|
||||||
|
{
|
||||||
|
testRemoveDict
|
||||||
|
(
|
||||||
|
"some entry ( string1 ; )"
|
||||||
|
"{ sub dict1; value 100; value2 200; }"
|
||||||
|
"other entry ( string2 ; )"
|
||||||
|
"{ sub dict2; value 100; value2 200; }"
|
||||||
|
"{ sub dict3; value 100; value2 200; }"
|
||||||
|
"trailing entry"
|
||||||
|
, args.verbose()
|
||||||
|
);
|
||||||
|
|
||||||
|
testRemoveDict
|
||||||
|
(
|
||||||
|
"some entry no dictionary"
|
||||||
|
, args.verbose()
|
||||||
|
);
|
||||||
|
testRemoveDict
|
||||||
|
(
|
||||||
|
"{ leading dict; } last-stuff"
|
||||||
|
, args.verbose()
|
||||||
|
);
|
||||||
|
testRemoveDict
|
||||||
|
(
|
||||||
|
"first-stuff { trailing dict; }"
|
||||||
|
, args.verbose()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
|||||||
@ -183,9 +183,7 @@ int main(int argc, char *argv[])
|
|||||||
Pout<<"recv: " << flatOutput(recv) << endl;
|
Pout<<"recv: " << flatOutput(recv) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MPI barrier
|
UPstream::barrier(UPstream::worldComm);
|
||||||
bool barrier = true;
|
|
||||||
Pstream::broadcast(barrier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
applications/test/ListRead1/Make/files
Normal file
3
applications/test/ListRead1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-ListRead1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-ListRead1
|
||||||
2
applications/test/ListRead1/Make/options
Normal file
2
applications/test/ListRead1/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
234
applications/test/ListRead1/Test-ListRead1.C
Normal file
234
applications/test/ListRead1/Test-ListRead1.C
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
Test-ListRead1
|
||||||
|
|
||||||
|
Description
|
||||||
|
List reading
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "argList.H"
|
||||||
|
#include "wordRes.H"
|
||||||
|
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "Fstream.H"
|
||||||
|
#include "StringStream.H"
|
||||||
|
#include "scalar.H"
|
||||||
|
#include "vector.H"
|
||||||
|
|
||||||
|
#include "labelRange.H"
|
||||||
|
#include "scalarList.H"
|
||||||
|
#include "HashOps.H"
|
||||||
|
#include "ListOps.H"
|
||||||
|
#include "IndirectList.H"
|
||||||
|
#include "SubList.H"
|
||||||
|
#include "SliceList.H"
|
||||||
|
#include "ListPolicy.H"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <numeric>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
label chunkSize = 128;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool readBracketList(List<T>& list, Istream& is)
|
||||||
|
{
|
||||||
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
|
||||||
|
token tok(is);
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"List<T>::readBracketList(Istream&) : reading first token"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!tok.isPunctuation(token::BEGIN_LIST))
|
||||||
|
{
|
||||||
|
is.putBack(tok);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// "(...)" : read element-wise.
|
||||||
|
// Uses chunk-wise reading to avoid too many re-allocations
|
||||||
|
// and avoids relocation of contiguous memory until all of the reading
|
||||||
|
// is completed. Chunks are wrapped as unique_ptr to ensure proper
|
||||||
|
// cleanup on failure.
|
||||||
|
|
||||||
|
// The choice of chunk-size is somewhat arbitrary...
|
||||||
|
// constexpr label chunkSize = 128;
|
||||||
|
typedef std::unique_ptr<List<T>> chunkType;
|
||||||
|
|
||||||
|
is >> tok;
|
||||||
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
|
||||||
|
if (tok.isPunctuation(token::END_LIST))
|
||||||
|
{
|
||||||
|
// Trivial case, an empty list
|
||||||
|
list.clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use all storage
|
||||||
|
//private:// list.resize(list.capacity());
|
||||||
|
|
||||||
|
// Start with a few slots, recover current memory where possible
|
||||||
|
List<chunkType> chunks(16);
|
||||||
|
if (list.empty())
|
||||||
|
{
|
||||||
|
chunks[0] = chunkType(new List<T>(chunkSize));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chunks[0] = chunkType(new List<T>(std::move(list)));
|
||||||
|
}
|
||||||
|
|
||||||
|
label nChunks = 1; // Active number of chunks
|
||||||
|
label totalCount = 0; // Total number of elements
|
||||||
|
label localIndex = 0; // Chunk-local index
|
||||||
|
|
||||||
|
InfoErr
|
||||||
|
<< nl << "initial chunk: " << chunks[0]->size() << endl;
|
||||||
|
|
||||||
|
while (!tok.isPunctuation(token::END_LIST))
|
||||||
|
{
|
||||||
|
is.putBack(tok);
|
||||||
|
|
||||||
|
if (chunks[nChunks-1]->size() <= localIndex)
|
||||||
|
{
|
||||||
|
// Increase number of slots (doubling)
|
||||||
|
if (nChunks >= chunks.size())
|
||||||
|
{
|
||||||
|
chunks.resize(2*chunks.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
InfoErr<< "new chunk" << endl;
|
||||||
|
chunks[nChunks] = chunkType(new List<T>(chunkSize));
|
||||||
|
++nChunks;
|
||||||
|
localIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
is >> chunks[nChunks-1]->operator[](localIndex);
|
||||||
|
++localIndex;
|
||||||
|
++totalCount;
|
||||||
|
|
||||||
|
InfoErr
|
||||||
|
<< " chunk=" << nChunks
|
||||||
|
<< " index=" << localIndex
|
||||||
|
<< " total=" << totalCount << nl;
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"List<T>::readBracketList(Istream&) : "
|
||||||
|
"reading entry"
|
||||||
|
);
|
||||||
|
|
||||||
|
is >> tok;
|
||||||
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simple case
|
||||||
|
if (nChunks == 1)
|
||||||
|
{
|
||||||
|
list = std::move(*(chunks[0]));
|
||||||
|
list.resize(totalCount);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destination
|
||||||
|
//private:// list.setCapacity_nocopy(totalCount);
|
||||||
|
list.resize_nocopy(totalCount);
|
||||||
|
auto dest = list.begin();
|
||||||
|
|
||||||
|
for (label chunki = 0; chunki < nChunks; ++chunki)
|
||||||
|
{
|
||||||
|
List<T> currChunk(std::move(*(chunks[chunki])));
|
||||||
|
chunks[chunki].reset(nullptr);
|
||||||
|
|
||||||
|
const label localLen = min(currChunk.size(), totalCount);
|
||||||
|
|
||||||
|
dest = std::move
|
||||||
|
(
|
||||||
|
currChunk.begin(),
|
||||||
|
currChunk.begin(localLen),
|
||||||
|
dest
|
||||||
|
);
|
||||||
|
|
||||||
|
totalCount -= localLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noParallel();
|
||||||
|
argList::noFunctionObjects();
|
||||||
|
argList::addOption("chunk-size", "value", "change read chunk size");
|
||||||
|
argList::addArgument("file1 .. fileN");
|
||||||
|
|
||||||
|
argList args(argc, argv, false, true);
|
||||||
|
|
||||||
|
args.readIfPresent("chunk-size", chunkSize);
|
||||||
|
|
||||||
|
Info<< "chunk-size: " << chunkSize << nl;
|
||||||
|
|
||||||
|
if (args.size() <= 1)
|
||||||
|
{
|
||||||
|
InfoErr<< "Provide a file or files to test" << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (label argi=1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
const auto input = args.get<fileName>(argi);
|
||||||
|
IFstream is(input);
|
||||||
|
|
||||||
|
while (!is.eof())
|
||||||
|
{
|
||||||
|
labelList list;
|
||||||
|
|
||||||
|
readBracketList(list, is);
|
||||||
|
Info<< "read: " << flatOutput(list) << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
17
applications/test/ListRead1/testLists1
Normal file
17
applications/test/ListRead1/testLists1
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
(
|
||||||
|
0 1 2 3 4 5 6 7 8 9
|
||||||
|
10 11 12 13 14 15 16 17 18 19
|
||||||
|
20 21 22 23 24 25 26 27 28 29
|
||||||
|
30 31 32 33 34 35 36 37 38 39
|
||||||
|
40 41 42 43 44 45 46 47 48 49
|
||||||
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
0 1 2 3 4 5 6 7 8 9
|
||||||
|
10 11 12 13 14 15 16 17 18 19
|
||||||
|
20 21 22 23 24 25 26 27 28 29
|
||||||
|
30 31 32 33 34 35 36 37 38 39
|
||||||
|
40 41 42 43 44 45 46 47 48 49
|
||||||
|
)
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -47,43 +47,29 @@ class Scalar
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalar()
|
static bool verbose;
|
||||||
:
|
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar val)
|
constexpr Scalar() noexcept : data_(0) {}
|
||||||
:
|
Scalar(scalar val) noexcept : data_(val) {}
|
||||||
data_(val)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Scalar()
|
~Scalar()
|
||||||
{
|
{
|
||||||
Info<< "delete Scalar: " << data_ << endl;
|
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const scalar& value() const
|
scalar value() const noexcept { return data_; }
|
||||||
{
|
scalar& value() noexcept { return data_; }
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar& value()
|
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
|
||||||
{
|
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
autoPtr<Scalar> clone() const
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
return autoPtr<Scalar>::New(data_);
|
os << item.value();
|
||||||
}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
|
||||||
{
|
|
||||||
os << val.data_;
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
// As per
|
// As per
|
||||||
@ -268,6 +254,22 @@ Ostream& report
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
#if 1
|
||||||
|
{
|
||||||
|
DLPtrList<Scalar> llist1;
|
||||||
|
Info<< "emplace_front: " << llist1.emplace_front(100) << nl;
|
||||||
|
Info<< "emplace_front: " << llist1.emplace_front(200) << nl;
|
||||||
|
Info<< "emplace_front: " << llist1.emplace_front(300) << nl;
|
||||||
|
Info<< "emplace_back: " << llist1.emplace_back(500) << nl;
|
||||||
|
|
||||||
|
Info<< "DLPtrList: " << llist1 << endl;
|
||||||
|
|
||||||
|
Scalar::verbose = false;
|
||||||
|
llist1.clear();
|
||||||
|
Scalar::verbose = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
DLPtrList<Scalar> llist1;
|
DLPtrList<Scalar> llist1;
|
||||||
@ -325,6 +327,22 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
list1.set(i, new Scalar(1.3*i));
|
list1.set(i, new Scalar(1.3*i));
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
auto ptr = autoPtr<Scalar>::New(10);
|
||||||
|
|
||||||
|
Info<< "add: " << Foam::name(ptr.get());
|
||||||
|
list1.set(0, ptr);
|
||||||
|
|
||||||
|
Info<< "ptrlist: " << Foam::name(list1.get(0)) << nl;
|
||||||
|
Info<< "now: " << Foam::name(ptr.get()) << nl;
|
||||||
|
|
||||||
|
ptr = autoPtr<Scalar>::New(20);
|
||||||
|
|
||||||
|
list1.append(ptr);
|
||||||
|
// Delete method: list1.push_back(ptr);
|
||||||
|
// list1.push_back(std::move(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PtrList<Scalar> list2(15);
|
PtrList<Scalar> list2(15);
|
||||||
Info<< "Emplace set " << list2.size() << " values" << nl;
|
Info<< "Emplace set " << list2.size() << " values" << nl;
|
||||||
@ -333,6 +351,20 @@ int main(int argc, char *argv[])
|
|||||||
list2.emplace(i, (10 + 1.3*i));
|
list2.emplace(i, (10 + 1.3*i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list2.release(5);
|
||||||
|
list2.release(10);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Memory error (with fulldebug): const label len = (list2.size()+2);
|
||||||
|
const label len = list2.size();
|
||||||
|
Info<< "try_emplace " << len << " values" << nl;
|
||||||
|
|
||||||
|
for (label i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
list2.try_emplace(i, (50 + 1.3*i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PtrList<Scalar> listApp;
|
PtrList<Scalar> listApp;
|
||||||
for (label i = 0; i < 5; ++i)
|
for (label i = 0; i < 5; ++i)
|
||||||
{
|
{
|
||||||
@ -623,7 +655,7 @@ int main(int argc, char *argv[])
|
|||||||
dynPlanes.set(6, new plane(vector(2,2,1), vector::one));
|
dynPlanes.set(6, new plane(vector(2,2,1), vector::one));
|
||||||
dynPlanes.set(10, new plane(vector(4,5,6), vector::one));
|
dynPlanes.set(10, new plane(vector(4,5,6), vector::one));
|
||||||
|
|
||||||
Info<< "emplaced :"
|
Info<< "emplaced[12]: "
|
||||||
<< dynPlanes.emplace(12, vector(3,2,1), vector::one) << endl;
|
<< dynPlanes.emplace(12, vector(3,2,1), vector::one) << endl;
|
||||||
|
|
||||||
dynPlanes.emplace_back(Zero, vector::one);
|
dynPlanes.emplace_back(Zero, vector::one);
|
||||||
|
|||||||
@ -45,28 +45,29 @@ class Scalar
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalar()
|
static bool verbose;
|
||||||
:
|
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar val)
|
constexpr Scalar() noexcept : data_(0) {}
|
||||||
:
|
Scalar(scalar val) noexcept : data_(val) {}
|
||||||
data_(val)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Scalar()
|
~Scalar()
|
||||||
{
|
{
|
||||||
Info<<"delete Scalar: " << data_ << endl;
|
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
const scalar& value() const noexcept { return data_; }
|
||||||
|
scalar& value() noexcept { return data_; }
|
||||||
|
|
||||||
|
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
|
||||||
|
|
||||||
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
os << val.data_;
|
os << item.value();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -370,7 +370,7 @@ void test_global_funcs(Type)
|
|||||||
Type(126)
|
Type(126)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
cmp(" Square of Frobenius norm = ", magSqr(sT), Type(205));
|
cmp(" Square of Frobenius norm = ", magSqr(sT), scalar(205));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -325,7 +325,7 @@ void test_global_funcs(Type)
|
|||||||
Type(13)
|
Type(13)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
cmp(" Square of Frobenius norm = ", magSqr(sT), Type(17.999999999999996));
|
cmp(" Square of Frobenius norm = ", magSqr(sT), scalar(17.999999999999996));
|
||||||
cmp
|
cmp
|
||||||
(
|
(
|
||||||
" Outer-product of a Vector2D with itself = ",
|
" Outer-product of a Vector2D with itself = ",
|
||||||
|
|||||||
@ -51,10 +51,7 @@ public:
|
|||||||
i_(i)
|
i_(i)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const word& keyword() const
|
const word& keyword() const noexcept { return keyword_; }
|
||||||
{
|
|
||||||
return keyword_;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const ent& e)
|
friend Ostream& operator<<(Ostream& os, const ent& e)
|
||||||
{
|
{
|
||||||
@ -83,7 +80,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
dict.swapDown(dict.first());
|
dict.swapDown(dict.first());
|
||||||
|
|
||||||
forAllConstIter(UDictionary<ent>, dict, iter)
|
forAllConstIters(dict, iter)
|
||||||
{
|
{
|
||||||
Info<< "element : " << *iter;
|
Info<< "element : " << *iter;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -124,6 +124,9 @@ int main(int argc, char *argv[])
|
|||||||
argList::addDryRunOption("Just for testing");
|
argList::addDryRunOption("Just for testing");
|
||||||
argList::addVerboseOption("Increase verbosity");
|
argList::addVerboseOption("Increase verbosity");
|
||||||
|
|
||||||
|
// Check -verbose before initialisation
|
||||||
|
UPstream::debug = argList::verbose(argc, argv);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
Pout<< "command-line ("
|
Pout<< "command-line ("
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -84,6 +84,20 @@ struct DerivedList : public List<T>
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void printInfo(const autoPtr<T>& item, const bool verbose = false)
|
||||||
|
{
|
||||||
|
Info<< "autoPtr good:" << Switch::name(item.good())
|
||||||
|
<< " addr: " << Foam::name(item.get());
|
||||||
|
|
||||||
|
if (verbose && item)
|
||||||
|
{
|
||||||
|
Info<< " content: " << item();
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
@ -112,6 +126,17 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<<"move unique to autoPtr: " << *list3 << nl;
|
Info<<"move unique to autoPtr: " << *list3 << nl;
|
||||||
Info<<"old is " << Switch(bool(list2)) << nl;
|
Info<<"old is " << Switch(bool(list2)) << nl;
|
||||||
|
|
||||||
|
Info<< "before emplace: ";
|
||||||
|
printInfo(list, true);
|
||||||
|
|
||||||
|
list.emplace(4, label(-2));
|
||||||
|
Info<< "after emplace: ";
|
||||||
|
printInfo(list, true);
|
||||||
|
|
||||||
|
list.emplace(2, label(-4));
|
||||||
|
Info<< "after emplace: ";
|
||||||
|
printInfo(list, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm that forwarding with move construct actually works as expected
|
// Confirm that forwarding with move construct actually works as expected
|
||||||
|
|||||||
3
applications/test/broadcastCopy/Make/files
Normal file
3
applications/test/broadcastCopy/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-broadcastCopy.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-broadcastCopy
|
||||||
2
applications/test/broadcastCopy/Make/options
Normal file
2
applications/test/broadcastCopy/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
97
applications/test/broadcastCopy/Test-broadcastCopy.C
Normal file
97
applications/test/broadcastCopy/Test-broadcastCopy.C
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test file/directory broadcasting
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "fileOperation.H"
|
||||||
|
#include "Pstream.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noFunctionObjects();
|
||||||
|
argList::noCheckProcessorDirectories();
|
||||||
|
|
||||||
|
argList::addNote("Test broadcast file via MPI");
|
||||||
|
|
||||||
|
argList::addArgument("srcFile");
|
||||||
|
argList::addBoolOption("even", "Broadcast to even directories only");
|
||||||
|
argList::addBoolOption("relative", "Copy relative to output dir");
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
const auto srcFile = args.get<fileName>(1);
|
||||||
|
|
||||||
|
// const auto dstFile = args.get<fileName>(2);
|
||||||
|
fileName dstFile("proc" + Foam::name(UPstream::myProcNo()));
|
||||||
|
|
||||||
|
|
||||||
|
const bool writeOnProc =
|
||||||
|
(
|
||||||
|
!args.found("even") || 0 == (UPstream::myProcNo() % 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (args.found("relative"))
|
||||||
|
{
|
||||||
|
// if (writeOnProc)
|
||||||
|
// {
|
||||||
|
// Foam::mkDir(dstFile);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dstFile /= srcFile + ".copy";
|
||||||
|
}
|
||||||
|
|
||||||
|
Pout<< "writing: " << writeOnProc << " : " << dstFile << endl;
|
||||||
|
|
||||||
|
const auto& fp = fileHandler();
|
||||||
|
|
||||||
|
fp.broadcastCopy
|
||||||
|
(
|
||||||
|
UPstream::worldComm,
|
||||||
|
writeOnProc,
|
||||||
|
srcFile,
|
||||||
|
dstFile
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -58,8 +58,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
Info<< "Known compound tokens: "
|
// Info<< "Known compound tokens: "
|
||||||
<< token::compound::IstreamConstructorTablePtr_->sortedToc() << nl;
|
// << token::compound::emptyConstructorTablePtr_->sortedToc() << nl;
|
||||||
|
|
||||||
OStringStream ostr;
|
OStringStream ostr;
|
||||||
|
|
||||||
@ -79,6 +79,13 @@ int main(int argc, char *argv[])
|
|||||||
List<char> alphabet(istr);
|
List<char> alphabet(istr);
|
||||||
|
|
||||||
Info<< "re-read: " << alphabet << nl;
|
Info<< "re-read: " << alphabet << nl;
|
||||||
|
|
||||||
|
// Can assign zero?
|
||||||
|
//Fails: alphabet = char(Zero);
|
||||||
|
alphabet = Foam::zero{};
|
||||||
|
|
||||||
|
// alphabet = '@';
|
||||||
|
Info<< "blanked: " << alphabet << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -34,6 +34,9 @@ Description
|
|||||||
#include "complex.H"
|
#include "complex.H"
|
||||||
#include "complexFields.H"
|
#include "complexFields.H"
|
||||||
#include "scalarField.H"
|
#include "scalarField.H"
|
||||||
|
#include "diagTensor.H"
|
||||||
|
#include "symmTensor.H"
|
||||||
|
#include "symmTensor2D.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
#include "ops.H"
|
#include "ops.H"
|
||||||
|
|
||||||
@ -164,6 +167,72 @@ int main(int argc, char *argv[])
|
|||||||
<< " => " << imags << nl;
|
<< " => " << imags << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SymmTensor<complex> st1(SymmTensor<complex>::uniform({3, 4}));
|
||||||
|
|
||||||
|
Info<< "symmTensor: " << st1 << nl
|
||||||
|
<< " tr: " << tr(st1) << nl
|
||||||
|
<< " diagSqr: " << st1.diagSqr() << nl
|
||||||
|
<< " magSqr: " << magSqr(st1) << nl
|
||||||
|
<< " mag: " << mag(st1) << nl;
|
||||||
|
|
||||||
|
SymmTensor<scalar> st2(SymmTensor<scalar>::uniform(5));
|
||||||
|
|
||||||
|
Info<< "symmTensor: " << st2 << nl
|
||||||
|
<< " tr: " << tr(st2) << nl
|
||||||
|
<< " diagSqr: " << st2.diagSqr() << nl
|
||||||
|
<< " magSqr: " << magSqr(st2) << nl
|
||||||
|
<< " mag: " << mag(st2) << nl;
|
||||||
|
|
||||||
|
st2 = Zero;
|
||||||
|
|
||||||
|
DiagTensor<complex> dt1(SphericalTensor<complex>({3, 4}));
|
||||||
|
|
||||||
|
Info<< "diagTensor: " << dt1 << nl
|
||||||
|
<< " tr: " << tr(dt1) << nl
|
||||||
|
<< " diagSqr: " << dt1.diagSqr() << nl
|
||||||
|
<< " magSqr: " << magSqr(dt1) << nl
|
||||||
|
<< " mag: " << mag(dt1) << nl;
|
||||||
|
|
||||||
|
|
||||||
|
// A bit ugly...
|
||||||
|
st1 = SphericalTensor<complex>({3, 4});
|
||||||
|
|
||||||
|
Info<< "symmTensor: " << st1 << nl
|
||||||
|
<< " tr: " << tr(st1) << nl
|
||||||
|
<< " diagSqr: " << st1.diagSqr() << nl
|
||||||
|
<< " magSqr: " << magSqr(st1) << nl
|
||||||
|
<< " mag: " << mag(st1) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SymmTensor2D<complex> st1(SymmTensor2D<complex>::uniform({3, 4}));
|
||||||
|
|
||||||
|
Info<< "symmTensor: " << st1 << nl
|
||||||
|
<< " tr: " << tr(st1) << nl
|
||||||
|
<< " diagSqr: " << st1.diagSqr() << nl
|
||||||
|
<< " magSqr: " << magSqr(st1) << nl
|
||||||
|
<< " mag: " << mag(st1) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Tensor<complex> st1(Tensor<complex>::uniform({3, 4}));
|
||||||
|
|
||||||
|
Info<< "tensor: " << st1 << nl
|
||||||
|
<< " tr: " << tr(st1) << nl
|
||||||
|
<< " diagSqr: " << st1.diagSqr() << nl
|
||||||
|
<< " magSqr: " << magSqr(st1) << nl
|
||||||
|
<< " mag: " << mag(st1) << endl;
|
||||||
|
|
||||||
|
Tensor<scalar> st2(Tensor<scalar>::uniform(5));
|
||||||
|
|
||||||
|
Info<< "Tensor: " << st2 << nl
|
||||||
|
<< " tr: " << tr(st2) << nl
|
||||||
|
<< " diagSqr: " << st2.diagSqr() << nl
|
||||||
|
<< " magSqr: " << magSqr(st2) << nl
|
||||||
|
<< " mag: " << mag(st2) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
complexField fld1(3, complex(2.0, 1.0));
|
complexField fld1(3, complex(2.0, 1.0));
|
||||||
complexField fld2(fld1);
|
complexField fld2(fld1);
|
||||||
|
|
||||||
|
|||||||
3
applications/test/compoundToken1/Make/files
Normal file
3
applications/test/compoundToken1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-compoundToken1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-compoundToken1
|
||||||
1
applications/test/compoundToken1/Make/options
Normal file
1
applications/test/compoundToken1/Make/options
Normal file
@ -0,0 +1 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
307
applications/test/compoundToken1/Test-compoundToken1.C
Normal file
307
applications/test/compoundToken1/Test-compoundToken1.C
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test token construct assign etc.
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "IOobject.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "IFstream.H"
|
||||||
|
#include "StringStream.H"
|
||||||
|
#include "cpuTime.H"
|
||||||
|
#include "labelList.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class OS>
|
||||||
|
OS& printTypeCode(OS& os, char typeCode)
|
||||||
|
{
|
||||||
|
os << int(static_cast<unsigned char>(typeCode));
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class IFstream Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
bool test_pending = false;
|
||||||
|
|
||||||
|
class IFstreamDelayed
|
||||||
|
:
|
||||||
|
public IFstream
|
||||||
|
{
|
||||||
|
virtual bool readCompoundToken(token& tok, const word& type)
|
||||||
|
{
|
||||||
|
auto& is = *this;
|
||||||
|
|
||||||
|
bool delay = true;
|
||||||
|
|
||||||
|
// Low-level: get next valid character (after comments)
|
||||||
|
// and branch based on it being a '{' or not
|
||||||
|
|
||||||
|
char c = 0;
|
||||||
|
if (is.read(c))
|
||||||
|
{
|
||||||
|
// Delay further reading?
|
||||||
|
delay = (c == token::BEGIN_BLOCK);
|
||||||
|
is.putback(c);
|
||||||
|
|
||||||
|
if (c)
|
||||||
|
{
|
||||||
|
cerr<< "nextChar:" << c << " : delay read: " << delay << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Caller already checked token::compound::isCompound(...)
|
||||||
|
// but use readCompoundToken anyhow for convenience
|
||||||
|
|
||||||
|
if (tok.readCompoundToken(type, is, !delay))
|
||||||
|
{
|
||||||
|
cerr<< "readCompound(" << type << ")\n";
|
||||||
|
cerr<< "typeCode: ";
|
||||||
|
printTypeCode(cerr, tok.compoundToken().typeCode()) << nl;
|
||||||
|
|
||||||
|
if (test_pending && delay)
|
||||||
|
{
|
||||||
|
InfoErr<< "pending read "
|
||||||
|
<< tok.compoundToken().type() << endl;
|
||||||
|
|
||||||
|
tok.refCompoundToken().pending(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
using IFstream::IFstream;
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~IFstreamDelayed() = default;
|
||||||
|
|
||||||
|
// Testing deprecation warnings
|
||||||
|
FOAM_DEPRECATED_STRICT(2023-08, "direct calling")
|
||||||
|
Istream& operator()() const
|
||||||
|
{
|
||||||
|
return const_cast<IFstreamDelayed&>(*this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
void populateCompound(token::compound& ct, const dictionary& dict)
|
||||||
|
{
|
||||||
|
Info<< "populateCompound: " << nl;
|
||||||
|
|
||||||
|
// This is where runTime dispatch, eg based on transport type
|
||||||
|
// could be used...
|
||||||
|
|
||||||
|
switch (ct.typeCode())
|
||||||
|
{
|
||||||
|
#undef fillComponents
|
||||||
|
#define fillComponents(Type, Variable, Value) \
|
||||||
|
{ \
|
||||||
|
ct.pending(false); \
|
||||||
|
ct.resize(10); \
|
||||||
|
UList<Type> Variable \
|
||||||
|
( \
|
||||||
|
reinterpret_cast<Type*>(ct.data_bytes()), \
|
||||||
|
label(ct.size_bytes() / sizeof(Type)) \
|
||||||
|
); \
|
||||||
|
Variable = Value; \
|
||||||
|
}
|
||||||
|
|
||||||
|
case token::tokenType::PUNCTUATION :
|
||||||
|
{
|
||||||
|
fillComponents(char, cmpts, '@');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::BOOL :
|
||||||
|
{
|
||||||
|
fillComponents(bool, cmpts, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::LABEL :
|
||||||
|
{
|
||||||
|
fillComponents(label, cmpts, 123);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::FLOAT :
|
||||||
|
{
|
||||||
|
fillComponents(float, cmpts, 2.7);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::DOUBLE :
|
||||||
|
{
|
||||||
|
fillComponents(double, cmpts, 3.1415);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
#undef fillComponents
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ct.pending())
|
||||||
|
{
|
||||||
|
Info<< "assigned values:" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rewriteCompounds(ITstream& is)
|
||||||
|
{
|
||||||
|
Info<< "rewrite: " << flatOutput(is) << endl;
|
||||||
|
|
||||||
|
for (label toki = 0; toki < is.size(); ++toki)
|
||||||
|
{
|
||||||
|
if (is[toki].isCompound() && is[toki].compoundToken().pending())
|
||||||
|
{
|
||||||
|
Info<< "replace : " << is[toki].info() << endl;
|
||||||
|
|
||||||
|
if (is.peekToken(toki+1).isPunctuation(token::BEGIN_BLOCK))
|
||||||
|
{
|
||||||
|
labelRange slice
|
||||||
|
(
|
||||||
|
is.find(token::BEGIN_BLOCK, token::END_BLOCK, toki+1)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (slice.good() && (slice.start() == toki+1))
|
||||||
|
{
|
||||||
|
Info<< "Compound at:" << toki
|
||||||
|
<< " dict:" << slice << endl;
|
||||||
|
|
||||||
|
ITstream substream(is.extract(slice));
|
||||||
|
|
||||||
|
dictionary dict(substream);
|
||||||
|
|
||||||
|
populateCompound(is[toki].refCompoundToken(), dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rewriteDict(dictionary& dict)
|
||||||
|
{
|
||||||
|
for (entry& e : dict)
|
||||||
|
{
|
||||||
|
if (e.isDict())
|
||||||
|
{
|
||||||
|
rewriteDict(e.dict());
|
||||||
|
}
|
||||||
|
else if (e.isStream())
|
||||||
|
{
|
||||||
|
rewriteCompounds(e.stream());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noParallel();
|
||||||
|
argList::addBoolOption("std", "standard reading (no delayed compounds)");
|
||||||
|
argList::addBoolOption("pending", "read with pending");
|
||||||
|
|
||||||
|
argList args(argc, argv, false, true);
|
||||||
|
|
||||||
|
Info<< "typeCodes:" << nl;
|
||||||
|
Info<< " bool=";
|
||||||
|
printTypeCode(Info, token::tokenType::BOOL) << nl;
|
||||||
|
Info<< " label=";
|
||||||
|
printTypeCode(Info, token::tokenType::LABEL) << nl;
|
||||||
|
Info<< " float=";
|
||||||
|
printTypeCode(Info, token::tokenType::FLOAT) << nl;
|
||||||
|
Info<< " double=";
|
||||||
|
printTypeCode(Info, token::tokenType::DOUBLE) << nl;
|
||||||
|
Info<< nl;
|
||||||
|
|
||||||
|
if (args.found("pending"))
|
||||||
|
{
|
||||||
|
test_pending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.found("std"))
|
||||||
|
{
|
||||||
|
for (label argi = 1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
Info<< "Read: " << args[argi] << endl;
|
||||||
|
IFstream is(args[argi]);
|
||||||
|
|
||||||
|
dictionary dict(is);
|
||||||
|
|
||||||
|
Info<< "read: " << dict << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (label argi = 1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
Info<< "Read delay: " << args[argi] << endl;
|
||||||
|
|
||||||
|
IFstreamDelayed is(args[argi]);
|
||||||
|
|
||||||
|
// Trigger strict warning?
|
||||||
|
Info<< "stream: " << is().name() << nl;
|
||||||
|
|
||||||
|
dictionary dict(is);
|
||||||
|
Info<< "read: " << dict << nl;
|
||||||
|
|
||||||
|
rewriteDict(dict);
|
||||||
|
|
||||||
|
Info<< "modified: " << dict << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
24
applications/test/compoundToken1/testDict1
Normal file
24
applications/test/compoundToken1/testDict1
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2312 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object dictionary;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
internalField uniform 1;
|
||||||
|
|
||||||
|
temperature List<scalar> 10(270 271 272 273 274 275 276 277 278 279);
|
||||||
|
|
||||||
|
pressure 1e5;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
65
applications/test/compoundToken1/testDict2
Normal file
65
applications/test/compoundToken1/testDict2
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2312 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object dictionary;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
internalField uniform 1;
|
||||||
|
|
||||||
|
// Regular syntax
|
||||||
|
valuesT List<scalar> (123 456 890);
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
temperature List<scalar>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values (270 271 272 273 274 275 276 277 278 279);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
velocity List<vector>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values (270 271 272 273 274 275 276 277 278 279);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
isGood List<bool>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values (true false true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
master List<label>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values (0 100 35 50);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
edges List<edge>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values ((0 1) (2 1));
|
||||||
|
};
|
||||||
|
|
||||||
|
pressure 1e5;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -61,7 +61,7 @@ void basicTests(const coordinateSystem& cs)
|
|||||||
|
|
||||||
if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
|
if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
|
||||||
{
|
{
|
||||||
if (!cartptr->valid())
|
if (!cartptr->good())
|
||||||
{
|
{
|
||||||
Info<< "invalid cartesian = " << (*cartptr)
|
Info<< "invalid cartesian = " << (*cartptr)
|
||||||
<< " with: " << (*cartptr).R() << nl;
|
<< " with: " << (*cartptr).R() << nl;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v2212 |
|
| \\ / O peration | Version: v2306 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user