MRG: resolved merge conflicts from merge from develop branch

This commit is contained in:
Andrew Heather
2017-05-19 16:29:54 +01:00
308 changed files with 2914 additions and 1667 deletions

View File

@ -43,7 +43,7 @@ Foam::autoPtr<Foam::PDRDragModel> Foam::PDRDragModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType); dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown PDRDragModel type " << "Unknown PDRDragModel type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::XiEqModel> Foam::XiEqModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType); dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown XiEqModel type " << "Unknown XiEqModel type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::XiGModel> Foam::XiGModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType); dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown XiGModel type " << "Unknown XiGModel type "

View File

@ -45,7 +45,7 @@ Foam::autoPtr<Foam::XiModel> Foam::XiModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType); dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown XiModel type " << "Unknown XiModel type "

View File

@ -44,7 +44,7 @@ Foam::autoPtr<Foam::mixtureViscosityModel> Foam::mixtureViscosityModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType); dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown mixtureViscosityModel type " << "Unknown mixtureViscosityModel type "

View File

@ -111,7 +111,7 @@ Foam::autoPtr<Foam::relativeVelocityModel> Foam::relativeVelocityModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType); dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown time scale model type " << modelType << "Unknown time scale model type " << modelType

View File

@ -63,7 +63,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New
componentsConstructorTablePtr_ componentsConstructorTablePtr_
->find(temperaturePhaseChangeTwoPhaseMixtureTypeName); ->find(temperaturePhaseChangeTwoPhaseMixtureTypeName);
if (cstrIter == componentsConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown temperaturePhaseChangeTwoPhaseMixture type " << "Unknown temperaturePhaseChangeTwoPhaseMixture type "

View File

@ -60,7 +60,7 @@ Foam::phaseChangeTwoPhaseMixture::New
componentsConstructorTablePtr_ componentsConstructorTablePtr_
->find(phaseChangeTwoPhaseMixtureTypeName); ->find(phaseChangeTwoPhaseMixtureTypeName);
if (cstrIter == componentsConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown phaseChangeTwoPhaseMixture type " << "Unknown phaseChangeTwoPhaseMixture type "

View File

@ -44,7 +44,7 @@ Foam::autoPtr<Foam::dragModel> Foam::dragModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(dragModelType); dictionaryConstructorTablePtr_->find(dragModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown dragModelType type " << "Unknown dragModelType type "

View File

@ -48,7 +48,7 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(heatTransferModelType); dictionaryConstructorTablePtr_->find(heatTransferModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown heatTransferModelType type " << "Unknown heatTransferModelType type "

View File

@ -46,7 +46,7 @@ Foam::autoPtr<Foam::diameterModel> Foam::diameterModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(diameterModelType); dictionaryConstructorTablePtr_->find(diameterModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown diameterModelType type " << "Unknown diameterModelType type "

View File

@ -52,7 +52,7 @@ Foam::interfaceCompositionModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(interfaceCompositionModelType); dictionaryConstructorTablePtr_->find(interfaceCompositionModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown interfaceCompositionModelType type " << "Unknown interfaceCompositionModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::massTransferModel> Foam::massTransferModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(massTransferModelType); dictionaryConstructorTablePtr_->find(massTransferModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown massTransferModelType type " << "Unknown massTransferModelType type "

View File

@ -40,7 +40,7 @@ Foam::autoPtr<Foam::saturationModel> Foam::saturationModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(saturationModelType); dictionaryConstructorTablePtr_->find(saturationModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown saturationModelType type " << "Unknown saturationModelType type "

View File

@ -43,7 +43,7 @@ Foam::surfaceTensionModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(surfaceTensionModelType); dictionaryConstructorTablePtr_->find(surfaceTensionModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown surfaceTensionModelType type " << "Unknown surfaceTensionModelType type "

View File

@ -43,7 +43,7 @@ Foam::aspectRatioModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(aspectRatioModelType); dictionaryConstructorTablePtr_->find(aspectRatioModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown aspectRatioModelType type " << "Unknown aspectRatioModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::dragModel> Foam::dragModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(dragModelType); dictionaryConstructorTablePtr_->find(dragModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown dragModelType type " << "Unknown dragModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(heatTransferModelType); dictionaryConstructorTablePtr_->find(heatTransferModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown heatTransferModelType type " << "Unknown heatTransferModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::liftModel> Foam::liftModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(liftModelType); dictionaryConstructorTablePtr_->find(liftModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown liftModelType type " << "Unknown liftModelType type "

View File

@ -43,7 +43,7 @@ Foam::swarmCorrection::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(swarmCorrectionType); dictionaryConstructorTablePtr_->find(swarmCorrectionType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown swarmCorrectionType type " << "Unknown swarmCorrectionType type "

View File

@ -43,7 +43,7 @@ Foam::turbulentDispersionModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(turbulentDispersionModelType); dictionaryConstructorTablePtr_->find(turbulentDispersionModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown turbulentDispersionModelType type " << "Unknown turbulentDispersionModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::virtualMassModel> Foam::virtualMassModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(virtualMassModelType); dictionaryConstructorTablePtr_->find(virtualMassModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown virtualMassModelType type " << "Unknown virtualMassModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::wallDampingModel> Foam::wallDampingModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(wallDampingModelType); dictionaryConstructorTablePtr_->find(wallDampingModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown wallDampingModelType type " << "Unknown wallDampingModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::wallLubricationModel> Foam::wallLubricationModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(wallLubricationModelType); dictionaryConstructorTablePtr_->find(wallLubricationModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown wallLubricationModelType type " << "Unknown wallLubricationModelType type "

View File

@ -41,7 +41,7 @@ Foam::autoPtr<Foam::blendingMethod> Foam::blendingMethod::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(blendingMethodType); dictionaryConstructorTablePtr_->find(blendingMethodType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown blendingMethodType type " << "Unknown blendingMethodType type "

View File

@ -46,7 +46,7 @@ Foam::autoPtr<Foam::diameterModel> Foam::diameterModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(diameterModelType); dictionaryConstructorTablePtr_->find(diameterModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown diameterModelType type " << "Unknown diameterModelType type "

View File

@ -43,7 +43,7 @@ Foam::autoPtr<Foam::phaseModel> Foam::phaseModel::New
phaseSystemConstructorTable::iterator cstrIter = phaseSystemConstructorTable::iterator cstrIter =
phaseSystemConstructorTablePtr_->find(phaseModelType); phaseSystemConstructorTablePtr_->find(phaseModelType);
if (cstrIter == phaseSystemConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown phaseModelType type " << "Unknown phaseModelType type "

View File

@ -54,7 +54,7 @@ Foam::autoPtr<Foam::multiphaseSystem> Foam::multiphaseSystem::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(multiphaseSystemType); dictionaryConstructorTablePtr_->find(multiphaseSystemType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown multiphaseSystemType type " << "Unknown multiphaseSystemType type "

View File

@ -41,7 +41,7 @@ Foam::wallBoilingModels::departureDiameterModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(departureDiameterModelType); dictionaryConstructorTablePtr_->find(departureDiameterModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown departureDiameterModelType type " << "Unknown departureDiameterModelType type "

View File

@ -41,7 +41,7 @@ Foam::wallBoilingModels::departureFrequencyModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(departureFrequencyModelType); dictionaryConstructorTablePtr_->find(departureFrequencyModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown departureFrequencyModelType type " << "Unknown departureFrequencyModelType type "

View File

@ -41,7 +41,7 @@ Foam::wallBoilingModels::nucleationSiteModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(nucleationSiteModelType); dictionaryConstructorTablePtr_->find(nucleationSiteModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown nucleationSiteModelType type " << "Unknown nucleationSiteModelType type "

View File

@ -41,7 +41,7 @@ Foam::wallBoilingModels::partitioningModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(partitioningModelType); dictionaryConstructorTablePtr_->find(partitioningModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown partitioningModelType type " << "Unknown partitioningModelType type "

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::conductivityModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(conductivityModelType); dictionaryConstructorTablePtr_->find(conductivityModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "conductivityModel::New(const dictionary&) : " << endl << "conductivityModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::frictionalStressModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(frictionalStressModelType); dictionaryConstructorTablePtr_->find(frictionalStressModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "frictionalStressModel::New(const dictionary&) : " << endl << "frictionalStressModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::granularPressureModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(granularPressureModelType); dictionaryConstructorTablePtr_->find(granularPressureModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "granularPressureModel::New(const dictionary&) : " << endl << "granularPressureModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::radialModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(radialModelType); dictionaryConstructorTablePtr_->find(radialModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "radialModel::New(const dictionary&) : " << endl << "radialModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::viscosityModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(viscosityModelType); dictionaryConstructorTablePtr_->find(viscosityModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "viscosityModel::New(const dictionary&) : " << endl << "viscosityModel::New(const dictionary&) : " << endl

View File

@ -53,7 +53,7 @@ Foam::diameterModels::IATEsource::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(type); dictionaryConstructorTablePtr_->find(type);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown IATE source type " << "Unknown IATE source type "

View File

@ -54,7 +54,7 @@ Foam::autoPtr<Foam::twoPhaseSystem> Foam::twoPhaseSystem::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(twoPhaseSystemType); dictionaryConstructorTablePtr_->find(twoPhaseSystemType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown twoPhaseSystemType type " << "Unknown twoPhaseSystemType type "

View File

@ -43,7 +43,7 @@ Foam::aspectRatioModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(aspectRatioModelType); dictionaryConstructorTablePtr_->find(aspectRatioModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown aspectRatioModelType type " << "Unknown aspectRatioModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::dragModel> Foam::dragModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(dragModelType); dictionaryConstructorTablePtr_->find(dragModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown dragModelType type " << "Unknown dragModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::heatTransferModel> Foam::heatTransferModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(heatTransferModelType); dictionaryConstructorTablePtr_->find(heatTransferModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown heatTransferModelType type " << "Unknown heatTransferModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::liftModel> Foam::liftModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(liftModelType); dictionaryConstructorTablePtr_->find(liftModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown liftModelType type " << "Unknown liftModelType type "

View File

@ -43,7 +43,7 @@ Foam::swarmCorrection::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(swarmCorrectionType); dictionaryConstructorTablePtr_->find(swarmCorrectionType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown swarmCorrectionType type " << "Unknown swarmCorrectionType type "

View File

@ -43,7 +43,7 @@ Foam::turbulentDispersionModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(turbulentDispersionModelType); dictionaryConstructorTablePtr_->find(turbulentDispersionModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown turbulentDispersionModelType type " << "Unknown turbulentDispersionModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::virtualMassModel> Foam::virtualMassModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(virtualMassModelType); dictionaryConstructorTablePtr_->find(virtualMassModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown virtualMassModelType type " << "Unknown virtualMassModelType type "

View File

@ -42,7 +42,7 @@ Foam::autoPtr<Foam::wallLubricationModel> Foam::wallLubricationModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(wallLubricationModelType); dictionaryConstructorTablePtr_->find(wallLubricationModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown wallLubricationModelType type " << "Unknown wallLubricationModelType type "

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::conductivityModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(conductivityModelType); dictionaryConstructorTablePtr_->find(conductivityModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "conductivityModel::New(const dictionary&) : " << endl << "conductivityModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::frictionalStressModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(frictionalStressModelType); dictionaryConstructorTablePtr_->find(frictionalStressModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "frictionalStressModel::New(const dictionary&) : " << endl << "frictionalStressModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::granularPressureModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(granularPressureModelType); dictionaryConstructorTablePtr_->find(granularPressureModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "granularPressureModel::New(const dictionary&) : " << endl << "granularPressureModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::radialModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(radialModelType); dictionaryConstructorTablePtr_->find(radialModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "radialModel::New(const dictionary&) : " << endl << "radialModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::kineticTheoryModels::viscosityModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(viscosityModelType); dictionaryConstructorTablePtr_->find(viscosityModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalError FatalError
<< "viscosityModel::New(const dictionary&) : " << endl << "viscosityModel::New(const dictionary&) : " << endl

View File

@ -41,7 +41,7 @@ Foam::autoPtr<Foam::blendingMethod> Foam::blendingMethod::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(blendingMethodType); dictionaryConstructorTablePtr_->find(blendingMethodType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown blendingMethodType type " << "Unknown blendingMethodType type "

View File

@ -54,7 +54,7 @@ Foam::diameterModels::IATEsource::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(type); dictionaryConstructorTablePtr_->find(type);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown IATE source type " << "Unknown IATE source type "

View File

@ -46,7 +46,7 @@ Foam::autoPtr<Foam::diameterModel> Foam::diameterModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(diameterModelType); dictionaryConstructorTablePtr_->find(diameterModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown diameterModelType type " << "Unknown diameterModelType type "

View File

@ -234,6 +234,97 @@ int main()
Info<<"\ntable1: " << table1 << endl; 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"; Info<< "\nDone\n";
return 0; return 0;

View File

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

View File

@ -0,0 +1,3 @@
EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = -lfiniteVolume

View 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;
}
// ************************************************************************* //

View File

@ -180,9 +180,9 @@ int main(int argc, char *argv[])
// A regex with a zero length matcher doesn't work at all: // A regex with a zero length matcher doesn't work at all:
// eg "(png|jpg|txt|)" regex matcher itself // eg "(png|jpg|txt|)" regex matcher itself
wordRe matcher0("()", wordRe::REGEXP); wordRe matcher0("()", wordRe::REGEX);
wordRe matcher1("(png|jpg|txt)", wordRe::REGEXP); wordRe matcher1("(png|jpg|txt)", wordRe::REGEX);
wordRe matcher2("(png|txt)", wordRe::REGEXP); wordRe matcher2("(png|txt)", wordRe::REGEX);
Info<<"Has extension(s):" << nl Info<<"Has extension(s):" << nl
<< "input: " << endWithDot << nl; << "input: " << endWithDot << nl;

View File

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

View File

@ -0,0 +1 @@
/**/

View 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;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,7 +30,10 @@ Description
#include "IFstream.H" #include "IFstream.H"
#include "List.H" #include "List.H"
#include "Tuple2.H" #include "Tuple2.H"
#include "keyType.H"
#include "wordRe.H" #include "wordRe.H"
#include "wordRes.H"
#include "predicates.H"
using namespace Foam; using namespace Foam;
@ -44,12 +47,37 @@ int main(int argc, char *argv[])
Foam::string s2("this .* file"); Foam::string s2("this .* file");
const char * s3 = "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(s1, wordRe::DETECT).info(Info) << endl;
wordRe(s2).info(Info) << endl; wordRe(s2).info(Info) << endl;
wordRe(s2, wordRe::DETECT).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"; wre = "this .* file";
Info<<"substring: " << wre(4) << endl;
wre.info(Info) << endl; wre.info(Info) << endl;
wre = s1; wre = s1;
wre.info(Info) << endl; wre.info(Info) << endl;

View File

@ -90,7 +90,7 @@ Foam::cellSizeAndAlignmentControl::New
cellSizeAndAlignmentControlTypeName cellSizeAndAlignmentControlTypeName
); );
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown cellSizeAndAlignmentControl type " << "Unknown cellSizeAndAlignmentControl type "

View File

@ -133,7 +133,7 @@ Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(cellSizeFunctionTypeName); dictionaryConstructorTablePtr_->find(cellSizeFunctionTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown cellSizeFunction type " << "Unknown cellSizeFunction type "

View File

@ -71,7 +71,7 @@ Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(cellSizeCalculationTypeTypeName); dictionaryConstructorTablePtr_->find(cellSizeCalculationTypeTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown cellSizeCalculationType type " << "Unknown cellSizeCalculationType type "

View File

@ -75,7 +75,7 @@ Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(surfaceCellSizeFunctionTypeName); dictionaryConstructorTablePtr_->find(surfaceCellSizeFunctionTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown surfaceCellSizeFunction type " << "Unknown surfaceCellSizeFunction type "

View File

@ -68,7 +68,7 @@ autoPtr<faceAreaWeightModel> faceAreaWeightModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(faceAreaWeightModelTypeName); dictionaryConstructorTablePtr_->find(faceAreaWeightModelTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown faceAreaWeightModel type " << "Unknown faceAreaWeightModel type "

View File

@ -94,7 +94,7 @@ autoPtr<initialPointsMethod> initialPointsMethod::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(initialPointsMethodTypeName); dictionaryConstructorTablePtr_->find(initialPointsMethodTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown initialPointsMethod type " << "Unknown initialPointsMethod type "

View File

@ -71,7 +71,7 @@ autoPtr<relaxationModel> relaxationModel::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(relaxationModelTypeName); dictionaryConstructorTablePtr_->find(relaxationModelTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown relaxationModel type " << "Unknown relaxationModel type "

View File

@ -48,7 +48,7 @@ Foam::searchableSurfaceFeatures::New
dictConstructorTable::iterator cstrIter = dictConstructorTable::iterator cstrIter =
dictConstructorTablePtr_->find(searchableSurfaceFeaturesType); dictConstructorTablePtr_->find(searchableSurfaceFeaturesType);
if (cstrIter == dictConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown searchableSurfaceFeatures type " << "Unknown searchableSurfaceFeatures type "

View File

@ -71,7 +71,7 @@ Foam::autoPtr<Foam::faceSelection> Foam::faceSelection::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(sampleType); dictionaryConstructorTablePtr_->find(sampleType);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown faceSelection type " << "Unknown faceSelection type "

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -112,7 +112,7 @@ labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs)
{ {
WarningInFunction WarningInFunction
<< "Did not visit some faces, e.g. face " << faceI << "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" << "Using patch " << patchIDs[0] << " as nearest"
<< endl; << endl;
haveWarned = true; 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 fvMeshSubset& subsetter,
const wordList& fieldNames, HashTable<wordHashSet>& availableFields,
PtrList<GeometricField<Type, fvPatchField, volMesh>>& subFields 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(); const fvMesh& baseMesh = subsetter.baseMesh();
if (fieldNames.empty())
{
return;
}
Info<< "Subsetting " << fieldType << " (";
forAll(fieldNames, i) forAll(fieldNames, i)
{ {
const word& fieldName = fieldNames[i]; const word& fieldName = fieldNames[i];
if (i) Info<< ' ';
Info<< fieldName;
Info<< "Subsetting field " << fieldName << endl; FieldType fld
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
( (
IOobject IOobject
( (
@ -193,7 +174,11 @@ void subsetSurfaceFields
); );
subFields.set(i, subsetter.interpolate(fld)); 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 fvMeshSubset& subsetter,
const pointMesh& pMesh, const pointMesh& pMesh,
const wordList& fieldNames, HashTable<wordHashSet>& availableFields,
PtrList<GeometricField<Type, pointPatchField, pointMesh>>& subFields 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(); const fvMesh& baseMesh = subsetter.baseMesh();
if (fieldNames.empty())
{
return;
}
Info<< "Subsetting " << fieldType << " (";
forAll(fieldNames, i) forAll(fieldNames, i)
{ {
const word& fieldName = fieldNames[i]; const word& fieldName = fieldNames[i];
if (i) Info<< ' ';
Info<< fieldName;
Info<< "Subsetting field " << fieldName << endl; FieldType fld
GeometricField<Type, pointPatchField, pointMesh> fld
( (
IOobject IOobject
( (
@ -228,7 +224,11 @@ void subsetPointFields
); );
subFields.set(i, subsetter.interpolate(fld)); 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 void subsetDimensionedFields
( (
const fvMeshSubset& subsetter, const fvMeshSubset& subsetter,
const wordList& fieldNames, HashTable<wordHashSet>& availableFields,
PtrList<DimensionedField<Type, volMesh>>& subFields 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(); const fvMesh& baseMesh = subsetter.baseMesh();
if (fieldNames.empty())
{
return;
}
Info<< "Subsetting " << fieldType << " (";
forAll(fieldNames, i) forAll(fieldNames, i)
{ {
const word& fieldName = fieldNames[i]; const word& fieldName = fieldNames[i];
if (i) Info<< ' ';
Info<< fieldName;
Info<< "Subsetting field " << fieldName << endl; FieldType fld
DimensionedField<Type, volMesh> fld
( (
IOobject IOobject
( (
@ -262,7 +273,11 @@ void subsetDimensionedFields
); );
subFields.set(i, subsetter.interpolate(fld)); 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 // Map the data
PackedBoolList isSet(set.maxSize(mesh)); PackedBoolList isSet(set.maxSize(mesh));
forAllConstIter(labelHashSet, set, iter) forAllConstIters(set, iter)
{ {
isSet[iter.key()] = true; isSet[iter.key()] = true;
} }
@ -359,7 +374,6 @@ int main(int argc, char *argv[])
#include "createNamedMesh.H" #include "createNamedMesh.H"
const word setName = args[1]; const word setName = args[1];
word meshInstance = mesh.pointsInstance(); 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 // Create mesh subsetting engine
fvMeshSubset subsetter(mesh); fvMeshSubset subsetter(mesh);
@ -389,11 +403,7 @@ int main(int argc, char *argv[])
{ {
const word patchName = args["patch"]; const word patchName = args["patch"];
exposedPatchIDs = labelList exposedPatchIDs = { mesh.boundaryMesh().findPatchID(patchName) };
(
1,
mesh.boundaryMesh().findPatchID(patchName)
);
if (exposedPatchIDs[0] == -1) if (exposedPatchIDs[0] == -1)
{ {
@ -402,8 +412,8 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
Info<< "Adding exposed internal faces to patch " << patchName << endl Info<< "Adding exposed internal faces to patch " << patchName
<< endl; << nl << endl;
} }
else if (args.optionFound("patches")) else if (args.optionFound("patches"))
{ {
@ -412,14 +422,14 @@ int main(int argc, char *argv[])
exposedPatchIDs = mesh.boundaryMesh().patchSet(patchNames).sortedToc(); exposedPatchIDs = mesh.boundaryMesh().patchSet(patchNames).sortedToc();
Info<< "Adding exposed internal faces to nearest of patches " Info<< "Adding exposed internal faces to nearest of patches "
<< patchNames << endl << endl; << patchNames << nl << endl;
} }
else else
{ {
Info<< "Adding exposed internal faces to a patch called" Info<< "Adding exposed internal faces to a patch called"
<< " \"oldInternalFaces\" (created if necessary)" << endl << " \"oldInternalFaces\" (created if necessary)" << endl
<< endl; << endl;
exposedPatchIDs = labelList(1, label(-1)); exposedPatchIDs = { -1 };
} }
@ -431,7 +441,6 @@ int main(int argc, char *argv[])
} }
else else
{ {
// Find per face the nearest patch // Find per face the nearest patch
labelList nearestExposedPatch(nearestPatch(mesh, exposedPatchIDs)); labelList nearestExposedPatch(nearestPatch(mesh, exposedPatchIDs));
@ -454,77 +463,45 @@ int main(int argc, char *argv[])
IOobjectList objects(mesh, runTime.timeName()); IOobjectList objects(mesh, runTime.timeName());
HashTable<wordHashSet> availableFields = objects.classes();
// Read vol fields and subset // Read vol fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~
wordList scalarNames(objects.names(volScalarField::typeName)); PtrList<volScalarField> scalarFlds;
PtrList<volScalarField> scalarFlds(scalarNames.size()); subsetFields(subsetter, availableFields, scalarFlds);
subsetVolFields(subsetter, scalarNames, scalarFlds);
wordList vectorNames(objects.names(volVectorField::typeName)); PtrList<volVectorField> vectorFlds;
PtrList<volVectorField> vectorFlds(vectorNames.size()); subsetFields(subsetter, availableFields, vectorFlds);
subsetVolFields(subsetter, vectorNames, vectorFlds);
wordList sphericalTensorNames PtrList<volSphericalTensorField> sphTensorFlds;
( subsetFields(subsetter, availableFields, sphTensorFlds);
objects.names(volSphericalTensorField::typeName)
);
PtrList<volSphericalTensorField> sphericalTensorFlds
(
sphericalTensorNames.size()
);
subsetVolFields(subsetter, sphericalTensorNames, sphericalTensorFlds);
wordList symmTensorNames(objects.names(volSymmTensorField::typeName)); PtrList<volSymmTensorField> symmTensorFlds;
PtrList<volSymmTensorField> symmTensorFlds(symmTensorNames.size()); subsetFields(subsetter, availableFields, symmTensorFlds);
subsetVolFields(subsetter, symmTensorNames, symmTensorFlds);
wordList tensorNames(objects.names(volTensorField::typeName)); PtrList<volTensorField> tensorFlds;
PtrList<volTensorField> tensorFlds(tensorNames.size()); subsetFields(subsetter, availableFields, tensorFlds);
subsetVolFields(subsetter, tensorNames, tensorFlds);
// Read surface fields and subset // Read surface fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wordList surfScalarNames(objects.names(surfaceScalarField::typeName)); PtrList<surfaceScalarField> surfScalarFlds;
PtrList<surfaceScalarField> surfScalarFlds(surfScalarNames.size()); subsetFields(subsetter, availableFields, surfScalarFlds);
subsetSurfaceFields(subsetter, surfScalarNames, surfScalarFlds);
wordList surfVectorNames(objects.names(surfaceVectorField::typeName)); PtrList<surfaceVectorField> surfVectorFlds;
PtrList<surfaceVectorField> surfVectorFlds(surfVectorNames.size()); subsetFields(subsetter, availableFields, surfVectorFlds);
subsetSurfaceFields(subsetter, surfVectorNames, surfVectorFlds);
wordList surfSphericalTensorNames PtrList<surfaceSphericalTensorField> surfSphTensorFlds;
( subsetFields(subsetter, availableFields, surfSphTensorFlds);
objects.names(surfaceSphericalTensorField::typeName)
);
PtrList<surfaceSphericalTensorField> surfSphericalTensorFlds
(
surfSphericalTensorNames.size()
);
subsetSurfaceFields
(
subsetter,
surfSphericalTensorNames,
surfSphericalTensorFlds
);
wordList surfSymmTensorNames PtrList<surfaceSymmTensorField> surfSymmTensorFlds;
( subsetFields(subsetter, availableFields, surfSymmTensorFlds);
objects.names(surfaceSymmTensorField::typeName)
);
PtrList<surfaceSymmTensorField> surfSymmTensorFlds
(
surfSymmTensorNames.size()
);
subsetSurfaceFields(subsetter, surfSymmTensorNames, surfSymmTensorFlds);
wordList surfTensorNames(objects.names(surfaceTensorField::typeName)); PtrList<surfaceTensorField> surfTensorFlds;
PtrList<surfaceTensorField> surfTensorFlds(surfTensorNames.size()); subsetFields(subsetter, availableFields, surfTensorFlds);
subsetSurfaceFields(subsetter, surfTensorNames, surfTensorFlds);
// Read point fields and subset // Read point fields and subset
@ -532,86 +509,39 @@ int main(int argc, char *argv[])
const pointMesh& pMesh = pointMesh::New(mesh); const pointMesh& pMesh = pointMesh::New(mesh);
wordList pointScalarNames(objects.names(pointScalarField::typeName)); PtrList<pointScalarField> pointScalarFlds;
PtrList<pointScalarField> pointScalarFlds(pointScalarNames.size()); subsetPointFields(subsetter, pMesh, availableFields, pointScalarFlds);
subsetPointFields(subsetter, pMesh, pointScalarNames, pointScalarFlds);
wordList pointVectorNames(objects.names(pointVectorField::typeName)); PtrList<pointVectorField> pointVectorFlds;
PtrList<pointVectorField> pointVectorFlds(pointVectorNames.size()); subsetPointFields(subsetter, pMesh, availableFields, pointVectorFlds);
subsetPointFields(subsetter, pMesh, pointVectorNames, pointVectorFlds);
wordList pointSphericalTensorNames PtrList<pointSphericalTensorField> pointSphTensorFlds;
( subsetPointFields(subsetter, pMesh, availableFields, pointSphTensorFlds);
objects.names(pointSphericalTensorField::typeName)
);
PtrList<pointSphericalTensorField> pointSphericalTensorFlds
(
pointSphericalTensorNames.size()
);
subsetPointFields
(
subsetter,
pMesh,
pointSphericalTensorNames,
pointSphericalTensorFlds
);
wordList pointSymmTensorNames PtrList<pointSymmTensorField> pointSymmTensorFlds;
( subsetPointFields(subsetter, pMesh, availableFields, pointSymmTensorFlds);
objects.names(pointSymmTensorField::typeName)
);
PtrList<pointSymmTensorField> pointSymmTensorFlds
(
pointSymmTensorNames.size()
);
subsetPointFields
(
subsetter,
pMesh,
pointSymmTensorNames,
pointSymmTensorFlds
);
wordList pointTensorNames(objects.names(pointTensorField::typeName)); PtrList<pointTensorField> pointTensorFlds;
PtrList<pointTensorField> pointTensorFlds(pointTensorNames.size()); subsetPointFields(subsetter, pMesh, availableFields, pointTensorFlds);
subsetPointFields(subsetter, pMesh, pointTensorNames, pointTensorFlds);
// Read dimensioned fields and subset // Read dimensioned fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
typedef volScalarField::Internal dimScalType; PtrList<volScalarField::Internal> scalarDimFlds;
wordList scalarDimNames(objects.names(dimScalType::typeName)); subsetDimensionedFields(subsetter, availableFields, scalarDimFlds);
PtrList<dimScalType> scalarDimFlds(scalarDimNames.size());
subsetDimensionedFields(subsetter, scalarDimNames, scalarDimFlds);
typedef volVectorField::Internal dimVecType; PtrList<volVectorField::Internal> vectorDimFlds;
wordList vectorDimNames(objects.names(dimVecType::typeName)); subsetDimensionedFields(subsetter, availableFields, vectorDimFlds);
PtrList<dimVecType> vectorDimFlds(vectorDimNames.size());
subsetDimensionedFields(subsetter, vectorDimNames, vectorDimFlds);
typedef volSphericalTensorField::Internal dimSphereType; PtrList<volSphericalTensorField::Internal> sphTensorDimFlds;
wordList sphericalTensorDimNames(objects.names(dimSphereType::typeName)); subsetDimensionedFields(subsetter, availableFields, sphTensorDimFlds);
PtrList<dimSphereType> sphericalTensorDimFlds
(
sphericalTensorDimNames.size()
);
subsetDimensionedFields
(
subsetter,
sphericalTensorDimNames,
sphericalTensorDimFlds
);
typedef volSymmTensorField::Internal dimSymmTensorType; PtrList<volSymmTensorField::Internal> symmTensorDimFlds;
wordList symmTensorDimNames(objects.names(dimSymmTensorType::typeName)); subsetDimensionedFields(subsetter, availableFields, symmTensorDimFlds);
PtrList<dimSymmTensorType> symmTensorDimFlds(symmTensorDimNames.size());
subsetDimensionedFields(subsetter, symmTensorDimNames, symmTensorDimFlds);
typedef volTensorField::Internal dimTensorType; PtrList<volTensorField::Internal> tensorDimFlds;
wordList tensorDimNames(objects.names(dimTensorType::typeName)); subsetDimensionedFields(subsetter, availableFields, tensorDimFlds);
PtrList<dimTensorType> tensorDimFlds(tensorDimNames.size());
subsetDimensionedFields(subsetter, tensorDimNames, tensorDimFlds);
// topoSets and subset // topoSets and subset
@ -620,6 +550,7 @@ int main(int argc, char *argv[])
PtrList<cellSet> cellSets; PtrList<cellSet> cellSets;
PtrList<faceSet> faceSets; PtrList<faceSet> faceSets;
PtrList<pointSet> pointSets; PtrList<pointSet> pointSets;
{ {
IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets"); IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets");
objects.remove(currentSet); objects.remove(currentSet);
@ -650,7 +581,6 @@ int main(int argc, char *argv[])
} }
// Write mesh and fields to new time // Write mesh and fields to new time
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -668,123 +598,100 @@ int main(int argc, char *argv[])
subsetter.subMesh().setInstance(runTime.timeName()); subsetter.subMesh().setInstance(runTime.timeName());
} }
Info<< "Writing subsetted mesh and fields to time " << runTime.timeName() Info<< "Writing subsetted mesh and fields to time " << runTime.timeName()
<< endl; << endl;
subsetter.subMesh().write(); subsetter.subMesh().write();
processorMeshes::removeFiles(subsetter.subMesh()); processorMeshes::removeFiles(subsetter.subMesh());
// Subsetting adds 'subset' prefix. Rename field to be like original. // Volume fields
forAll(scalarFlds, i) forAll(scalarFlds, i)
{ {
scalarFlds[i].rename(scalarNames[i]);
scalarFlds[i].write(); scalarFlds[i].write();
} }
forAll(vectorFlds, i) forAll(vectorFlds, i)
{ {
vectorFlds[i].rename(vectorNames[i]);
vectorFlds[i].write(); vectorFlds[i].write();
} }
forAll(sphericalTensorFlds, i) forAll(sphTensorFlds, i)
{ {
sphericalTensorFlds[i].rename(sphericalTensorNames[i]); sphTensorFlds[i].write();
sphericalTensorFlds[i].write();
} }
forAll(symmTensorFlds, i) forAll(symmTensorFlds, i)
{ {
symmTensorFlds[i].rename(symmTensorNames[i]);
symmTensorFlds[i].write(); symmTensorFlds[i].write();
} }
forAll(tensorFlds, i) forAll(tensorFlds, i)
{ {
tensorFlds[i].rename(tensorNames[i]);
tensorFlds[i].write(); tensorFlds[i].write();
} }
// Surface ones. // Surface fields.
forAll(surfScalarFlds, i) forAll(surfScalarFlds, i)
{ {
surfScalarFlds[i].rename(surfScalarNames[i]);
surfScalarFlds[i].write(); surfScalarFlds[i].write();
} }
forAll(surfVectorFlds, i) forAll(surfVectorFlds, i)
{ {
surfVectorFlds[i].rename(surfVectorNames[i]);
surfVectorFlds[i].write(); surfVectorFlds[i].write();
} }
forAll(surfSphericalTensorFlds, i) forAll(surfSphTensorFlds, i)
{ {
surfSphericalTensorFlds[i].rename(surfSphericalTensorNames[i]); surfSphTensorFlds[i].write();
surfSphericalTensorFlds[i].write();
} }
forAll(surfSymmTensorFlds, i) forAll(surfSymmTensorFlds, i)
{ {
surfSymmTensorFlds[i].rename(surfSymmTensorNames[i]);
surfSymmTensorFlds[i].write(); surfSymmTensorFlds[i].write();
} }
forAll(surfTensorNames, i) forAll(surfTensorFlds, i)
{ {
surfTensorFlds[i].rename(surfTensorNames[i]);
surfTensorFlds[i].write(); surfTensorFlds[i].write();
} }
// Point ones // Point fields
forAll(pointScalarFlds, i) forAll(pointScalarFlds, i)
{ {
pointScalarFlds[i].rename(pointScalarNames[i]);
pointScalarFlds[i].write(); pointScalarFlds[i].write();
} }
forAll(pointVectorFlds, i) forAll(pointVectorFlds, i)
{ {
pointVectorFlds[i].rename(pointVectorNames[i]);
pointVectorFlds[i].write(); pointVectorFlds[i].write();
} }
forAll(pointSphericalTensorFlds, i) forAll(pointSphTensorFlds, i)
{ {
pointSphericalTensorFlds[i].rename(pointSphericalTensorNames[i]); pointSphTensorFlds[i].write();
pointSphericalTensorFlds[i].write();
} }
forAll(pointSymmTensorFlds, i) forAll(pointSymmTensorFlds, i)
{ {
pointSymmTensorFlds[i].rename(pointSymmTensorNames[i]);
pointSymmTensorFlds[i].write(); pointSymmTensorFlds[i].write();
} }
forAll(pointTensorNames, i) forAll(pointTensorFlds, i)
{ {
pointTensorFlds[i].rename(pointTensorNames[i]);
pointTensorFlds[i].write(); pointTensorFlds[i].write();
} }
// DimensionedFields // Dimensioned fields
forAll(scalarDimFlds, i) forAll(scalarDimFlds, i)
{ {
scalarDimFlds[i].rename(scalarDimNames[i]);
scalarDimFlds[i].write(); scalarDimFlds[i].write();
} }
forAll(vectorDimFlds, i) forAll(vectorDimFlds, i)
{ {
vectorDimFlds[i].rename(vectorDimNames[i]);
vectorDimFlds[i].write(); vectorDimFlds[i].write();
} }
forAll(sphericalTensorDimFlds, i) forAll(sphTensorDimFlds, i)
{ {
sphericalTensorDimFlds[i].rename(sphericalTensorDimNames[i]); sphTensorDimFlds[i].write();
sphericalTensorDimFlds[i].write();
} }
forAll(symmTensorDimFlds, i) forAll(symmTensorDimFlds, i)
{ {
symmTensorDimFlds[i].rename(symmTensorDimNames[i]);
symmTensorDimFlds[i].write(); symmTensorDimFlds[i].write();
} }
forAll(tensorDimFlds, i) forAll(tensorDimFlds, i)
{ {
tensorDimFlds[i].rename(tensorDimNames[i]);
tensorDimFlds[i].write(); tensorDimFlds[i].write();
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;
return 0; return 0;

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "doxygenXmlParser.H" #include "doxygenXmlParser.H"
#include "wordRe.H" #include "regExp.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -40,8 +40,8 @@ Foam::doxygenXmlParser::doxygenXmlParser
dictionary(dictionary::null) dictionary(dictionary::null)
{ {
// Pre-construct and compile regular expressions // Pre-construct and compile regular expressions
const wordRe nameRe(".*.H", wordRe::DETECT); const regExp nameRe(".*.H");
const wordRe searchStrRe(searchStr, wordRe::DETECT); const regExp searchStrRe(searchStr);
// Pre-construct constant strings and names to speed-up comparisons // Pre-construct constant strings and names to speed-up comparisons
const string slashStartTag('/' + startTag); const string slashStartTag('/' + startTag);
@ -163,7 +163,7 @@ Foam::doxygenXmlParser::doxygenXmlParser
( (
!exactMatch !exactMatch
&& !found(tName) // not already added && !found(tName) // not already added
&& wordRe(".*" + tName + ".*", wordRe::DETECT).match(name) && regExp(".*" + tName + ".*").match(name)
) )
{ {
dictionary dict(dictionary::null); dictionary dict(dictionary::null);

View File

@ -37,7 +37,7 @@ Foam::autoPtr<Foam::helpType> Foam::helpType::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(helpTypeName); dictionaryConstructorTablePtr_->find(helpTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
// special treatment for -help // special treatment for -help
// exit without stack trace // exit without stack trace

View File

@ -23,7 +23,7 @@ if (!fieldsToUse.found(fieldName))
).typeHeaderOk<volScalarField>(false, false) ).typeHeaderOk<volScalarField>(false, false)
); );
if (variableGood) if (!variableGood)
{ {
break; break;
} }

View File

@ -35,36 +35,25 @@ if (timeDirs.size() && !noLagrangian)
cloudPrefix/cloudName cloudPrefix/cloudName
); );
// clouds always require "positions" // Clouds always have "positions"
if (cloudObjs.found("positions")) if (cloudObjs.found("positions"))
{ {
HashTable<HashTable<word>>::iterator cloudIter = // Save the cloud fields on a per cloud basis
cloudFields.find(cloudName); auto fieldsPerCloud = cloudFields(cloudName);
if (cloudIter == cloudFields.end()) forAllConstIters(cloudObjs, fieldIter)
{ {
// A newly discovered cloud const IOobject* obj = fieldIter();
cloudFields.insert(cloudName, HashTable<word>());
cloudIter = cloudFields.find(cloudName);
}
forAllConstIter(IOobjectList, cloudObjs, fieldIter) // Field name/type
{ fieldsPerCloud.insert(obj->name(), obj->headerClassName());
const IOobject& obj = *fieldIter();
// Add field and field type
cloudIter().insert
(
obj.name(),
obj.headerClassName()
);
} }
} }
} }
} }
// prune out "positions" again since it gets treated specially // Prune out "positions" again since it gets treated specially
forAllIter(HashTable<HashTable<word>>, cloudFields, cloudIter) forAllIters(cloudFields, cloudIter)
{ {
cloudIter().erase("positions"); 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()); const wordList cloudNames(cloudFields.sortedToc());
if (cloudNames.size()) if (cloudNames.size())
{ {
// complete the echo information // Complete the echo information - as flatOutput
Info<< "("; cloudNames.writeList(Info) << endl;
forAll(cloudNames, cloudNo)
{
Info<< ' ' << cloudNames[cloudNo];
}
Info<< " ) " << endl;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -78,6 +78,7 @@ Note
#include "fvc.H" #include "fvc.H"
#include "volFields.H" #include "volFields.H"
#include "hashedWordList.H"
#include "labelIOField.H" #include "labelIOField.H"
#include "scalarIOField.H" #include "scalarIOField.H"
@ -190,7 +191,7 @@ int main(int argc, char *argv[])
); );
// The volume field types that we handle // The volume field types that we handle
const wordList volFieldTypes const hashedWordList volFieldTypes
{ {
volScalarField::typeName, volScalarField::typeName,
volVectorField::typeName, volVectorField::typeName,
@ -207,7 +208,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
// default to binary output, unless otherwise specified // Default to binary output, unless otherwise specified
const IOstream::streamFormat format = const IOstream::streamFormat format =
( (
args.optionFound("ascii") 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); 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); ensightMesh::options writeOpts(format);
writeOpts.noPatches(args.optionFound("noPatches")); writeOpts.noPatches(args.optionFound("noPatches"));
@ -313,12 +314,6 @@ int main(int argc, char *argv[])
ensCase.printInfo(Info) << endl; 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 "checkMeshMoving.H"
#include "findCloudFields.H" #include "findCloudFields.H"
@ -331,6 +326,40 @@ int main(int argc, char *argv[])
<< timer.cpuTimeIncrement() << " s, " << timer.cpuTimeIncrement() << " s, "
<< mem.update().size() << " kB" << nl << endl; << 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 special fields (_0 fields),
// ignore fields we don't handle, // ignore fields we don't handle,
// ignore fields that are not available for all time-steps // ignore fields that are not available for all time-steps
@ -362,25 +391,22 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~
Info<< "Write volume field ("; Info<< "Write volume field (";
forAll(volFieldTypes, typei) for (auto fieldType : volFieldTypes)
{ {
const word& fieldType = volFieldTypes[typei]; // For convenience, just force each field-type into existence.
wordList fieldNames = objects.names(fieldType); // This simplifies code logic and doesn't cost much at all.
wordHashSet& fieldNames = usableObjects(fieldType);
// Filter on name as required forAllIters(fieldNames, fieldIter)
if (!fieldPatterns.empty())
{ {
inplaceSubsetStrings(fieldPatterns, fieldNames); const word& fieldName = fieldIter.key();
}
forAll(fieldNames, fieldi)
{
const word& fieldName = fieldNames[fieldi];
#include "checkData.H" #include "checkData.H"
// Partially complete field?
if (!fieldsToUse[fieldName]) if (!fieldsToUse[fieldName])
{ {
fieldNames.erase(fieldIter);
continue; continue;
} }
@ -597,7 +623,8 @@ int main(int argc, char *argv[])
} }
else 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); fieldsToUse.set(fieldName, false);
} }

View File

@ -199,7 +199,7 @@ void print(Ostream& os, const wordList& flds)
labelList getSelectedPatches labelList getSelectedPatches
( (
const polyBoundaryMesh& patches, const polyBoundaryMesh& patches,
const List<wordRe>& excludePatches const wordRes& excludePatches
) )
{ {
DynamicList<label> patchIDs(patches.size()); DynamicList<label> patchIDs(patches.size());
@ -219,7 +219,7 @@ labelList getSelectedPatches
Info<< " discarding empty/processor patch " << patchi Info<< " discarding empty/processor patch " << patchi
<< " " << pp.name() << endl; << " " << pp.name() << endl;
} }
else if (findStrings(excludePatches, pp.name())) else if (excludePatches.match(pp.name()))
{ {
Info<< " excluding patch " << patchi Info<< " excluding patch " << patchi
<< " " << pp.name() << endl; << " " << pp.name() << endl;
@ -379,7 +379,7 @@ int main(int argc, char *argv[])
const bool allPatches = args.optionFound("allPatches"); const bool allPatches = args.optionFound("allPatches");
List<wordRe> excludePatches; wordReList excludePatches;
if (args.optionFound("excludePatches")) if (args.optionFound("excludePatches"))
{ {
args.optionLookup("excludePatches")() >> excludePatches; args.optionLookup("excludePatches")() >> excludePatches;

View File

@ -55,7 +55,7 @@ namespace Foam
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class vtkPVFoamReader Declaration Class vtkPVFoamReader Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class vtkPVFoamReader class vtkPVFoamReader
@ -64,7 +64,7 @@ class vtkPVFoamReader
{ {
public: public:
vtkTypeMacro(vtkPVFoamReader, vtkMultiBlockDataSetAlgorithm); vtkTypeMacro(vtkPVFoamReader, vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream&, vtkIndent); void PrintSelf(ostream&, vtkIndent) VTK_OVERRIDE;
static vtkPVFoamReader* New(); static vtkPVFoamReader* New();
@ -199,7 +199,7 @@ protected:
vtkInformation*, vtkInformation*,
vtkInformationVector**, vtkInformationVector**,
vtkInformationVector* vtkInformationVector*
); ) VTK_OVERRIDE;
//- Get the mesh/fields for a particular time //- Get the mesh/fields for a particular time
virtual int RequestData virtual int RequestData
@ -207,10 +207,10 @@ protected:
vtkInformation*, vtkInformation*,
vtkInformationVector**, vtkInformationVector**,
vtkInformationVector* vtkInformationVector*
); ) VTK_OVERRIDE;
//- Fill in additional port information //- 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 //- The observer to modify this object when array selections are modified
vtkCallbackCommand* SelectionObserver; vtkCallbackCommand* SelectionObserver;

View File

@ -62,7 +62,7 @@ class vtkPVblockMeshReader
{ {
public: public:
vtkTypeMacro(vtkPVblockMeshReader, vtkMultiBlockDataSetAlgorithm); vtkTypeMacro(vtkPVblockMeshReader, vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream&, vtkIndent); void PrintSelf(ostream&, vtkIndent) VTK_OVERRIDE;
static vtkPVblockMeshReader* New(); static vtkPVblockMeshReader* New();
@ -127,7 +127,7 @@ protected:
vtkInformation* unusedRequest, vtkInformation* unusedRequest,
vtkInformationVector** unusedInputVector, vtkInformationVector** unusedInputVector,
vtkInformationVector* outputVector vtkInformationVector* outputVector
); ) VTK_OVERRIDE;
//- Get the mesh for a particular time //- Get the mesh for a particular time
virtual int RequestData virtual int RequestData
@ -135,10 +135,10 @@ protected:
vtkInformation* unusedRequest, vtkInformation* unusedRequest,
vtkInformationVector** unusedInputVector, vtkInformationVector** unusedInputVector,
vtkInformationVector* outputVector vtkInformationVector* outputVector
); ) VTK_OVERRIDE;
//- Fill in additional port information //- 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 // The observer to modify this object when array selections are modified
vtkCallbackCommand* SelectionObserver; vtkCallbackCommand* SelectionObserver;

View File

@ -169,7 +169,7 @@ void Foam::boundaryInfo::setType(const label patchI, const word& condition)
return; return;
} }
if (wordRe(".*[Mm]apped.*", wordRe::REGEXP).match(types_[patchI])) if (regExp(".*[Mm]apped.*").match(types_[patchI]))
{ {
// ugly hack to avoid overriding mapped types // ugly hack to avoid overriding mapped types
return; return;

View File

@ -47,7 +47,7 @@ autoPtr<tabulatedWallFunction> tabulatedWallFunction::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(twfTypeName); dictionaryConstructorTablePtr_->find(twfTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown tabulatedWallFunction type " << twfTypeName << "Unknown tabulatedWallFunction type " << twfTypeName

View File

@ -67,7 +67,7 @@ Foam::searchableSurfaceModifier::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(type); dictionaryConstructorTablePtr_->find(type);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown searchableSurfaceModifier type " << "Unknown searchableSurfaceModifier type "

View File

@ -1,9 +1,9 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory 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 chmod a+rX $WM_PROJECT_DIR $WM_PROJECT_DIR/doc Doxygen
Doxygen/Allwmake exec Doxygen/Allwmake "$@"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -14,13 +14,17 @@ usage() {
usage: ${0##*/} [OPTION] usage: ${0##*/} [OPTION]
options: 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 -help
USAGE USAGE
exit 1 exit 1
} }
# -----------------------------------------------------------------------------
defineURL() { defineURL() {
WEB_PATH="https://develop.openfoam.com" WEB_PATH="https://develop.openfoam.com"
@ -39,13 +43,43 @@ defineURL() {
export FOAM_ONLINE_REPO="$FOAM_BASE_REPO/blob/${FOAM_REPO_TAG}" export FOAM_ONLINE_REPO="$FOAM_BASE_REPO/blob/${FOAM_REPO_TAG}"
} }
# parse options
unset configName dirName
# Parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help) -h | -help)
usage 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) -online)
defineURL defineURL
;; ;;
@ -56,19 +90,31 @@ do
shift shift
done done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
rm -rf latex man rm -rf latex man
# remove html directory in background # Remove html directory in background
mv html html-stagedRemove$$ 2> /dev/null mv html html-stagedRemove$$ 2> /dev/null
rm -rf html-stagedRemove$$ >/dev/null 2>&1 & 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 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 chmod -R a+rX html latex man 2>/dev/null
echo echo

View File

@ -39,7 +39,7 @@ Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(ODESolverTypeName); dictionaryConstructorTablePtr_->find(ODESolverTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end()) if (!cstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown ODESolver type " << "Unknown ODESolver type "

View File

@ -111,7 +111,7 @@ Foam::regExp::~regExp()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::regExp::set(const char* pattern, bool ignoreCase) bool Foam::regExp::set(const char* pattern, bool ignoreCase)
{ {
clear(); clear();
@ -137,7 +137,7 @@ void Foam::regExp::set(const char* pattern, bool ignoreCase)
// avoid zero-length patterns // avoid zero-length patterns
if (!*pat) if (!*pat)
{ {
return; return false;
} }
} }
@ -154,11 +154,15 @@ void Foam::regExp::set(const char* pattern, bool ignoreCase)
<< nl << errbuf << nl << errbuf
<< exit(FatalError); << 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); return set(pattern.c_str(), ignoreCase);
} }
@ -208,7 +212,7 @@ bool Foam::regExp::match(const std::string& text) const
if if
( (
regexec(preg_, text.c_str(), nmatch, pmatch, 0) == 0 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; return true;

View File

@ -128,20 +128,23 @@ public:
// Editing // Editing
//- Compile pattern into a regular expression, optionally ignore case //- Compile pattern into a regular expression, optionally ignore case.
void set(const char* pattern, bool ignoreCase=false); // \return True if the pattern was compiled
bool set(const char* pattern, bool ignoreCase=false);
//- Compile pattern into a regular expression, optionally ignore case //- 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(); bool clear();
// Matching/Searching // Matching/Searching
//- Find position within string. //- 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; std::string::size_type find(const std::string& text) const;
//- Return true if it matches the entire string //- Return true if it matches the entire string
@ -158,6 +161,9 @@ public:
// Member Operators // Member Operators
//- Perform match on text
inline bool operator()(const std::string& text) const;
//- Assign and compile pattern from a character array //- Assign and compile pattern from a character array
// Always case sensitive // Always case sensitive
inline void operator=(const char* pattern); inline void operator=(const char* pattern);

View File

@ -66,6 +66,12 @@ inline bool Foam::regExp::search(const std::string& text) const
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
inline bool Foam::regExp::operator()(const std::string& text) const
{
return match(text);
}
inline void Foam::regExp::operator=(const char* pattern) inline void Foam::regExp::operator=(const char* pattern)
{ {
set(pattern); set(pattern);

View File

@ -103,8 +103,8 @@ $(strings)/fileName/fileName.C
$(strings)/fileName/fileNameIO.C $(strings)/fileName/fileNameIO.C
$(strings)/keyType/keyType.C $(strings)/keyType/keyType.C
$(strings)/wordRe/wordRe.C $(strings)/wordRe/wordRe.C
$(strings)/wordRes/wordRes.C
$(strings)/lists/hashedWordList.C $(strings)/lists/hashedWordList.C
$(strings)/lists/wordReListMatcher.C
$(strings)/stringOps/stringOps.C $(strings)/stringOps/stringOps.C
ops = primitives/ops ops = primitives/ops

View File

@ -158,6 +158,20 @@ Foam::label Foam::HashSet<Key, Hash>::insert(std::initializer_list<Key> lst)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator=(const UList<Key>& lst) 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> template<class Key, class Hash>
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const

View File

@ -156,22 +156,24 @@ public:
// Edit // Edit
//- Insert a new entry //- 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) bool insert(const Key& key)
{ {
return this->parent_type::insert(key, nil()); return this->parent_type::insert(key, nil());
} }
//- Insert keys from the list of Key //- 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); label insert(const UList<Key>& lst);
//- Insert keys from the list of Key //- Insert keys from the list of Key
// Return the number of new elements inserted // \return The number of new elements inserted
template<unsigned Size> template<unsigned Size>
label insert(const FixedList<Key, Size>& lst); label insert(const FixedList<Key, Size>& lst);
//- Insert keys from a initializer list of Key //- 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); label insert(std::initializer_list<Key> lst);
//- Same as insert (cannot overwrite nil content) //- Same as insert (cannot overwrite nil content)
@ -200,18 +202,21 @@ public:
} }
//- Unset the specified key - same as erase //- Unset the specified key - same as erase
// \return True if the entry existed and was removed
bool unset(const Key& key) bool unset(const Key& key)
{ {
return this->parent_type::erase(key); return this->parent_type::erase(key);
} }
//- Unset the listed keys - same as erase //- Unset the listed keys - same as erase
// \return The number of items removed
label unset(const UList<Key>& lst) label unset(const UList<Key>& lst)
{ {
return this->parent_type::erase(lst); return this->parent_type::erase(lst);
} }
//- Unset the listed keys - same as erase //- Unset the listed keys - same as erase
// \return The number of items removed
template<unsigned Size> template<unsigned Size>
label unset(const FixedList<Key, Size>& lst) label unset(const FixedList<Key, Size>& lst)
{ {
@ -219,11 +224,36 @@ public:
} }
//- Unset the listed keys - same as erase //- Unset the listed keys - same as erase
// \return The number of items removed
label unset(std::initializer_list<Key> lst) label unset(std::initializer_list<Key> lst)
{ {
return this->parent_type::erase(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 // STL iterators
@ -248,12 +278,15 @@ public:
// Member Operators // 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() //- 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; inline bool operator[](const Key& key) const;
// Comparison
//- Equality. Two hashset are equal when they have the same keys. //- Equality. Two hashset are equal when they have the same keys.
// Independent of table size or order. // Independent of table size or order.
bool operator==(const this_type& rhs) const; bool operator==(const this_type& rhs) const;
@ -262,6 +295,8 @@ public:
bool operator!=(const this_type& rhs) const; bool operator!=(const this_type& rhs) const;
// Assignment
//- Assignment from a UList of keys //- Assignment from a UList of keys
void operator=(const UList<Key>& lst); void operator=(const UList<Key>& lst);
@ -273,6 +308,8 @@ public:
void operator=(std::initializer_list<Key> lst); void operator=(std::initializer_list<Key> lst);
// Logical operations
//- Combine entries from HashSets //- Combine entries from HashSets
void operator|=(const HashSet<Key, Hash>& rhs); void operator|=(const HashSet<Key, Hash>& rhs);

View File

@ -231,25 +231,169 @@ Foam::HashTable<T, Key, Hash>::find
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const
{ {
List<Key> keys(nElmts_); List<Key> keyLst(nElmts_);
label keyI = 0; label count = 0;
for (const_iterator iter = cbegin(); iter != cend(); ++iter) 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> template<class T, class Key, class Hash>
Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc() const Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc() const
{ {
List<Key> sortedLst = this->toc(); List<Key> keyLst = this->toc();
sort(sortedLst); 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, class Key, class Hash> template<class T, class Key, class Hash>

View File

@ -255,7 +255,7 @@ private:
inline label hashKeyIndex(const Key& key) const; inline label hashKeyIndex(const Key& key) const;
//- Assign a new hash-entry to a possibly already existing key. //- 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); 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 //- Return hashed entry if it exists, or return the given default
inline const T& lookup(const Key& key, const T& deflt) const; inline const T& lookup(const Key& key, const T& deflt) const;
// Table of contents
//- Return the table of contents //- Return the table of contents
List<Key> toc() const; List<Key> toc() const;
//- Return the table of contents as a sorted list //- Return the table of contents as a sorted list
List<Key> sortedToc() const; 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 // Edit
//- Insert a new entry //- 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. // not previously exist in the table.
inline bool insert(const Key& key, const T& obj); inline bool insert(const Key& key, const T& obj);
//- Assign a new entry, overwriting existing entries. //- 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); inline bool set(const Key& key, const T& obj);
//- Erase an entry specified by given iterator //- Erase an entry specified by given iterator
@ -357,30 +418,34 @@ public:
// auto iter = table.find(unknownKey); // auto iter = table.find(unknownKey);
// table.erase(iter); // table.erase(iter);
// \endcode // \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); bool erase(const iterator& iter);
//- Erase an entry specified by the given key //- Erase an entry specified by the given key
// \return True if the entry existed and was removed
bool erase(const Key& key); bool erase(const Key& key);
//- Remove table entries given by the listed keys //- 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); label erase(const UList<Key>& keys);
//- Remove table entries given by the listed keys //- Remove table entries given by the listed keys
// Return the number of elements removed // \return The number of items removed
template<unsigned Size> template<unsigned Size>
label erase(const FixedList<Key, Size>& keys); label erase(const FixedList<Key, Size>& keys);
//- Remove table entries given by the listed 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); label erase(std::initializer_list<Key> keys);
//- Remove table entries given by keys of the other hash-table. //- 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 // The other hash-table must have the same type of key, but the
// type of values held and the hashing function are arbitrary. // type of values held and the hashing function are arbitrary.
//
// \return The number of items removed
template<class AnyType, class AnyHash> template<class AnyType, class AnyHash>
label erase(const HashTable<AnyType, Key, AnyHash>& other); 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 // The other hash-table must have the same type of key, but the
// type of values held and the hashing function are arbitrary. // type of values held and the hashing function are arbitrary.
//
// \return The number of items changed (removed)
template<class AnyType, class AnyHash> template<class AnyType, class AnyHash>
label retain(const HashTable<AnyType, Key, AnyHash>& other); 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 //- Resize the hash table for efficiency
void resize(const label sz); void resize(const label sz);

View File

@ -46,26 +46,26 @@ Foam::label Foam::HashTableCore::canonicalSize(const label requested_size)
{ {
return 0; 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. // Use unsigned for these calculations.
// //
// - The lower limit (8) is somewhat arbitrary, but if the hash table // - The lower limit (8) is somewhat arbitrary, but if the hash table
// is too small, there will be many direct table collisions. // 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. // need not be extremely large for hashing.
uLabel powerOfTwo = 8; // lower-limit uLabel powerOfTwo = 8; // lower-limit
const uLabel size = requested_size; const uLabel size = requested_size;
if (size < powerOfTwo) if (size <= powerOfTwo)
{ {
return powerOfTwo; return powerOfTwo;
} }
else if (requested_size >= maxTableSize)
{
return maxTableSize;
}
else if (size & (size-1)) // <- Modulus of i^2 else if (size & (size-1)) // <- Modulus of i^2
{ {
// Determine power-of-two. Brute-force is fast enough. // Determine power-of-two. Brute-force is fast enough.

View File

@ -46,26 +46,26 @@ Foam::label Foam::StaticHashTableCore::canonicalSize(const label requested_size)
{ {
return 0; 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. // Use unsigned for these calculations.
// //
// - The lower limit (8) is somewhat arbitrary, but if the hash table // - The lower limit (8) is somewhat arbitrary, but if the hash table
// is too small, there will be many direct table collisions. // 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. // need not be extremely large for hashing.
uLabel powerOfTwo = 8; // lower-limit uLabel powerOfTwo = 8; // lower-limit
const uLabel size = requested_size; const uLabel size = requested_size;
if (size < powerOfTwo) if (size <= powerOfTwo)
{ {
return powerOfTwo; return powerOfTwo;
} }
else if (requested_size >= maxTableSize)
{
return maxTableSize;
}
else if (size & (size-1)) // <- Modulus of i^2 else if (size & (size-1)) // <- Modulus of i^2
{ {
// Determine power-of-two. Brute-force is fast enough. // Determine power-of-two. Brute-force is fast enough.

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,7 +27,99 @@ License
#include "Time.H" #include "Time.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "IOList.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -62,14 +154,14 @@ Foam::IOobjectList::IOobjectList
} }
// Create a list of file names in this directory // Create a list of file names in this directory
fileNameList ObjectNames = fileNameList objNames =
readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE); readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
forAll(ObjectNames, i) forAll(objNames, i)
{ {
IOobject* objectPtr = new IOobject IOobject* objectPtr = new IOobject
( (
ObjectNames[i], objNames[i],
newInstance, newInstance,
local, local,
db, db,
@ -81,7 +173,7 @@ Foam::IOobjectList::IOobjectList
// Use object with local scope // Use object with local scope
if (objectPtr->typeHeaderOk<IOList<label>>(false)) if (objectPtr->typeHeaderOk<IOList<label>>(false))
{ {
insert(ObjectNames[i], objectPtr); insert(objectPtr->name(), objectPtr);
} }
else else
{ {
@ -119,7 +211,7 @@ bool Foam::IOobjectList::remove(IOobject& io)
Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
{ {
HashPtrTable<IOobject>::const_iterator iter = find(name); const_iterator iter = find(name);
if (iter.found()) 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 Foam::IOobjectList Foam::IOobjectList::lookup(const wordRe& matcher) const
{ {
IOobjectList results(size()); return lookupImpl(*this, matcher);
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;
} }
Foam::IOobjectList Foam::IOobjectList::lookup(const wordReList& matcher) const Foam::IOobjectList Foam::IOobjectList::lookup(const wordRes& matcher) const
{ {
wordReListMatcher mat(matcher); return lookupImpl(*this, 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;
} }
@ -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 Foam::wordList Foam::IOobjectList::names() const
{ {
return HashPtrTable<IOobject>::toc(); return HashPtrTable<IOobject>::toc();
@ -236,20 +308,7 @@ Foam::wordList Foam::IOobjectList::names
const word& clsName const word& clsName
) const ) const
{ {
wordList objNames(size()); return namesImpl(*this, clsName, predicates::always(), false);
label count = 0;
forAllConstIters(*this, iter)
{
if (iter()->headerClassName() == clsName)
{
objNames[count++] = iter.key();
}
}
objNames.setSize(count);
return objNames;
} }
@ -259,21 +318,17 @@ Foam::wordList Foam::IOobjectList::names
const wordRe& matcher const wordRe& matcher
) const ) const
{ {
wordList objNames = names(clsName); return namesImpl(*this, clsName, matcher, false);
return wordList(objNames, findStrings(matcher, objNames));
} }
Foam::wordList Foam::IOobjectList::names Foam::wordList Foam::IOobjectList::names
( (
const word& clsName, const word& clsName,
const wordReList& matcher const wordRes& matcher
) const ) const
{ {
wordList objNames = names(clsName); return namesImpl(*this, clsName, matcher, false);
return wordList(objNames, findStrings(matcher, objNames));
} }
@ -282,10 +337,7 @@ Foam::wordList Foam::IOobjectList::sortedNames
const word& clsName const word& clsName
) const ) const
{ {
wordList sortedLst = names(clsName); return namesImpl(*this, clsName, predicates::always(), true);
sort(sortedLst);
return sortedLst;
} }
@ -295,23 +347,35 @@ Foam::wordList Foam::IOobjectList::sortedNames
const wordRe& matcher const wordRe& matcher
) const ) const
{ {
wordList sortedLst = names(clsName, matcher); return namesImpl(*this, clsName, matcher, true);
sort(sortedLst);
return sortedLst;
} }
Foam::wordList Foam::IOobjectList::sortedNames Foam::wordList Foam::IOobjectList::sortedNames
( (
const word& clsName, const word& clsName,
const wordReList& matcher const wordRes& matcher
) const ) const
{ {
wordList sortedLst = names(clsName, matcher); return namesImpl(*this, clsName, matcher, true);
sort(sortedLst); }
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;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -36,14 +36,20 @@ SourceFiles
#define IOobjectList_H #define IOobjectList_H
#include "HashPtrTable.H" #include "HashPtrTable.H"
#include "HashSet.H"
#include "IOobject.H" #include "IOobject.H"
#include "wordReList.H" #include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators
class IOobjectList;
Ostream& operator<<(Ostream& os, const IOobjectList& list);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class IOobjectList Declaration Class IOobjectList Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -86,12 +92,17 @@ public:
// Member functions // Member functions
// Basic methods
//- Add an IOobject to the list //- Add an IOobject to the list
bool add(IOobject& io); bool add(IOobject& io);
//- Remove an IOobject from the list //- Remove an IOobject from the list
bool remove(IOobject& io); bool remove(IOobject& io);
// Lookup
//- Lookup a given name and return IOobject ptr if found else nullptr //- Lookup a given name and return IOobject ptr if found else nullptr
IOobject* lookup(const word& name) const; IOobject* lookup(const word& name) const;
@ -99,12 +110,94 @@ public:
IOobjectList lookup(const wordRe& matcher) const; IOobjectList lookup(const wordRe& matcher) const;
//- The list of all IOobjects with matching names //- 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 //- The list of all IOobjects with the given class name
IOobjectList lookupClass(const word& clsName) const; 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 //- A list of names of the IOobjects
wordList names() const; wordList names() const;
@ -117,9 +210,11 @@ public:
//- The names of IOobjects with the given class name that also //- The names of IOobjects with the given class name that also
// have a name satisfying the input matcher // 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 //- A sorted list of names of the IOobjects
wordList sortedNames() const; wordList sortedNames() const;
@ -132,11 +227,12 @@ public:
//- The sorted names of IOobjects with the given class name that also //- The sorted names of IOobjects with the given class name that also
// have a name satisfying the input matcher // have a name satisfying the input matcher
wordList sortedNames wordList sortedNames(const word& clsName, const wordRes& matcher) const;
(
const word& clsName,
const wordReList& matcher // Ostream Operator
) const;
friend Ostream& operator<<(Ostream& os, const IOobjectList& list);
}; };

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