mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
MRG: resolved merge conflicts from merge from develop branch
This commit is contained in:
@ -43,7 +43,7 @@ Foam::autoPtr<Foam::PDRDragModel> Foam::PDRDragModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown PDRDragModel type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::XiEqModel> Foam::XiEqModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown XiEqModel type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::XiGModel> Foam::XiGModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown XiGModel type "
|
||||
|
||||
@ -45,7 +45,7 @@ Foam::autoPtr<Foam::XiModel> Foam::XiModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown XiModel type "
|
||||
|
||||
@ -44,7 +44,7 @@ Foam::autoPtr<Foam::mixtureViscosityModel> Foam::mixtureViscosityModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown mixtureViscosityModel type "
|
||||
|
||||
@ -111,7 +111,7 @@ Foam::autoPtr<Foam::relativeVelocityModel> Foam::relativeVelocityModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(modelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown time scale model type " << modelType
|
||||
|
||||
@ -63,7 +63,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New
|
||||
componentsConstructorTablePtr_
|
||||
->find(temperaturePhaseChangeTwoPhaseMixtureTypeName);
|
||||
|
||||
if (cstrIter == componentsConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown temperaturePhaseChangeTwoPhaseMixture type "
|
||||
|
||||
@ -60,7 +60,7 @@ Foam::phaseChangeTwoPhaseMixture::New
|
||||
componentsConstructorTablePtr_
|
||||
->find(phaseChangeTwoPhaseMixtureTypeName);
|
||||
|
||||
if (cstrIter == componentsConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown phaseChangeTwoPhaseMixture type "
|
||||
|
||||
@ -44,7 +44,7 @@ Foam::autoPtr<Foam::dragModel> Foam::dragModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(dragModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown dragModelType type "
|
||||
|
||||
@ -48,7 +48,7 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(heatTransferModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown heatTransferModelType type "
|
||||
|
||||
@ -46,7 +46,7 @@ Foam::autoPtr<Foam::diameterModel> Foam::diameterModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(diameterModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown diameterModelType type "
|
||||
|
||||
@ -52,7 +52,7 @@ Foam::interfaceCompositionModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(interfaceCompositionModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown interfaceCompositionModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::massTransferModel> Foam::massTransferModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(massTransferModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown massTransferModelType type "
|
||||
|
||||
@ -40,7 +40,7 @@ Foam::autoPtr<Foam::saturationModel> Foam::saturationModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(saturationModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown saturationModelType type "
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::surfaceTensionModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(surfaceTensionModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown surfaceTensionModelType type "
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::aspectRatioModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(aspectRatioModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown aspectRatioModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::dragModel> Foam::dragModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(dragModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown dragModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(heatTransferModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown heatTransferModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::liftModel> Foam::liftModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(liftModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown liftModelType type "
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::swarmCorrection::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(swarmCorrectionType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown swarmCorrectionType type "
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::turbulentDispersionModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(turbulentDispersionModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown turbulentDispersionModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::virtualMassModel> Foam::virtualMassModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(virtualMassModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown virtualMassModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::wallDampingModel> Foam::wallDampingModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(wallDampingModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown wallDampingModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::wallLubricationModel> Foam::wallLubricationModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(wallLubricationModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown wallLubricationModelType type "
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::autoPtr<Foam::blendingMethod> Foam::blendingMethod::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(blendingMethodType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown blendingMethodType type "
|
||||
|
||||
@ -46,7 +46,7 @@ Foam::autoPtr<Foam::diameterModel> Foam::diameterModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(diameterModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown diameterModelType type "
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::autoPtr<Foam::phaseModel> Foam::phaseModel::New
|
||||
phaseSystemConstructorTable::iterator cstrIter =
|
||||
phaseSystemConstructorTablePtr_->find(phaseModelType);
|
||||
|
||||
if (cstrIter == phaseSystemConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown phaseModelType type "
|
||||
|
||||
@ -54,7 +54,7 @@ Foam::autoPtr<Foam::multiphaseSystem> Foam::multiphaseSystem::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(multiphaseSystemType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown multiphaseSystemType type "
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::wallBoilingModels::departureDiameterModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(departureDiameterModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown departureDiameterModelType type "
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::wallBoilingModels::departureFrequencyModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(departureFrequencyModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown departureFrequencyModelType type "
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::wallBoilingModels::nucleationSiteModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(nucleationSiteModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown nucleationSiteModelType type "
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::wallBoilingModels::partitioningModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(partitioningModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown partitioningModelType type "
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::conductivityModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(conductivityModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "conductivityModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::frictionalStressModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(frictionalStressModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "frictionalStressModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::granularPressureModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(granularPressureModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "granularPressureModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::radialModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(radialModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "radialModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::viscosityModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(viscosityModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "viscosityModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -53,7 +53,7 @@ Foam::diameterModels::IATEsource::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(type);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown IATE source type "
|
||||
|
||||
@ -54,7 +54,7 @@ Foam::autoPtr<Foam::twoPhaseSystem> Foam::twoPhaseSystem::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(twoPhaseSystemType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown twoPhaseSystemType type "
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::aspectRatioModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(aspectRatioModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown aspectRatioModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::dragModel> Foam::dragModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(dragModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown dragModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(heatTransferModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown heatTransferModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::liftModel> Foam::liftModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(liftModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown liftModelType type "
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::swarmCorrection::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(swarmCorrectionType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown swarmCorrectionType type "
|
||||
|
||||
@ -43,7 +43,7 @@ Foam::turbulentDispersionModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(turbulentDispersionModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown turbulentDispersionModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::virtualMassModel> Foam::virtualMassModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(virtualMassModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown virtualMassModelType type "
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::wallLubricationModel> Foam::wallLubricationModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(wallLubricationModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown wallLubricationModelType type "
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::conductivityModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(conductivityModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "conductivityModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::frictionalStressModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(frictionalStressModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "frictionalStressModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::granularPressureModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(granularPressureModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "granularPressureModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::radialModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(radialModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "radialModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::kineticTheoryModels::viscosityModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(viscosityModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalError
|
||||
<< "viscosityModel::New(const dictionary&) : " << endl
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::autoPtr<Foam::blendingMethod> Foam::blendingMethod::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(blendingMethodType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown blendingMethodType type "
|
||||
|
||||
@ -54,7 +54,7 @@ Foam::diameterModels::IATEsource::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(type);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown IATE source type "
|
||||
|
||||
@ -46,7 +46,7 @@ Foam::autoPtr<Foam::diameterModel> Foam::diameterModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(diameterModelType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown diameterModelType type "
|
||||
|
||||
@ -234,6 +234,97 @@ int main()
|
||||
|
||||
Info<<"\ntable1: " << table1 << endl;
|
||||
|
||||
// Start again
|
||||
HashTable<scalar> table1start
|
||||
{
|
||||
{"aaa", 1.0},
|
||||
{"aba", 2.0},
|
||||
{"a_ca", 3.0},
|
||||
{"ada", 4.0},
|
||||
{"aeq_", 5.0},
|
||||
{"aaw", 6.0},
|
||||
{"abs", 7.0},
|
||||
{"a_cr", 8.0},
|
||||
{"adx", 9.0},
|
||||
{"ae_c", 10.0}
|
||||
};
|
||||
|
||||
table1 = table1start;
|
||||
Info<< "\ntable has keys: "
|
||||
<< flatOutput(table1.sortedToc()) << nl;
|
||||
|
||||
wordRe matcher(".*_.*", wordRe::REGEX);
|
||||
table1.filterKeys
|
||||
(
|
||||
[&matcher](const word& k){ return matcher.match(k); }
|
||||
);
|
||||
Info<< "retain things matching " << matcher << " => "
|
||||
<< flatOutput(table1.sortedToc()) << nl;
|
||||
|
||||
table1 = table1start;
|
||||
table1.filterKeys
|
||||
(
|
||||
[&matcher](const word& k){ return matcher.match(k); },
|
||||
true
|
||||
);
|
||||
|
||||
Info<< "prune things matching " << matcher << " => "
|
||||
<< flatOutput(table1.sortedToc()) << nl;
|
||||
|
||||
// Same, without a lambda
|
||||
table1 = table1start;
|
||||
table1.filterKeys(matcher, true);
|
||||
|
||||
Info<< "prune things matching " << matcher << " => "
|
||||
<< flatOutput(table1.sortedToc()) << nl;
|
||||
|
||||
|
||||
// Same idea, but inverted logic inside the lambda
|
||||
table1 = table1start;
|
||||
table1.filterKeys
|
||||
(
|
||||
[&matcher](const word& k){ return !matcher.match(k); },
|
||||
true
|
||||
);
|
||||
|
||||
Info<< "prune things matching " << matcher << " => "
|
||||
<< flatOutput(table1.sortedToc()) << nl;
|
||||
|
||||
|
||||
table1 = table1start;
|
||||
Info<< "\ntable:" << table1 << nl;
|
||||
|
||||
table1.filterValues
|
||||
(
|
||||
[](const scalar& v){ return (v >= 5); }
|
||||
);
|
||||
|
||||
Info<< "\ntable with values >= 5:" << table1 << nl;
|
||||
|
||||
table1 = table1start;
|
||||
Info<< "\ntable:" << table1 << nl;
|
||||
|
||||
table1.filterEntries
|
||||
(
|
||||
[&matcher](const word& k, const scalar& v)
|
||||
{
|
||||
return matcher(k) && (v >= 5);
|
||||
}
|
||||
);
|
||||
|
||||
Info<< "\ntable with values >= 5 and matching " << matcher
|
||||
<< table1 << nl;
|
||||
|
||||
|
||||
table1 = table1start;
|
||||
Info<< "\ntable:" << table1 << nl;
|
||||
Info<< "has "
|
||||
<< table1.countValues([](const scalar& v) { return v >= 7; })
|
||||
<< " values >= 7 with these keys: "
|
||||
<< table1.tocValues([](const scalar& v) { return v >= 7; })
|
||||
<< nl;
|
||||
|
||||
|
||||
Info<< "\nDone\n";
|
||||
|
||||
return 0;
|
||||
|
||||
3
applications/test/IOobjectList/Make/files
Normal file
3
applications/test/IOobjectList/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-IOobjectList.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IOobjectList
|
||||
3
applications/test/IOobjectList/Make/options
Normal file
3
applications/test/IOobjectList/Make/options
Normal file
@ -0,0 +1,3 @@
|
||||
EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = -lfiniteVolume
|
||||
104
applications/test/IOobjectList/Test-IOobjectList.C
Normal file
104
applications/test/IOobjectList/Test-IOobjectList.C
Normal file
@ -0,0 +1,104 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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
|
||||
Basic tests of IOobjectList
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "volFields.H"
|
||||
#include "timeSelector.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "hashedWordList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::addOption("re", "wordReList");
|
||||
|
||||
// timeSelector::addOptions();
|
||||
timeSelector::addOptions(true, true);
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
wordReList matcher;
|
||||
if (args.optionFound("re"))
|
||||
{
|
||||
matcher = args.optionReadList<wordRe>("re");
|
||||
Info<<"limit names: " << matcher << nl;
|
||||
|
||||
}
|
||||
|
||||
const hashedWordList subsetTypes
|
||||
{
|
||||
volScalarField::typeName,
|
||||
volScalarField::Internal::typeName,
|
||||
volVectorField::typeName,
|
||||
};
|
||||
|
||||
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
// Objects at this time
|
||||
IOobjectList objects(runTime, runTime.timeName());
|
||||
HashTable<wordHashSet> classes =
|
||||
(
|
||||
matcher.size()
|
||||
? objects.classes(matcher)
|
||||
: objects.classes()
|
||||
);
|
||||
|
||||
Info<< "Time: " << runTime.timeName() << nl;
|
||||
|
||||
Info<<"Name: " << flatOutput(objects.sortedNames()) << nl
|
||||
<<"Objects: " << objects << nl
|
||||
<<"Classes: " << classes << nl;
|
||||
|
||||
classes.filterKeys(subsetTypes);
|
||||
Info<<"only retain: " << flatOutput(subsetTypes) << nl;
|
||||
Info<<"Pruned: " << classes << nl;
|
||||
|
||||
classes = objects.classes();
|
||||
classes.erase(subsetTypes);
|
||||
Info<<"remove: " << flatOutput(subsetTypes) << nl;
|
||||
Info<<"Pruned: " << classes << nl;
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -180,9 +180,9 @@ int main(int argc, char *argv[])
|
||||
// A regex with a zero length matcher doesn't work at all:
|
||||
// eg "(png|jpg|txt|)" regex matcher itself
|
||||
|
||||
wordRe matcher0("()", wordRe::REGEXP);
|
||||
wordRe matcher1("(png|jpg|txt)", wordRe::REGEXP);
|
||||
wordRe matcher2("(png|txt)", wordRe::REGEXP);
|
||||
wordRe matcher0("()", wordRe::REGEX);
|
||||
wordRe matcher1("(png|jpg|txt)", wordRe::REGEX);
|
||||
wordRe matcher2("(png|txt)", wordRe::REGEX);
|
||||
|
||||
Info<<"Has extension(s):" << nl
|
||||
<< "input: " << endWithDot << nl;
|
||||
|
||||
3
applications/test/predicates/Make/files
Normal file
3
applications/test/predicates/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-predicates.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-predicates
|
||||
1
applications/test/predicates/Make/options
Normal file
1
applications/test/predicates/Make/options
Normal file
@ -0,0 +1 @@
|
||||
/**/
|
||||
112
applications/test/predicates/Test-predicates.C
Normal file
112
applications/test/predicates/Test-predicates.C
Normal file
@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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-predicates
|
||||
|
||||
Description
|
||||
Simple tests using predicates
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOstreams.H"
|
||||
#include "labelList.H"
|
||||
#include "wordList.H"
|
||||
#include "predicates.H"
|
||||
#include "FlatOutput.H"
|
||||
#include "regExp.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
template<class ListType, class UnaryPredicate>
|
||||
label printMatching(const ListType& list, const UnaryPredicate& pred)
|
||||
{
|
||||
label count = 0;
|
||||
|
||||
Info<< "(";
|
||||
|
||||
for (const auto& val : list)
|
||||
{
|
||||
if (pred(val))
|
||||
{
|
||||
if (count) Info<< ' ';
|
||||
Info<< val;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< ") => " << count << nl;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
wordList words
|
||||
{
|
||||
"abc",
|
||||
"def",
|
||||
"hij",
|
||||
"abc_",
|
||||
"def_",
|
||||
"hij_",
|
||||
};
|
||||
|
||||
labelRange range(-10, 40);
|
||||
labelList values(range.begin(), range.end());
|
||||
|
||||
Info<<"words: " << flatOutput(words) << endl;
|
||||
Info<<"values: " << flatOutput(values) << endl;
|
||||
|
||||
regExp matcher(".*_.*");
|
||||
|
||||
Info<<"With '_': ";
|
||||
printMatching(words, matcher);
|
||||
|
||||
Info<<"All: ";
|
||||
printMatching(words, predicates::always());
|
||||
|
||||
Info<<"None: ";
|
||||
printMatching(words, predicates::never());
|
||||
|
||||
Info<<"Neg values: ";
|
||||
printMatching(values, [](const label v) { return v < 0; });
|
||||
|
||||
Info<<"Even values: ";
|
||||
printMatching(values, [](const label v) { return !(v % 2); });
|
||||
|
||||
Info<<"All: ";
|
||||
printMatching(values, predicates::always());
|
||||
|
||||
Info<<"None: ";
|
||||
printMatching(values, predicates::never());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,7 +30,10 @@ Description
|
||||
#include "IFstream.H"
|
||||
#include "List.H"
|
||||
#include "Tuple2.H"
|
||||
#include "keyType.H"
|
||||
#include "wordRe.H"
|
||||
#include "wordRes.H"
|
||||
#include "predicates.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -44,12 +47,37 @@ int main(int argc, char *argv[])
|
||||
Foam::string s2("this .* file");
|
||||
const char * s3 = "this .* file";
|
||||
|
||||
keyType keyre("x.*", true);
|
||||
|
||||
wordReList wordrelist
|
||||
{
|
||||
{"this", wordRe::LITERAL},
|
||||
{"x.*", wordRe::REGEX},
|
||||
{"file[a-b]", wordRe::REGEX},
|
||||
};
|
||||
|
||||
wordRes wrelist(wordrelist);
|
||||
|
||||
Info<< "re-list:" << wrelist() << endl;
|
||||
Info<< "match this: " << wrelist("this") << endl;
|
||||
Info<< "match xyz: " << wrelist("xyz") << endl;
|
||||
Info<< "match zyx: " << wrelist("zyx") << endl;
|
||||
Info<< "match xyz: " << wrelist.match("xyz") << endl;
|
||||
Info<< "match any: " << predicates::always()("any junk") << endl;
|
||||
Info<< "keyre match: " << keyre("xyz") << endl;
|
||||
Info<< "string match: " << string("this").match("xyz") << endl;
|
||||
Info<< "string match: " << string("x.*")("xyz") << endl;
|
||||
Info<< "string match: " << string("x.*")(keyre) << endl;
|
||||
|
||||
wordRe(s1, wordRe::DETECT).info(Info) << endl;
|
||||
wordRe(s2).info(Info) << endl;
|
||||
wordRe(s2, wordRe::DETECT).info(Info) << endl;
|
||||
wordRe(s3, wordRe::REGEXP).info(Info) << endl;
|
||||
wordRe(s3, wordRe::REGEX).info(Info) << endl;
|
||||
|
||||
wre = "this .* file";
|
||||
|
||||
Info<<"substring: " << wre(4) << endl;
|
||||
|
||||
wre.info(Info) << endl;
|
||||
wre = s1;
|
||||
wre.info(Info) << endl;
|
||||
|
||||
@ -90,7 +90,7 @@ Foam::cellSizeAndAlignmentControl::New
|
||||
cellSizeAndAlignmentControlTypeName
|
||||
);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown cellSizeAndAlignmentControl type "
|
||||
|
||||
@ -133,7 +133,7 @@ Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(cellSizeFunctionTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown cellSizeFunction type "
|
||||
|
||||
@ -71,7 +71,7 @@ Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(cellSizeCalculationTypeTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown cellSizeCalculationType type "
|
||||
|
||||
@ -75,7 +75,7 @@ Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(surfaceCellSizeFunctionTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown surfaceCellSizeFunction type "
|
||||
|
||||
@ -68,7 +68,7 @@ autoPtr<faceAreaWeightModel> faceAreaWeightModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(faceAreaWeightModelTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown faceAreaWeightModel type "
|
||||
|
||||
@ -94,7 +94,7 @@ autoPtr<initialPointsMethod> initialPointsMethod::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(initialPointsMethodTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown initialPointsMethod type "
|
||||
|
||||
@ -71,7 +71,7 @@ autoPtr<relaxationModel> relaxationModel::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(relaxationModelTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown relaxationModel type "
|
||||
|
||||
@ -48,7 +48,7 @@ Foam::searchableSurfaceFeatures::New
|
||||
dictConstructorTable::iterator cstrIter =
|
||||
dictConstructorTablePtr_->find(searchableSurfaceFeaturesType);
|
||||
|
||||
if (cstrIter == dictConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown searchableSurfaceFeatures type "
|
||||
|
||||
@ -71,7 +71,7 @@ Foam::autoPtr<Foam::faceSelection> Foam::faceSelection::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(sampleType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown faceSelection type "
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -112,7 +112,7 @@ labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Did not visit some faces, e.g. face " << faceI
|
||||
<< " at " << mesh.faceCentres()[faceI] << endl
|
||||
<< " at " << mesh.faceCentres()[faceI] << nl
|
||||
<< "Using patch " << patchIDs[0] << " as nearest"
|
||||
<< endl;
|
||||
haveWarned = true;
|
||||
@ -129,57 +129,38 @@ labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs)
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void subsetVolFields
|
||||
//
|
||||
// Subset field-type, availability information cached
|
||||
// in the availableFields hashtable.
|
||||
//
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void subsetFields
|
||||
(
|
||||
const fvMeshSubset& subsetter,
|
||||
const wordList& fieldNames,
|
||||
PtrList<GeometricField<Type, fvPatchField, volMesh>>& subFields
|
||||
HashTable<wordHashSet>& availableFields,
|
||||
PtrList<GeometricField<Type, PatchField, GeoMesh>>& subFields
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, PatchField, GeoMesh> FieldType;
|
||||
const word fieldType = FieldType::typeName;
|
||||
|
||||
const wordList fieldNames = availableFields(fieldType).sortedToc();
|
||||
subFields.setSize(fieldNames.size());
|
||||
|
||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||
|
||||
if (fieldNames.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Info<< "Subsetting " << fieldType << " (";
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = fieldNames[i];
|
||||
if (i) Info<< ' ';
|
||||
Info<< fieldName;
|
||||
|
||||
Info<< "Subsetting field " << fieldName << endl;
|
||||
|
||||
GeometricField<Type, fvPatchField, volMesh> fld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
baseMesh.time().timeName(),
|
||||
baseMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
baseMesh
|
||||
);
|
||||
|
||||
subFields.set(i, subsetter.interpolate(fld));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void subsetSurfaceFields
|
||||
(
|
||||
const fvMeshSubset& subsetter,
|
||||
const wordList& fieldNames,
|
||||
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& subFields
|
||||
)
|
||||
{
|
||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = fieldNames[i];
|
||||
|
||||
Info<< "Subsetting field " << fieldName << endl;
|
||||
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh> fld
|
||||
FieldType fld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -193,7 +174,11 @@ void subsetSurfaceFields
|
||||
);
|
||||
|
||||
subFields.set(i, subsetter.interpolate(fld));
|
||||
|
||||
// Subsetting adds 'subset' prefix - rename to match original.
|
||||
subFields[i].rename(fieldName);
|
||||
}
|
||||
Info<< ")" << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -202,19 +187,30 @@ void subsetPointFields
|
||||
(
|
||||
const fvMeshSubset& subsetter,
|
||||
const pointMesh& pMesh,
|
||||
const wordList& fieldNames,
|
||||
HashTable<wordHashSet>& availableFields,
|
||||
PtrList<GeometricField<Type, pointPatchField, pointMesh>>& subFields
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, pointPatchField, pointMesh> FieldType;
|
||||
const word fieldType = FieldType::typeName;
|
||||
|
||||
const wordList fieldNames = availableFields(fieldType).sortedToc();
|
||||
subFields.setSize(fieldNames.size());
|
||||
|
||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||
|
||||
if (fieldNames.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Info<< "Subsetting " << fieldType << " (";
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = fieldNames[i];
|
||||
if (i) Info<< ' ';
|
||||
Info<< fieldName;
|
||||
|
||||
Info<< "Subsetting field " << fieldName << endl;
|
||||
|
||||
GeometricField<Type, pointPatchField, pointMesh> fld
|
||||
FieldType fld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -228,7 +224,11 @@ void subsetPointFields
|
||||
);
|
||||
|
||||
subFields.set(i, subsetter.interpolate(fld));
|
||||
|
||||
// Subsetting adds 'subset' prefix - rename to match original.
|
||||
subFields[i].rename(fieldName);
|
||||
}
|
||||
Info<< ")" << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -236,19 +236,30 @@ template<class Type>
|
||||
void subsetDimensionedFields
|
||||
(
|
||||
const fvMeshSubset& subsetter,
|
||||
const wordList& fieldNames,
|
||||
HashTable<wordHashSet>& availableFields,
|
||||
PtrList<DimensionedField<Type, volMesh>>& subFields
|
||||
)
|
||||
{
|
||||
typedef DimensionedField<Type, volMesh> FieldType;
|
||||
const word fieldType = FieldType::typeName;
|
||||
|
||||
const wordList fieldNames = availableFields(fieldType).sortedToc();
|
||||
subFields.setSize(fieldNames.size());
|
||||
|
||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||
|
||||
if (fieldNames.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Info<< "Subsetting " << fieldType << " (";
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = fieldNames[i];
|
||||
if (i) Info<< ' ';
|
||||
Info<< fieldName;
|
||||
|
||||
Info<< "Subsetting field " << fieldName << endl;
|
||||
|
||||
DimensionedField<Type, volMesh> fld
|
||||
FieldType fld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -262,7 +273,11 @@ void subsetDimensionedFields
|
||||
);
|
||||
|
||||
subFields.set(i, subsetter.interpolate(fld));
|
||||
|
||||
// Subsetting adds 'subset' prefix - rename to match original.
|
||||
subFields[i].rename(fieldName);
|
||||
}
|
||||
Info<< ")" << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -289,7 +304,7 @@ void subsetTopoSets
|
||||
|
||||
// Map the data
|
||||
PackedBoolList isSet(set.maxSize(mesh));
|
||||
forAllConstIter(labelHashSet, set, iter)
|
||||
forAllConstIters(set, iter)
|
||||
{
|
||||
isSet[iter.key()] = true;
|
||||
}
|
||||
@ -359,7 +374,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
|
||||
const word setName = args[1];
|
||||
|
||||
word meshInstance = mesh.pointsInstance();
|
||||
@ -378,7 +392,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
Info<< "Reading cell set from " << setName << endl << endl;
|
||||
Info<< "Reading cell set from " << setName << nl << endl;
|
||||
|
||||
// Create mesh subsetting engine
|
||||
fvMeshSubset subsetter(mesh);
|
||||
@ -389,11 +403,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const word patchName = args["patch"];
|
||||
|
||||
exposedPatchIDs = labelList
|
||||
(
|
||||
1,
|
||||
mesh.boundaryMesh().findPatchID(patchName)
|
||||
);
|
||||
exposedPatchIDs = { mesh.boundaryMesh().findPatchID(patchName) };
|
||||
|
||||
if (exposedPatchIDs[0] == -1)
|
||||
{
|
||||
@ -402,8 +412,8 @@ int main(int argc, char *argv[])
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< "Adding exposed internal faces to patch " << patchName << endl
|
||||
<< endl;
|
||||
Info<< "Adding exposed internal faces to patch " << patchName
|
||||
<< nl << endl;
|
||||
}
|
||||
else if (args.optionFound("patches"))
|
||||
{
|
||||
@ -412,14 +422,14 @@ int main(int argc, char *argv[])
|
||||
exposedPatchIDs = mesh.boundaryMesh().patchSet(patchNames).sortedToc();
|
||||
|
||||
Info<< "Adding exposed internal faces to nearest of patches "
|
||||
<< patchNames << endl << endl;
|
||||
<< patchNames << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Adding exposed internal faces to a patch called"
|
||||
<< " \"oldInternalFaces\" (created if necessary)" << endl
|
||||
<< endl;
|
||||
exposedPatchIDs = labelList(1, label(-1));
|
||||
exposedPatchIDs = { -1 };
|
||||
}
|
||||
|
||||
|
||||
@ -431,7 +441,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Find per face the nearest patch
|
||||
labelList nearestExposedPatch(nearestPatch(mesh, exposedPatchIDs));
|
||||
|
||||
@ -454,77 +463,45 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
HashTable<wordHashSet> availableFields = objects.classes();
|
||||
|
||||
|
||||
// Read vol fields and subset
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
wordList scalarNames(objects.names(volScalarField::typeName));
|
||||
PtrList<volScalarField> scalarFlds(scalarNames.size());
|
||||
subsetVolFields(subsetter, scalarNames, scalarFlds);
|
||||
PtrList<volScalarField> scalarFlds;
|
||||
subsetFields(subsetter, availableFields, scalarFlds);
|
||||
|
||||
wordList vectorNames(objects.names(volVectorField::typeName));
|
||||
PtrList<volVectorField> vectorFlds(vectorNames.size());
|
||||
subsetVolFields(subsetter, vectorNames, vectorFlds);
|
||||
PtrList<volVectorField> vectorFlds;
|
||||
subsetFields(subsetter, availableFields, vectorFlds);
|
||||
|
||||
wordList sphericalTensorNames
|
||||
(
|
||||
objects.names(volSphericalTensorField::typeName)
|
||||
);
|
||||
PtrList<volSphericalTensorField> sphericalTensorFlds
|
||||
(
|
||||
sphericalTensorNames.size()
|
||||
);
|
||||
subsetVolFields(subsetter, sphericalTensorNames, sphericalTensorFlds);
|
||||
PtrList<volSphericalTensorField> sphTensorFlds;
|
||||
subsetFields(subsetter, availableFields, sphTensorFlds);
|
||||
|
||||
wordList symmTensorNames(objects.names(volSymmTensorField::typeName));
|
||||
PtrList<volSymmTensorField> symmTensorFlds(symmTensorNames.size());
|
||||
subsetVolFields(subsetter, symmTensorNames, symmTensorFlds);
|
||||
PtrList<volSymmTensorField> symmTensorFlds;
|
||||
subsetFields(subsetter, availableFields, symmTensorFlds);
|
||||
|
||||
wordList tensorNames(objects.names(volTensorField::typeName));
|
||||
PtrList<volTensorField> tensorFlds(tensorNames.size());
|
||||
subsetVolFields(subsetter, tensorNames, tensorFlds);
|
||||
PtrList<volTensorField> tensorFlds;
|
||||
subsetFields(subsetter, availableFields, tensorFlds);
|
||||
|
||||
|
||||
// Read surface fields and subset
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
wordList surfScalarNames(objects.names(surfaceScalarField::typeName));
|
||||
PtrList<surfaceScalarField> surfScalarFlds(surfScalarNames.size());
|
||||
subsetSurfaceFields(subsetter, surfScalarNames, surfScalarFlds);
|
||||
PtrList<surfaceScalarField> surfScalarFlds;
|
||||
subsetFields(subsetter, availableFields, surfScalarFlds);
|
||||
|
||||
wordList surfVectorNames(objects.names(surfaceVectorField::typeName));
|
||||
PtrList<surfaceVectorField> surfVectorFlds(surfVectorNames.size());
|
||||
subsetSurfaceFields(subsetter, surfVectorNames, surfVectorFlds);
|
||||
PtrList<surfaceVectorField> surfVectorFlds;
|
||||
subsetFields(subsetter, availableFields, surfVectorFlds);
|
||||
|
||||
wordList surfSphericalTensorNames
|
||||
(
|
||||
objects.names(surfaceSphericalTensorField::typeName)
|
||||
);
|
||||
PtrList<surfaceSphericalTensorField> surfSphericalTensorFlds
|
||||
(
|
||||
surfSphericalTensorNames.size()
|
||||
);
|
||||
subsetSurfaceFields
|
||||
(
|
||||
subsetter,
|
||||
surfSphericalTensorNames,
|
||||
surfSphericalTensorFlds
|
||||
);
|
||||
PtrList<surfaceSphericalTensorField> surfSphTensorFlds;
|
||||
subsetFields(subsetter, availableFields, surfSphTensorFlds);
|
||||
|
||||
wordList surfSymmTensorNames
|
||||
(
|
||||
objects.names(surfaceSymmTensorField::typeName)
|
||||
);
|
||||
PtrList<surfaceSymmTensorField> surfSymmTensorFlds
|
||||
(
|
||||
surfSymmTensorNames.size()
|
||||
);
|
||||
subsetSurfaceFields(subsetter, surfSymmTensorNames, surfSymmTensorFlds);
|
||||
PtrList<surfaceSymmTensorField> surfSymmTensorFlds;
|
||||
subsetFields(subsetter, availableFields, surfSymmTensorFlds);
|
||||
|
||||
wordList surfTensorNames(objects.names(surfaceTensorField::typeName));
|
||||
PtrList<surfaceTensorField> surfTensorFlds(surfTensorNames.size());
|
||||
subsetSurfaceFields(subsetter, surfTensorNames, surfTensorFlds);
|
||||
PtrList<surfaceTensorField> surfTensorFlds;
|
||||
subsetFields(subsetter, availableFields, surfTensorFlds);
|
||||
|
||||
|
||||
// Read point fields and subset
|
||||
@ -532,86 +509,39 @@ int main(int argc, char *argv[])
|
||||
|
||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||
|
||||
wordList pointScalarNames(objects.names(pointScalarField::typeName));
|
||||
PtrList<pointScalarField> pointScalarFlds(pointScalarNames.size());
|
||||
subsetPointFields(subsetter, pMesh, pointScalarNames, pointScalarFlds);
|
||||
PtrList<pointScalarField> pointScalarFlds;
|
||||
subsetPointFields(subsetter, pMesh, availableFields, pointScalarFlds);
|
||||
|
||||
wordList pointVectorNames(objects.names(pointVectorField::typeName));
|
||||
PtrList<pointVectorField> pointVectorFlds(pointVectorNames.size());
|
||||
subsetPointFields(subsetter, pMesh, pointVectorNames, pointVectorFlds);
|
||||
PtrList<pointVectorField> pointVectorFlds;
|
||||
subsetPointFields(subsetter, pMesh, availableFields, pointVectorFlds);
|
||||
|
||||
wordList pointSphericalTensorNames
|
||||
(
|
||||
objects.names(pointSphericalTensorField::typeName)
|
||||
);
|
||||
PtrList<pointSphericalTensorField> pointSphericalTensorFlds
|
||||
(
|
||||
pointSphericalTensorNames.size()
|
||||
);
|
||||
subsetPointFields
|
||||
(
|
||||
subsetter,
|
||||
pMesh,
|
||||
pointSphericalTensorNames,
|
||||
pointSphericalTensorFlds
|
||||
);
|
||||
PtrList<pointSphericalTensorField> pointSphTensorFlds;
|
||||
subsetPointFields(subsetter, pMesh, availableFields, pointSphTensorFlds);
|
||||
|
||||
wordList pointSymmTensorNames
|
||||
(
|
||||
objects.names(pointSymmTensorField::typeName)
|
||||
);
|
||||
PtrList<pointSymmTensorField> pointSymmTensorFlds
|
||||
(
|
||||
pointSymmTensorNames.size()
|
||||
);
|
||||
subsetPointFields
|
||||
(
|
||||
subsetter,
|
||||
pMesh,
|
||||
pointSymmTensorNames,
|
||||
pointSymmTensorFlds
|
||||
);
|
||||
PtrList<pointSymmTensorField> pointSymmTensorFlds;
|
||||
subsetPointFields(subsetter, pMesh, availableFields, pointSymmTensorFlds);
|
||||
|
||||
wordList pointTensorNames(objects.names(pointTensorField::typeName));
|
||||
PtrList<pointTensorField> pointTensorFlds(pointTensorNames.size());
|
||||
subsetPointFields(subsetter, pMesh, pointTensorNames, pointTensorFlds);
|
||||
PtrList<pointTensorField> pointTensorFlds;
|
||||
subsetPointFields(subsetter, pMesh, availableFields, pointTensorFlds);
|
||||
|
||||
|
||||
// Read dimensioned fields and subset
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
typedef volScalarField::Internal dimScalType;
|
||||
wordList scalarDimNames(objects.names(dimScalType::typeName));
|
||||
PtrList<dimScalType> scalarDimFlds(scalarDimNames.size());
|
||||
subsetDimensionedFields(subsetter, scalarDimNames, scalarDimFlds);
|
||||
PtrList<volScalarField::Internal> scalarDimFlds;
|
||||
subsetDimensionedFields(subsetter, availableFields, scalarDimFlds);
|
||||
|
||||
typedef volVectorField::Internal dimVecType;
|
||||
wordList vectorDimNames(objects.names(dimVecType::typeName));
|
||||
PtrList<dimVecType> vectorDimFlds(vectorDimNames.size());
|
||||
subsetDimensionedFields(subsetter, vectorDimNames, vectorDimFlds);
|
||||
PtrList<volVectorField::Internal> vectorDimFlds;
|
||||
subsetDimensionedFields(subsetter, availableFields, vectorDimFlds);
|
||||
|
||||
typedef volSphericalTensorField::Internal dimSphereType;
|
||||
wordList sphericalTensorDimNames(objects.names(dimSphereType::typeName));
|
||||
PtrList<dimSphereType> sphericalTensorDimFlds
|
||||
(
|
||||
sphericalTensorDimNames.size()
|
||||
);
|
||||
subsetDimensionedFields
|
||||
(
|
||||
subsetter,
|
||||
sphericalTensorDimNames,
|
||||
sphericalTensorDimFlds
|
||||
);
|
||||
PtrList<volSphericalTensorField::Internal> sphTensorDimFlds;
|
||||
subsetDimensionedFields(subsetter, availableFields, sphTensorDimFlds);
|
||||
|
||||
typedef volSymmTensorField::Internal dimSymmTensorType;
|
||||
wordList symmTensorDimNames(objects.names(dimSymmTensorType::typeName));
|
||||
PtrList<dimSymmTensorType> symmTensorDimFlds(symmTensorDimNames.size());
|
||||
subsetDimensionedFields(subsetter, symmTensorDimNames, symmTensorDimFlds);
|
||||
PtrList<volSymmTensorField::Internal> symmTensorDimFlds;
|
||||
subsetDimensionedFields(subsetter, availableFields, symmTensorDimFlds);
|
||||
|
||||
typedef volTensorField::Internal dimTensorType;
|
||||
wordList tensorDimNames(objects.names(dimTensorType::typeName));
|
||||
PtrList<dimTensorType> tensorDimFlds(tensorDimNames.size());
|
||||
subsetDimensionedFields(subsetter, tensorDimNames, tensorDimFlds);
|
||||
PtrList<volTensorField::Internal> tensorDimFlds;
|
||||
subsetDimensionedFields(subsetter, availableFields, tensorDimFlds);
|
||||
|
||||
|
||||
// topoSets and subset
|
||||
@ -620,6 +550,7 @@ int main(int argc, char *argv[])
|
||||
PtrList<cellSet> cellSets;
|
||||
PtrList<faceSet> faceSets;
|
||||
PtrList<pointSet> pointSets;
|
||||
|
||||
{
|
||||
IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets");
|
||||
objects.remove(currentSet);
|
||||
@ -650,7 +581,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Write mesh and fields to new time
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -668,123 +598,100 @@ int main(int argc, char *argv[])
|
||||
subsetter.subMesh().setInstance(runTime.timeName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Info<< "Writing subsetted mesh and fields to time " << runTime.timeName()
|
||||
<< endl;
|
||||
subsetter.subMesh().write();
|
||||
processorMeshes::removeFiles(subsetter.subMesh());
|
||||
|
||||
|
||||
// Subsetting adds 'subset' prefix. Rename field to be like original.
|
||||
// Volume fields
|
||||
forAll(scalarFlds, i)
|
||||
{
|
||||
scalarFlds[i].rename(scalarNames[i]);
|
||||
scalarFlds[i].write();
|
||||
}
|
||||
forAll(vectorFlds, i)
|
||||
{
|
||||
vectorFlds[i].rename(vectorNames[i]);
|
||||
vectorFlds[i].write();
|
||||
}
|
||||
forAll(sphericalTensorFlds, i)
|
||||
forAll(sphTensorFlds, i)
|
||||
{
|
||||
sphericalTensorFlds[i].rename(sphericalTensorNames[i]);
|
||||
sphericalTensorFlds[i].write();
|
||||
sphTensorFlds[i].write();
|
||||
}
|
||||
forAll(symmTensorFlds, i)
|
||||
{
|
||||
symmTensorFlds[i].rename(symmTensorNames[i]);
|
||||
symmTensorFlds[i].write();
|
||||
}
|
||||
forAll(tensorFlds, i)
|
||||
{
|
||||
tensorFlds[i].rename(tensorNames[i]);
|
||||
tensorFlds[i].write();
|
||||
}
|
||||
|
||||
// Surface ones.
|
||||
// Surface fields.
|
||||
forAll(surfScalarFlds, i)
|
||||
{
|
||||
surfScalarFlds[i].rename(surfScalarNames[i]);
|
||||
surfScalarFlds[i].write();
|
||||
}
|
||||
forAll(surfVectorFlds, i)
|
||||
{
|
||||
surfVectorFlds[i].rename(surfVectorNames[i]);
|
||||
surfVectorFlds[i].write();
|
||||
}
|
||||
forAll(surfSphericalTensorFlds, i)
|
||||
forAll(surfSphTensorFlds, i)
|
||||
{
|
||||
surfSphericalTensorFlds[i].rename(surfSphericalTensorNames[i]);
|
||||
surfSphericalTensorFlds[i].write();
|
||||
surfSphTensorFlds[i].write();
|
||||
}
|
||||
forAll(surfSymmTensorFlds, i)
|
||||
{
|
||||
surfSymmTensorFlds[i].rename(surfSymmTensorNames[i]);
|
||||
surfSymmTensorFlds[i].write();
|
||||
}
|
||||
forAll(surfTensorNames, i)
|
||||
forAll(surfTensorFlds, i)
|
||||
{
|
||||
surfTensorFlds[i].rename(surfTensorNames[i]);
|
||||
surfTensorFlds[i].write();
|
||||
}
|
||||
|
||||
// Point ones
|
||||
// Point fields
|
||||
forAll(pointScalarFlds, i)
|
||||
{
|
||||
pointScalarFlds[i].rename(pointScalarNames[i]);
|
||||
pointScalarFlds[i].write();
|
||||
}
|
||||
forAll(pointVectorFlds, i)
|
||||
{
|
||||
pointVectorFlds[i].rename(pointVectorNames[i]);
|
||||
pointVectorFlds[i].write();
|
||||
}
|
||||
forAll(pointSphericalTensorFlds, i)
|
||||
forAll(pointSphTensorFlds, i)
|
||||
{
|
||||
pointSphericalTensorFlds[i].rename(pointSphericalTensorNames[i]);
|
||||
pointSphericalTensorFlds[i].write();
|
||||
pointSphTensorFlds[i].write();
|
||||
}
|
||||
forAll(pointSymmTensorFlds, i)
|
||||
{
|
||||
pointSymmTensorFlds[i].rename(pointSymmTensorNames[i]);
|
||||
pointSymmTensorFlds[i].write();
|
||||
}
|
||||
forAll(pointTensorNames, i)
|
||||
forAll(pointTensorFlds, i)
|
||||
{
|
||||
pointTensorFlds[i].rename(pointTensorNames[i]);
|
||||
pointTensorFlds[i].write();
|
||||
}
|
||||
|
||||
// DimensionedFields
|
||||
// Dimensioned fields
|
||||
forAll(scalarDimFlds, i)
|
||||
{
|
||||
scalarDimFlds[i].rename(scalarDimNames[i]);
|
||||
scalarDimFlds[i].write();
|
||||
}
|
||||
forAll(vectorDimFlds, i)
|
||||
{
|
||||
vectorDimFlds[i].rename(vectorDimNames[i]);
|
||||
vectorDimFlds[i].write();
|
||||
}
|
||||
forAll(sphericalTensorDimFlds, i)
|
||||
forAll(sphTensorDimFlds, i)
|
||||
{
|
||||
sphericalTensorDimFlds[i].rename(sphericalTensorDimNames[i]);
|
||||
sphericalTensorDimFlds[i].write();
|
||||
sphTensorDimFlds[i].write();
|
||||
}
|
||||
forAll(symmTensorDimFlds, i)
|
||||
{
|
||||
symmTensorDimFlds[i].rename(symmTensorDimNames[i]);
|
||||
symmTensorDimFlds[i].write();
|
||||
}
|
||||
forAll(tensorDimFlds, i)
|
||||
{
|
||||
tensorDimFlds[i].rename(tensorDimNames[i]);
|
||||
tensorDimFlds[i].write();
|
||||
}
|
||||
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "doxygenXmlParser.H"
|
||||
#include "wordRe.H"
|
||||
#include "regExp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -40,8 +40,8 @@ Foam::doxygenXmlParser::doxygenXmlParser
|
||||
dictionary(dictionary::null)
|
||||
{
|
||||
// Pre-construct and compile regular expressions
|
||||
const wordRe nameRe(".*.H", wordRe::DETECT);
|
||||
const wordRe searchStrRe(searchStr, wordRe::DETECT);
|
||||
const regExp nameRe(".*.H");
|
||||
const regExp searchStrRe(searchStr);
|
||||
|
||||
// Pre-construct constant strings and names to speed-up comparisons
|
||||
const string slashStartTag('/' + startTag);
|
||||
@ -163,7 +163,7 @@ Foam::doxygenXmlParser::doxygenXmlParser
|
||||
(
|
||||
!exactMatch
|
||||
&& !found(tName) // not already added
|
||||
&& wordRe(".*" + tName + ".*", wordRe::DETECT).match(name)
|
||||
&& regExp(".*" + tName + ".*").match(name)
|
||||
)
|
||||
{
|
||||
dictionary dict(dictionary::null);
|
||||
|
||||
@ -37,7 +37,7 @@ Foam::autoPtr<Foam::helpType> Foam::helpType::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(helpTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
// special treatment for -help
|
||||
// exit without stack trace
|
||||
|
||||
@ -23,7 +23,7 @@ if (!fieldsToUse.found(fieldName))
|
||||
).typeHeaderOk<volScalarField>(false, false)
|
||||
);
|
||||
|
||||
if (variableGood)
|
||||
if (!variableGood)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@ -35,36 +35,25 @@ if (timeDirs.size() && !noLagrangian)
|
||||
cloudPrefix/cloudName
|
||||
);
|
||||
|
||||
// clouds always require "positions"
|
||||
// Clouds always have "positions"
|
||||
if (cloudObjs.found("positions"))
|
||||
{
|
||||
HashTable<HashTable<word>>::iterator cloudIter =
|
||||
cloudFields.find(cloudName);
|
||||
// Save the cloud fields on a per cloud basis
|
||||
auto fieldsPerCloud = cloudFields(cloudName);
|
||||
|
||||
if (cloudIter == cloudFields.end())
|
||||
forAllConstIters(cloudObjs, fieldIter)
|
||||
{
|
||||
// A newly discovered cloud
|
||||
cloudFields.insert(cloudName, HashTable<word>());
|
||||
cloudIter = cloudFields.find(cloudName);
|
||||
}
|
||||
const IOobject* obj = fieldIter();
|
||||
|
||||
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
|
||||
{
|
||||
const IOobject& obj = *fieldIter();
|
||||
|
||||
// Add field and field type
|
||||
cloudIter().insert
|
||||
(
|
||||
obj.name(),
|
||||
obj.headerClassName()
|
||||
);
|
||||
// Field name/type
|
||||
fieldsPerCloud.insert(obj->name(), obj->headerClassName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// prune out "positions" again since it gets treated specially
|
||||
forAllIter(HashTable<HashTable<word>>, cloudFields, cloudIter)
|
||||
// Prune out "positions" again since it gets treated specially
|
||||
forAllIters(cloudFields, cloudIter)
|
||||
{
|
||||
cloudIter().erase("positions");
|
||||
}
|
||||
@ -76,18 +65,13 @@ if (timeDirs.size() && !noLagrangian)
|
||||
}
|
||||
|
||||
|
||||
// sorted list of cloud names
|
||||
// Sorted list of cloud names
|
||||
const wordList cloudNames(cloudFields.sortedToc());
|
||||
|
||||
if (cloudNames.size())
|
||||
{
|
||||
// complete the echo information
|
||||
Info<< "(";
|
||||
forAll(cloudNames, cloudNo)
|
||||
{
|
||||
Info<< ' ' << cloudNames[cloudNo];
|
||||
}
|
||||
Info<< " ) " << endl;
|
||||
// Complete the echo information - as flatOutput
|
||||
cloudNames.writeList(Info) << endl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,6 +78,7 @@ Note
|
||||
|
||||
#include "fvc.H"
|
||||
#include "volFields.H"
|
||||
#include "hashedWordList.H"
|
||||
|
||||
#include "labelIOField.H"
|
||||
#include "scalarIOField.H"
|
||||
@ -190,7 +191,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
// The volume field types that we handle
|
||||
const wordList volFieldTypes
|
||||
const hashedWordList volFieldTypes
|
||||
{
|
||||
volScalarField::typeName,
|
||||
volVectorField::typeName,
|
||||
@ -207,7 +208,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
// default to binary output, unless otherwise specified
|
||||
// Default to binary output, unless otherwise specified
|
||||
const IOstream::streamFormat format =
|
||||
(
|
||||
args.optionFound("ascii")
|
||||
@ -234,7 +235,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
//
|
||||
// general (case) output options
|
||||
// General (case) output options
|
||||
//
|
||||
ensightCase::options caseOpts(format);
|
||||
|
||||
@ -257,7 +258,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
//
|
||||
// output configuration (geometry related)
|
||||
// Output configuration (geometry related)
|
||||
//
|
||||
ensightMesh::options writeOpts(format);
|
||||
writeOpts.noPatches(args.optionFound("noPatches"));
|
||||
@ -313,12 +314,6 @@ int main(int argc, char *argv[])
|
||||
ensCase.printInfo(Info) << endl;
|
||||
}
|
||||
|
||||
|
||||
// Set Time to the last time before looking for lagrangian objects
|
||||
runTime.setTime(timeDirs.last(), timeDirs.size()-1);
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
#include "checkMeshMoving.H"
|
||||
#include "findCloudFields.H"
|
||||
|
||||
@ -331,6 +326,40 @@ int main(int argc, char *argv[])
|
||||
<< timer.cpuTimeIncrement() << " s, "
|
||||
<< mem.update().size() << " kB" << nl << endl;
|
||||
|
||||
// Get the list of supported classes/fields
|
||||
HashTable<wordHashSet> usableObjects;
|
||||
{
|
||||
// Initially all possible objects that are available at the final time
|
||||
IOobjectList objects(mesh, timeDirs.last().name());
|
||||
|
||||
// Categorize by classes, pre-filter on name (if requested)
|
||||
usableObjects =
|
||||
(
|
||||
fieldPatterns.empty()
|
||||
? objects.classes()
|
||||
: objects.classes(fieldPatterns)
|
||||
);
|
||||
|
||||
// Limit to types that we explicitly handle
|
||||
usableObjects.filterKeys(volFieldTypes);
|
||||
|
||||
// Force each field-type into existence (simplifies code logic
|
||||
// and doesn't cost much) and simultaneously remove all
|
||||
// "*_0" restart fields
|
||||
|
||||
for (auto fieldType : volFieldTypes)
|
||||
{
|
||||
usableObjects
|
||||
(
|
||||
fieldType
|
||||
).filterKeys
|
||||
(
|
||||
[](const word& k){ return k.endsWith("_0"); },
|
||||
true // prune
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ignore special fields (_0 fields),
|
||||
// ignore fields we don't handle,
|
||||
// ignore fields that are not available for all time-steps
|
||||
@ -362,25 +391,22 @@ int main(int argc, char *argv[])
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
Info<< "Write volume field (";
|
||||
|
||||
forAll(volFieldTypes, typei)
|
||||
for (auto fieldType : volFieldTypes)
|
||||
{
|
||||
const word& fieldType = volFieldTypes[typei];
|
||||
wordList fieldNames = objects.names(fieldType);
|
||||
// For convenience, just force each field-type into existence.
|
||||
// This simplifies code logic and doesn't cost much at all.
|
||||
wordHashSet& fieldNames = usableObjects(fieldType);
|
||||
|
||||
// Filter on name as required
|
||||
if (!fieldPatterns.empty())
|
||||
forAllIters(fieldNames, fieldIter)
|
||||
{
|
||||
inplaceSubsetStrings(fieldPatterns, fieldNames);
|
||||
}
|
||||
|
||||
forAll(fieldNames, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldNames[fieldi];
|
||||
const word& fieldName = fieldIter.key();
|
||||
|
||||
#include "checkData.H"
|
||||
|
||||
// Partially complete field?
|
||||
if (!fieldsToUse[fieldName])
|
||||
{
|
||||
fieldNames.erase(fieldIter);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -597,7 +623,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not currently handle this type - blacklist for the future.
|
||||
// Do not currently handle this type
|
||||
// - blacklist for the future.
|
||||
fieldsToUse.set(fieldName, false);
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +199,7 @@ void print(Ostream& os, const wordList& flds)
|
||||
labelList getSelectedPatches
|
||||
(
|
||||
const polyBoundaryMesh& patches,
|
||||
const List<wordRe>& excludePatches
|
||||
const wordRes& excludePatches
|
||||
)
|
||||
{
|
||||
DynamicList<label> patchIDs(patches.size());
|
||||
@ -219,7 +219,7 @@ labelList getSelectedPatches
|
||||
Info<< " discarding empty/processor patch " << patchi
|
||||
<< " " << pp.name() << endl;
|
||||
}
|
||||
else if (findStrings(excludePatches, pp.name()))
|
||||
else if (excludePatches.match(pp.name()))
|
||||
{
|
||||
Info<< " excluding patch " << patchi
|
||||
<< " " << pp.name() << endl;
|
||||
@ -379,7 +379,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
const bool allPatches = args.optionFound("allPatches");
|
||||
|
||||
List<wordRe> excludePatches;
|
||||
wordReList excludePatches;
|
||||
if (args.optionFound("excludePatches"))
|
||||
{
|
||||
args.optionLookup("excludePatches")() >> excludePatches;
|
||||
|
||||
@ -55,7 +55,7 @@ namespace Foam
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkPVFoamReader Declaration
|
||||
Class vtkPVFoamReader Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkPVFoamReader
|
||||
@ -64,7 +64,7 @@ class vtkPVFoamReader
|
||||
{
|
||||
public:
|
||||
vtkTypeMacro(vtkPVFoamReader, vtkMultiBlockDataSetAlgorithm);
|
||||
void PrintSelf(ostream&, vtkIndent);
|
||||
void PrintSelf(ostream&, vtkIndent) VTK_OVERRIDE;
|
||||
|
||||
static vtkPVFoamReader* New();
|
||||
|
||||
@ -199,7 +199,7 @@ protected:
|
||||
vtkInformation*,
|
||||
vtkInformationVector**,
|
||||
vtkInformationVector*
|
||||
);
|
||||
) VTK_OVERRIDE;
|
||||
|
||||
//- Get the mesh/fields for a particular time
|
||||
virtual int RequestData
|
||||
@ -207,10 +207,10 @@ protected:
|
||||
vtkInformation*,
|
||||
vtkInformationVector**,
|
||||
vtkInformationVector*
|
||||
);
|
||||
) VTK_OVERRIDE;
|
||||
|
||||
//- Fill in additional port information
|
||||
virtual int FillOutputPortInformation(int, vtkInformation*);
|
||||
virtual int FillOutputPortInformation(int, vtkInformation*) VTK_OVERRIDE;
|
||||
|
||||
//- The observer to modify this object when array selections are modified
|
||||
vtkCallbackCommand* SelectionObserver;
|
||||
|
||||
@ -62,7 +62,7 @@ class vtkPVblockMeshReader
|
||||
{
|
||||
public:
|
||||
vtkTypeMacro(vtkPVblockMeshReader, vtkMultiBlockDataSetAlgorithm);
|
||||
void PrintSelf(ostream&, vtkIndent);
|
||||
void PrintSelf(ostream&, vtkIndent) VTK_OVERRIDE;
|
||||
|
||||
static vtkPVblockMeshReader* New();
|
||||
|
||||
@ -127,7 +127,7 @@ protected:
|
||||
vtkInformation* unusedRequest,
|
||||
vtkInformationVector** unusedInputVector,
|
||||
vtkInformationVector* outputVector
|
||||
);
|
||||
) VTK_OVERRIDE;
|
||||
|
||||
//- Get the mesh for a particular time
|
||||
virtual int RequestData
|
||||
@ -135,10 +135,10 @@ protected:
|
||||
vtkInformation* unusedRequest,
|
||||
vtkInformationVector** unusedInputVector,
|
||||
vtkInformationVector* outputVector
|
||||
);
|
||||
) VTK_OVERRIDE;
|
||||
|
||||
//- Fill in additional port information
|
||||
virtual int FillOutputPortInformation(int, vtkInformation*);
|
||||
virtual int FillOutputPortInformation(int, vtkInformation*) VTK_OVERRIDE;
|
||||
|
||||
// The observer to modify this object when array selections are modified
|
||||
vtkCallbackCommand* SelectionObserver;
|
||||
|
||||
@ -169,7 +169,7 @@ void Foam::boundaryInfo::setType(const label patchI, const word& condition)
|
||||
return;
|
||||
}
|
||||
|
||||
if (wordRe(".*[Mm]apped.*", wordRe::REGEXP).match(types_[patchI]))
|
||||
if (regExp(".*[Mm]apped.*").match(types_[patchI]))
|
||||
{
|
||||
// ugly hack to avoid overriding mapped types
|
||||
return;
|
||||
|
||||
@ -47,7 +47,7 @@ autoPtr<tabulatedWallFunction> tabulatedWallFunction::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(twfTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown tabulatedWallFunction type " << twfTypeName
|
||||
|
||||
@ -67,7 +67,7 @@ Foam::searchableSurfaceModifier::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(type);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown searchableSurfaceModifier type "
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# fix permissions (NB: '+X' and not '+x'!)
|
||||
# Fix permissions (NB: '+X' and not '+x'!)
|
||||
chmod a+rX $WM_PROJECT_DIR $WM_PROJECT_DIR/doc Doxygen
|
||||
|
||||
Doxygen/Allwmake
|
||||
exec Doxygen/Allwmake "$@"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -14,13 +14,17 @@ usage() {
|
||||
|
||||
usage: ${0##*/} [OPTION]
|
||||
options:
|
||||
-online use links to the Github repositories instead of the local source code
|
||||
-config name use alternative doxygen config
|
||||
-dir name process given directory name directly
|
||||
-online use links to the Github repositories instead of the
|
||||
local source code
|
||||
-help
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
defineURL() {
|
||||
WEB_PATH="https://develop.openfoam.com"
|
||||
@ -39,13 +43,43 @@ defineURL() {
|
||||
export FOAM_ONLINE_REPO="$FOAM_BASE_REPO/blob/${FOAM_REPO_TAG}"
|
||||
}
|
||||
|
||||
# parse options
|
||||
|
||||
unset configName dirName
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h | -help)
|
||||
usage
|
||||
;;
|
||||
-config)
|
||||
configName="$2"
|
||||
[ -f "$configName" ] || {
|
||||
# No such file. Try some common alternatives
|
||||
for ending in $configName ".$configName" "-$configName"
|
||||
do
|
||||
if [ -f "Doxyfile$ending" ]
|
||||
then
|
||||
configName="Doxyfile$ending"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
[ -f "$configName" ] || {
|
||||
echo "Could not resolve Doxyfile config: $configName" 1>&2
|
||||
exit 1
|
||||
}
|
||||
shift
|
||||
;;
|
||||
-dir)
|
||||
dirName="$2"
|
||||
[ -d "$dirName" ] || {
|
||||
echo "Could not resolve input directory: $dirName" 1>&2
|
||||
exit 1
|
||||
}
|
||||
shift
|
||||
;;
|
||||
-online)
|
||||
defineURL
|
||||
;;
|
||||
@ -56,19 +90,31 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
rm -rf latex man
|
||||
|
||||
# remove html directory in background
|
||||
# Remove html directory in background
|
||||
mv html html-stagedRemove$$ 2> /dev/null
|
||||
rm -rf html-stagedRemove$$ >/dev/null 2>&1 &
|
||||
|
||||
# ensure that created files are readable by everyone
|
||||
# Ensure that created files are readable by everyone
|
||||
umask 22
|
||||
doxygen
|
||||
|
||||
# fix permissions (NB: '+X' and not '+x'!)
|
||||
if [ -n "$dirName" ]
|
||||
then
|
||||
# Create a temporary with only the specified directory
|
||||
tmpConfig="${TMPDIR:-/tmp}/Doxyfile.$$"
|
||||
trap 'rm -f $tmpConfig 2>/dev/null; exit 0' EXIT TERM INT
|
||||
cat $PWD/Doxyfile > $tmpConfig
|
||||
echo "INPUT = $dirName" >> $tmpConfig
|
||||
doxygen $tmpConfig
|
||||
else
|
||||
doxygen $configName
|
||||
fi
|
||||
|
||||
# Fix permissions (NB: '+X' and not '+x'!)
|
||||
chmod -R a+rX html latex man 2>/dev/null
|
||||
|
||||
echo
|
||||
|
||||
@ -39,7 +39,7 @@ Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(ODESolverTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown ODESolver type "
|
||||
|
||||
@ -111,7 +111,7 @@ Foam::regExp::~regExp()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::regExp::set(const char* pattern, bool ignoreCase)
|
||||
bool Foam::regExp::set(const char* pattern, bool ignoreCase)
|
||||
{
|
||||
clear();
|
||||
|
||||
@ -137,7 +137,7 @@ void Foam::regExp::set(const char* pattern, bool ignoreCase)
|
||||
// avoid zero-length patterns
|
||||
if (!*pat)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,11 +154,15 @@ void Foam::regExp::set(const char* pattern, bool ignoreCase)
|
||||
<< nl << errbuf
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; // Was cleared and nothing was set
|
||||
}
|
||||
|
||||
|
||||
void Foam::regExp::set(const std::string& pattern, bool ignoreCase)
|
||||
bool Foam::regExp::set(const std::string& pattern, bool ignoreCase)
|
||||
{
|
||||
return set(pattern.c_str(), ignoreCase);
|
||||
}
|
||||
@ -208,7 +212,7 @@ bool Foam::regExp::match(const std::string& text) const
|
||||
if
|
||||
(
|
||||
regexec(preg_, text.c_str(), nmatch, pmatch, 0) == 0
|
||||
&& (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(text.size()))
|
||||
&& (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == regoff_t(text.size()))
|
||||
)
|
||||
{
|
||||
return true;
|
||||
|
||||
@ -128,20 +128,23 @@ public:
|
||||
|
||||
// Editing
|
||||
|
||||
//- Compile pattern into a regular expression, optionally ignore case
|
||||
void set(const char* pattern, bool ignoreCase=false);
|
||||
//- Compile pattern into a regular expression, optionally ignore case.
|
||||
// \return True if the pattern was compiled
|
||||
bool set(const char* pattern, bool ignoreCase=false);
|
||||
|
||||
//- Compile pattern into a regular expression, optionally ignore case
|
||||
void set(const std::string& pattern, bool ignoreCase=false);
|
||||
// \return True if the pattern was compiled
|
||||
bool set(const std::string& pattern, bool ignoreCase=false);
|
||||
|
||||
//- Clear expression, return true if expression had existed.
|
||||
//- Clear expression.
|
||||
// \return True if expression had existed prior to the clear.
|
||||
bool clear();
|
||||
|
||||
|
||||
// Matching/Searching
|
||||
|
||||
//- Find position within string.
|
||||
// Returns the index where it begins or string::npos if not found
|
||||
// \Return The index where it begins or string::npos if not found
|
||||
std::string::size_type find(const std::string& text) const;
|
||||
|
||||
//- Return true if it matches the entire string
|
||||
@ -158,6 +161,9 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Perform match on text
|
||||
inline bool operator()(const std::string& text) const;
|
||||
|
||||
//- Assign and compile pattern from a character array
|
||||
// Always case sensitive
|
||||
inline void operator=(const char* pattern);
|
||||
|
||||
@ -66,6 +66,12 @@ inline bool Foam::regExp::search(const std::string& text) const
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::regExp::operator()(const std::string& text) const
|
||||
{
|
||||
return match(text);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::regExp::operator=(const char* pattern)
|
||||
{
|
||||
set(pattern);
|
||||
|
||||
@ -103,8 +103,8 @@ $(strings)/fileName/fileName.C
|
||||
$(strings)/fileName/fileNameIO.C
|
||||
$(strings)/keyType/keyType.C
|
||||
$(strings)/wordRe/wordRe.C
|
||||
$(strings)/wordRes/wordRes.C
|
||||
$(strings)/lists/hashedWordList.C
|
||||
$(strings)/lists/wordReListMatcher.C
|
||||
$(strings)/stringOps/stringOps.C
|
||||
|
||||
ops = primitives/ops
|
||||
|
||||
@ -158,6 +158,20 @@ Foam::label Foam::HashSet<Key, Hash>::insert(std::initializer_list<Key> lst)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Key, class Hash>
|
||||
inline bool Foam::HashSet<Key, Hash>::operator()(const Key& key) const
|
||||
{
|
||||
return this->found(key);
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
|
||||
{
|
||||
return this->found(key);
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
void Foam::HashSet<Key, Hash>::operator=(const UList<Key>& lst)
|
||||
{
|
||||
@ -180,12 +194,6 @@ void Foam::HashSet<Key, Hash>::operator=(std::initializer_list<Key> lst)
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
|
||||
{
|
||||
return this->found(key);
|
||||
}
|
||||
|
||||
|
||||
template<class Key, class Hash>
|
||||
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
|
||||
|
||||
@ -156,22 +156,24 @@ public:
|
||||
// Edit
|
||||
|
||||
//- Insert a new entry
|
||||
// \return True if the entry inserted, which means that it did
|
||||
// not previously exist in the set.
|
||||
bool insert(const Key& key)
|
||||
{
|
||||
return this->parent_type::insert(key, nil());
|
||||
}
|
||||
|
||||
//- Insert keys from the list of Key
|
||||
// Return the number of new elements inserted
|
||||
// \return The number of new elements inserted
|
||||
label insert(const UList<Key>& lst);
|
||||
|
||||
//- Insert keys from the list of Key
|
||||
// Return the number of new elements inserted
|
||||
// \return The number of new elements inserted
|
||||
template<unsigned Size>
|
||||
label insert(const FixedList<Key, Size>& lst);
|
||||
|
||||
//- Insert keys from a initializer list of Key
|
||||
// Return the number of new elements inserted
|
||||
// \return The number of new elements inserted
|
||||
label insert(std::initializer_list<Key> lst);
|
||||
|
||||
//- Same as insert (cannot overwrite nil content)
|
||||
@ -200,18 +202,21 @@ public:
|
||||
}
|
||||
|
||||
//- Unset the specified key - same as erase
|
||||
// \return True if the entry existed and was removed
|
||||
bool unset(const Key& key)
|
||||
{
|
||||
return this->parent_type::erase(key);
|
||||
}
|
||||
|
||||
//- Unset the listed keys - same as erase
|
||||
// \return The number of items removed
|
||||
label unset(const UList<Key>& lst)
|
||||
{
|
||||
return this->parent_type::erase(lst);
|
||||
}
|
||||
|
||||
//- Unset the listed keys - same as erase
|
||||
// \return The number of items removed
|
||||
template<unsigned Size>
|
||||
label unset(const FixedList<Key, Size>& lst)
|
||||
{
|
||||
@ -219,11 +224,36 @@ public:
|
||||
}
|
||||
|
||||
//- Unset the listed keys - same as erase
|
||||
// \return The number of items removed
|
||||
label unset(std::initializer_list<Key> lst)
|
||||
{
|
||||
return this->parent_type::erase(lst);
|
||||
}
|
||||
|
||||
//- Not applicable for HashSet
|
||||
template<class UnaryPredicate>
|
||||
List<Key> tocValues(const UnaryPredicate&, const bool) = delete;
|
||||
|
||||
//- Not applicable for HashSet
|
||||
template<class BinaryPredicate>
|
||||
List<Key> tocEntries(const BinaryPredicate&, const bool) = delete;
|
||||
|
||||
//- Not applicable for HashSet
|
||||
template<class UnaryPredicate>
|
||||
label countValues(const UnaryPredicate&, const bool) = delete;
|
||||
|
||||
//- Not applicable for HashSet
|
||||
template<class BinaryPredicate>
|
||||
label countEntries(const BinaryPredicate&, const bool) = delete;
|
||||
|
||||
//- Not applicable for HashSet
|
||||
template<class UnaryPredicate>
|
||||
label filterValues(const UnaryPredicate&, const bool) = delete;
|
||||
|
||||
//- Not applicable for HashSet
|
||||
template<class BinaryPredicate>
|
||||
label filterEntries(const BinaryPredicate&, const bool) = delete;
|
||||
|
||||
|
||||
// STL iterators
|
||||
|
||||
@ -248,12 +278,15 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- This operation doesn't make much sense for a hash-set
|
||||
void operator()(const Key& key) = delete;
|
||||
|
||||
//- Return true if the entry exists, same as found()
|
||||
inline bool operator()(const Key& key) const;
|
||||
|
||||
//- Return true if the entry exists, same as found().
|
||||
inline bool operator[](const Key& key) const;
|
||||
|
||||
|
||||
// Comparison
|
||||
|
||||
//- Equality. Two hashset are equal when they have the same keys.
|
||||
// Independent of table size or order.
|
||||
bool operator==(const this_type& rhs) const;
|
||||
@ -262,6 +295,8 @@ public:
|
||||
bool operator!=(const this_type& rhs) const;
|
||||
|
||||
|
||||
// Assignment
|
||||
|
||||
//- Assignment from a UList of keys
|
||||
void operator=(const UList<Key>& lst);
|
||||
|
||||
@ -273,6 +308,8 @@ public:
|
||||
void operator=(std::initializer_list<Key> lst);
|
||||
|
||||
|
||||
// Logical operations
|
||||
|
||||
//- Combine entries from HashSets
|
||||
void operator|=(const HashSet<Key, Hash>& rhs);
|
||||
|
||||
|
||||
@ -231,25 +231,169 @@ Foam::HashTable<T, Key, Hash>::find
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const
|
||||
{
|
||||
List<Key> keys(nElmts_);
|
||||
label keyI = 0;
|
||||
List<Key> keyLst(nElmts_);
|
||||
label count = 0;
|
||||
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
keys[keyI++] = iter.key();
|
||||
keyLst[count++] = iter.key();
|
||||
}
|
||||
|
||||
return keys;
|
||||
return keyLst;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc() const
|
||||
{
|
||||
List<Key> sortedLst = this->toc();
|
||||
sort(sortedLst);
|
||||
List<Key> keyLst = this->toc();
|
||||
Foam::sort(keyLst);
|
||||
|
||||
return sortedLst;
|
||||
return keyLst;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class UnaryPredicate>
|
||||
Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocKeys
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool invert
|
||||
) const
|
||||
{
|
||||
List<Key> keyLst(nElmts_);
|
||||
label count = 0;
|
||||
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
if ((pred(iter.key()) ? !invert : invert))
|
||||
{
|
||||
keyLst[count++] = iter.key();
|
||||
}
|
||||
}
|
||||
|
||||
keyLst.setSize(count);
|
||||
Foam::sort(keyLst);
|
||||
|
||||
return keyLst;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class UnaryPredicate>
|
||||
Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocValues
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool invert
|
||||
) const
|
||||
{
|
||||
List<Key> keyLst(nElmts_);
|
||||
label count = 0;
|
||||
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
if ((pred(iter.object()) ? !invert : invert))
|
||||
{
|
||||
keyLst[count++] = iter.key();
|
||||
}
|
||||
}
|
||||
|
||||
keyLst.setSize(count);
|
||||
Foam::sort(keyLst);
|
||||
|
||||
return keyLst;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class BinaryPredicate>
|
||||
Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocEntries
|
||||
(
|
||||
const BinaryPredicate& pred,
|
||||
const bool invert
|
||||
) const
|
||||
{
|
||||
List<Key> keyLst(nElmts_);
|
||||
label count = 0;
|
||||
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
if ((pred(iter.key(), iter.object()) ? !invert : invert))
|
||||
{
|
||||
keyLst[count++] = iter.key();
|
||||
}
|
||||
}
|
||||
|
||||
keyLst.setSize(count);
|
||||
Foam::sort(keyLst);
|
||||
|
||||
return keyLst;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class UnaryPredicate>
|
||||
Foam::label Foam::HashTable<T, Key, Hash>::countKeys
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool invert
|
||||
) const
|
||||
{
|
||||
label count = 0;
|
||||
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
if ((pred(iter.key()) ? !invert : invert))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class UnaryPredicate>
|
||||
Foam::label Foam::HashTable<T, Key, Hash>::countValues
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool invert
|
||||
) const
|
||||
{
|
||||
label count = 0;
|
||||
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
if ((pred(iter.object()) ? !invert : invert))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class BinaryPredicate>
|
||||
Foam::label Foam::HashTable<T, Key, Hash>::countEntries
|
||||
(
|
||||
const BinaryPredicate& pred,
|
||||
const bool invert
|
||||
) const
|
||||
{
|
||||
label count = 0;
|
||||
|
||||
for (const_iterator iter = cbegin(); iter != cend(); ++iter)
|
||||
{
|
||||
if ((pred(iter.key(), iter.object()) ? !invert : invert))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@ -617,6 +761,87 @@ void Foam::HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht)
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class UnaryPredicate>
|
||||
Foam::label Foam::HashTable<T, Key, Hash>::filterKeys
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool pruning
|
||||
)
|
||||
{
|
||||
label changed = 0;
|
||||
|
||||
for (iterator iter = begin(); iter != end(); ++iter)
|
||||
{
|
||||
// Matches? either prune (pruning) or keep (!pruning)
|
||||
if
|
||||
(
|
||||
(pred(iter.key()) ? pruning : !pruning)
|
||||
&& erase(iter)
|
||||
)
|
||||
{
|
||||
++changed;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class UnaryPredicate>
|
||||
Foam::label Foam::HashTable<T, Key, Hash>::filterValues
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool pruning
|
||||
)
|
||||
{
|
||||
label changed = 0;
|
||||
|
||||
for (iterator iter = begin(); iter != end(); ++iter)
|
||||
{
|
||||
// Matches? either prune (pruning) or keep (!pruning)
|
||||
if
|
||||
(
|
||||
(pred(iter.object()) ? pruning : !pruning)
|
||||
&& erase(iter)
|
||||
)
|
||||
{
|
||||
++changed;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class BinaryPredicate>
|
||||
Foam::label Foam::HashTable<T, Key, Hash>::filterEntries
|
||||
(
|
||||
const BinaryPredicate& pred,
|
||||
const bool pruning
|
||||
)
|
||||
{
|
||||
label changed = 0;
|
||||
|
||||
for (iterator iter = begin(); iter != end(); ++iter)
|
||||
{
|
||||
// Matches? either prune (pruning) or keep (!pruning)
|
||||
if
|
||||
(
|
||||
(pred(iter.key(), iter.object()) ? pruning : !pruning)
|
||||
&& erase(iter)
|
||||
)
|
||||
{
|
||||
++changed;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
|
||||
@ -255,7 +255,7 @@ private:
|
||||
inline label hashKeyIndex(const Key& key) const;
|
||||
|
||||
//- Assign a new hash-entry to a possibly already existing key.
|
||||
// Return true if the new entry was set.
|
||||
// \return True if the new entry was set.
|
||||
bool set(const Key& key, const T& obj, const bool protect);
|
||||
|
||||
|
||||
@ -330,22 +330,83 @@ public:
|
||||
//- Return hashed entry if it exists, or return the given default
|
||||
inline const T& lookup(const Key& key, const T& deflt) const;
|
||||
|
||||
|
||||
// Table of contents
|
||||
|
||||
//- Return the table of contents
|
||||
List<Key> toc() const;
|
||||
|
||||
//- Return the table of contents as a sorted list
|
||||
List<Key> sortedToc() const;
|
||||
|
||||
//- Return the sorted table of contents with keys that satisfy
|
||||
// the unary predicate, optionally with inverted logic.
|
||||
template<class UnaryPredicate>
|
||||
List<Key> tocKeys
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool invert = false
|
||||
) const;
|
||||
|
||||
//- Return the sorted table of contents with values that satisfy
|
||||
// the unary predicate, optionally with inverted logic.
|
||||
template<class UnaryPredicate>
|
||||
List<Key> tocValues
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool invert = false
|
||||
) const;
|
||||
|
||||
//- Return the sorted table of contents with keys/values that satisfy
|
||||
// the binary predicate, optionally with inverted logic.
|
||||
template<class BinaryPredicate>
|
||||
List<Key> tocEntries
|
||||
(
|
||||
const BinaryPredicate& pred,
|
||||
const bool invert = false
|
||||
) const;
|
||||
|
||||
|
||||
// Counting
|
||||
|
||||
//- Count the number of keys that satisfy the unary predicate,
|
||||
// optionally with inverted logic.
|
||||
template<class UnaryPredicate>
|
||||
label countKeys
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool invert = false
|
||||
) const;
|
||||
|
||||
//- Count the number of values that satisfy the unary predicate,
|
||||
// optionally with inverted logic.
|
||||
template<class UnaryPredicate>
|
||||
label countValues
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool invert = false
|
||||
) const;
|
||||
|
||||
//- Count the number of entries that satisfy the binary predicate,
|
||||
// optionally with inverted logic.
|
||||
template<class BinaryPredicate>
|
||||
label countEntries
|
||||
(
|
||||
const BinaryPredicate& pred,
|
||||
const bool invert = false
|
||||
) const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Insert a new entry
|
||||
// Return true if the entry inserted, which means that it did
|
||||
// \return True if the entry inserted, which means that it did
|
||||
// not previously exist in the table.
|
||||
inline bool insert(const Key& key, const T& obj);
|
||||
|
||||
//- Assign a new entry, overwriting existing entries.
|
||||
// Returns true.
|
||||
//
|
||||
// \return True, since it always overwrites any entries.
|
||||
inline bool set(const Key& key, const T& obj);
|
||||
|
||||
//- Erase an entry specified by given iterator
|
||||
@ -357,30 +418,34 @@ public:
|
||||
// auto iter = table.find(unknownKey);
|
||||
// table.erase(iter);
|
||||
// \endcode
|
||||
// which is what \code table.erase(unknownKey) \endcode does anyhow
|
||||
// which is what \code table.erase(unknownKey) \endcode does anyhow.
|
||||
//
|
||||
// \return True if the corresponding entry existed and was removed
|
||||
bool erase(const iterator& iter);
|
||||
|
||||
//- Erase an entry specified by the given key
|
||||
// \return True if the entry existed and was removed
|
||||
bool erase(const Key& key);
|
||||
|
||||
//- Remove table entries given by the listed keys
|
||||
// Return the number of elements removed
|
||||
// \return The number of items removed
|
||||
label erase(const UList<Key>& keys);
|
||||
|
||||
//- Remove table entries given by the listed keys
|
||||
// Return the number of elements removed
|
||||
// \return The number of items removed
|
||||
template<unsigned Size>
|
||||
label erase(const FixedList<Key, Size>& keys);
|
||||
|
||||
//- Remove table entries given by the listed keys
|
||||
// Return the number of elements removed
|
||||
// \return The number of items removed
|
||||
label erase(std::initializer_list<Key> keys);
|
||||
|
||||
//- Remove table entries given by keys of the other hash-table.
|
||||
// Return the number of elements removed.
|
||||
//
|
||||
// The other hash-table must have the same type of key, but the
|
||||
// type of values held and the hashing function are arbitrary.
|
||||
//
|
||||
// \return The number of items removed
|
||||
template<class AnyType, class AnyHash>
|
||||
label erase(const HashTable<AnyType, Key, AnyHash>& other);
|
||||
|
||||
@ -388,9 +453,66 @@ public:
|
||||
//
|
||||
// The other hash-table must have the same type of key, but the
|
||||
// type of values held and the hashing function are arbitrary.
|
||||
//
|
||||
// \return The number of items changed (removed)
|
||||
template<class AnyType, class AnyHash>
|
||||
label retain(const HashTable<AnyType, Key, AnyHash>& other);
|
||||
|
||||
//- Generalized means to filter table entries based on their keys.
|
||||
// Keep (or optionally prune) entries with keys that satisfy
|
||||
// the unary predicate, which has the following signature:
|
||||
// \code
|
||||
// bool operator()(const Key& k);
|
||||
// \endcode
|
||||
//
|
||||
// For example,
|
||||
// \code
|
||||
// wordRes goodFields = ...;
|
||||
// allFieldNames.filterKeys
|
||||
// (
|
||||
// [&goodFields](const word& k){ return goodFields.match(k); }
|
||||
// );
|
||||
// \endcode
|
||||
//
|
||||
// \return The number of items changed (removed)
|
||||
template<class UnaryPredicate>
|
||||
label filterKeys
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool pruning = false
|
||||
);
|
||||
|
||||
//- Generalized means to filter table entries based on their values.
|
||||
// Keep (or optionally prune) entries with values that satisfy
|
||||
// the unary predicate, which has the following signature:
|
||||
// \code
|
||||
// bool operator()(const T& v);
|
||||
// \endcode
|
||||
//
|
||||
// \return The number of items changed (removed)
|
||||
template<class UnaryPredicate>
|
||||
label filterValues
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool pruning = false
|
||||
);
|
||||
|
||||
//- Generalized means to filter table entries based on their key/value.
|
||||
// Keep (or optionally prune) entries with keys/values that satisfy
|
||||
// the binary predicate, which has the following signature:
|
||||
// \code
|
||||
// bool operator()(const Key& k, const T& v);
|
||||
// \endcode
|
||||
//
|
||||
// \return The number of items changed (removed)
|
||||
template<class BinaryPredicate>
|
||||
label filterEntries
|
||||
(
|
||||
const BinaryPredicate& pred,
|
||||
const bool pruning = false
|
||||
);
|
||||
|
||||
|
||||
//- Resize the hash table for efficiency
|
||||
void resize(const label sz);
|
||||
|
||||
|
||||
@ -46,26 +46,26 @@ Foam::label Foam::HashTableCore::canonicalSize(const label requested_size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (requested_size >= maxTableSize)
|
||||
{
|
||||
return maxTableSize;
|
||||
}
|
||||
|
||||
// Enforce power of two - makes for a vey fast modulus etc.
|
||||
// Enforce power of two - makes for a very fast modulus.
|
||||
// Use unsigned for these calculations.
|
||||
//
|
||||
// - The lower limit (8) is somewhat arbitrary, but if the hash table
|
||||
// is too small, there will be many direct table collisions.
|
||||
// - The uper limit (approx. labelMax/4) must be a power of two,
|
||||
// - The upper limit (approx. labelMax/4) must be a power of two,
|
||||
// need not be extremely large for hashing.
|
||||
|
||||
uLabel powerOfTwo = 8; // lower-limit
|
||||
|
||||
const uLabel size = requested_size;
|
||||
if (size < powerOfTwo)
|
||||
if (size <= powerOfTwo)
|
||||
{
|
||||
return powerOfTwo;
|
||||
}
|
||||
else if (requested_size >= maxTableSize)
|
||||
{
|
||||
return maxTableSize;
|
||||
}
|
||||
else if (size & (size-1)) // <- Modulus of i^2
|
||||
{
|
||||
// Determine power-of-two. Brute-force is fast enough.
|
||||
|
||||
@ -46,26 +46,26 @@ Foam::label Foam::StaticHashTableCore::canonicalSize(const label requested_size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (requested_size >= maxTableSize)
|
||||
{
|
||||
return maxTableSize;
|
||||
}
|
||||
|
||||
// Enforce power of two - makes for a vey fast modulus etc.
|
||||
// Enforce power of two - makes for a very fast modulus.
|
||||
// Use unsigned for these calculations.
|
||||
//
|
||||
// - The lower limit (8) is somewhat arbitrary, but if the hash table
|
||||
// is too small, there will be many direct table collisions.
|
||||
// - The uper limit (approx. labelMax/4) must be a power of two,
|
||||
// - The upper limit (approx. labelMax/4) must be a power of two,
|
||||
// need not be extremely large for hashing.
|
||||
|
||||
uLabel powerOfTwo = 8; // lower-limit
|
||||
|
||||
const uLabel size = requested_size;
|
||||
if (size < powerOfTwo)
|
||||
if (size <= powerOfTwo)
|
||||
{
|
||||
return powerOfTwo;
|
||||
}
|
||||
else if (requested_size >= maxTableSize)
|
||||
{
|
||||
return maxTableSize;
|
||||
}
|
||||
else if (size & (size-1)) // <- Modulus of i^2
|
||||
{
|
||||
// Determine power-of-two. Brute-force is fast enough.
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,7 +27,99 @@ License
|
||||
#include "Time.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IOList.H"
|
||||
#include "stringListOps.H"
|
||||
#include "predicates.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Functions * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Templated implementation for lookup() - file-scope
|
||||
template<class UnaryMatchPredicate>
|
||||
static IOobjectList lookupImpl
|
||||
(
|
||||
const IOobjectList& list,
|
||||
const UnaryMatchPredicate& matcher
|
||||
)
|
||||
{
|
||||
IOobjectList results(list.size());
|
||||
|
||||
forAllConstIters(list, iter)
|
||||
{
|
||||
if (matcher(iter.key()))
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
InfoInFunction << "Found " << iter.key() << endl;
|
||||
}
|
||||
|
||||
results.insert
|
||||
(
|
||||
iter.key(),
|
||||
new IOobject(*(iter.object()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
// Templated implementation for classes() - file-scope
|
||||
template<class UnaryMatchPredicate>
|
||||
static HashTable<wordHashSet> classesImpl
|
||||
(
|
||||
const IOobjectList& list,
|
||||
const UnaryMatchPredicate& matcher
|
||||
)
|
||||
{
|
||||
HashTable<wordHashSet> summary(2*list.size());
|
||||
|
||||
// Summary (key,val) = (class-name, object-names)
|
||||
forAllConstIters(list, iter)
|
||||
{
|
||||
if (matcher(iter.key()))
|
||||
{
|
||||
// Create entry (if needed) and insert
|
||||
summary(iter.object()->headerClassName()).insert(iter.key());
|
||||
}
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
|
||||
// Templated implementation for names(), sortedNames() - file-scope
|
||||
template<class UnaryMatchPredicate>
|
||||
static wordList namesImpl
|
||||
(
|
||||
const IOobjectList& list,
|
||||
const word& clsName,
|
||||
const UnaryMatchPredicate& matcher,
|
||||
const bool doSort
|
||||
)
|
||||
{
|
||||
wordList objNames(list.size());
|
||||
|
||||
label count = 0;
|
||||
forAllConstIters(list, iter)
|
||||
{
|
||||
if (iter()->headerClassName() == clsName && matcher(iter.key()))
|
||||
{
|
||||
objNames[count++] = iter.key();
|
||||
}
|
||||
}
|
||||
|
||||
objNames.setSize(count);
|
||||
|
||||
if (doSort)
|
||||
{
|
||||
Foam::sort(objNames);
|
||||
}
|
||||
|
||||
return objNames;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -62,14 +154,14 @@ Foam::IOobjectList::IOobjectList
|
||||
}
|
||||
|
||||
// Create a list of file names in this directory
|
||||
fileNameList ObjectNames =
|
||||
fileNameList objNames =
|
||||
readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
|
||||
|
||||
forAll(ObjectNames, i)
|
||||
forAll(objNames, i)
|
||||
{
|
||||
IOobject* objectPtr = new IOobject
|
||||
(
|
||||
ObjectNames[i],
|
||||
objNames[i],
|
||||
newInstance,
|
||||
local,
|
||||
db,
|
||||
@ -81,7 +173,7 @@ Foam::IOobjectList::IOobjectList
|
||||
// Use object with local scope
|
||||
if (objectPtr->typeHeaderOk<IOList<label>>(false))
|
||||
{
|
||||
insert(ObjectNames[i], objectPtr);
|
||||
insert(objectPtr->name(), objectPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -119,7 +211,7 @@ bool Foam::IOobjectList::remove(IOobject& io)
|
||||
|
||||
Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
|
||||
{
|
||||
HashPtrTable<IOobject>::const_iterator iter = find(name);
|
||||
const_iterator iter = find(name);
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
@ -144,53 +236,13 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
|
||||
|
||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordRe& matcher) const
|
||||
{
|
||||
IOobjectList results(size());
|
||||
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (matcher.match(iter.key()))
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
InfoInFunction << "Found " << iter.key() << endl;
|
||||
}
|
||||
|
||||
results.insert
|
||||
(
|
||||
iter.key(),
|
||||
new IOobject(*(iter.object()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
return lookupImpl(*this, matcher);
|
||||
}
|
||||
|
||||
|
||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordReList& matcher) const
|
||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordRes& matcher) const
|
||||
{
|
||||
wordReListMatcher mat(matcher);
|
||||
|
||||
IOobjectList results(size());
|
||||
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (mat.match(iter.key()))
|
||||
{
|
||||
if (IOobject::debug)
|
||||
{
|
||||
InfoInFunction << "Found " << iter.key() << endl;
|
||||
}
|
||||
|
||||
results.insert
|
||||
(
|
||||
iter.key(),
|
||||
new IOobject(*(iter.object()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
return lookupImpl(*this, matcher);
|
||||
}
|
||||
|
||||
|
||||
@ -219,6 +271,26 @@ Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& clsName) const
|
||||
}
|
||||
|
||||
|
||||
Foam::HashTable<Foam::wordHashSet> Foam::IOobjectList::classes() const
|
||||
{
|
||||
return classesImpl(*this, predicates::always());
|
||||
}
|
||||
|
||||
|
||||
Foam::HashTable<Foam::wordHashSet>
|
||||
Foam::IOobjectList::classes(const wordRe& matcher) const
|
||||
{
|
||||
return classesImpl(*this, matcher);
|
||||
}
|
||||
|
||||
|
||||
Foam::HashTable<Foam::wordHashSet>
|
||||
Foam::IOobjectList::classes(const wordRes& matcher) const
|
||||
{
|
||||
return classesImpl(*this, matcher);
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::names() const
|
||||
{
|
||||
return HashPtrTable<IOobject>::toc();
|
||||
@ -236,20 +308,7 @@ Foam::wordList Foam::IOobjectList::names
|
||||
const word& clsName
|
||||
) const
|
||||
{
|
||||
wordList objNames(size());
|
||||
|
||||
label count = 0;
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (iter()->headerClassName() == clsName)
|
||||
{
|
||||
objNames[count++] = iter.key();
|
||||
}
|
||||
}
|
||||
|
||||
objNames.setSize(count);
|
||||
|
||||
return objNames;
|
||||
return namesImpl(*this, clsName, predicates::always(), false);
|
||||
}
|
||||
|
||||
|
||||
@ -259,21 +318,17 @@ Foam::wordList Foam::IOobjectList::names
|
||||
const wordRe& matcher
|
||||
) const
|
||||
{
|
||||
wordList objNames = names(clsName);
|
||||
|
||||
return wordList(objNames, findStrings(matcher, objNames));
|
||||
return namesImpl(*this, clsName, matcher, false);
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::names
|
||||
(
|
||||
const word& clsName,
|
||||
const wordReList& matcher
|
||||
const wordRes& matcher
|
||||
) const
|
||||
{
|
||||
wordList objNames = names(clsName);
|
||||
|
||||
return wordList(objNames, findStrings(matcher, objNames));
|
||||
return namesImpl(*this, clsName, matcher, false);
|
||||
}
|
||||
|
||||
|
||||
@ -282,10 +337,7 @@ Foam::wordList Foam::IOobjectList::sortedNames
|
||||
const word& clsName
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(clsName);
|
||||
sort(sortedLst);
|
||||
|
||||
return sortedLst;
|
||||
return namesImpl(*this, clsName, predicates::always(), true);
|
||||
}
|
||||
|
||||
|
||||
@ -295,23 +347,35 @@ Foam::wordList Foam::IOobjectList::sortedNames
|
||||
const wordRe& matcher
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(clsName, matcher);
|
||||
sort(sortedLst);
|
||||
|
||||
return sortedLst;
|
||||
return namesImpl(*this, clsName, matcher, true);
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::sortedNames
|
||||
(
|
||||
const word& clsName,
|
||||
const wordReList& matcher
|
||||
const wordRes& matcher
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(clsName, matcher);
|
||||
sort(sortedLst);
|
||||
return namesImpl(*this, clsName, matcher, true);
|
||||
}
|
||||
|
||||
return sortedLst;
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const IOobjectList& list)
|
||||
{
|
||||
os << nl << list.size() << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
forAllConstIters(list, it)
|
||||
{
|
||||
os << it.key() << token::SPACE << it.object()->headerClassName() << nl;
|
||||
}
|
||||
|
||||
os << token::END_LIST;
|
||||
os.check(FUNCTION_NAME);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,14 +36,20 @@ SourceFiles
|
||||
#define IOobjectList_H
|
||||
|
||||
#include "HashPtrTable.H"
|
||||
#include "HashSet.H"
|
||||
#include "IOobject.H"
|
||||
#include "wordReList.H"
|
||||
#include "wordRes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
class IOobjectList;
|
||||
Ostream& operator<<(Ostream& os, const IOobjectList& list);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IOobjectList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -86,12 +92,17 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
// Basic methods
|
||||
|
||||
//- Add an IOobject to the list
|
||||
bool add(IOobject& io);
|
||||
|
||||
//- Remove an IOobject from the list
|
||||
bool remove(IOobject& io);
|
||||
|
||||
|
||||
// Lookup
|
||||
|
||||
//- Lookup a given name and return IOobject ptr if found else nullptr
|
||||
IOobject* lookup(const word& name) const;
|
||||
|
||||
@ -99,12 +110,94 @@ public:
|
||||
IOobjectList lookup(const wordRe& matcher) const;
|
||||
|
||||
//- The list of all IOobjects with matching names
|
||||
IOobjectList lookup(const wordReList& matcher) const;
|
||||
IOobjectList lookup(const wordRes& matcher) const;
|
||||
|
||||
//- The list of all IOobjects with the given class name
|
||||
IOobjectList lookupClass(const word& clsName) const;
|
||||
|
||||
|
||||
// Summary of classes
|
||||
|
||||
//- A summary hash of classes used and their associated object names.
|
||||
// The HashTable representation allows us to leverage various
|
||||
// HashTable methods.
|
||||
// This hashed summary view can be useful when querying particular
|
||||
// aspects. For example,
|
||||
//
|
||||
// \code
|
||||
// IOobjectList objects(runTime, runTime.timeName());
|
||||
// HashTable<wordHashSet> classes = objects.classes();
|
||||
//
|
||||
// // How many volScalarField?
|
||||
// word checkType = volScalarField::typeName;
|
||||
//
|
||||
// Info<< checkType << "="
|
||||
// << (classes.found(checkType) ? classes[checkType].size() : 0)
|
||||
// << nl;
|
||||
// \endcode
|
||||
// Using the two-parameter HashTable::lookup method lets us avoid
|
||||
// the \c '?' ternary, but still looks fairly ugly:
|
||||
// \code
|
||||
// Info<< checkType << "="
|
||||
// << classes.lookup(checkType, wordHashSet()).size() << nl;
|
||||
// \endcode
|
||||
//
|
||||
// If we have non-const access to the hash table, and don't mind
|
||||
// incidentally creating empty entries,
|
||||
// we can use the HashTable::operator() directly:
|
||||
// \code
|
||||
// Info<< checkType << "=" << classes(checkType).size() << nl;
|
||||
// \endcode
|
||||
//
|
||||
// Of course, for a single query it would have been easier
|
||||
// and simpler to have used a direct query of the names:
|
||||
// \code
|
||||
// Info<< checkType << "=" << objects.names(checkType).size() << nl;
|
||||
// \endcode
|
||||
//
|
||||
// The summary hash, however, becomes most useful when reducing
|
||||
// the objects in consideration to a particular subset. For example,
|
||||
// \code
|
||||
// const wordHashSet interestingTypes
|
||||
// {
|
||||
// volScalarField::typeName,
|
||||
// volVectorField::typeName
|
||||
// };
|
||||
//
|
||||
// classes.retain(interestingTypes);
|
||||
// \endcode
|
||||
// Or do just the opposite:
|
||||
// \code
|
||||
// classes.erase(unsupportedTypes);
|
||||
// \endcode
|
||||
// This also works with a hashedWordList, since it provides the
|
||||
// expected '()' operator. But in this case the more general
|
||||
// HashTable::filterKeys is required:
|
||||
// \code
|
||||
// const hashedWordList interestingTypes
|
||||
// {
|
||||
// volScalarField::typeName,
|
||||
// volVectorField::typeName
|
||||
// };
|
||||
//
|
||||
// classes.filterKeys(interestingTypes);
|
||||
// \endcode
|
||||
//
|
||||
// Of course, there are many other ways to use and manipulate the
|
||||
// summary information.
|
||||
HashTable<wordHashSet> classes() const;
|
||||
|
||||
//- A summary hash of classes used and their associated object names
|
||||
// restricted to objects with names that satisfy the input matcher
|
||||
HashTable<wordHashSet> classes(const wordRe& matcher) const;
|
||||
|
||||
//- A summary hash of classes used and their associated object names
|
||||
// restricted to objects with names that satisfy the input matcher
|
||||
HashTable<wordHashSet> classes(const wordRes& matcher) const;
|
||||
|
||||
|
||||
// Summary of names
|
||||
|
||||
//- A list of names of the IOobjects
|
||||
wordList names() const;
|
||||
|
||||
@ -117,9 +210,11 @@ public:
|
||||
|
||||
//- The names of IOobjects with the given class name that also
|
||||
// have a name satisfying the input matcher
|
||||
wordList names(const word& clsName, const wordReList& matcher) const;
|
||||
wordList names(const word& clsName, const wordRes& matcher) const;
|
||||
|
||||
|
||||
// Summary of names (sorted)
|
||||
|
||||
//- A sorted list of names of the IOobjects
|
||||
wordList sortedNames() const;
|
||||
|
||||
@ -132,11 +227,12 @@ public:
|
||||
|
||||
//- The sorted names of IOobjects with the given class name that also
|
||||
// have a name satisfying the input matcher
|
||||
wordList sortedNames
|
||||
(
|
||||
const word& clsName,
|
||||
const wordReList& matcher
|
||||
) const;
|
||||
wordList sortedNames(const word& clsName, const wordRes& matcher) const;
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const IOobjectList& list);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user