Compare commits

..

6 Commits

Author SHA1 Message Date
88477b66f0 CONFIG: handle string splitting [zsh] (#2640) 2022-11-26 14:17:34 +01:00
aaf921ba73 ENH: handle watching included files 2022-11-26 14:17:34 +01:00
4918161d0c ENH: support selective disabling of directory caching 2022-11-26 14:17:34 +01:00
f26b9c5a9f ENH: improved fileOperations
- all file-handlers can now be created with a user-specified
  communicator and/or with specified io-ranks. This makes it possible
  to quickly create special file-handlers for subsets of ranks.

  For the uncollated file output this implies that the file-handler
  now has a communicator only with itself, which is correct since each
  rank is acting like it own IO master rank and doesn't coordinate
  effort with other ranks.
2022-11-26 14:17:34 +01:00
6582002ccc WIP: code juggling fileOperations 2022-11-26 14:17:31 +01:00
9bcef219a8 ENH: more consistent single-ownership when swapping fileHandlers
- make fileHandler deletion mechanism more
  transparent by providing a nullptr signature. A nullptr parameter
  is already being used in the argList destructor for shutdown, but that
  relied on an implicit conversion to autoPtr to trigger things.

- improved handling of file handler replacement.

  Previously had a very basic check on old vs new handlers using their
  type() values (string comparison!!), which would unfortunately
  prevent proper swapping of the contents.
  Check the actual pointers instead.

  As part of the change, treat any empty autoPtr as no-op instead of as
  deletion (which is handled explicitly as nullptr instead).

  In addition to making the internal logic simpler, it means that the
  current file handler always changes to a valid state without
  inadvertently removing everything and falling back to creating a new
  default handler (again).

  This handling of no-ops also simplifies call code. For example,

  <code>
      autoPtr<fileHandler> oldHandler;
      autoPtr<fileHandler> writeHandler;
      word handlerName;

      if (arg.readIfPresent("writeHandler", handlerName))
      {
          writeHandler = fileOperation::New(handlerName);
      }

      oldHandler = fileHandler(std::move(writeHandler));

      ... do something

      writeHandler = fileHandler(std::move(oldHandler));
  </code>

  If the "writeHandler" is not specified, each call is a no-op.
  If it is specified, the handlers are swapped out each time.

- the management of the fileHandler communicators is now encapsulated
  privately (managedComm_) with the final layer being responsible for
  cleaning up after itself. This makes delegation/inheritance clearer
  and avoids the risk of freeing an MPI communicator twice.

STYLE: uniformFile static check relocated to fileOperation layer
2022-11-26 01:13:53 +01:00
10452 changed files with 35600 additions and 53528 deletions

View File

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

View File

@ -1,2 +1,2 @@
api=2301
patch=230110
api=2208
patch=220907

View File

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

View File

@ -1,4 +1,125 @@
#include "../createFields.H"
Info<< "Reading velocity field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
// Initialise the velocity internal field to zero
U = dimensionedVector(U.dimensions(), Zero);
surfaceScalarField phi
(
IOobject
(
"phi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
fvc::flux(U)
);
if (args.found("initialiseUBCs"))
{
U.correctBoundaryConditions();
phi = fvc::flux(U);
}
// Construct a pressure field
// If it is available read it otherwise construct from the velocity BCs
// converting fixed-value BCs to zero-gradient and vice versa.
// Allow override from command-line -pName option
const word pName = args.getOrDefault<word>("pName", "p");
// Infer the pressure BCs from the velocity
wordList pBCTypes
(
U.boundaryField().size(),
fixedValueFvPatchScalarField::typeName
);
forAll(U.boundaryField(), patchi)
{
if (U.boundaryField()[patchi].fixesValue())
{
pBCTypes[patchi] = zeroGradientFvPatchScalarField::typeName;
}
}
// Note that registerObject is false for the pressure field. The pressure
// field in this solver doesn't have a physical value during the solution.
// It shouldn't be looked up and used by sub models or boundary conditions.
Info<< "Constructing pressure field " << pName << nl << endl;
volScalarField p
(
IOobject
(
pName,
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
),
mesh,
dimensionedScalar(sqr(dimVelocity), Zero),
pBCTypes
);
// Infer the velocity potential BCs from the pressure
wordList PhiBCTypes
(
p.boundaryField().size(),
zeroGradientFvPatchScalarField::typeName
);
forAll(p.boundaryField(), patchi)
{
if (p.boundaryField()[patchi].fixesValue())
{
PhiBCTypes[patchi] = fixedValueFvPatchScalarField::typeName;
}
}
Info<< "Constructing velocity potential field Phi\n" << endl;
volScalarField Phi
(
IOobject
(
"Phi",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar(dimLength*dimVelocity, Zero),
PhiBCTypes
);
label PhiRefCell = 0;
scalar PhiRefValue = 0;
setRefCell
(
Phi,
potentialFlow.dict(),
PhiRefCell,
PhiRefValue
);
mesh.setFluxRequired(Phi.name());
#include "createMRF.H"
// Add solver-specific interpolations
{

View File

@ -83,7 +83,6 @@ Description
\heading Options
\plaintable
-writep | write the Euler pressure
-writephi | Write the final volumetric flux
-writePhi | Write the final velocity potential
-initialiseUBCs | Update the velocity boundaries before solving for Phi
\endplaintable
@ -118,12 +117,6 @@ int main(int argc, char *argv[])
"Initialise U boundary conditions"
);
argList::addBoolOption
(
"writephi",
"Write the final volumetric flux field"
);
argList::addBoolOption
(
"writePhi",
@ -142,8 +135,6 @@ int main(int argc, char *argv[])
"Execute functionObjects"
);
#include "addRegionOption.H"
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createNamedDynamicFvMesh.H"
@ -203,16 +194,11 @@ int main(int argc, char *argv[])
<< endl;
}
// Write U
// Write U and phi
U.write();
phi.write();
// Optionally write the volumetric flux, phi
if (args.found("writephi"))
{
phi.write();
}
// Optionally write velocity potential, Phi
// Optionally write Phi
if (args.found("writePhi"))
{
Phi.write();

View File

@ -171,7 +171,10 @@ if (ign.ignited())
fvOptions.correct(Su);
Su.clamp_range(SuMin, SuMax);
// Limit the maximum Su
// ~~~~~~~~~~~~~~~~~~~~
Su.min(SuMax);
Su.max(SuMin);
}
else
{
@ -215,7 +218,7 @@ if (ign.ignited())
+ (
scalar(1)
+ (2*XiShapeCoef)
*(scalar(0.5) - clamp(b, zero_one{}))
*(scalar(0.5) - min(max(b, scalar(0)), scalar(1)))
)*(XiEqStar - scalar(1.001))
);

View File

@ -39,13 +39,13 @@ tmp<fv::convectionScheme<scalar>> mvConvection
fvOptions.correct(Yi);
Yi.clamp_min(0);
Yi.max(0.0);
Yt += Yi;
}
}
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].clamp_min(0);
Y[inertIndex].max(0.0);
radiation->correct();

View File

@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
fvOptions.correct(Yi);
Yi.clamp_min(0);
Yi.max(0.0);
Yt += Yi;
}
}
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].clamp_min(0);
Y[inertIndex].max(0.0);
}

View File

@ -165,10 +165,14 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
return;
}
const auto& pmu = patch().lookupPatchField<volScalarField>(muName_);
const auto& prho = patch().lookupPatchField<volScalarField>(rhoName_);
const auto& ppsi = patch().lookupPatchField<volScalarField>(psiName_);
const auto& pU = patch().lookupPatchField<volVectorField>(UName_);
const fvPatchScalarField& pmu =
patch().lookupPatchField<volScalarField, scalar>(muName_);
const fvPatchScalarField& prho =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
const fvPatchField<scalar>& ppsi =
patch().lookupPatchField<volScalarField, scalar>(psiName_);
const fvPatchVectorField& pU =
patch().lookupPatchField<volVectorField, vector>(UName_);
// Prandtl number reading consistent with rhoCentralFoam
const dictionary& thermophysicalProperties =
@ -203,7 +207,7 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
// Write
void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
fvPatchScalarField::write(os);
os.writeEntryIfDifferent<word>("U", "U", UName_);
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
@ -213,7 +217,7 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
os.writeEntry("accommodationCoeff", accommodationCoeff_);
Twall_.writeEntry("Twall", os);
os.writeEntry("gamma", gamma_);
fvPatchField<scalar>::writeValueEntry(os);
writeEntry("value", os);
}

View File

@ -155,9 +155,12 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs()
return;
}
const auto& pmu = patch().lookupPatchField<volScalarField>(muName_);
const auto& prho = patch().lookupPatchField<volScalarField>(rhoName_);
const auto& ppsi = patch().lookupPatchField<volScalarField>(psiName_);
const fvPatchScalarField& pmu =
patch().lookupPatchField<volScalarField, scalar>(muName_);
const fvPatchScalarField& prho =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
const fvPatchField<scalar>& ppsi =
patch().lookupPatchField<volScalarField, scalar>(psiName_);
Field<scalar> C1
(
@ -184,8 +187,8 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs()
if (curvature_)
{
const auto& ptauMC =
patch().lookupPatchField<volTensorField>(tauMCName_);
const fvPatchTensorField& ptauMC =
patch().lookupPatchField<volTensorField, tensor>(tauMCName_);
vectorField n(patch().nf());
refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
@ -197,7 +200,7 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs()
void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
fvPatchVectorField::write(os);
os.writeEntryIfDifferent<word>("T", "T", TName_);
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
@ -212,7 +215,7 @@ void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const
refValue().writeEntry("refValue", os);
valueFraction().writeEntry("valueFraction", os);
fvPatchField<vector>::writeValueEntry(os);
writeEntry("value", os);
}

View File

@ -104,8 +104,11 @@ void Foam::fixedRhoFvPatchScalarField::updateCoeffs()
return;
}
const auto& psip = patch().lookupPatchField<volScalarField>(psiName_);
const auto& pp = patch().lookupPatchField<volScalarField>(pName_);
const fvPatchField<scalar>& psip =
patch().lookupPatchField<volScalarField, scalar>(psiName_);
const fvPatchField<scalar>& pp =
patch().lookupPatchField<volScalarField, scalar>(pName_);
operator==(psip*pp);
@ -115,10 +118,11 @@ void Foam::fixedRhoFvPatchScalarField::updateCoeffs()
void Foam::fixedRhoFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
fvPatchScalarField::write(os);
os.writeEntryIfDifferent<word>("p", "p", pName_);
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
fvPatchField<scalar>::writeValueEntry(os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -9,7 +9,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/regionFaModels/lnInclude
-I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \
-lfiniteVolume \

View File

@ -7,7 +7,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/regionFaModels/lnInclude
-I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \
-lfiniteVolume \

View File

@ -4,7 +4,7 @@
sqrt
(
2*M_PI*sigma*sqr(aMesh.edgeInterpolation::deltaCoeffs())
*mag(aMesh.edgeInterpolation::deltaCoeffs())
*aMesh.edgeInterpolation::deltaCoeffs()
/rhol
)
).value()*runTime.deltaT().value();

View File

@ -1,6 +1,3 @@
// Volume-to surface mapping object
const volSurfaceMapping vsm(aMesh);
volVectorField U
(
IOobject
@ -29,3 +26,6 @@ volScalarField H
mesh,
dimensionedScalar(dimLength, Zero)
);
// Create volume-to surface mapping object
volSurfaceMapping vsm(aMesh);

View File

@ -1,5 +1,5 @@
// Volume-to surface mapping object
const volSurfaceMapping vsm(aMesh);
// Create volume-to surface mapping object
volSurfaceMapping vsm(aMesh);
volScalarField Cvf
(

View File

@ -1,5 +1,5 @@
// Volume-to surface mapping object
const volSurfaceMapping vsm(aMesh);
// Create volume-to surface mapping object
volSurfaceMapping vsm(aMesh);
volScalarField Cvf
(

View File

@ -10,7 +10,7 @@ EXE_INC = \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/regionFaModels/lnInclude
-I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \
-lfiniteVolume \

View File

@ -7,7 +7,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/regionFaModels/lnInclude
-I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \
-lfiniteVolume \

View File

@ -19,7 +19,7 @@ EXE_INC = \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionFaModels/lnInclude
-I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \

View File

@ -113,19 +113,15 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
fvMesh& mesh = fluidRegions[i];
#include "readFluidMultiRegionPIMPLEControls.H"
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
#include "solveFluid.H"
}
forAll(solidRegions, i)
{
fvMesh& mesh = solidRegions[i];
#include "readSolidMultiRegionPIMPLEControls.H"
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H"
}
@ -137,10 +133,8 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
fvMesh& mesh = fluidRegions[i];
#include "readFluidMultiRegionPIMPLEControls.H"
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
if (!frozenFlow)
{
Info<< "\nSolving for fluid region "
@ -172,24 +166,20 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
fvMesh& mesh = fluidRegions[i];
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
#include "readFluidMultiRegionPIMPLEControls.H"
#include "setRegionFluidFields.H"
frozenFlow = true;
#include "solveFluid.H"
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
frozenFlow = true;
#include "solveFluid.H"
}
forAll(solidRegions, i)
{
fvMesh& mesh = solidRegions[i];
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "readSolidMultiRegionPIMPLEControls.H"
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H"
}

View File

@ -76,21 +76,17 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
fvMesh& mesh = fluidRegions[i];
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
#include "readFluidMultiRegionSIMPLEControls.H"
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionSIMPLEControls.H"
#include "solveFluid.H"
}
forAll(solidRegions, i)
{
fvMesh& mesh = solidRegions[i];
#include "readSolidMultiRegionSIMPLEControls.H"
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
#include "solveSolid.H"
}
@ -103,10 +99,8 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
fvMesh& mesh = fluidRegions[i];
#include "readSolidMultiRegionSIMPLEControls.H"
#include "setRegionFluidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
if (!frozenFlow)
{
#include "pEqn.H"
@ -127,24 +121,20 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
fvMesh& mesh = fluidRegions[i];
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
#include "readFluidMultiRegionSIMPLEControls.H"
#include "setRegionFluidFields.H"
frozenFlow = true;
#include "solveFluid.H"
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionSIMPLEControls.H"
frozenFlow = true;
#include "solveFluid.H"
}
forAll(solidRegions, i)
{
fvMesh& mesh = solidRegions[i];
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "readSolidMultiRegionSIMPLEControls.H"
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
#include "solveSolid.H"
}

View File

@ -5,5 +5,3 @@
const bool momentumPredictor =
simple.getOrDefault("momentumPredictor", true);
simple.readIfPresent("frozenFlow", frozenFlowFluid[i]);

View File

@ -1,3 +1,5 @@
const fvMesh& mesh = fluidRegions[i];
rhoThermo& thermo = thermoFluid[i];
thermo.validate(args.executable(), "h", "e");

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -108,23 +108,19 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
fvMesh& mesh = fluidRegions[i];
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
#include "readFluidMultiRegionPIMPLEControls.H"
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
#include "solveFluid.H"
}
forAll(solidRegions, i)
{
fvMesh& mesh = solidRegions[i];
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "readSolidMultiRegionPIMPLEControls.H"
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H"
}
@ -139,24 +135,20 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
fvMesh& mesh = fluidRegions[i];
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
#include "readFluidMultiRegionPIMPLEControls.H"
#include "setRegionFluidFields.H"
frozenFlow = true;
#include "solveFluid.H"
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
frozenFlow = true;
#include "solveFluid.H"
}
forAll(solidRegions, i)
{
fvMesh& mesh = solidRegions[i];
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "readSolidMultiRegionPIMPLEControls.H"
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H"
}
}

View File

@ -88,29 +88,26 @@ kappa
case mtLookup:
{
if (mesh.foundObject<volScalarField>(kappaName_))
{
const auto* ptr =
mesh.cfindObject<volScalarField>(kappaName_);
if (ptr)
{
return patch().patchField(*ptr);
}
return patch().lookupPatchField<volScalarField, scalar>
(
kappaName_
);
}
else if (mesh.foundObject<volSymmTensorField>(kappaName_))
{
const auto* ptr =
mesh.cfindObject<volSymmTensorField>(kappaName_);
const symmTensorField& KWall =
patch().lookupPatchField<volSymmTensorField, scalar>
(
kappaName_
);
if (ptr)
{
const symmTensorField& KWall = patch().patchField(*ptr);
const vectorField n(patch().nf());
const vectorField n(patch().nf());
return n & KWall & n;
}
return n & KWall & n;
}
else
{
FatalErrorInFunction
<< "Did not find field " << kappaName_
@ -120,6 +117,9 @@ kappa
<< " or volSymmTensorField."
<< exit(FatalError);
}
break;
}
@ -131,8 +131,10 @@ kappa
mesh.lookupObject<phaseSystem>("phaseProperties")
);
auto tkappaEff = tmp<scalarField>::New(patch().size(), Zero);
auto& kappaEff = tkappaEff.ref();
tmp<scalarField> kappaEff
(
new scalarField(patch().size(), 0.0)
);
forAll(fluid.phases(), phasei)
{
@ -140,10 +142,10 @@ kappa
const fvPatchScalarField& alpha = phase.boundaryField()[patchi];
kappaEff += alpha*phase.kappaEff(patchi)();
kappaEff.ref() += alpha*phase.kappaEff(patchi)();
}
return tkappaEff;
return kappaEff;
break;
}
@ -159,11 +161,9 @@ kappa
}
}
// Return zero-sized (not nullptr)
return tmp<scalarField>::New();
return scalarField(0);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -308,11 +308,12 @@ updateCoeffs()
scalarField& Tp = *this;
const auto& nbrField =
refCast
<
const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField
>(nbrPatch.lookupPatchField<volScalarField>(TnbrName_));
const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField&
nbrField = refCast
<const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField>
(
nbrPatch.lookupPatchField<volScalarField, scalar>(TnbrName_)
);
// Swap to obtain full local values of neighbour internal field
scalarField TcNbr(nbrField.patchInternalField());
@ -329,13 +330,13 @@ updateCoeffs()
scalarField qr(Tp.size(), 0.0);
if (qrName_ != "none")
{
qr = patch().lookupPatchField<volScalarField>(qrName_);
qr = patch().lookupPatchField<volScalarField, scalar>(qrName_);
}
scalarField qrNbr(Tp.size(), 0.0);
if (qrNbrName_ != "none")
{
qrNbr = nbrPatch.lookupPatchField<volScalarField>(qrNbrName_);
qrNbr = nbrPatch.lookupPatchField<volScalarField, scalar>(qrNbrName_);
mpp.distribute(qrNbr);
}
@ -485,7 +486,7 @@ void turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField::write
Ostream& os
) const
{
mixedFvPatchField<scalar>::write(os);
mixedFvPatchScalarField::write(os);
os.writeEntry("kappaMethod", KMethodTypeNames_[method_]);
os.writeEntryIfDifferent<word>("kappa","none", kappaName_);

View File

@ -9,5 +9,3 @@
(
pimpleDict.getOrDefault<int>("nEnergyCorrectors", 1)
);
pimpleDict.readIfPresent("frozenFlow", frozenFlowFluid[i]);

View File

@ -1,3 +1,5 @@
fvMesh& mesh = fluidRegions[i];
twoPhaseSystem& fluid = phaseSystemFluid[i];
phaseModel& phase1 = fluid.phase1();

View File

@ -48,7 +48,7 @@ if (Y.size())
fvOptions.correct(Yi);
Yi.clamp_min(0);
Yi.max(0.0);
Yt += Yi;
}
}
@ -56,6 +56,6 @@ if (Y.size())
if (Y.size())
{
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].clamp_min(0);
Y[inertIndex].max(0.0);
}
}

View File

@ -8,5 +8,3 @@
const bool momentumPredictor =
pimple.getOrDefault("momentumPredictor", true);
pimple.readIfPresent("frozenFlow", frozenFlowFluid[i]);

View File

@ -1,3 +1,5 @@
fvMesh& mesh = fluidRegions[i];
CombustionModel<rhoReactionThermo>& reaction = reactionFluid[i];
rhoReactionThermo& thermo = reaction.thermo();

View File

@ -1,3 +1,4 @@
fvMesh& mesh = solidRegions[i];
solidThermo& thermo = thermos[i];
tmp<volScalarField> trho = thermo.rho();

View File

@ -89,10 +89,17 @@ void Foam::adjointOutletPressureFvPatchScalarField::updateCoeffs()
return;
}
const auto& phip = patch().lookupPatchField<surfaceScalarField>("phi");
const auto& phiap = patch().lookupPatchField<surfaceScalarField>("phia");
const auto& Up = patch().lookupPatchField<volVectorField>("U");
const auto& Uap = patch().lookupPatchField<volVectorField>("Ua");
const fvsPatchField<scalar>& phip =
patch().lookupPatchField<surfaceScalarField, scalar>("phi");
const fvsPatchField<scalar>& phiap =
patch().lookupPatchField<surfaceScalarField, scalar>("phia");
const fvPatchField<vector>& Up =
patch().lookupPatchField<volVectorField, vector>("U");
const fvPatchField<vector>& Uap =
patch().lookupPatchField<volVectorField, vector>("Ua");
operator==((phiap/patch().magSf() - 1.0)*phip/patch().magSf() + (Up & Uap));
@ -102,8 +109,8 @@ void Foam::adjointOutletPressureFvPatchScalarField::updateCoeffs()
void Foam::adjointOutletPressureFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
fvPatchField<scalar>::writeValueEntry(os);
fvPatchScalarField::write(os);
writeEntry("value", os);
}

View File

@ -90,8 +90,11 @@ void Foam::adjointOutletVelocityFvPatchVectorField::updateCoeffs()
return;
}
const auto& phiap = patch().lookupPatchField<surfaceScalarField>("phia");
const auto& Up = patch().lookupPatchField<volVectorField>("U");
const fvsPatchField<scalar>& phiap =
patch().lookupPatchField<surfaceScalarField, scalar>("phia");
const fvPatchField<vector>& Up =
patch().lookupPatchField<volVectorField, vector>("U");
scalarField Un(mag(patch().nf() & Up));
vectorField UtHat((Up - patch().nf()*Un)/(Un + SMALL));
@ -107,8 +110,8 @@ void Foam::adjointOutletVelocityFvPatchVectorField::updateCoeffs()
void Foam::adjointOutletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
fvPatchField<vector>::writeValueEntry(os);
fvPatchVectorField::write(os);
writeEntry("value", os);
}

View File

@ -8,7 +8,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/regionFaModels/lnInclude
-I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \
-lfiniteVolume \

View File

@ -94,7 +94,7 @@ if (mesh.changing())
{
if (refCells[zoneId] != -1)
{
validCells.push_back(refCells[zoneId]);
validCells.append(refCells[zoneId]);
}
}

View File

@ -40,11 +40,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
fvOptions.correct(Yi);
Yi.clamp_min(0);
Yi.max(0.0);
Yt += Yi;
}
}
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].clamp_min(0);
Y[inertIndex].max(0.0);
}

View File

@ -41,11 +41,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
fvOptions.correct(Yi);
Yi.clamp_min(0);
Yi.max(0.0);
Yt += Yi;
}
}
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].clamp_min(0);
Y[inertIndex].max(0.0);
}

View File

@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
fvOptions.correct(Yi);
Yi.clamp_min(0);
Yi.max(0.0);
Yt += Yi;
}
}
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].clamp_min(0);
Y[inertIndex].max(0.0);
}

View File

@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
fvOptions.correct(Yi);
Yi.clamp_min(0);
Yi.max(0.0);
Yt += Yi;
}
}
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].clamp_min(0);
Y[inertIndex].max(0.0);
}

View File

@ -39,11 +39,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
fvOptions.correct(Yi);
Yi.clamp_min(0);
Yi.max(0.0);
Yt += Yi;
}
}
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].clamp_min(0);
Y[inertIndex].max(0.0);
}

View File

@ -1,5 +1,14 @@
{
alphav = clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});
alphav =
max
(
min
(
(rho - rholSat)/(rhovSat - rholSat),
scalar(1)
),
scalar(0)
);
alphal = 1.0 - alphav;
Info<< "max-min alphav: " << max(alphav).value()

View File

@ -126,9 +126,9 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
fvPatchScalarField::write(os);
os.writeEntry("thetaProperties", thetaProps_);
fvPatchField<scalar>::writeValueEntry(os);
writeEntry("value", os);
}

View File

@ -779,7 +779,7 @@ Foam::multiphaseMixtureThermo::surfaceTensionForce() const
auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2));
if (!sigma.good())
if (!sigma.found())
{
FatalErrorInFunction
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
@ -907,7 +907,7 @@ void Foam::multiphaseMixtureThermo::correctContactAngle
const auto tp =
acap.thetaProps().cfind(interfacePair(alpha1, alpha2));
if (!tp.good())
if (!tp.found())
{
FatalErrorInFunction
<< "Cannot find interface " << interfacePair(alpha1, alpha2)

View File

@ -99,6 +99,17 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotAlphal() const
Foam::Pair<Foam::tmp<Foam::volScalarField>>
Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
{
volScalarField limitedAlpha1
(
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
);
volScalarField limitedAlpha2
(
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
);
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
const twoPhaseMixtureEThermo& thermo =
@ -113,15 +124,11 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
volScalarField mDotE
(
"mDotE",
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
* max(T - TSat, T0)
"mDotE", coeffE_*mixture_.rho1()*limitedAlpha1*max(T - TSat, T0)
);
volScalarField mDotC
(
"mDotC",
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
* max(TSat - T, T0)
"mDotC", coeffC_*mixture_.rho2()*limitedAlpha2*max(TSat - T, T0)
);
if (mesh_.time().outputTime())
@ -141,6 +148,16 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
Foam::Pair<Foam::tmp<Foam::volScalarField>>
Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotDeltaT() const
{
volScalarField limitedAlpha1
(
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
);
volScalarField limitedAlpha2
(
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
);
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
const twoPhaseMixtureEThermo& thermo =
@ -153,14 +170,8 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotDeltaT() const
return Pair<tmp<volScalarField>>
(
(
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
* pos(TSat - T)
),
(
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
* pos(T - TSat)
)
coeffC_*mixture_.rho2()*limitedAlpha2*pos(TSat - T),
coeffE_*mixture_.rho1()*limitedAlpha1*pos(T - TSat)
);
}
@ -190,17 +201,25 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::TSource() const
const dimensionedScalar& TSat = thermo.TSat();
const dimensionedScalar L = mixture_.Hf2() - mixture_.Hf1();
dimensionedScalar L = mixture_.Hf2() - mixture_.Hf1();
volScalarField limitedAlpha1
(
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
);
volScalarField limitedAlpha2
(
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
);
const volScalarField Vcoeff
(
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
* L*pos(T - TSat)
coeffE_*mixture_.rho1()*limitedAlpha1*L*pos(T - TSat)
);
const volScalarField Ccoeff
(
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
* L*pos(TSat - T)
coeffC_*mixture_.rho2()*limitedAlpha2*L*pos(TSat - T)
);
TSource =

View File

@ -167,10 +167,20 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
Foam::temperaturePhaseChangeTwoPhaseMixtures::interfaceHeatResistance::
mDotAlphal() const
{
volScalarField limitedAlpha1
(
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
);
volScalarField limitedAlpha2
(
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
);
return Pair<tmp<volScalarField>>
(
(mDotc_/clamp(mixture_.alpha2(), scalarMinMax(SMALL, 1))),
-(mDote_/clamp(mixture_.alpha1(), scalarMinMax(SMALL, 1)))
(mDotc_/(limitedAlpha2 + SMALL)),
-(mDote_/(limitedAlpha1 + SMALL))
);
}

View File

@ -155,7 +155,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::Cp() const
{
const volScalarField limitedAlpha1
(
clamp(alpha1_, zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
return tmp<volScalarField>
@ -176,11 +176,13 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::Cp
const label patchi
) const
{
const scalarField alpha1p
const volScalarField limitedAlpha1
(
clamp(alpha1_.boundaryField()[patchi], zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
return
(
alpha1p*Cp1().value() + (scalar(1) - alpha1p)*Cp2().value()
@ -192,7 +194,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::rho() const
{
const volScalarField limitedAlpha1
(
clamp(alpha1_, zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
return tmp<volScalarField>
@ -212,11 +214,13 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::rho
const label patchi
) const
{
const scalarField alpha1p
const volScalarField limitedAlpha1
(
clamp(alpha1_.boundaryField()[patchi], zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
return
(
alpha1p*rho1().value() + (scalar(1) - alpha1p)*rho2().value()
@ -228,7 +232,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::Cv() const
{
const volScalarField limitedAlpha1
(
clamp(alpha1_, zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
return tmp<volScalarField>
@ -249,11 +253,13 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::Cv
const label patchi
) const
{
const scalarField alpha1p
const volScalarField limitedAlpha1
(
clamp(alpha1_.boundaryField()[patchi], zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
return
(
alpha1p*Cv1().value() + (scalar(1) - alpha1p)*Cv2().value()
@ -333,7 +339,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::kappa() const
{
const volScalarField limitedAlpha1
(
clamp(alpha1_, zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
return tmp<volScalarField>
@ -352,11 +358,13 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::kappa
const label patchi
) const
{
const scalarField alpha1p
const volScalarField limitedAlpha1
(
clamp(alpha1_.boundaryField()[patchi], zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
return (alpha1p*kappa1().value() + (1 - alpha1p)*kappa2().value());
}
@ -394,11 +402,13 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::kappaEff
const label patchi
) const
{
const scalarField alpha1p
const volScalarField limitedAlpha1
(
clamp(alpha1_.boundaryField()[patchi], zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
return
(alpha1p*kappa1().value() + (1 - alpha1p)*kappa2().value()) + kappat;
@ -425,11 +435,13 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::alphaEff
const label patchi
) const
{
const scalarField alpha1p
const volScalarField limitedAlpha1
(
clamp(alpha1_.boundaryField()[patchi], zero_one{})
min(max(alpha1_, scalar(0)), scalar(1))
);
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
const scalarField rho
(
alpha1p*rho1().value() + (1.0 - alpha1p)*rho2().value()

View File

@ -103,7 +103,7 @@
{
if (refCells[zoneId] != -1)
{
validCells.push_back(refCells[zoneId]);
validCells.append(refCells[zoneId]);
}
}

View File

@ -70,7 +70,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
Foam::phaseChangeTwoPhaseMixtures::Kunz::mDotAlphal() const
{
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
return Pair<tmp<volScalarField>>
(
@ -85,7 +85,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
Foam::phaseChangeTwoPhaseMixtures::Kunz::mDotP() const
{
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
return Pair<tmp<volScalarField>>
(

View File

@ -82,7 +82,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
Foam::phaseChangeTwoPhaseMixtures::Merkle::mDotP() const
{
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
return Pair<tmp<volScalarField>>
(

View File

@ -99,7 +99,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::pCoeff
const volScalarField& p
) const
{
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
volScalarField rho
(
limitedAlpha1*rho1() + (scalar(1) - limitedAlpha1)*rho2()
@ -117,7 +117,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotAlphal() const
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
volScalarField pCoeff(this->pCoeff(p));
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
return Pair<tmp<volScalarField>>
(
@ -134,7 +134,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotP() const
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
volScalarField pCoeff(this->pCoeff(p));
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
volScalarField apCoeff(limitedAlpha1*pCoeff);
return Pair<tmp<volScalarField>>

View File

@ -37,7 +37,7 @@ surfaceScalarField phi
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimVelocity*dimArea, Zero)
dimensionedScalar(dimArea*dimVelocity, Zero)
);
multiphaseSystem fluid(U, phi);

View File

@ -53,7 +53,7 @@
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimVelocity*dimArea, Zero)
dimensionedScalar(dimArea*dimVelocity, Zero)
);
volScalarField rho("rho", fluid.rho());

View File

@ -126,9 +126,9 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
fvPatchScalarField::write(os);
os.writeEntry("thetaProperties", thetaProps_);
fvPatchField<scalar>::writeValueEntry(os);
writeEntry("value", os);
}

View File

@ -287,7 +287,7 @@ Foam::multiphaseMixture::surfaceTensionForce() const
auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2));
if (!sigma.good())
if (!sigma.found())
{
FatalErrorInFunction
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
@ -463,7 +463,7 @@ void Foam::multiphaseMixture::correctBoundaryContactAngle
const auto tp = acap.thetaProps().cfind(interfacePair(alpha1, alpha2));
if (!tp.good())
if (!tp.found())
{
FatalErrorInFunction
<< "Cannot find interface " << interfacePair(alpha1, alpha2)

View File

@ -180,7 +180,7 @@ while (pimple.correct())
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimVelocity*dimArea, Zero)
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
);
forAll(phases, phasei)

View File

@ -165,7 +165,7 @@ while (pimple.correct())
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimVelocity*dimArea, Zero)
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
);
forAll(phases, phasei)

View File

@ -152,9 +152,14 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
db().lookupObject<IOdictionary>("thermalProperties");
const auto& rho = patch().lookupPatchField<volScalarField>("rho");
const auto& rhoE = patch().lookupPatchField<volScalarField>("E");
const auto& nu = patch().lookupPatchField<volScalarField>("nu");
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>("rho");
const fvPatchField<scalar>& rhoE =
patch().lookupPatchField<volScalarField, scalar>("E");
const fvPatchField<scalar>& nu =
patch().lookupPatchField<volScalarField, scalar>("nu");
scalarField E(rhoE/rho);
scalarField mu(E/(2.0*(1.0 + nu)));
@ -171,7 +176,8 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
vectorField n(patch().nf());
const auto& sigmaD = patch().lookupPatchField<volSymmTensorField>("sigmaD");
const fvPatchField<symmTensor>& sigmaD =
patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
gradient() =
(
@ -181,10 +187,11 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
if (thermalProperties.get<bool>("thermalStress"))
{
const auto& threeKalpha =
patch().lookupPatchField<volScalarField>("threeKalpha");
const fvPatchField<scalar>& threeKalpha=
patch().lookupPatchField<volScalarField, scalar>("threeKalpha");
const auto& T = patch().lookupPatchField<volScalarField>("T");
const fvPatchField<scalar>& T =
patch().lookupPatchField<volScalarField, scalar>("T");
gradient() += n*threeKalpha*T/twoMuLambda;
}
@ -195,10 +202,10 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
void tractionDisplacementFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
fvPatchVectorField::write(os);
traction_.writeEntry("traction", os);
pressure_.writeEntry("pressure", os);
fvPatchField<vector>::writeValueEntry(os);
writeEntry("value", os);
}

View File

@ -152,9 +152,14 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
"mechanicalProperties"
);
const auto& rho = patch().lookupPatchField<volScalarField>("rho");
const auto& rhoE = patch().lookupPatchField<volScalarField>("E");
const auto& nu = patch().lookupPatchField<volScalarField>("nu");
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>("rho");
const fvPatchField<scalar>& rhoE =
patch().lookupPatchField<volScalarField, scalar>("E");
const fvPatchField<scalar>& nu =
patch().lookupPatchField<volScalarField, scalar>("nu");
scalarField E(rhoE/rho);
scalarField mu(E/(2.0*(1.0 + nu)));
@ -167,8 +172,11 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
vectorField n(patch().nf());
const auto& sigmaD = patch().lookupPatchField<volSymmTensorField>("sigmaD");
const auto& sigmaExp = patch().lookupPatchField<volTensorField>("sigmaExp");
const fvPatchField<symmTensor>& sigmaD =
patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
const fvPatchField<tensor>& sigmaExp =
patch().lookupPatchField<volTensorField, tensor>("sigmaExp");
gradient() =
(
@ -182,10 +190,10 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
// Write
void tractionDisplacementCorrectionFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
fvPatchVectorField::write(os);
traction_.writeEntry("traction", os);
pressure_.writeEntry("pressure", os);
fvPatchField<vector>::writeValueEntry(os);
writeEntry("value", os);
}

View File

@ -64,23 +64,23 @@ inline Ostream& report
int main(int argc, char *argv[])
{
CircularBuffer<label> buf1(1); report(buf1);
buf1.push_back(10); report(buf1);
buf1.append(10); report(buf1);
Info<< buf1.range_one() << nl;
buf1.push_back(20); report(buf1);
buf1.push_back(30); report(buf1);
buf1.append(20); report(buf1);
buf1.append(30); report(buf1);
buf1.push_back(40); report(buf1);
buf1.push_front(-50); report(buf1);
buf1.push_back(60); report(buf1);
buf1.push_back(labelList({70,80,90})); report(buf1);
buf1.append(60); report(buf1);
buf1.append(labelList({70,80,90})); report(buf1);
Info<< nl << "access: " << buf1 << nl;
Info<< buf1[-12] << nl;
Info<< "found: " << buf1.found(40) << nl;
buf1.push_uniq(100); report(buf1);
buf1.appendUniq(100); report(buf1);
buf1 = Zero; report(buf1);
@ -92,7 +92,7 @@ int main(int argc, char *argv[])
}
report(buf1);
buf1.push_back(identity(5)); report(buf1);
buf1.append(identity(5)); report(buf1);
buf1.info(Info);
Info<< buf1 << nl;

View File

@ -67,11 +67,11 @@ int main(int argc, char *argv[])
for (int i = 0; i<10; i++)
{
myList.push_back(1.3*i);
myList.append(1.3*i);
}
myList.push_back(100.3);
myList.push_back(500.3);
myList.append(100.3);
myList.append(500.3);
Info<< "DLList<scalar>" << nl;
Info<< nl << "flat-output: " << flatOutput(myList) << nl;
@ -144,9 +144,9 @@ int main(int argc, char *argv[])
Info<< " => " << flatOutput(myList) << nl;
}
myList.push_back(500.3);
myList.push_back(200.3);
myList.push_back(100.3);
myList.append(500.3);
myList.append(200.3);
myList.append(100.3);
Info<< nl << "Testing swapUp and swapDown:" << nl;
Info<< " => " << flatOutput(myList) << nl;
@ -200,7 +200,7 @@ int main(int argc, char *argv[])
for (int i = 0; i<5; i++)
{
labList.push_back(identity(6));
labList.append(identity(6));
}
Info<< nl
@ -221,16 +221,16 @@ int main(int argc, char *argv[])
List<label> content1 = identity(10);
Info<< nl
<< " move push_back ";
<< " move append ";
printAddress(content1);
labList.push_back(std::move(content1));
labList.append(std::move(content1));
Info<< " content " << flatOutput(content1) << nl
<< " list" << labList << nl;
printAddresses(labList);
// labList.push_back(content1);
// labList.append(content1);
}
Info<< nl << "Done." << endl;

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,29 +52,28 @@ int main(int argc, char *argv[])
Info << "testField:" << testField << endl;
testField.emplace_back(0.5, 4.8, 6.2);
testField.append(vector(0.5, 4.8, 6.2));
Info << "testField after appending:" << testField << endl;
testField.emplace_back(2.7, 2.3, 6.1);
testField.append(vector(2.7, 2.3, 6.1));
Info << "testField after appending:" << testField << endl;
vector elem = testField.back();
testField.pop_back();
vector elem = testField.remove();
Info << "removed element:" << elem << endl;
Info << "testField:" << testField << endl;
testField.emplace_back(3.0, 1.3, 9.2);
testField.append(vector(3.0, 1.3, 9.2));
Info << "testField:" << testField << endl;
testField.resize(10, vector(1.5, 0.6, -1.0));
testField.setSize(10, vector(1.5, 0.6, -1.0));
Info << "testField after setSize:" << testField << endl;
testField.push_back(testField2);
testField.append(testField2);
Info << "testField after appending testField2:" << testField << endl;
@ -89,7 +87,7 @@ int main(int argc, char *argv[])
testField.clear();
testField.emplace_back(3.0, 1.3, 9.2);
testField.append(vector(3.0, 1.3, 9.2));
Info << "testField after clear and append:" << testField << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -140,7 +140,7 @@ int main(int argc, char *argv[])
{
0, 1, 2, 3, 4
};
dlA.push_back({ 5, 6 });
dlA.append({ 5, 6 });
dlA = { 1, 2, 4 };
DynamicList<label> dlB;
@ -172,7 +172,7 @@ int main(int argc, char *argv[])
// Copy back and append a few time
for (label i=0; i < 3; i++)
{
dlB.push_back(lstA);
dlB.append(lstA);
}
Info<< "appended list a few times" << endl;
@ -186,7 +186,7 @@ int main(int argc, char *argv[])
// Copy back and append a few time
for (label i=0; i < 3; i++)
{
dlB.push_back(lstA);
dlB.append(lstA);
}
@ -220,8 +220,8 @@ int main(int argc, char *argv[])
for (label elemI=0; elemI < 5; ++elemI)
{
dlE1.push_back(4 - elemI);
dlE2.push_back(elemI);
dlE1.append(4 - elemI);
dlE2.append(elemI);
}
printInfo("dlE2", dlE2, true);
@ -243,12 +243,9 @@ int main(int argc, char *argv[])
{
DynamicList<label> addr(10);
addr.emplace_back(3);
addr.emplace_back(1);
addr.emplace_back(2);
// Can also use the return value
Info<< "adding " << addr.emplace_back(4) << endl;
addr.append(3);
addr.append(1);
addr.append(2);
forAll(dlE2, i)
{
@ -300,9 +297,9 @@ int main(int argc, char *argv[])
Info<< "test move-append with "
<< flatOutput(input1) << " and " << flatOutput(input2) << endl;
list2.push_back(std::move(list1));
list2.push_back(std::move(input1));
list2.push_back(std::move(input2));
list2.append(std::move(list1));
list2.append(std::move(input1));
list2.append(std::move(input2));
Info<< "result: " << flatOutput(list2) << nl
<< "inputs: " << flatOutput(list1) << " / "

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -309,45 +309,32 @@ int main(int argc, char *argv[])
if (Pstream::parRun())
{
// Fixed buffer would also work, but want to test using UList
List<labelPair> buffer;
const label startOfRequests = UPstream::nRequests();
if (Pstream::master())
{
buffer.resize(UPstream::nProcs());
buffer[0] = labelPair(0, UPstream::myProcNo());
for (const int proci : Pstream::subProcs())
{
UIPstream::read
(
UPstream::commsTypes::nonBlocking,
proci,
buffer.slice(proci, 1)
);
IPstream fromSlave(Pstream::commsTypes::blocking, proci);
FixedList<label, 2> list3(fromSlave);
Serr<< "Receiving from " << proci
<< " : " << list3 << endl;
}
}
else
{
buffer.resize(1);
buffer[0] = labelPair(0, UPstream::myProcNo());
Perr<< "Sending to master" << endl;
Perr<< "Sending to master: " << buffer << endl;
UOPstream::write
OPstream toMaster
(
UPstream::commsTypes::nonBlocking,
UPstream::masterNo(),
buffer.slice(0, 1) // OK
/// buffer // Also OK
Pstream::commsTypes::blocking,
Pstream::masterNo()
);
FixedList<label, 2> list3;
list3[0] = 0;
list3[1] = Pstream::myProcNo();
toMaster << list3;
}
UPstream::waitRequests(startOfRequests);
Info<< "Gathered: " << buffer << endl;
}
return 0;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2023 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -109,11 +109,7 @@ int main(int argc, char *argv[])
{
#include "setConstantRunTimeDictionaryIO.H"
#if (OPENFOAM > 2212)
dictionary propsDict(IOdictionary::readContents(dictIO));
#else
dictionary propsDict(static_cast<dictionary&&>(IOdictionary(dictIO)));
#endif
IOdictionary propsDict(dictIO);
const scalarField xvals(propsDict.lookup("x"));
@ -136,7 +132,7 @@ int main(int argc, char *argv[])
{
if (nameFilter(f))
{
functionNames.push_back(f);
functionNames.append(f);
}
}
}
@ -144,7 +140,7 @@ int main(int argc, char *argv[])
{
for (label argi=1; argi < args.size(); ++argi)
{
functionNames.push_back(args[argi]);
functionNames.append(args[argi]);
}
}

View File

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

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +25,11 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Some simple HashSet tests
\*---------------------------------------------------------------------------*/
#include "hashedWordList.H"
#include "nil.H"
#include "HashOps.H"
#include "HashSet.H"
#include "Map.H"
@ -37,6 +37,8 @@ Description
#include "labelPairHashes.H"
#include "FlatOutput.H"
#include <algorithm>
using namespace Foam;
template<class Iter>
@ -73,22 +75,6 @@ void printMinMax(const HashSet<Key, Hash>& set)
}
template<class Key, class Hash>
void printHashSet(const HashSet<Key, Hash>& table)
{
Info<< table.size() << '(' << nl;
for (const auto& key : table.sortedToc())
{
const auto iter = table.find(key);
Info<< " " << key << " : " << Foam::name(&(iter.key())) << nl;
}
Info<< ')' << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
@ -100,33 +86,33 @@ int main(int argc, char *argv[])
<< typeid(HashSet<label>::hasher).name() << nl << nl;
hashedWordList words
({
{
"abc",
"def",
"ghi"
});
};
words = { "def", "ghi", "xy", "all", "end", "all" };
wordHashSet setA
({
{
"xx",
"yy",
"zz"
});
};
setA = { "kjhk", "kjhk2", "abced" };
HashTable<label> tableA
({
{
{ "value1", 1 },
{ "value2", 2 },
{ "value3", 3 }
});
};
HashTable<Foam::zero> tableB;
tableB.emplace("value4");
tableB.emplace("value5");
tableB.emplace("value6");
HashTable<nil> tableB;
tableB.insert("value4", nil());
tableB.insert("value5", nil());
tableB.insert("value6", nil());
Info<< "tableA keys: "; tableA.writeKeys(Info) << endl;
@ -139,11 +125,11 @@ int main(int argc, char *argv[])
}
Map<label> mapA
({
{
{ 1, 1 },
{ 2, 2 },
{ 3, 3 }
});
};
mapA.set(4, 4);
Info<< "hashedWordList: " << words << nl
@ -185,7 +171,7 @@ int main(int argc, char *argv[])
Info<< wordHashSet(setA) << endl;
Info<< "create from HashTable<T>: ";
Info<< wordHashSet(tableA) << endl;
Info<< "create from HashTable<zero>: ";
Info<< "create from HashTable<nil>: ";
Info<< wordHashSet(tableB) << endl;
Info<< "create from Map<label>: ";
@ -201,9 +187,9 @@ int main(int argc, char *argv[])
}
labelHashSet setB
({
{
1, 11, 42
});
};
Info<<"Set with min/max:" << minMax(setB)
<< " min:" << min(setB) << " max:" << max(setB) << nl;
@ -325,26 +311,6 @@ int main(int argc, char *argv[])
Info<< "setA1: " << setA1 << nl
<< "setB1: " << setB1 << nl;
// Merging
{
wordHashSet set0({ "abc", "kjhk", "kjhk2" });
wordHashSet set1({ "abc", "def", "ghi", "jkl" });
Info<< nl
<< "Set0" << nl;
printHashSet(set0);
Info<< "Set1" << nl;
printHashSet(set1);
set1.merge(set0);
Info<< "merged 0" << nl;
printHashSet(set0);
Info<< "merged 1" << nl;
printHashSet(set1);
}
return 0;
}

View File

@ -79,56 +79,26 @@ public:
};
template<class T, class Key, class Hash>
void printTable(const HashPtrTable<T, Key, Hash>& table)
{
Info<< table.size() << '(' << nl;
for (const auto& key : table.sortedToc())
{
const auto iter = table.find(key);
Info
<< " " << iter.key() << " (" << Foam::name(&(iter.key()))
<< ") : ";
if (iter.val())
{
Info<< *(iter.val());
}
else
{
Info<< "nullptr";
}
Info<< " (" << Foam::name(iter.val()) << ")" << nl;;
}
Info<< ')' << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
HashTable<Label, Foam::string> table0
({
{"abc", 123},
HashTable<label, Foam::string> table1
{
{"kjhk", 10},
{"kjhk2", 12}
});
};
Info<< "table0: " << table0 << nl
<< "toc: " << flatOutput(table0.toc()) << nl;
Info<< "table1: " << table1 << nl
<< "toc: " << flatOutput(table1.toc()) << nl;
HashTable<label, label, Hash<label>> table2
({
{
{3, 10},
{5, 12},
{7, 16}
});
};
Info<< "table2: " << table2 << nl
<< "toc: " << flatOutput(table2.toc()) << nl;
@ -157,7 +127,7 @@ int main(int argc, char *argv[])
table1.insert("ghi", 15);
table1.insert("jkl", 20);
Info<< nl << "Table toc: " << flatOutput(table1.sortedToc()) << nl;
Info<< nl << "Table toc: " << flatOutput(table1.toc()) << nl;
for (const word k : { "abc" })
{
@ -183,30 +153,16 @@ int main(int argc, char *argv[])
;
}
}
Info<< nl
<< "Table0: " << flatOutput(table0.sortedToc()) << nl
<< "Table1: " << flatOutput(table1.sortedToc()) << nl;
table1.merge(table0);
Info<< "merged 0: " << flatOutput(table0.sortedToc()) << nl
<< "merged 1: " << flatOutput(table1.sortedToc()) << nl;
}
{
HashPtrTable<Label> ptable0(0);
ptable0.emplace("abc", 123),
ptable0.emplace("kjhk", 10);
ptable0.emplace("kjhk2", 12);
HashPtrTable<Label> ptable1(0);
ptable1.insert("abc", autoPtr<Label>::New(5));
ptable1.emplace("def", 10);
ptable1.emplace("ghi", 15);
ptable1.emplace("jkl", 20);
ptable1.insert("def", autoPtr<Label>::New(10));
ptable1.insert("ghi", autoPtr<Label>::New(15));
ptable1.insert("jkl", autoPtr<Label>::New(20));
Info<< nl << "PtrTable toc: " << flatOutput(ptable1.sortedToc()) << nl;
Info<< nl << "PtrTable toc: " << flatOutput(ptable1.toc()) << nl;
for (const word k : { "abc" })
{
@ -286,20 +242,6 @@ int main(int argc, char *argv[])
}
}
Info<< nl
<< "Table0" << nl;
printTable(ptable0);
Info<< "Table1" << nl;
printTable(ptable1);
ptable1.merge(ptable0);
Info<< "merged 0" << nl;
printTable(ptable0);
Info<< "merged 1" << nl;
printTable(ptable1);
Info<< nl << "Ending scope" << nl;
}
@ -335,28 +277,6 @@ int main(int argc, char *argv[])
Info<< "got with " << (*iter).size() << nl;
}
Info<< nl
<< "Test (DIY) insert_or_assign" << nl;
label nKeys = 0;
for (const auto& key : { "abc", "foo", "mno", "xyz" })
{
Info<< key;
if (ltable1.contains(key))
{
Info<< " : " << ltable1[key];
}
else
{
Info<< " : n/a";
}
/// ltable1.insert_or_assign(key, identity(++nKeys));
ltable1(key) = identity(++nKeys);
Info<< " --> " << ltable1[key] << nl;
}
}
Info<< "\nEnd\n" << endl;

View File

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

View File

@ -334,7 +334,7 @@ int main(int argc, char *argv[])
Info<< "==target==" << nl; reportDetail(objects);
Info<< "==source==" << nl; reportDetail(other);
objects.merge(other);
objects.merge(std::move(other));
Info<< nl << "After merge" << nl;
Info<< "==target==" << nl; reportDetail(objects);

View File

@ -76,11 +76,11 @@ int main(int argc, char *argv[])
for (int i = 0; i<10; i++)
{
myList.push_back(new Scalar(1.3*i));
myList.append(new Scalar(1.3*i));
}
myList.push_back(new Scalar(100.3));
myList.push_back(new Scalar(500.3));
myList.append(new Scalar(100.3));
myList.append(new Scalar(500.3));
Info<< "ISLList<scalar>" << myList << nl;
Info<< nl << "flat-output: " << flatOutput(myList) << nl;

View File

@ -126,8 +126,8 @@ void doTest
if (testskip)
{
Info<< " front : " << its.front().info() << nl
<< " back : " << its.back().info() << nl;
Info<< " first : " << its.peekFirst().info() << nl
<< " last : " << its.peekLast().info() << nl;
Info<< "rewind():" << nl;
reportPeek(its);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -81,7 +81,7 @@ namespace ListPolicy
{
// Override on a per-type basis
template<> struct short_length<short> : std::integral_constant<int,20> {};
template<> struct short_length<short> : std::integral_constant<short,20> {};
} // End namespace ListPolicy
} // End namespace Detail
@ -214,8 +214,8 @@ int main(int argc, char *argv[])
forAllReverseIters(list2, iter) { *iter *= 0.5; Info<< " " << *iter; }
Info<< endl;
list1.push_back(list2);
Info<< "list1.push_back(list2): " << list1 << endl;
list1.append(list2);
Info<< "list1.append(list2): " << list1 << endl;
for (const vector& val : { vector(3, 4, 5), vector(10,11, 12)} )
{
@ -365,12 +365,6 @@ int main(int argc, char *argv[])
Info<<"assigned identity in range:" << subset
<< "=> " << flatOutput(longLabelList) << nl;
// Assign values in iterator range
std::iota(longLabelList.begin(15), longLabelList.begin(50), 115);
Info<<"assigned values in iterator range "
<< "=> " << flatOutput(longLabelList) << nl;
labelList someList(identity(24));
longLabelList.slice(subset) =
@ -416,20 +410,8 @@ int main(int argc, char *argv[])
longLabelList.slice({5,-5}) = 42;
longLabelList.slice({21,100}) = 42;
#if 0
// Compiles, but is runtime abort!
const bool oldThrowingError = FatalError.throwing(true);
try
{
longLabelList.slice(labelRange(20,50)) = constLabelList;
}
catch (const Foam::error& err)
{
Info<< "Caught FatalError "
<< err << nl << endl;
}
FatalError.throwing(oldThrowingError);
#endif
//Good: does not compile
longLabelList.slice(labelRange(20,50)) = constLabelList;
//Good: does not compile
// longLabelList[labelRange(20,50)] = fixedLabelList;

View File

@ -40,6 +40,8 @@ Description
#include "OFstream.H"
#include "cpuTime.H"
#include <initializer_list>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;

View File

@ -40,6 +40,8 @@ Description
#include "OFstream.H"
#include "cpuTime.H"
#include <initializer_list>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;

View File

@ -155,7 +155,7 @@ int main(int argc, char *argv[])
<< IndirectList<label>::subset_if(test6, evenNonZero) << nl
<< endl;
test6.push_back(identity(13, 12));
test6.append(identity(13, 12));
Info<< "Randomized: " << flatOutput(test6) << endl;
inplaceUniqueSort(test6);

View File

@ -191,7 +191,7 @@ int main(int argc, char *argv[])
Info<< nl << "list: " << flatOutput(list) << nl << endl;
list.pop_back();
list.remove();
Info<<"remove = " << flatOutput(list) << nl;
{

View File

@ -52,13 +52,13 @@ int main(int argc, char *argv[])
// Same, but with non-const access
// Map<bool>::iterator map1Iter = map1.find(5);
if (!map1Iter.good())
if (!map1Iter.found()) // same as (map1Iter == map1.end())
{
Info<< "not found" << endl;
}
else
{
Info<< "5 is " << map1Iter.val() << endl;
Info<< "5 is " << *map1Iter << endl;
}
// Repeat with std::map

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -245,10 +245,10 @@ int main(int argc, char *argv[])
list1.resize(8);
report(list1);
Info<< "\ntest push_back() operation\n";
list1.push_back(2);
list1.push_back(3);
list1.push_back(4);
Info<< "\ntest append() operation\n";
list1.append(2);
list1.append(3);
list1.append(4);
report(list1);
Info<< "\ntest reserve() operation\n";
@ -326,9 +326,9 @@ int main(int argc, char *argv[])
report(list1);
Info<< "\ntest copy constructor + push_back\n";
Info<< "\ntest copy constructor + append\n";
PackedList<3> list2(list1);
list2.push_back(4);
list2.append(4);
Info<< "source list:\n";
report(list1);

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -72,9 +71,16 @@ int main(int argc, char *argv[])
label edgeI = 0;
Info<< "Starting walk on edge " << edgeI << endl;
initialEdges.push_back(edgeI);
initialEdges.append(edgeI);
const edge& e = patch.edges()[edgeI];
initialEdgesInfo.emplace_back(e.centre(patch.localPoints()), 0);
initialEdgesInfo.append
(
patchEdgeFaceInfo
(
e.centre(patch.localPoints()),
0.0
)
);
}

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -268,7 +268,10 @@ Ostream& report
int main(int argc, char *argv[])
{
#if 0
PtrList<Scalar> list1(10);
PtrList<Scalar> list2(15);
PtrList<Scalar> listApp;
{
DLPtrList<Scalar> llist1;
llist1.push_front(new Scalar(100));
@ -298,10 +301,8 @@ int main(int argc, char *argv[])
<< "for-: " << it << endl;
}
}
#endif
// Same but as SLPtrList
#if 0
{
SLPtrList<Scalar> llist1;
llist1.push_front(new Scalar(100));
@ -317,27 +318,24 @@ int main(int argc, char *argv[])
PtrList<Scalar> list1b(llist1);
Info<< list1b << endl;
}
#endif
PtrList<Scalar> list1(10);
forAll(list1, i)
{
list1.set(i, new Scalar(1.3*i));
}
PtrList<Scalar> list2(15);
Info<< "Emplace set " << list2.size() << " values" << nl;
forAll(list2, i)
{
list2.emplace(i, (10 + 1.3*i));
}
PtrList<Scalar> listApp;
for (label i = 0; i < 5; ++i)
{
listApp.emplace_back(1.3*i);
listApp.append(new Scalar(1.3*i));
}
listApp.emplace_back(100);
Info<< nl
<< "list1: " << list1 << nl
@ -355,7 +353,7 @@ int main(int argc, char *argv[])
if (old)
{
ptrs.push_back(old.release());
ptrs.append(old.release());
}
}
@ -379,24 +377,6 @@ int main(int argc, char *argv[])
list1.set(i, nullptr);
}
{
Info<< "range-for of list (" << list1.count() << '/'
<< list1.size() << ") non-null entries" << nl
<< "(" << nl;
for (const auto& item : list1)
{
Info<< " " << item << nl;
}
Info<< ")" << nl;
}
{
Info<< "iterate on non-null:" << endl;
forAllConstIters(list1, iter)
{
Info<< " " << iter.key() << " : " << iter.val() << nl;
}
}
Info<< "release some items:" << endl;
for (label i = -2; i < 5; i++)
@ -479,8 +459,8 @@ int main(int argc, char *argv[])
printAddr(Info, dynlist1b);
printAddr(Info, dynlist1c);
dynlist1d.push_back(std::move(dynlist1b));
dynlist1d.push_back(std::move(dynlist1c));
dynlist1d.append(std::move(dynlist1b));
dynlist1d.append(std::move(dynlist1c));
Info<< "result:" << nl;
print(Info, dynlist1d);
@ -497,8 +477,8 @@ int main(int argc, char *argv[])
printAddr(Info, list1b);
printAddr(Info, list1c);
list1d.push_back(std::move(list1b));
list1d.push_back(std::move(list1c));
list1d.append(std::move(list1b));
list1d.append(std::move(list1c));
Info<< "result:" << nl;
print(Info, list1d);
@ -543,7 +523,7 @@ int main(int argc, char *argv[])
printAddr(Info, ulist1);
Info<< nl;
ulist1c.push_back(std::move(ulist1b));
ulist1c.append(std::move(ulist1b));
Info<< "UPtrList append/append:";
printAddr(Info, ulist1c);
@ -584,7 +564,6 @@ int main(int argc, char *argv[])
<< "ulist2: " << ulist2 << nl;
// Test iterator random access
#if (OPENFOAM <= 2212)
{
auto iter1 = ulist1.begin();
auto iter2 = iter1 + 3;
@ -599,7 +578,6 @@ int main(int argc, char *argv[])
Info<< "*" << (*iter1).value() << nl;
Info<< "()" << iter1().value() << nl;
}
#endif
PtrList<plane> planes;
planes.emplace_back(vector::one, vector::one);
@ -618,14 +596,12 @@ int main(int argc, char *argv[])
{
dynPlanes.emplace_back(vector::one, vector::one);
dynPlanes.emplace_back(vector(1,2,3), vector::one);
dynPlanes.push_back(nullptr);
dynPlanes.append(nullptr);
dynPlanes.set(6, new plane(vector(2,2,1), vector::one));
dynPlanes.set(10, new plane(vector(4,5,6), vector::one));
Info<< "emplaced :"
<< dynPlanes.emplace(12, vector(3,2,1), vector::one) << endl;
dynPlanes.emplace(12, vector(3,2,1), vector::one);
dynPlanes.emplace_back(Zero, vector::one);
}
@ -643,10 +619,10 @@ int main(int argc, char *argv[])
Info<< "now append again" << endl;
{
dynPlanes.emplace_back(vector::one, vector::one);
dynPlanes.emplace_back(vector(1,2,3), vector::one);
dynPlanes.append(new plane(vector::one, vector::one));
dynPlanes.append(new plane(vector(1,2,3), vector::one));
dynPlanes.emplace(5, vector(2,2,1), vector::one);
dynPlanes.set(5, new plane(vector(2,2,1), vector::one));
}
report(Info, dynPlanes, true);
@ -682,12 +658,12 @@ int main(int argc, char *argv[])
{
PtrDynList<plane> dynPlanes2;
dynPlanes2.emplace_back(vector::one, vector::one);
dynPlanes2.emplace_back(vector(1,2,3), vector::one);
dynPlanes2.push_back(nullptr);
dynPlanes2.append(new plane(vector::one, vector::one));
dynPlanes2.append(new plane(vector(1,2,3), vector::one));
dynPlanes2.append(nullptr);
dynPlanes2.emplace(6, vector(2,2,1), vector::one);
dynPlanes2.emplace(10, Zero, vector::one);
dynPlanes2.set(6, new plane(vector(2,2,1), vector::one));
dynPlanes2.set(10, new plane(Zero, vector::one));
labelList order;
sortedOrder(dynPlanes2, order);
@ -725,7 +701,7 @@ int main(int argc, char *argv[])
Info<< "Append" << endl;
report(Info, dynPlanes2, false);
dynPlanes.push_back(std::move(dynPlanes2));
dynPlanes.append(std::move(dynPlanes2));
Info<< "Result" << endl;
report(Info, dynPlanes, false);

View File

@ -67,11 +67,11 @@ int main(int argc, char *argv[])
for (int i = 0; i<10; i++)
{
myList.push_back(1.3*i);
myList.append(1.3*i);
}
myList.push_back(100.3);
myList.push_back(500.3);
myList.append(100.3);
myList.append(500.3);
Info<< "SLList<scalar>" << myList << nl;
Info<< nl << "flat-output: " << flatOutput(myList) << nl;
@ -103,11 +103,11 @@ int main(int argc, char *argv[])
for (int i = 0; i<10; i++)
{
myList.push_back(1.3*i);
myList.append(1.3*i);
}
myList.push_back(100.3);
myList.push_back(500.3);
myList.append(100.3);
myList.append(500.3);
Info<< nl << "Transfer: " << nl;
Info<< "original: " << flatOutput(myList) << endl;
@ -143,7 +143,7 @@ int main(int argc, char *argv[])
for (int i = 0; i<5; i++)
{
labList.push_back(identity(6));
labList.append(identity(6));
}
Info<< nl
@ -164,16 +164,16 @@ int main(int argc, char *argv[])
List<label> content1 = identity(10);
Info<< nl
<< " move push_back ";
<< " move append ";
printAddress(content1);
labList.push_back(std::move(content1));
labList.append(std::move(content1));
Info<< " content " << flatOutput(content1) << nl
<< " list" << labList << nl;
printAddresses(labList);
// labList.push_back(content1);
// labList.append(content1);
}
Info<< nl << "Done." << endl;

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -131,7 +130,7 @@ int main(int argc, char *argv[])
flatList = labelUIndList(completeList, addresses);
Info<< "List assign from UIndirectList: " << flatOutput(flatList) << nl;
flatList.push_back(labelUIndList(completeList, addresses));
flatList.append(labelUIndList(completeList, addresses));
Info<< "List::append(UIndirectList): " << flatOutput(flatList) << nl;
@ -139,7 +138,7 @@ int main(int argc, char *argv[])
Info<< "DynamicList construct from UIndirectList: " << flatOutput(dynList)
<< nl;
flatList.push_back(labelUIndList(completeList, addresses));
dynList.append(labelUIndList(completeList, addresses));
Info<< "DynamicList::append(UIndirectList): " << flatOutput(dynList) << nl;
Info<< "\nEnd\n" << endl;

View File

@ -39,6 +39,7 @@ Description
#include "Pair.H"
#include <sstream>
#include <initializer_list>
using namespace Foam;

View File

@ -33,6 +33,7 @@ Description
#include "IOstreams.H"
#include "stdFoam.H"
#include <algorithm>
#include <type_traits>
#include <limits>

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2022 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -165,24 +165,24 @@ int main(int argc, char *argv[])
// Use predicate, or test() method
if (list2.test(1))
if (list2(1))
{
Info<< "1 is on (original)" << nl;
}
if (!list2.test(2))
if (!list2(2))
{
Info<< "2 is off (original)" << nl;
}
if (!list2.test(100))
if (!list2(100))
{
Info<< "100 is off (original)" << nl;
}
if (wrapper.test(1))
if (wrapper(1))
{
Info<< "1 is on (wrapped)" << nl;
}
if (!wrapper.test(2))
if (!wrapper(2))
{
Info<< "2 is off (wrapped)" << nl;
}

View File

@ -72,13 +72,13 @@ public:
// Member Functions
//- Is empty
bool empty() const noexcept
bool empty() const
{
return bits_.empty() && bools_.empty();
}
//- Size
label size() const noexcept
label size() const
{
return bits_.size() + bools_.size();
}
@ -93,7 +93,7 @@ public:
bool operator()(const label i) const
{
// Can also use test(i) etc...
return bits_.test(i) || bools_.test(i);
return bits_(i) || bools_(i);
}
};

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,24 +59,9 @@ int main(int argc, char *argv[])
<< "complexVector::one : " << complexVector::one << nl
<< nl;
{
const complex a(0, 1);
const complex b(20, 100);
Info<< "lerp of " << a << " : " << b << nl;
for (const double t : { 0.0, 0.5, 1.0, -0.5, 1.5 })
{
Info<< " " << t << " = " << lerp(a, b, t) << nl;
}
}
for (complex c : { complex{1, 0}, complex{1, 2}} )
{
Info<< nl << "complex : " << c
<< " mag = " << c.magnitude()
<< " norm = " << c.magSqr()
<< nl;
Info<< nl << "complex : " << c << nl;
Info<< "sin: " << sin(c) << nl
<< "pow(3.0f): " << pow(c, 3.0f) << nl
@ -145,8 +130,6 @@ int main(int argc, char *argv[])
complexField cmplx(4);
zip(cmplx, reals, zero{});
zip(cmplx, 1, imags);
zip(cmplx, reals, imags);
Info<< nl
<< "zip " << reals << nl
@ -362,24 +345,6 @@ int main(int argc, char *argv[])
// MinMax fails since there is no less comparison operator
// Info<< "min/max = " << MinMax<complex>(fld1) << nl;
// Cross-product
{
const vector vec(1, 2, 3);
const vector realValue(4, 5, 6);
const vector imagValue(7, 8, 9);
complexVector cmplxVec(zip(realValue, imagValue));
Info<< "complexVector: " << cmplxVec << nl;
Info<< "cross: " << (vec ^ cmplxVec) << nl;
Info<< "cross real: " << (vec ^ realValue) << nl
<< "cross imag: " << (vec ^ imagValue) << nl
<< "cross : "
<< zip((vec ^ realValue), (vec ^ imagValue)) << nl;
}
Info<< "\nEnd\n" << endl;
return 0;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,7 +59,7 @@ void basicTests(const coordinateSystem& cs)
{
cs.writeEntry(cs.name(), Info);
if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
if ((const auto* cartptr = isA<coordSystem::cartesian>(cs)) != nullptr)
{
if (!cartptr->valid())
{

View File

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

View File

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

View File

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

View File

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

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