From 91aba2db2ecba575d4241198a75ff3ee983ee421 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 15 May 2016 16:40:01 +0100 Subject: [PATCH] functionObjects: rewritten to all be derived from 'functionObject' - Avoids the need for the 'OutputFilterFunctionObject' wrapper - Time-control for execution and writing is now provided by the 'timeControlFunctionObject' which instantiates the processing 'functionObject' and controls its operation. - Alternative time-control functionObjects can now be written and selected at run-time without the need to compile wrapped version of EVERY existing functionObject which would have been required in the old structure. - The separation of 'execute' and 'write' functions is now formalized in the 'functionObject' base-class and all derived classes implement the two functions. - Unnecessary implementations of functions with appropriate defaults in the 'functionObject' base-class have been removed reducing clutter and simplifying implementation of new functionObjects. - The 'coded' 'functionObject' has also been updated, simplified and tested. - Further simplification is now possible by creating some general intermediate classes derived from 'functionObject'. --- .../dataConversion/foamToVTK/Make/options | 6 +- .../foamToVTK/foamToVTK/Make/files | 1 - .../foamToVTK/foamToVTK/Make/options | 6 +- .../foamToVTK/foamToVTK/writeVTK/writeVTK.C | 48 ++-- .../foamToVTK/foamToVTK/writeVTK/writeVTK.H | 50 +--- .../writeVTK/writeVTKFunctionObject.C | 46 ---- .../writeVTK/writeVTKFunctionObject.H | 54 ---- .../miscellaneous/dsmcFieldsCalc/Make/files | 3 - .../miscellaneous/dsmcFieldsCalc/Make/options | 15 -- .../dsmcFieldsCalc/dsmcFieldsCalc.C | 155 ----------- .../utilities/postProcessing/noise/noise.C | 2 +- .../FilterFunctionObjectTemplate.C | 65 ----- .../FilterFunctionObjectTemplate.H | 51 ---- .../dynamicCode/functionObjectTemplate.C | 69 ++++- .../dynamicCode/functionObjectTemplate.H | 45 +--- .../FUNCTIONOBJECTFunctionObject.H | 54 ---- .../OutputFilterFunctionObject.C | 245 ------------------ .../OutputFilterFunctionObject.H | 197 -------------- .../OutputFilterFunctionObjectI.H | 60 ----- .../functionObject/functionObject.C | 16 +- .../functionObject/functionObject.H | 19 +- .../functionObjectList/functionObjectList.C | 17 +- .../functionObjectList/functionObjectList.H | 9 +- .../writeFile.C} | 76 ++++-- .../writeFile.H} | 72 +++-- .../writeFileTemplates.C} | 2 +- .../writeFiles.C} | 76 ++---- .../writeFiles.H} | 49 ++-- .../functionObjects/field/Make/files | 26 +- .../functionObjects/field/div/div.C | 45 ++-- .../functionObjects/field/div/div.H | 57 +--- .../field/div/divFunctionObject.C | 42 --- .../field/div/divFunctionObject.H | 54 ---- .../{fieldAverage => }/fieldAverage.C | 57 ++-- .../{fieldAverage => }/fieldAverage.H | 51 +--- .../fieldAverageFunctionObject.C | 42 --- .../fieldAverageFunctionObject.H | 54 ---- .../fieldAverageTemplates.C | 0 .../fieldCoordinateSystemTransform.C | 61 +++-- .../fieldCoordinateSystemTransform.H | 49 +--- ...dCoordinateSystemTransformFunctionObject.C | 45 ---- ...dCoordinateSystemTransformFunctionObject.H | 56 ---- .../field/fieldMinMax/fieldMinMax.C | 118 ++++----- .../field/fieldMinMax/fieldMinMax.H | 73 ++---- .../fieldMinMax/fieldMinMaxFunctionObject.C | 42 --- .../fieldMinMax/fieldMinMaxFunctionObject.H | 54 ---- .../field/fieldValues/cellSource/cellSource.C | 50 +++- .../field/fieldValues/cellSource/cellSource.H | 51 ++-- .../cellSource/cellSourceFunctionObject.C | 46 ---- .../cellSource/cellSourceFunctionObject.H | 56 ---- .../field/fieldValues/faceSource/faceSource.C | 63 ++++- .../field/fieldValues/faceSource/faceSource.H | 97 ++++--- .../faceSource/faceSourceFunctionObject.C | 46 ---- .../faceSource/faceSourceFunctionObject.H | 56 ---- .../faceSource/faceSourceTemplates.C | 5 +- .../field/fieldValues/fieldValue/fieldValue.C | 88 ++++--- .../field/fieldValues/fieldValue/fieldValue.H | 158 +++++------ .../fieldValues/fieldValue/fieldValueI.H | 32 +-- .../fieldValues/fieldValue/fieldValueNew.C | 17 +- .../fieldValue/fieldValueTemplates.C | 4 +- .../fieldValueDelta/fieldValueDelta.C | 71 ++--- .../fieldValueDelta/fieldValueDelta.H | 52 +--- .../fieldValueDeltaFunctionObject.C | 46 ---- .../fieldValueDeltaFunctionObject.H | 56 ---- .../functionObjects/field/grad/grad.C | 45 ++-- .../functionObjects/field/grad/grad.H | 53 +--- .../field/grad/gradFunctionObject.C | 42 --- .../field/grad/gradFunctionObject.H | 54 ---- .../field/histogram/histogram.C | 40 ++- .../field/histogram/histogram.H | 57 +--- .../field/histogram/histogramFunctionObject.C | 46 ---- .../field/histogram/histogramFunctionObject.H | 54 ---- .../functionObjects/field/mag/mag.C | 45 ++-- .../functionObjects/field/mag/mag.H | 53 +--- .../field/mag/magFunctionObject.C | 42 --- .../field/mag/magFunctionObject.H | 54 ---- .../field/nearWallFields/nearWallFields.C | 52 ++-- .../field/nearWallFields/nearWallFields.H | 46 +--- .../nearWallFieldsFunctionObject.C | 46 ---- .../nearWallFieldsFunctionObject.H | 54 ---- .../field/processorField/processorField.C | 46 ++-- .../field/processorField/processorField.H | 54 +--- .../processorFieldFunctionObject.C | 42 --- .../processorFieldFunctionObject.H | 54 ---- .../field/readFields/readFields.C | 42 +-- .../field/readFields/readFields.H | 51 +--- .../readFields/readFieldsFunctionObject.C | 42 --- .../readFields/readFieldsFunctionObject.H | 54 ---- .../regionSizeDistribution.C | 57 ++-- .../regionSizeDistribution.H | 48 +--- .../regionSizeDistributionFunctionObject.C | 46 ---- .../regionSizeDistributionFunctionObject.H | 54 ---- .../field/streamLine/streamLine.C | 214 +++++++-------- .../field/streamLine/streamLine.H | 50 +--- .../streamLine/streamLineFunctionObject.C | 42 --- .../streamLine/streamLineFunctionObject.H | 54 ---- .../surfaceInterpolateFields.C | 58 +++-- .../surfaceInterpolateFields.H | 48 +--- .../surfaceInterpolateFieldsFunctionObject.C | 46 ---- .../surfaceInterpolateFieldsFunctionObject.H | 56 ---- .../wallBoundedStreamLine.C | 220 ++++++++-------- .../wallBoundedStreamLine.H | 51 +--- .../wallBoundedStreamLineFunctionObject.C | 42 --- .../wallBoundedStreamLineFunctionObject.H | 55 ---- .../functionObjects/forces/Make/files | 7 - .../forces/forceCoeffs/forceCoeffs.C | 46 ++-- .../forces/forceCoeffs/forceCoeffs.H | 24 +- .../forceCoeffs/forceCoeffsFunctionObject.C | 42 --- .../forceCoeffs/forceCoeffsFunctionObject.H | 54 ---- .../functionObjects/forces/forces/forces.C | 126 ++++----- .../functionObjects/forces/forces/forces.H | 80 ++---- .../forces/forces/forcesFunctionObject.C | 42 --- .../forces/forces/forcesFunctionObject.H | 54 ---- .../forces/pressureTools/pressureTools.C | 46 ++-- .../forces/pressureTools/pressureTools.H | 45 +--- .../pressureToolsFunctionObject.C | 42 --- .../pressureToolsFunctionObject.H | 54 ---- .../forces/wallShearStress/wallShearStress.C | 49 ++-- .../forces/wallShearStress/wallShearStress.H | 61 ++--- .../wallShearStressFunctionObject.C | 42 --- .../wallShearStressFunctionObject.H | 54 ---- .../functionObjects/lagrangian/Make/files | 1 - .../lagrangian/cloudInfo/cloudInfo.C | 50 ++-- .../lagrangian/cloudInfo/cloudInfo.H | 59 +---- .../cloudInfo/cloudInfoFunctionObject.C | 42 --- .../cloudInfo/cloudInfoFunctionObject.H | 54 ---- .../utilities/CourantNo/CourantNo.C | 49 ++-- .../utilities/CourantNo/CourantNo.H | 47 +--- .../CourantNo/CourantNoFunctionObject.C | 42 --- .../CourantNo/CourantNoFunctionObject.H | 54 ---- .../utilities/Lambda2/Lambda2.C | 50 ++-- .../utilities/Lambda2/Lambda2.H | 50 +--- .../utilities/Lambda2/Lambda2FunctionObject.C | 42 --- .../utilities/Lambda2/Lambda2FunctionObject.H | 54 ---- .../functionObjects/utilities/Make/files | 36 --- .../functionObjects/utilities/Peclet/Peclet.C | 48 ++-- .../functionObjects/utilities/Peclet/Peclet.H | 47 +--- .../utilities/Peclet/PecletFunctionObject.C | 42 --- .../utilities/Peclet/PecletFunctionObject.H | 54 ---- .../functionObjects/utilities/Q/Q.C | 50 ++-- .../functionObjects/utilities/Q/Q.H | 50 +--- .../utilities/Q/QFunctionObject.C | 42 --- .../utilities/Q/QFunctionObject.H | 54 ---- .../functionObjects/utilities/abort/abort.C | 58 +++-- .../functionObjects/utilities/abort/abort.H | 52 +--- .../utilities/abort/abortFunctionObject.C | 42 --- .../utilities/abort/abortFunctionObject.H | 54 ---- .../utilities/blendingFactor/blendingFactor.C | 44 ++-- .../utilities/blendingFactor/blendingFactor.H | 53 +--- .../blendingFactorFunctionObject.C | 42 --- .../blendingFactorFunctionObject.H | 54 ---- .../codedFunctionObject/codedFunctionObject.C | 48 ++-- .../codedFunctionObject/codedFunctionObject.H | 13 +- .../utilities/dsmcFields/dsmcFields.C | 52 ++-- .../utilities/dsmcFields/dsmcFields.H | 49 +--- .../dsmcFields/dsmcFieldsFunctionObject.C | 42 --- .../dsmcFields/dsmcFieldsFunctionObject.H | 54 ---- .../utilities/partialWrite/partialWrite.C | 48 ++-- .../utilities/partialWrite/partialWrite.H | 61 ++--- .../partialWrite/partialWriteFunctionObject.C | 46 ---- .../partialWrite/partialWriteFunctionObject.H | 36 +-- .../removeRegisteredObject.C | 53 ++-- .../removeRegisteredObject.H | 60 +---- .../removeRegisteredObjectFunctionObject.C | 46 ---- .../removeRegisteredObjectFunctionObject.H | 54 ---- .../utilities/residuals/residuals.C | 52 ++-- .../utilities/residuals/residuals.H | 71 ++--- .../residuals/residualsFunctionObject.C | 42 --- .../residuals/residualsFunctionObject.H | 54 ---- .../utilities/residuals/residualsTemplates.C | 2 - .../scalarTransport/scalarTransport.C | 52 ++-- .../scalarTransport/scalarTransport.H | 49 +--- .../scalarTransportFunctionObject.C | 42 --- .../scalarTransportFunctionObject.H | 54 ---- .../setTimeStep/setTimeStepFunctionObject.C | 46 +--- .../setTimeStep/setTimeStepFunctionObject.H | 45 +--- .../utilities/systemCall/systemCall.C | 35 ++- .../utilities/systemCall/systemCall.H | 48 +--- .../systemCall/systemCallFunctionObject.C | 42 --- .../systemCall/systemCallFunctionObject.H | 54 ---- .../timeActivatedFileUpdate.C | 48 ++-- .../timeActivatedFileUpdate.H | 53 +--- .../timeActivatedFileUpdateFunctionObject.C | 46 ---- .../timeActivatedFileUpdateFunctionObject.H | 54 ---- .../turbulenceFields/turbulenceFields.C | 52 ++-- .../turbulenceFields/turbulenceFields.H | 51 +--- .../turbulenceFieldsFunctionObject.C | 42 --- .../turbulenceFieldsFunctionObject.H | 54 ---- .../utilities/vorticity/vorticity.C | 50 ++-- .../utilities/vorticity/vorticity.H | 43 +-- .../vorticity/vorticityFunctionObject.C | 42 --- .../vorticity/vorticityFunctionObject.H | 54 ---- .../writeDictionary/writeDictionary.C | 52 ++-- .../writeDictionary/writeDictionary.H | 46 +--- .../writeDictionaryFunctionObject.C | 42 --- .../writeDictionaryFunctionObject.H | 54 ---- .../writeRegisteredObject.C | 59 +++-- .../writeRegisteredObject.H | 61 ++--- .../writeRegisteredObjectFunctionObject.C | 46 ---- .../writeRegisteredObjectFunctionObject.H | 54 ---- .../functionObjects/utilities/yPlus/yPlus.C | 52 ++-- .../functionObjects/utilities/yPlus/yPlus.H | 56 +--- .../utilities/yPlus/yPlusFunctionObject.C | 42 --- .../utilities/yPlus/yPlusFunctionObject.H | 54 ---- src/sampling/Make/files | 3 - src/sampling/Make/options | 2 + src/sampling/meshToMesh/meshToMesh.C | 10 +- src/sampling/probes/patchProbes.C | 40 ++- src/sampling/probes/patchProbes.H | 13 +- src/sampling/probes/probes.C | 102 +++++--- src/sampling/probes/probes.H | 41 ++- .../probesFunctionObject.C | 49 ---- .../probesFunctionObject.H | 55 ---- .../sampledSet/sampledSets/sampledSets.C | 80 ++++-- .../sampledSet/sampledSets/sampledSets.H | 38 ++- .../sampledSetsFunctionObject/sampledSetsDict | 34 --- .../sampledSetsFunctionObject.C | 42 --- .../sampledSetsFunctionObject.H | 54 ---- .../sampledSurfaces/sampledSurfaces.C | 75 ++++-- .../sampledSurfaces/sampledSurfaces.H | 40 ++- .../sampledSurfacesFunctionObject.C | 42 --- .../sampledSurfacesFunctionObject.H | 54 ---- .../moleFractions/moleFractions.C | 43 ++- .../moleFractions/moleFractions.H | 46 +--- .../moleFractionsFunctionObjects.C | 15 +- .../moleFractionsFunctionObjects.H | 10 +- .../potentialFoam/cylinder/system/controlDict | 12 +- .../engineFoam/kivaTest/system/controlDict | 4 + .../multiRegionHeater/Allrun | 2 +- .../motorBike/system/wallBoundedStreamLines | 3 + 230 files changed, 2731 insertions(+), 8756 deletions(-) delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H delete mode 100644 applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files delete mode 100644 applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options delete mode 100644 applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C delete mode 100644 etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.C delete mode 100644 etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.H delete mode 100644 etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.H delete mode 100644 src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C delete mode 100644 src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H delete mode 100644 src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H rename src/OpenFOAM/db/functionObjects/{functionObjectFile/functionObjectFile.C => writeFile/writeFile.C} (66%) rename src/OpenFOAM/db/functionObjects/{functionObjectFile/functionObjectFile.H => writeFile/writeFile.H} (73%) rename src/OpenFOAM/db/functionObjects/{functionObjectFile/functionObjectFileTemplates.C => writeFile/writeFileTemplates.C} (96%) rename src/OpenFOAM/db/functionObjects/{functionObjectFiles/functionObjectFiles.C => writeFiles/writeFiles.C} (73%) rename src/OpenFOAM/db/functionObjects/{functionObjectFiles/functionObjectFiles.H => writeFiles/writeFiles.H} (77%) delete mode 100644 src/postProcessing/functionObjects/field/div/divFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/div/divFunctionObject.H rename src/postProcessing/functionObjects/field/fieldAverage/{fieldAverage => }/fieldAverage.C (91%) rename src/postProcessing/functionObjects/field/fieldAverage/{fieldAverage => }/fieldAverage.H (88%) delete mode 100644 src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.H rename src/postProcessing/functionObjects/field/fieldAverage/{fieldAverage => }/fieldAverageTemplates.C (100%) delete mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/grad/gradFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/grad/gradFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/mag/magFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/mag/magFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/Q/QFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.H delete mode 100644 src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.C delete mode 100644 src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.H delete mode 100644 src/sampling/probes/probesFunctionObject/probesFunctionObject.C delete mode 100644 src/sampling/probes/probesFunctionObject/probesFunctionObject.H delete mode 100644 src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsDict delete mode 100644 src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C delete mode 100644 src/sampling/sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.H delete mode 100644 src/sampling/sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C delete mode 100644 src/sampling/sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.H diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options index 5980905c0..c2445fd54 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options @@ -2,11 +2,11 @@ EXE_INC = \ -IfoamToVTK/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lfoamToVTK \ - -lfiniteVolume \ + -ldynamicMesh \ -llagrangian \ - -lgenericPatchFields \ - -lmeshTools + -lgenericPatchFields diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files index c0df3f199..4deaaa68f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files @@ -10,6 +10,5 @@ vtkMesh.C vtkTopo.C writeVTK/writeVTK.C -writeVTK/writeVTKFunctionObject.C LIB = $(FOAM_LIBBIN)/libfoamToVTK diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/options b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/options index 12747a273..f10e4ec1d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/options @@ -1,10 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude LIB_LIBS = \ - -lfiniteVolume \ + -ldynamicMesh \ -llagrangian \ - -lgenericPatchFields \ - -lmeshTools + -lgenericPatchFields diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C index 9513a64a1..5cc6f2213 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.C @@ -28,6 +28,7 @@ License #include "Time.H" #include "vtkMesh.H" #include "internalWriter.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,6 +37,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(writeVTK, 0); + addToRunTimeSelectionTable(functionObject, writeVTK, dictionary); } } @@ -45,16 +47,22 @@ namespace functionObjects Foam::functionObjects::writeVTK::writeVTK ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& t, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + time_(t), + obr_ + ( + time_.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), objectNames_() { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -72,27 +80,23 @@ Foam::functionObjects::writeVTK::~writeVTK() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::writeVTK::read(const dictionary& dict) +bool Foam::functionObjects::writeVTK::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; + + return true; } -void Foam::functionObjects::writeVTK::execute() -{} - - -void Foam::functionObjects::writeVTK::end() -{} - - -void Foam::functionObjects::writeVTK::timeSet() -{} - - -void Foam::functionObjects::writeVTK::write() +bool Foam::functionObjects::writeVTK::execute(const bool postProcess) { - Info<< type() << " " << name_ << " output:" << nl; + return true; +} + + +bool Foam::functionObjects::writeVTK::write(const bool postProcess) +{ + Info<< type() << " " << name() << " output:" << nl; fvMesh& mesh = const_cast(refCast(obr_)); @@ -162,6 +166,8 @@ void Foam::functionObjects::writeVTK::write() writer.write(vsptf); writer.write(vstf); writer.write(vtf); + + return true; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H index d230d7726..2df7cb328 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTK.H @@ -55,7 +55,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles writeVTK.C @@ -66,8 +66,8 @@ SourceFiles #ifndef functionObjects_writeVTK_H #define functionObjects_writeVTK_H +#include "functionObject.H" #include "wordReList.H" -#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,10 +75,8 @@ namespace Foam { // Forward declaration of classes +class Time; class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -88,13 +86,15 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class writeVTK +: + public functionObject { // Private data - //- Name of this set of writeVTK - word name_; + //- Reference to the Time + const Time& time_; - //- Refererence to Db + //- Refererence to objectRegistry const objectRegistry& obr_; //- Names of objects @@ -121,14 +121,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary writeVTK ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& t, + const dictionary& ); @@ -138,34 +136,14 @@ public: // Member Functions - //- Return name of the writeVTK - virtual const word& name() const - { - return name_; - } - //- Read the writeVTK data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write the writeVTK - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C deleted file mode 100644 index 804d7156b..000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "writeVTKFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - writeVTKFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - writeVTKFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H deleted file mode 100644 index 7033928cc..000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeVTK/writeVTKFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::writeVTKFunctionObject - -Description - FunctionObject wrapper around writeVTK to allow them to be - created via the functions entry within controlDict. - -SourceFiles - writeVTKFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef writeVTKFunctionObject_H -#define writeVTKFunctionObject_H - -#include "writeVTK.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - writeVTKFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files deleted file mode 100644 index 5cba9c270..000000000 --- a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -dsmcFieldsCalc.C - -EXE = $(FOAM_APPBIN)/dsmcFieldsCalc diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options deleted file mode 100644 index 8411a01ed..000000000 --- a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/Make/options +++ /dev/null @@ -1,15 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/postProcessing/postCalc \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/lagrangian/basic/lnInclude \ - -I$(LIB_SRC)/postProcessing/functionObjects/utilities/lnInclude \ - -I$(LIB_SRC)/lagrangian/DSMC/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude - -EXE_LIBS = \ - $(FOAM_LIBBIN)/postCalc.o \ - -lmeshTools \ - -lfiniteVolume \ - -lutilityFunctionObjects \ - -llagrangian \ - -lDSMC diff --git a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C b/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C deleted file mode 100644 index ecd4b4f1e..000000000 --- a/applications/utilities/postProcessing/miscellaneous/dsmcFieldsCalc/dsmcFieldsCalc.C +++ /dev/null @@ -1,155 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Application - dsmcFieldsCalc - -Description - Calculate intensive fields (U and T) from averaged extensive fields from a - DSMC calculation. - -\*---------------------------------------------------------------------------*/ - -#include "calc.H" -#include "fvc.H" -#include "dsmcCloud.H" -#include "dsmcFields.H" -#include "IOobjectList.H" - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - template - bool addFieldsToList - ( - const fvMesh& mesh, - PtrList>& list, - const wordList& fieldNames - ) - { - typedef GeometricField fieldType; - - label index = 0; - forAll(fieldNames, i) - { - IOobject obj - ( - fieldNames[i], - mesh.time().timeName(), - mesh, - IOobject::MUST_READ - ); - - if (obj.headerOk() && obj.headerClassName() == fieldType::typeName) - { - list.set(index++, new fieldType(obj, mesh)); - } - else - { - Info<< "Could not find " << fieldNames[i] << endl; - - return false; - } - } - - return true; - } -} - - -void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) -{ - bool writeResults = !args.optionFound("noWrite"); - - wordList extensiveVSFNames - ( - IStringStream - ( - "( \ - rhoNMean \ - rhoMMean \ - linearKEMean \ - internalEMean \ - iDofMean \ - )" - )() - ); - - PtrList extensiveVSFs(extensiveVSFNames.size()); - - if - ( - !addFieldsToList - ( - mesh, - extensiveVSFs, - extensiveVSFNames - ) - ) - { - return; - } - - wordList extensiveVVFNames - ( - IStringStream - ( - "( \ - momentumMean \ - fDMean \ - )" - )() - ); - - PtrList extensiveVVFs(extensiveVVFNames.size()); - - if - ( - !addFieldsToList - ( - mesh, - extensiveVVFs, - extensiveVVFNames - ) - ) - { - return; - } - - functionObjects::dsmcFields dF - ( - "dsmcFieldsUtility", - mesh, - dictionary::null, - false - ); - - if (writeResults) - { - dF.write(); - } -} - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C index 24eda6383..323bfbf2b 100644 --- a/applications/utilities/postProcessing/noise/noise.C +++ b/applications/utilities/postProcessing/noise/noise.C @@ -82,7 +82,7 @@ SeeAlso #include "noiseFFT.H" #include "argList.H" #include "Time.H" -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "CSV.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.C b/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.C deleted file mode 100644 index 8d7d11a91..000000000 --- a/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.C +++ /dev/null @@ -1,65 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "FilterFunctionObjectTemplate.H" - -// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // - -extern "C" -{ - // dynamicCode: - // SHA1 = ${SHA1sum} - // - // unique function name that can be checked if the correct library version - // has been loaded - void ${typeName}_${SHA1sum}(bool load) - { - if (load) - { - // code that can be explicitly executed after loading - } - else - { - // code that can be explicitly executed before unloading - } - } -} - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(${typeName}FilterFunctionObject, 0); - - //addToRunTimeSelectionTable - addRemovableToRunTimeSelectionTable - ( - functionObject, - ${typeName}FilterFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.H b/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.H deleted file mode 100644 index 00239a941..000000000 --- a/etc/codeTemplates/dynamicCode/FilterFunctionObjectTemplate.H +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -Description - FunctionObject wrapper around functionObjectTemplate to allow them - to be created via the functions entry within controlDict. - -SourceFiles - FilterFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef FilterFunctionObject_H -#define FilterFunctionObject_H - -#include "functionObjectTemplate.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject<${typeName}FunctionObject> - ${typeName}FilterFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C index fae5975f5..28706d175 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C @@ -24,9 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "functionObjectTemplate.H" -#include "Time.H" #include "fvCFD.H" #include "unitConversion.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -37,6 +37,36 @@ namespace Foam defineTypeNameAndDebug(${typeName}FunctionObject, 0); +addRemovableToRunTimeSelectionTable +( + functionObject, + ${typeName}FunctionObject, + dictionary +); + + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +extern "C" +{ + // dynamicCode: + // SHA1 = ${SHA1sum} + // + // unique function name that can be checked if the correct library version + // has been loaded + void ${typeName}_${SHA1sum}(bool load) + { + if (load) + { + // code that can be explicitly executed after loading + } + else + { + // code that can be explicitly executed before unloading + } + } +} + // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // @@ -64,13 +94,18 @@ const fvMesh& ${typeName}FunctionObject::mesh() const ${typeName}FunctionObject::${typeName}FunctionObject ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr) + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) { read(dict); } @@ -84,7 +119,7 @@ ${typeName}FunctionObject::~${typeName}FunctionObject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void ${typeName}FunctionObject::read(const dictionary& dict) +bool ${typeName}FunctionObject::read(const dictionary& dict) { if (${verbose:-false}) { @@ -94,10 +129,12 @@ void ${typeName}FunctionObject::read(const dictionary& dict) //{{{ begin code ${codeRead} //}}} end code + + return true; } -void ${typeName}FunctionObject::execute() +bool ${typeName}FunctionObject::execute(const bool postProcess) { if (${verbose:-false}) { @@ -107,10 +144,12 @@ void ${typeName}FunctionObject::execute() //{{{ begin code ${codeExecute} //}}} end code + + return true; } -void ${typeName}FunctionObject::end() +bool ${typeName}FunctionObject::end() { if (${verbose:-false}) { @@ -120,10 +159,12 @@ void ${typeName}FunctionObject::end() //{{{ begin code ${codeEnd} //}}} end code + + return true; } -void ${typeName}FunctionObject::timeSet() +bool ${typeName}FunctionObject::timeSet() { if (${verbose:-false}) { @@ -133,10 +174,12 @@ void ${typeName}FunctionObject::timeSet() //{{{ begin codeTime ${codeTimeSet} //}}} end code + + return true; } -void ${typeName}FunctionObject::write() +bool ${typeName}FunctionObject::write(const bool postProcess) { if (${verbose:-false}) { @@ -146,11 +189,13 @@ void ${typeName}FunctionObject::write() //{{{ begin code ${code} //}}} end code + + return true; } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam - // ************************************************************************* // diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H index 60f04091a..32fcc6884 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H @@ -33,8 +33,7 @@ SourceFiles #ifndef functionObjectTemplate_H #define functionObjectTemplate_H -#include "stringList.H" -#include "pointField.H" +#include "functionObject.H" //{{{ begin codeInclude ${codeInclude} @@ -47,9 +46,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class fvMesh; /*---------------------------------------------------------------------------*\ @@ -57,13 +53,12 @@ class fvMesh; \*---------------------------------------------------------------------------*/ class ${typeName}FunctionObject +: + public functionObject { // Private data - //- Name of this set of system calls - word name_; - - //- Registry + //- Reference to the objectRegistry const objectRegistry& obr_; //{{{ begin codeData @@ -92,14 +87,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary ${typeName}FunctionObject ( const word& name, - const objectRegistry& unused, - const dictionary&, - const bool loadFromFilesUnused = false + const Time& runTime, + const dictionary& ); @@ -109,34 +102,20 @@ public: // Member Functions - //- Return name of the system call set - virtual const word& name() const - { - return name_; - } - //- Read the system calls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute the "executeCalls" at each time-step - virtual void execute(); + virtual bool execute(const bool postProcess = false); //- Execute the "endCalls" at the final time-loop - virtual void end(); + virtual bool end(); //- Write, execute the "writeCalls" - virtual void write(); + virtual bool write(const bool postProcess = false); //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool timeSet(); }; diff --git a/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.H b/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.H deleted file mode 100644 index 78e6a7f0b..000000000 --- a/etc/codeTemplates/functionObject/FUNCTIONOBJECTFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::FUNCTIONOBJECTFunctionObject - -Description - FunctionObject wrapper around FUNCTIONOBJECT to allow them to be - created via the functions entry within controlDict. - -SourceFiles - FUNCTIONOBJECTFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef FUNCTIONOBJECTFunctionObject_H -#define FUNCTIONOBJECTFunctionObject_H - -#include "FUNCTIONOBJECT.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - FUNCTIONOBJECTFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C deleted file mode 100644 index 459bc5492..000000000 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ /dev/null @@ -1,245 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "OutputFilterFunctionObject.H" -#include "polyMesh.H" -#include "mapPolyMesh.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * Private Members * * * * * * * * * * * * * * // - -template -void Foam::OutputFilterFunctionObject::readControls() -{ - dict_.readIfPresent("timeStart", timeStart_); - dict_.readIfPresent("timeEnd", timeEnd_); - dict_.readIfPresent("nStepsToStartTimeChange", nStepsToStartTimeChange_); -} - - -template -bool Foam::OutputFilterFunctionObject::active() const -{ - return - time_.value() >= timeStart_ - && time_.value() <= timeEnd_; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::OutputFilterFunctionObject::OutputFilterFunctionObject -( - const word& name, - const Time& t, - const dictionary& dict -) -: - functionObject(name), - time_(t), - dict_(dict), - timeStart_(-VGREAT), - timeEnd_(VGREAT), - nStepsToStartTimeChange_ - ( - dict.lookupOrDefault("nStepsToStartTimeChange", 3) - ), - writeControl_(t, dict, "write"), - evaluateControl_(t, dict, "evaluate"), - filter_ - ( - name, - time_.lookupObject - ( - dict.lookupOrDefault("region", polyMesh::defaultRegion) - ), - dict_ - ) -{ - readControls(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -bool Foam::OutputFilterFunctionObject::execute -( - const bool postProcess -) -{ - if (active()) - { - if (postProcess || evaluateControl_.execute()) - { - filter_.execute(); - } - } - - return true; -} - - -template -bool Foam::OutputFilterFunctionObject::write -( - const bool postProcess -) -{ - if (active()) - { - if (postProcess || writeControl_.execute()) - { - filter_.write(); - } - } - - return true; -} - - -template -bool Foam::OutputFilterFunctionObject::end() -{ - filter_.end(); - - if (writeControl_.execute()) - { - filter_.write(); - } - - return true; -} - - -template -bool Foam::OutputFilterFunctionObject::timeSet() -{ - if (active()) - { - filter_.timeSet(); - } - - return true; -} - - -template -bool Foam::OutputFilterFunctionObject::adjustTimeStep() -{ - if - ( - active() - && writeControl_.control() - == timeControl::ocAdjustableRunTime - ) - { - const label writeTimeIndex = writeControl_.executionIndex(); - const scalar writeInterval = writeControl_.interval(); - - scalar timeToNextWrite = max - ( - 0.0, - (writeTimeIndex + 1)*writeInterval - - (time_.value() - time_.startTime().value()) - ); - - scalar deltaT = time_.deltaTValue(); - - scalar nSteps = timeToNextWrite/deltaT - SMALL; - - // functionObjects modify deltaT within nStepsToStartTimeChange - // NOTE: Potential problems arise if two function objects dump within - // the same interval - if (nSteps < nStepsToStartTimeChange_) - { - label nStepsToNextWrite = label(nSteps) + 1; - - scalar newDeltaT = timeToNextWrite/nStepsToNextWrite; - - // Adjust time step - if (newDeltaT < deltaT) - { - deltaT = max(newDeltaT, 0.2*deltaT); - const_cast(time_).setDeltaT(deltaT, false); - } - } - } - - return true; -} - - -template -bool Foam::OutputFilterFunctionObject::read -( - const dictionary& dict -) -{ - if (dict != dict_) - { - dict_ = dict; - - writeControl_.read(dict); - evaluateControl_.read(dict); - readControls(); - - return true; - } - else - { - return false; - } -} - - -template -void Foam::OutputFilterFunctionObject::updateMesh -( - const mapPolyMesh& mpm -) -{ - if (active()) - { - filter_.updateMesh(mpm); - } -} - - -template -void Foam::OutputFilterFunctionObject::movePoints -( - const polyMesh& mesh -) -{ - if (active()) - { - filter_.movePoints(mesh); - } -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H deleted file mode 100644 index 6aa998052..000000000 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ /dev/null @@ -1,197 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Class - Foam::OutputFilterFunctionObject - -Description - A functionObject wrapper around OutputFilter to allow them to be - created via the functions entry within controlDict. - -Note - Since the timeIndex is used directly from Foam::Time, it is unaffected - by user-time conversions. For example, Foam::engineTime might cause \a - writeInterval to be degrees crank angle, but the functionObject - execution \a interval would still be in timestep. - -SourceFiles - OutputFilterFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef OutputFilterFunctionObject_H -#define OutputFilterFunctionObject_H - -#include "functionObject.H" -#include "dictionary.H" -#include "timeControl.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class OutputFilterFunctionObject Declaration -\*---------------------------------------------------------------------------*/ - -template -class OutputFilterFunctionObject -: - public functionObject -{ - // Private data - - //- Reference to the time database - const Time& time_; - - //- Input dictionary - dictionary dict_; - - - // Optional user inputs - - //- Activation time - defaults to -VGREAT - scalar timeStart_; - - //- De-activation time - defaults to VGREAT - scalar timeEnd_; - - //- Number of steps before the dump-time during which deltaT - // may be changed (valid for adjustableRunTime) - label nStepsToStartTimeChange_; - - - //- Output controls - timeControl writeControl_; - - //- Evaluate controls - timeControl evaluateControl_; - - //- The output filter - OutputFilter filter_; - - - // Private Member Functions - - //- Read relevant dictionary entries - void readControls(); - - //- Returns true if within time bounds - bool active() const; - - //- Disallow default bitwise copy construct - OutputFilterFunctionObject(const OutputFilterFunctionObject&); - - //- Disallow default bitwise assignment - void operator=(const OutputFilterFunctionObject&); - - -public: - - //- Runtime type information - TypeName(OutputFilter::typeName_()); - - - // Constructors - - //- Construct from components - OutputFilterFunctionObject - ( - const word& name, - const Time&, - const dictionary& - ); - - - // Member Functions - - // Access - - //- Return time database - inline const Time& time() const; - - //- Return the input dictionary - inline const dictionary& dict() const; - - //- Return the region name - inline const word& regionName() const; - - //- Return the output control object - inline const timeControl& writeControl() const; - - //- Return the output filter - inline const OutputFilter& outputFilter() const; - - - // Function object control - - //- Called at each ++ or += of the time-loop. - // postProcess overrides the usual executeControl behaviour and - // forces execution (used in post-processing mode) - virtual bool execute(const bool postProcess = false); - - //- Called at each ++ or += of the time-loop. - // postProcess overrides the usual writeControl behaviour and - // forces writing (used in post-processing mode) - virtual bool write(const bool postProcess = false); - - //- Called when Time::run() determines that the time-loop exits - virtual bool end(); - - //- Called when time was set at the end of the Time::operator++ - virtual bool timeSet(); - - //- Called at the end of Time::adjustDeltaT() if adjustTime is true - virtual bool adjustTimeStep(); - - //- Read and set the function object if its data have changed - virtual bool read(const dictionary&); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh& mpm); - - //- Update for changes of mesh - virtual void movePoints(const polyMesh& mesh); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "OutputFilterFunctionObjectI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "OutputFilterFunctionObject.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H deleted file mode 100644 index 42ea890c8..000000000 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H +++ /dev/null @@ -1,60 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline const Foam::Time& -Foam::OutputFilterFunctionObject::time() const -{ - return time_; -} - - -template -inline const Foam::dictionary& -Foam::OutputFilterFunctionObject::dict() const -{ - return dict_; -} - - -template -inline const Foam::timeControl& -Foam::OutputFilterFunctionObject::writeControl() const -{ - return writeControl_; -} - - -template -inline const OutputFilter& -Foam::OutputFilterFunctionObject::outputFilter() const -{ - return filter_; -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index 07ad55ad9..791a8139b 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -51,10 +51,10 @@ Foam::autoPtr Foam::functionObject::New ( const word& name, const Time& t, - const dictionary& functionDict + const dictionary& dict ) { - const word functionType(functionDict.lookup("type")); + const word functionType(dict.lookup("type")); if (debug) { @@ -63,7 +63,7 @@ Foam::autoPtr Foam::functionObject::New const_cast(t).libs().open ( - functionDict, + dict, "functionObjectLibs", dictionaryConstructorTablePtr_ ); @@ -90,7 +90,7 @@ Foam::autoPtr Foam::functionObject::New << exit(FatalError); } - return autoPtr(cstrIter()(name, t, functionDict)); + return autoPtr(cstrIter()(name, t, dict)); } @@ -126,4 +126,12 @@ bool Foam::functionObject::adjustTimeStep() } +void Foam::functionObject::updateMesh(const mapPolyMesh&) +{} + + +void Foam::functionObject::movePoints(const polyMesh&) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 2b2a0c94d..e730c2a6f 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -99,7 +99,8 @@ Description Abstract base-class for Time/database function objects. See Also - Foam::OutputFilterFunctionObject + Foam::functionObjectList + Foam::functionObjects::timeControl SourceFiles functionObject.C @@ -194,8 +195,11 @@ public: // Member Functions - //- Name - virtual const word& name() const; + //- Return the name of this functionObject + const word& name() const; + + //- Read and set the function object if its data have changed + virtual bool read(const dictionary&) = 0; //- Called at each ++ or += of the time-loop. // postProcess overrides the usual executeControl behaviour and @@ -217,14 +221,11 @@ public: //- Called at the end of Time::adjustDeltaT() if adjustTime is true virtual bool adjustTimeStep(); - //- Read and set the function object if its data have changed - virtual bool read(const dictionary&) = 0; + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh& mpm); //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh& mpm) = 0; - - //- Update for changes of mesh - virtual void movePoints(const polyMesh& mesh) = 0; + virtual void movePoints(const polyMesh& mesh); }; diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 606ce67eb..0655deb73 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -27,6 +27,7 @@ License #include "Time.H" #include "mapPolyMesh.H" #include "argList.H" +#include "timeControlFunctionObject.H" // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -354,7 +355,21 @@ bool Foam::functionObjectList::read() FatalIOError.throwExceptions(); try { - foPtr = functionObject::New(key, time_, dict); + if + ( + dict.found("writeControl") + || dict.found("outputControl") + ) + { + foPtr.set + ( + new functionObjects::timeControl(key, time_, dict) + ); + } + else + { + foPtr = functionObject::New(key, time_, dict); + } } catch (Foam::IOerror& ioErr) { diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 686b5d239..17dab0083 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -29,7 +29,8 @@ Description that is called for each object. See Also - Foam::functionObject and Foam::OutputFilterFunctionObject + Foam::functionObject + Foam::functionObjects::timeControl SourceFiles functionObjectList.C @@ -158,6 +159,9 @@ public: //- Find the ID of a given function object by name label findObjectID(const word& name) const; + //- Read and set the function objects if their data have changed + bool read(); + //- Switch the function objects on void on(); @@ -184,9 +188,6 @@ public: //- Called at the end of Time::adjustDeltaT() if adjustTime is true bool adjustTimeStep(); - //- Read and set the function objects if their data have changed - bool read(); - //- Update for changes of mesh void updateMesh(const mapPolyMesh& mpm); diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C similarity index 66% rename from src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C rename to src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 748199713..b2434f0cb 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -23,27 +23,31 @@ License \*---------------------------------------------------------------------------*/ -#include "functionObjectFile.H" +#include "writeFile.H" #include "Time.H" #include "polyMesh.H" #include "IOmanip.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::word Foam::functionObjectFile::outputPrefix = "postProcessing"; -Foam::label Foam::functionObjectFile::addChars = 7; +const Foam::word Foam::functionObjects::writeFile::outputPrefix +( + "postProcessing" +); + +Foam::label Foam::functionObjects::writeFile::addChars = 7; // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::functionObjectFile::initStream(Ostream& os) const +void Foam::functionObjects::writeFile::initStream(Ostream& os) const { os.setf(ios_base::scientific, ios_base::floatfield); os.width(charWidth()); } -Foam::fileName Foam::functionObjectFile::baseFileDir() const +Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const { fileName baseDir = obr_.time().path(); @@ -72,17 +76,20 @@ Foam::fileName Foam::functionObjectFile::baseFileDir() const } -Foam::fileName Foam::functionObjectFile::baseTimeDir() const +Foam::fileName Foam::functionObjects::writeFile::baseTimeDir() const { return baseFileDir()/prefix_/obr_.time().timeName(); } -void Foam::functionObjectFile::writeFileHeader(const label i) +void Foam::functionObjects::writeFile::writeFileHeader(const label i) {} -Foam::Omanip Foam::functionObjectFile::valueWidth(const label offset) const +Foam::Omanip Foam::functionObjects::writeFile::valueWidth +( + const label offset +) const { return setw(IOstream::defaultPrecision() + addChars + offset); } @@ -90,32 +97,67 @@ Foam::Omanip Foam::functionObjectFile::valueWidth(const label offset) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::functionObjectFile::functionObjectFile +Foam::functionObjects::writeFile::writeFile ( - const objectRegistry& obr, + const word& name, + const Time& t, + const dictionary& dict, const word& prefix ) : + functionObject(name), + time_(t), + obr_ + ( + time_.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), + prefix_(prefix), + log_(true) +{} + + +Foam::functionObjects::writeFile::writeFile +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const word& prefix +) +: + functionObject(name), + time_(obr.time()), obr_(obr), - prefix_(prefix) + prefix_(prefix), + log_(true) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::functionObjectFile::~functionObjectFile() +Foam::functionObjects::writeFile::~writeFile() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::functionObjectFile::charWidth() const +bool Foam::functionObjects::writeFile::read(const dictionary& dict) +{ + log_ = dict.lookupOrDefault("log", true); + + return true; +} + + +Foam::label Foam::functionObjects::writeFile::charWidth() const { return IOstream::defaultPrecision() + addChars; } -void Foam::functionObjectFile::writeCommented +void Foam::functionObjects::writeFile::writeCommented ( Ostream& os, const string& str @@ -126,7 +168,7 @@ void Foam::functionObjectFile::writeCommented } -void Foam::functionObjectFile::writeTabbed +void Foam::functionObjects::writeFile::writeTabbed ( Ostream& os, const string& str @@ -136,7 +178,7 @@ void Foam::functionObjectFile::writeTabbed } -void Foam::functionObjectFile::writeHeader +void Foam::functionObjects::writeFile::writeHeader ( Ostream& os, const string& str @@ -147,7 +189,7 @@ void Foam::functionObjectFile::writeHeader } -void Foam::functionObjectFile::writeTime(Ostream& os) const +void Foam::functionObjects::writeFile::writeTime(Ostream& os) const { os << setw(charWidth()) << obr_.time().timeName(); } diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H similarity index 73% rename from src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H rename to src/OpenFOAM/db/functionObjects/writeFile/writeFile.H index a48747452..5c5f2df6e 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H @@ -22,10 +22,10 @@ License along with OpenFOAM. If not, see . Class - Foam::functionObjectFile + Foam::functionObjects::writeFile Description - Base class for output file data handling + functionObject base class for writing single files See Also Foam::functionObject @@ -36,34 +36,45 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef functionObjectFile_H -#define functionObjectFile_H +#ifndef functionObjects_writeFile_H +#define functionObjects_writeFile_H -#include "objectRegistry.H" +#include "functionObject.H" +#include "Time.H" #include "IOmanip.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +namespace functionObjects +{ /*---------------------------------------------------------------------------*\ Class functionObjectFile Declaration \*---------------------------------------------------------------------------*/ -class functionObjectFile +class writeFile +: + public functionObject { protected: // Protected data + //- Reference to the Time + const Time& time_; + //- Reference to the objectRegistry const objectRegistry& obr_; //- Prefix const word prefix_; + //- Switch to send output to Info as well as to file + Switch log_; + // Protected Member Functions @@ -83,10 +94,10 @@ protected: virtual Omanip valueWidth(const label offset = 0) const; //- Disallow default bitwise copy construct - functionObjectFile(const functionObjectFile&); + writeFile(const writeFile&); //- Disallow default bitwise assignment - void operator=(const functionObjectFile&); + void operator=(const writeFile&); public: @@ -100,36 +111,42 @@ public: // Constructors - //- Construct from objectRegistry - functionObjectFile(const objectRegistry& obr, const word& prefix); + //- Construct from name, Time, dictionary and prefix + writeFile + ( + const word& name, + const Time& t, + const dictionary& dict, + const word& prefix + ); + + //- Construct from name, objectRegistry, dictionary and prefix + writeFile + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const word& prefix + ); //- Destructor - virtual ~functionObjectFile(); + virtual ~writeFile(); // Member Functions + //- Read optional controls + virtual bool read(const dictionary&); + //- Write a commented string to stream - void writeCommented - ( - Ostream& os, - const string& str - ) const; + void writeCommented(Ostream& os, const string& str) const; //- Write a tabbed string to stream - void writeTabbed - ( - Ostream& os, - const string& str - ) const; + void writeTabbed(Ostream& os, const string& str) const; //- Write a commented header to stream - void writeHeader - ( - Ostream& os, - const string& str - ) const; + void writeHeader(Ostream& os, const string& str) const; //- Write the current time to stream void writeTime(Ostream& os) const; @@ -150,12 +167,13 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository - #include "functionObjectFileTemplates.C" + #include "writeFileTemplates.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFileTemplates.C similarity index 96% rename from src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C rename to src/OpenFOAM/db/functionObjects/writeFile/writeFileTemplates.C index d0acfb855..e5f7209b7 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFileTemplates.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFileTemplates.C @@ -26,7 +26,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -void Foam::functionObjectFile::writeHeaderValue +void Foam::functionObjects::writeFile::writeHeaderValue ( Ostream& os, const string& property, diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C b/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C similarity index 73% rename from src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C rename to src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C index efaf20902..c907c2f9b 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.C +++ b/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.C @@ -23,13 +23,13 @@ License \*---------------------------------------------------------------------------*/ -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "Time.H" #include "IFstream.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::functionObjectFiles::createFiles() +void Foam::functionObjects::writeFiles::createFiles() { if (Pstream::master()) { @@ -64,13 +64,13 @@ void Foam::functionObjectFiles::createFiles() } -void Foam::functionObjectFiles::write() +void Foam::functionObjects::writeFiles::write() { createFiles(); } -void Foam::functionObjectFiles::resetNames(const wordList& names) +void Foam::functionObjects::writeFiles::resetNames(const wordList& names) { names_.clear(); names_.append(names); @@ -79,13 +79,11 @@ void Foam::functionObjectFiles::resetNames(const wordList& names) { filePtrs_.clear(); filePtrs_.setSize(names_.size()); - - createFiles(); } } -void Foam::functionObjectFiles::resetName(const word& name) +void Foam::functionObjects::writeFiles::resetName(const word& name) { names_.clear(); names_.append(name); @@ -94,87 +92,55 @@ void Foam::functionObjectFiles::resetName(const word& name) { filePtrs_.clear(); filePtrs_.setSize(1); - - createFiles(); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::functionObjectFiles::functionObjectFiles +Foam::functionObjects::writeFiles::writeFiles ( - const objectRegistry& obr, + const word& name, + const Time& time, + const dictionary& dict, const word& prefix ) : - functionObjectFile(obr, prefix), + writeFile(name, time, dict, prefix), names_(), filePtrs_() {} -Foam::functionObjectFiles::functionObjectFiles +Foam::functionObjects::writeFiles::writeFiles ( + const word& name, const objectRegistry& obr, - const word& prefix, - const word& name + const dictionary& dict, + const word& prefix ) : - functionObjectFile(obr, prefix), + writeFile(name, obr, dict, prefix), names_(), filePtrs_() -{ - names_.clear(); - names_.append(name); - if (Pstream::master()) - { - filePtrs_.clear(); - filePtrs_.setSize(1); - - // Cannot create files - need to access virtual function - } -} - - -Foam::functionObjectFiles::functionObjectFiles -( - const objectRegistry& obr, - const word& prefix, - const wordList& names -) -: - functionObjectFile(obr, prefix), - names_(names), - filePtrs_() -{ - names_.clear(); - names_.append(names); - if (Pstream::master()) - { - filePtrs_.clear(); - filePtrs_.setSize(names_.size()); - - // Cannot create files - need to access virtual function - } -} +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::functionObjectFiles::~functionObjectFiles() +Foam::functionObjects::writeFiles::~writeFiles() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::wordList& Foam::functionObjectFiles::names() const +const Foam::wordList& Foam::functionObjects::writeFiles::names() const { return names_; } -Foam::OFstream& Foam::functionObjectFiles::file() +Foam::OFstream& Foam::functionObjects::writeFiles::file() { if (!Pstream::master()) { @@ -201,7 +167,7 @@ Foam::OFstream& Foam::functionObjectFiles::file() } -Foam::PtrList& Foam::functionObjectFiles::files() +Foam::PtrList& Foam::functionObjects::writeFiles::files() { if (!Pstream::master()) { @@ -214,7 +180,7 @@ Foam::PtrList& Foam::functionObjectFiles::files() } -Foam::OFstream& Foam::functionObjectFiles::file(const label i) +Foam::OFstream& Foam::functionObjects::writeFiles::file(const label i) { if (!Pstream::master()) { diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H b/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H similarity index 77% rename from src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H rename to src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H index cf29461ad..8d9831e0a 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFiles/functionObjectFiles.H +++ b/src/OpenFOAM/db/functionObjects/writeFiles/writeFiles.H @@ -22,10 +22,10 @@ License along with OpenFOAM. If not, see . Class - Foam::functionObjectFiles + Foam::functionObjects::writeFiles Description - Base class for output file data handling + functionObject base class for writing files See Also Foam::functionObject @@ -36,10 +36,10 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef functionObjectFiles_H -#define functionObjectFiles_H +#ifndef functionObjects_writeFiles_H +#define functionObjects_writeFiles_H -#include "functionObjectFile.H" +#include "writeFile.H" #include "OFstream.H" #include "PtrList.H" @@ -47,15 +47,16 @@ SourceFiles namespace Foam { - +namespace functionObjects +{ /*---------------------------------------------------------------------------*\ - Class functionObjectFiles Declaration + Class writeFiles Declaration \*---------------------------------------------------------------------------*/ -class functionObjectFiles +class writeFiles : - public functionObjectFile + public writeFile { // Private data @@ -83,38 +84,37 @@ protected: virtual void resetName(const word& name); //- Disallow default bitwise copy construct - functionObjectFiles(const functionObjectFiles&); + writeFiles(const writeFiles&); //- Disallow default bitwise assignment - void operator=(const functionObjectFiles&); + void operator=(const writeFiles&); public: // Constructors - //- Construct from objectRegistry - functionObjectFiles(const objectRegistry& obr, const word& prefix); - - //- Construct from components - functionObjectFiles + //- Construct from name, Time, dictionary and prefix + writeFiles ( - const objectRegistry& obr, - const word& prefix, - const word& name + const word& name, + const Time& time, + const dictionary& dict, + const word& prefix ); - //- Construct from components - functionObjectFiles + //- Construct from name, objectRegistry, dictionary and prefix + writeFiles ( + const word& name, const objectRegistry& obr, - const word& prefix, - const wordList& names + const dictionary& dict, + const word& prefix ); //- Destructor - virtual ~functionObjectFiles(); + virtual ~writeFiles(); // Member Functions @@ -135,6 +135,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index 0aa4a5184..f25f7d517 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -1,61 +1,39 @@ -fieldAverage/fieldAverage/fieldAverage.C +fieldAverage/fieldAverage.C fieldAverage/fieldAverageItem/fieldAverageItem.C fieldAverage/fieldAverageItem/fieldAverageItemIO.C -fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C -fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C - fieldMinMax/fieldMinMax.C -fieldMinMax/fieldMinMaxFunctionObject.C fieldValues/fieldValue/fieldValue.C fieldValues/fieldValue/fieldValueNew.C fieldValues/fieldValueDelta/fieldValueDelta.C -fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C -fieldValues/faceSource/faceSource.C -fieldValues/faceSource/faceSourceFunctionObject.C fieldValues/cellSource/cellSource.C -fieldValues/cellSource/cellSourceFunctionObject.C +fieldValues/faceSource/faceSource.C nearWallFields/nearWallFields.C -nearWallFields/nearWallFieldsFunctionObject.C nearWallFields/findCellParticle.C nearWallFields/findCellParticleCloud.C processorField/processorField.C -processorField/processorFieldFunctionObject.C - readFields/readFields.C -readFields/readFieldsFunctionObject.C streamLine/streamLine.C streamLine/streamLineParticle.C streamLine/streamLineParticleCloud.C -streamLine/streamLineFunctionObject.C wallBoundedStreamLine/wallBoundedStreamLine.C -wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C wallBoundedStreamLine/wallBoundedStreamLineParticle.C wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.C wallBoundedStreamLine/wallBoundedParticle.C surfaceInterpolateFields/surfaceInterpolateFields.C -surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C regionSizeDistribution/regionSizeDistribution.C -regionSizeDistribution/regionSizeDistributionFunctionObject.C - histogram/histogram.C -histogram/histogramFunctionObject.C div/div.C -div/divFunctionObject.C - grad/grad.C -grad/gradFunctionObject.C - mag/mag.C -mag/magFunctionObject.C LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects diff --git a/src/postProcessing/functionObjects/field/div/div.C b/src/postProcessing/functionObjects/field/div/div.C index 599bb1946..691ff862c 100644 --- a/src/postProcessing/functionObjects/field/div/div.C +++ b/src/postProcessing/functionObjects/field/div/div.C @@ -25,8 +25,7 @@ License #include "div.H" #include "volFields.H" -#include "dictionary.H" -#include "div.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(div, 0); + addToRunTimeSelectionTable(functionObject, div, dictionary); } } @@ -82,17 +82,22 @@ Foam::volScalarField& Foam::functionObjects::div::divField Foam::functionObjects::div::div ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldName_("undefined-fieldName"), resultName_("undefined-resultName") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -110,7 +115,7 @@ Foam::functionObjects::div::~div() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::div::read(const dictionary& dict) +bool Foam::functionObjects::div::read(const dictionary& dict) { dict.lookup("fieldName") >> fieldName_; dict.lookup("resultName") >> resultName_; @@ -119,10 +124,12 @@ void Foam::functionObjects::div::read(const dictionary& dict) { resultName_ = "fvc::div(" + fieldName_ + ")"; } + + return true; } -void Foam::functionObjects::div::execute() +bool Foam::functionObjects::div::execute(const bool postProcess) { bool processed = false; @@ -134,31 +141,25 @@ void Foam::functionObjects::div::execute() WarningInFunction << "Unprocessed field " << fieldName_ << endl; } + + return true; } -void Foam::functionObjects::div::end() -{ - execute(); -} - - -void Foam::functionObjects::div::timeSet() -{} - - -void Foam::functionObjects::div::write() +bool Foam::functionObjects::div::write(const bool postProcess) { if (obr_.foundObject(resultName_)) { const regIOobject& field = obr_.lookupObject(resultName_); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << field.name() << nl << endl; field.write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/field/div/div.H b/src/postProcessing/functionObjects/field/div/div.H index 4f7bed7ae..5d1df72c4 100644 --- a/src/postProcessing/functionObjects/field/div/div.H +++ b/src/postProcessing/functionObjects/field/div/div.H @@ -29,8 +29,8 @@ Group Description This function object calculates the divergence of a field. The operation is - limited to surfaceScalarFields and volumeVector fields, and the output is a - volume scalar field. + limited to surfaceScalarFields and volVectorFields, and the output is a + volScalarField. SourceFiles div.C @@ -40,11 +40,8 @@ SourceFiles #ifndef functionObjects_div_H #define functionObjects_div_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "pointFieldFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class dimensionSet; namespace functionObjects @@ -66,13 +60,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class div +: + public functionObject { // Private data - //- Name of this div object - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of field to process @@ -115,14 +108,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary div ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -132,34 +123,14 @@ public: // Member Functions - //- Return name of the set of div - virtual const word& name() const - { - return name_; - } - //- Read the div data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the divergence field + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the div and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the divergence field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/div/divFunctionObject.C b/src/postProcessing/functionObjects/field/div/divFunctionObject.C deleted file mode 100644 index 33c4d507a..000000000 --- a/src/postProcessing/functionObjects/field/div/divFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "divFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(divFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - divFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/div/divFunctionObject.H b/src/postProcessing/functionObjects/field/div/divFunctionObject.H deleted file mode 100644 index 4ca010f84..000000000 --- a/src/postProcessing/functionObjects/field/div/divFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::divFunctionObject - -Description - FunctionObject wrapper around div to allow it to be created - via the functions entry within controlDict. - -SourceFiles - divFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef divFunctionObject_H -#define divFunctionObject_H - -#include "div.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - divFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.C similarity index 91% rename from src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C rename to src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.C index adfad58cb..c87983263 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.C @@ -25,8 +25,8 @@ License #include "fieldAverage.H" #include "volFields.H" -#include "Time.H" #include "fieldAverageItem.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(fieldAverage, 0); + addToRunTimeSelectionTable(functionObject, fieldAverage, dictionary); } } @@ -68,7 +69,7 @@ void Foam::functionObjects::fieldAverage::initialize() { resetFields(); - Info<< type() << " " << name_ << ":" << nl; + Info<< type() << " " << name() << ":" << nl; // Add mean fields to the field lists forAll(faItems_, fieldi) @@ -136,7 +137,7 @@ void Foam::functionObjects::fieldAverage::calcAverages() periodIndex_++; } - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; Info<< " Calculating averages" << nl; @@ -259,13 +260,18 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties() Foam::functionObjects::fieldAverage::fieldAverage ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& t, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + t.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), prevTimeIndex_(-1), restartOnRestart_(false), restartOnOutput_(false), @@ -277,7 +283,7 @@ Foam::functionObjects::fieldAverage::fieldAverage totalTime_(), periodIndex_(1) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -295,11 +301,11 @@ Foam::functionObjects::fieldAverage::~fieldAverage() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldAverage::read(const dictionary& dict) +bool Foam::functionObjects::fieldAverage::read(const dictionary& dict) { initialised_ = false; - Info<< type() << " " << name_ << ":" << nl; + Info<< type() << " " << name() << ":" << nl; dict.readIfPresent("restartOnRestart", restartOnRestart_); dict.readIfPresent("restartOnOutput", restartOnOutput_); @@ -314,28 +320,21 @@ void Foam::functionObjects::fieldAverage::read(const dictionary& dict) readAveragingProperties(); Info<< endl; + + return true; } -void Foam::functionObjects::fieldAverage::execute() +bool Foam::functionObjects::fieldAverage::execute(const bool postProcess) { calcAverages(); Info<< endl; + + return true; } -void Foam::functionObjects::fieldAverage::end() -{ - calcAverages(); - Info<< endl; -} - - -void Foam::functionObjects::fieldAverage::timeSet() -{} - - -void Foam::functionObjects::fieldAverage::write() +bool Foam::functionObjects::fieldAverage::write(const bool postProcess) { writeAverages(); writeAveragingProperties(); @@ -346,15 +345,9 @@ void Foam::functionObjects::fieldAverage::write() } Info<< endl; + + return true; } -void Foam::functionObjects::fieldAverage::updateMesh(const mapPolyMesh&) -{} - - -void Foam::functionObjects::fieldAverage::movePoints(const polyMesh&) -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.H similarity index 88% rename from src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H rename to src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.H index cec06ebcf..a4bda83f3 100644 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.H +++ b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.H @@ -110,7 +110,6 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles fieldAverage.C @@ -122,7 +121,7 @@ SourceFiles #ifndef functionObjects_fieldAverage_H #define functionObjects_fieldAverage_H -#include "volFieldsFwd.H" +#include "functionObject.H" #include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -132,11 +131,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -template -class List; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -149,15 +143,14 @@ class fieldAverageItem; \*---------------------------------------------------------------------------*/ class fieldAverage +: + public functionObject { protected: // Protected data - //- Name of this set of field averages. - word name_; - - //- Database this class is registered to + //- Reference to the objectRegistry const objectRegistry& obr_; //- Time at last call, prevents repeated averaging @@ -291,14 +284,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary fieldAverage ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& t, + const dictionary& ); @@ -308,32 +299,14 @@ public: // Member Functions - //- Return name of the set of field averages - virtual const word& name() const - { - return name_; - } - //- Read the field average data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute the averaging - virtual void execute(); + //- Calculate the field averages + virtual bool execute(const bool postProcess = false); - //- Execute the averaging at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the field average data and write - virtual void write(); - - //- Update mesh - virtual void updateMesh(const mapPolyMesh&); - - //- Move points - virtual void movePoints(const polyMesh&); + //- Write the field averages + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C deleted file mode 100644 index 5ecd65a06..000000000 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "fieldAverageFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(fieldAverageFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - fieldAverageFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.H b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.H deleted file mode 100644 index 13e149175..000000000 --- a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::fieldAverageFunctionObject - -Description - FunctionObject wrapper around fieldAverage to allow them to be created - via the functions entry within controlDict. - -SourceFiles - fieldAverageFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fieldAverageFunctionObject_H -#define fieldAverageFunctionObject_H - -#include "fieldAverage.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - fieldAverageFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverageTemplates.C b/src/postProcessing/functionObjects/field/fieldAverage/fieldAverageTemplates.C similarity index 100% rename from src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverageTemplates.C rename to src/postProcessing/functionObjects/field/fieldAverage/fieldAverageTemplates.C diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C index 7359bea38..702d77983 100644 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C @@ -25,6 +25,7 @@ License #include "fieldCoordinateSystemTransform.H" #include "dictionary.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(fieldCoordinateSystemTransform, 0); + + addToRunTimeSelectionTable + ( + functionObject, + fieldCoordinateSystemTransform, + dictionary + ); } } @@ -43,17 +51,22 @@ Foam::functionObjects::fieldCoordinateSystemTransform:: fieldCoordinateSystemTransform ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_(), - coordSys_(obr, dict) + coordSys_(obr_, dict) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -61,7 +74,7 @@ fieldCoordinateSystemTransform read(dict); - Info<< type() << " " << name_ << ":" << nl + Info<< type() << " " << name << ":" << nl << " Applying transformation from global Cartesian to local " << coordSys_ << nl << endl; } @@ -76,18 +89,23 @@ Foam::functionObjects::fieldCoordinateSystemTransform:: // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldCoordinateSystemTransform::read +bool Foam::functionObjects::fieldCoordinateSystemTransform::read ( const dictionary& dict ) { dict.lookup("fields") >> fieldSet_; + + return true; } -void Foam::functionObjects::fieldCoordinateSystemTransform::execute() +bool Foam::functionObjects::fieldCoordinateSystemTransform::execute +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; forAll(fieldSet_, fieldi) { @@ -98,22 +116,17 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::execute() transform(fieldSet_[fieldi]); transform(fieldSet_[fieldi]); } + + return true; } -void Foam::functionObjects::fieldCoordinateSystemTransform::end() +bool Foam::functionObjects::fieldCoordinateSystemTransform::write +( + const bool postProcess +) { - execute(); -} - - -void Foam::functionObjects::fieldCoordinateSystemTransform::timeSet() -{} - - -void Foam::functionObjects::fieldCoordinateSystemTransform::write() -{ - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; forAll(fieldSet_, fieldi) { @@ -128,6 +141,8 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::write() } Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H index 4995caea3..23334db14 100644 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H @@ -64,7 +64,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject Foam::coordinateSystem SourceFiles @@ -76,9 +75,8 @@ SourceFiles #ifndef functionObjects_fieldCoordinateSystemTransform_H #define functionObjects_fieldCoordinateSystemTransform_H -#include "OFstream.H" -#include "volFields.H" -#include "surfaceFields.H" +#include "functionObject.H" +#include "volFieldsFwd.H" #include "coordinateSystem.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -88,9 +86,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -100,14 +95,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class fieldCoordinateSystemTransform +: + public functionObject { protected: // Protected data - //- Name - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; //- Fields to transform @@ -145,14 +140,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary fieldCoordinateSystemTransform ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -162,34 +155,14 @@ public: // Member Functions - //- Return name of the fieldCoordinateSystemTransform object - virtual const word& name() const - { - return name_; - } - //- Read the input data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C deleted file mode 100644 index be3f5624b..000000000 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C +++ /dev/null @@ -1,45 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "fieldCoordinateSystemTransformFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - fieldCoordinateSystemTransformFunctionObject, 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - fieldCoordinateSystemTransformFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H deleted file mode 100644 index aaa018733..000000000 --- a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::fieldCoordinateSystemTransformFunctionObject - -Description - FunctionObject wrapper around fieldCoordinateSystemTransform to allow - them to be created via the functions entry within controlDict. - -SourceFiles - fieldCoordinateSystemTransformFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fieldCoordinateSystemTransformFunctionObject_H -#define fieldCoordinateSystemTransformFunctionObject_H - -#include "fieldCoordinateSystemTransform.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::fieldCoordinateSystemTransform - > fieldCoordinateSystemTransformFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C index a0ab4def6..ec0d25ad1 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -25,6 +25,7 @@ License #include "fieldMinMax.H" #include "fieldTypes.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(fieldMinMax, 0); + addToRunTimeSelectionTable(functionObject, fieldMinMax, dictionary); } } @@ -50,51 +52,7 @@ const Foam::NamedEnum > Foam::functionObjects::fieldMinMax::modeTypeNames_; -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::functionObjects::fieldMinMax::fieldMinMax -( - const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles -) -: - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - log_(true), - location_(true), - mode_(mdMag), - fieldSet_() -{ - if (!isA(obr)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - - read(dict); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::fieldMinMax::~fieldMinMax() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::functionObjects::fieldMinMax::read(const dictionary& dict) -{ - log_ = dict.lookupOrDefault("log", true); - location_ = dict.lookupOrDefault("location", true); - - mode_ = modeTypeNames_[dict.lookupOrDefault("mode", "magnitude")]; - dict.lookup("fields") >> fieldSet_; -} - +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::functionObjects::fieldMinMax::writeFileHeader(const label i) { @@ -136,24 +94,64 @@ void Foam::functionObjects::fieldMinMax::writeFileHeader(const label i) } -void Foam::functionObjects::fieldMinMax::execute() -{} +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -void Foam::functionObjects::fieldMinMax::end() -{} - - -void Foam::functionObjects::fieldMinMax::timeSet() -{} - - -void Foam::functionObjects::fieldMinMax::write() +Foam::functionObjects::fieldMinMax::fieldMinMax +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + writeFiles(name, runTime, dict, name), + location_(true), + mode_(mdMag), + fieldSet_() { - functionObjectFiles::write(); + if (!isA(obr_)) + { + FatalErrorInFunction + << "objectRegistry is not an fvMesh" << exit(FatalError); + } + + read(dict); + resetName(typeName); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::fieldMinMax::~fieldMinMax() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict) +{ + writeFiles::read(dict); + + location_ = dict.lookupOrDefault("location", true); + + mode_ = modeTypeNames_[dict.lookupOrDefault("mode", "magnitude")]; + dict.lookup("fields") >> fieldSet_; + + return true; +} + + +bool Foam::functionObjects::fieldMinMax::execute(const bool postProcess) +{ + return true; +} + + +bool Foam::functionObjects::fieldMinMax::write(const bool postProcess) +{ + writeFiles::write(); if (!location_) writeTime(file()); - if (log_) Info<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name() << " output:" << nl; forAll(fieldSet_, fieldi) { @@ -166,6 +164,8 @@ void Foam::functionObjects::fieldMinMax::write() if (!location_) file()<< endl; if (log_) Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H index 2f47d58c9..45942bf2b 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H @@ -67,7 +67,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFiles SourceFiles fieldMinMax.C @@ -77,21 +77,13 @@ SourceFiles #ifndef functionObjects_fieldMinMax_H #define functionObjects_fieldMinMax_H -#include "functionObjectFiles.H" -#include "Switch.H" +#include "writeFiles.H" #include "vector.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -101,7 +93,7 @@ namespace functionObjects class fieldMinMax : - public functionObjectFiles + public writeFiles { public: @@ -118,15 +110,6 @@ protected: //- Mode type names static const NamedEnum modeTypeNames_; - //- Name of this set of field min/max - // Also used as the name of the output directory - word name_; - - const objectRegistry& obr_; - - //- Switch to send output to Info as well - Switch log_; - //- Switch to write location of min/max values Switch location_; @@ -159,6 +142,14 @@ protected: //- Disallow default bitwise assignment void operator=(const fieldMinMax&); + //- Calculate the field min/max + template + void calcMinMaxFields + ( + const word& fieldName, + const modeType& mode + ); + //- Output file header information virtual void writeFileHeader(const label i); @@ -171,14 +162,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary fieldMinMax ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -188,42 +177,14 @@ public: // Member Functions - //- Return name of the set of field min/max - virtual const word& name() const - { - return name_; - } - //- Read the field min/max data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the field min/max - template - void calcMinMaxFields - ( - const word& fieldName, - const modeType& mode - ); + virtual bool execute(const bool postProcess = false); //- Write the fieldMinMax - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.C deleted file mode 100644 index a7c16ea90..000000000 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "fieldMinMaxFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(fieldMinMaxFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - fieldMinMaxFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.H b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.H deleted file mode 100644 index dceaac3bd..000000000 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::fieldMinMaxFunctionObject - -Description - FunctionObject wrapper around fieldMinMax to allow them to be created via - the functions entry within controlDict. - -SourceFiles - fieldMinMaxFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fieldMinMaxFunctionObject_H -#define fieldMinMaxFunctionObject_H - -#include "fieldMinMax.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - fieldMinMaxFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C index 62e689185..b4fa18204 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C @@ -38,6 +38,7 @@ namespace fieldValues { defineTypeNameAndDebug(cellSource, 0); addToRunTimeSelectionTable(fieldValue, cellSource, dictionary); + addToRunTimeSelectionTable(functionObject, cellSource, dictionary); } } } @@ -149,14 +150,14 @@ void Foam::functionObjects::fieldValues::cellSource::initialise if (nCells_ == 0) { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Source has no cells" << exit(FatalError); } volume_ = volume(); - Info<< type() << " " << name_ << ":" + Info<< type() << " " << name() << ":" << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " total cells = " << nCells_ << nl << " total volume = " << volume_ @@ -205,12 +206,11 @@ void Foam::functionObjects::fieldValues::cellSource::writeFileHeader Foam::functionObjects::fieldValues::cellSource::cellSource ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - fieldValue(name, obr, dict, typeName, loadFromFiles), + fieldValue(name, runTime, dict, typeName), source_(sourceTypeNames_.read(dict.lookup("source"))), operation_(operationTypeNames_.read(dict.lookup("operation"))), nCells_(0), @@ -218,7 +218,32 @@ Foam::functionObjects::fieldValues::cellSource::cellSource weightFieldName_("none"), writeVolume_(dict.lookupOrDefault("writeVolume", false)) { - if (!isA(obr)) + if (!isA(obr_)) + { + FatalErrorInFunction + << "objectRegistry is not an fvMesh" << exit(FatalError); + } + + read(dict); +} + + +Foam::functionObjects::fieldValues::cellSource::cellSource +( + const word& name, + const objectRegistry& obr, + const dictionary& dict +) +: + fieldValue(name, obr, dict, typeName), + source_(sourceTypeNames_.read(dict.lookup("source"))), + operation_(operationTypeNames_.read(dict.lookup("operation"))), + nCells_(0), + cellId_(), + weightFieldName_("none"), + writeVolume_(dict.lookupOrDefault("writeVolume", false)) +{ + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -236,7 +261,7 @@ Foam::functionObjects::fieldValues::cellSource::~cellSource() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldValues::cellSource::read +bool Foam::functionObjects::fieldValues::cellSource::read ( const dictionary& dict ) @@ -245,10 +270,15 @@ void Foam::functionObjects::fieldValues::cellSource::read // No additional info to read initialise(dict); + + return true; } -void Foam::functionObjects::fieldValues::cellSource::write() +bool Foam::functionObjects::fieldValues::cellSource::write +( + const bool postProcess +) { fieldValue::write(); @@ -293,6 +323,8 @@ void Foam::functionObjects::fieldValues::cellSource::write() } if (log_) Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H index 20f984d2c..db529bd17 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H @@ -95,7 +95,6 @@ Description SeeAlso Foam::fieldValues Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles cellSource.C @@ -105,10 +104,8 @@ SourceFiles #ifndef functionObjects_cellSource_H #define functionObjects_cellSource_H -#include "NamedEnum.H" #include "fieldValue.H" -#include "labelList.H" -#include "volFieldsFwd.H" +#include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -241,13 +238,20 @@ public: // Constructors - //- Construct from components + //- Construct from name, Time and dictionary + cellSource + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- Construct from name, objectRegistry and dictionary cellSource ( const word& name, const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles = false + const dictionary& dict ); @@ -257,30 +261,25 @@ public: // Public Member Functions - // Access + //- Return the source type + inline const sourceType& source() const; - //- Return the source type - inline const sourceType& source() const; + //- Return the local list of cell IDs + inline const labelList& cellId() const; - //- Return the local list of cell IDs - inline const labelList& cellId() const; + //- Templated helper function to output field values + template + bool writeValues(const word& fieldName); + //- Filter a field according to cellIds + template + tmp> filterField(const Field& field) const; - // Function object functions + //- Read from dictionary + virtual bool read(const dictionary&); - //- Read from dictionary - virtual void read(const dictionary&); - - //- Calculate and write - virtual void write(); - - //- Templated helper function to output field values - template - bool writeValues(const word& fieldName); - - //- Filter a field according to cellIds - template - tmp> filterField(const Field& field) const; + //- Calculate and write + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C deleted file mode 100644 index 17a41c258..000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "cellSourceFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - cellSourceFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - cellSourceFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H deleted file mode 100644 index a136d782b..000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::cellSourceFunctionObject - -Description - FunctionObject wrapper around cellSource to allow it to be - created via the functions entry within controlDict. - -SourceFiles - cellSourceFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef cellSourceFunctionObject_H -#define cellSourceFunctionObject_H - -#include "cellSource.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::fieldValues::cellSource - > cellSourceFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index 48b8d37a4..3800b5545 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -44,6 +44,7 @@ namespace fieldValues { defineTypeNameAndDebug(faceSource, 0); addToRunTimeSelectionTable(fieldValue, faceSource, dictionary); + addToRunTimeSelectionTable(functionObject, faceSource, dictionary); } } } @@ -106,7 +107,7 @@ void Foam::functionObjects::fieldValues::faceSource::setFaceZoneFaces() if (zoneId < 0) { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unknown face zone name: " << sourceName_ << ". Valid face zones are: " << mesh().faceZones().names() @@ -191,7 +192,7 @@ void Foam::functionObjects::fieldValues::faceSource::setPatchFaces() if (patchid < 0) { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unknown patch name: " << sourceName_ << ". Valid patch names are: " @@ -228,7 +229,7 @@ void Foam::functionObjects::fieldValues::faceSource::sampledSurfaceFaces { surfacePtr_ = sampledSurface::New ( - name_, + name(), mesh(), dict.subDict("sampledSurfaceDict") ); @@ -443,7 +444,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise default: { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unknown source type. Valid source types are:" << sourceTypeNames_.sortedToc() << nl << exit(FatalError); @@ -453,7 +454,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise if (nFaces_ == 0) { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Source has no faces" << exit(FatalError); } @@ -465,7 +466,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise totalArea_ = totalArea(); - Info<< type() << " " << name_ << ":" << nl + Info<< type() << " " << name() << ":" << nl << " total faces = " << nFaces_ << nl << " total area = " << totalArea_ @@ -641,12 +642,11 @@ Foam::vector Foam::functionObjects::fieldValues::faceSource::processValues Foam::functionObjects::fieldValues::faceSource::faceSource ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - fieldValue(name, obr, dict, typeName, loadFromFiles), + fieldValue(name, runTime, dict, typeName), surfaceWriterPtr_(NULL), source_(sourceTypeNames_.read(dict.lookup("source"))), operation_(operationTypeNames_.read(dict.lookup("operation"))), @@ -660,7 +660,37 @@ Foam::functionObjects::fieldValues::faceSource::faceSource facePatchId_(), faceSign_() { - if (!isA(obr)) + if (!isA(obr_)) + { + FatalErrorInFunction + << "objectRegistry is not an fvMesh" << exit(FatalError); + } + + read(dict); +} + +Foam::functionObjects::fieldValues::faceSource::faceSource +( + const word& name, + const objectRegistry& obr, + const dictionary& dict +) +: + fieldValue(name, obr, dict, typeName), + surfaceWriterPtr_(NULL), + source_(sourceTypeNames_.read(dict.lookup("source"))), + operation_(operationTypeNames_.read(dict.lookup("operation"))), + weightFieldName_("none"), + orientWeightField_(false), + orientedFieldsStart_(labelMax), + scaleFactor_(1.0), + writeArea_(dict.lookupOrDefault("writeArea", false)), + nFaces_(0), + faceId_(), + facePatchId_(), + faceSign_() +{ + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -678,17 +708,22 @@ Foam::functionObjects::fieldValues::faceSource::~faceSource() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldValues::faceSource::read +bool Foam::functionObjects::fieldValues::faceSource::read ( const dictionary& dict ) { fieldValue::read(dict); initialise(dict); + + return true; } -void Foam::functionObjects::fieldValues::faceSource::write() +bool Foam::functionObjects::fieldValues::faceSource::write +( + const bool postProcess +) { fieldValue::write(); @@ -757,6 +792,8 @@ void Foam::functionObjects::fieldValues::faceSource::write() } if (log_) Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index 774fa516f..0d775f01e 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -128,7 +128,6 @@ Note SeeAlso Foam::fieldValues Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles faceSource.C @@ -139,11 +138,8 @@ SourceFiles #ifndef functionObjects_faceSource_H #define functionObjects_faceSource_H -#include "NamedEnum.H" #include "fieldValue.H" -#include "surfaceFieldsFwd.H" -#include "volFieldsFwd.H" -#include "surfaceWriter.H" +#include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -151,6 +147,7 @@ namespace Foam { class sampledSurface; +class surfaceWriter; namespace functionObjects { @@ -341,13 +338,20 @@ public: // Constructors - //- Construct from components + //- Construct from name, Time and dictionary + faceSource + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- Construct from name, objectRegistry and dictionary faceSource ( const word& name, const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles = false + const dictionary& dict ); @@ -357,57 +361,52 @@ public: // Public Member Functions - // Access + //- Return the source type + inline const sourceType& source() const; - //- Return the source type - inline const sourceType& source() const; + //- Return the local list of face IDs + inline const labelList& faceId() const; - //- Return the local list of face IDs - inline const labelList& faceId() const; + //- Return the local list of patch ID per face + inline const labelList& facePatch() const; - //- Return the local list of patch ID per face - inline const labelList& facePatch() const; + //- Return the list of +1/-1 representing face flip map + inline const labelList& faceSign() const; - //- Return the list of +1/-1 representing face flip map - inline const labelList& faceSign() const; + //- Templated helper function to output field values + template + bool writeValues + ( + const word& fieldName, + const scalarField& weightField, + const bool orient + ); + //- Filter a surface field according to faceIds + template + tmp> filterField + ( + const GeometricField& field, + const bool applyOrientation + ) const; - // Function object functions + //- Filter a volume field according to faceIds + template + tmp> filterField + ( + const GeometricField& field, + const bool applyOrientation + ) const; - //- Read from dictionary - virtual void read(const dictionary&); + //- Read from dictionary + virtual bool read(const dictionary&); - //- Calculate and write - virtual void write(); - - //- Templated helper function to output field values - template - bool writeValues - ( - const word& fieldName, - const scalarField& weightField, - const bool orient - ); - - //- Filter a surface field according to faceIds - template - tmp> filterField - ( - const GeometricField& field, - const bool applyOrientation - ) const; - - //- Filter a volume field according to faceIds - template - tmp> filterField - ( - const GeometricField& field, - const bool applyOrientation - ) const; + //- Calculate and write + virtual bool write(const bool postProcess = false); }; -//- Specialisation of processing scalars +//- Specialisation for scalar template<> scalar faceSource::processValues ( @@ -417,7 +416,7 @@ scalar faceSource::processValues ) const; -//- Specialisation of processing vectors +//- Specialisation for vector template<> vector faceSource::processValues ( diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C deleted file mode 100644 index cc79b73eb..000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "faceSourceFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - faceSourceFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - faceSourceFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H deleted file mode 100644 index e368ea942..000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::faceSourceFunctionObject - -Description - FunctionObject wrapper around faceSource to allow it to be - created via the functions entry within controlDict. - -SourceFiles - faceSourceFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef faceSourceFunctionObject_H -#define faceSourceFunctionObject_H - -#include "faceSource.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::fieldValues::faceSource - > faceSourceFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index e11317f57..a5047f249 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -27,6 +27,7 @@ License #include "surfaceFields.H" #include "volFields.H" #include "sampledSurface.H" +#include "surfaceWriter.H" #include "interpolationCellPoint.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -315,7 +316,7 @@ bool Foam::functionObjects::fieldValues::faceSource::writeValues if (Pstream::master()) { fileName outputDir = - baseFileDir()/name_/"surface"/obr_.time().timeName(); + baseFileDir()/name()/"surface"/obr_.time().timeName(); surfaceWriterPtr_->write ( @@ -375,7 +376,7 @@ Foam::functionObjects::fieldValues::faceSource::filterField else { FatalErrorInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unable to process internal faces for volume field " diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C index cc0121779..602e143fd 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -24,90 +24,96 @@ License \*---------------------------------------------------------------------------*/ #include "fieldValue.H" -#include "fvMesh.H" #include "Time.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam +{ +namespace functionObjects { defineTypeNameAndDebug(fieldValue, 0); defineRunTimeSelectionTable(fieldValue, dictionary); } - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -void Foam::fieldValue::read(const dictionary& dict) -{ - dict_ = dict; - - log_ = dict.lookupOrDefault("log", true); - dict.lookup("fields") >> fields_; - dict.lookup("valueOutput") >> valueOutput_; -} - - -void Foam::fieldValue::write() -{ - functionObjectFiles::write(); - - if (log_) Info<< type() << " " << name_ << " output:" << nl; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::fieldValue::fieldValue +Foam::functionObjects::fieldValue::fieldValue ( const word& name, - const objectRegistry& obr, + const Time& runTime, const dictionary& dict, - const word& valueType, - const bool loadFromFiles + const word& valueType ) : - functionObjectFiles(obr, name, valueType), - name_(name), - obr_(obr), + writeFiles(name, runTime, dict, name), dict_(dict), - log_(true), sourceName_(word::null), fields_(dict.lookup("fields")), valueOutput_(dict.lookup("valueOutput")), resultDict_(fileName("name"), dictionary::null) { read(dict); + resetName(valueType); +} + + +Foam::functionObjects::fieldValue::fieldValue +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const word& valueType +) +: + writeFiles(name, obr, dict, name), + dict_(dict), + sourceName_(word::null), + fields_(dict.lookup("fields")), + valueOutput_(dict.lookup("valueOutput")), + resultDict_(fileName("name"), dictionary::null) +{ + read(dict); + resetName(valueType); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::fieldValue::~fieldValue() +Foam::functionObjects::fieldValue::~fieldValue() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::fieldValue::execute() -{} +bool Foam::functionObjects::fieldValue::read(const dictionary& dict) +{ + dict_ = dict; + writeFiles::read(dict); + dict.lookup("fields") >> fields_; + dict.lookup("valueOutput") >> valueOutput_; + + return true; +} -void Foam::fieldValue::end() -{} +bool Foam::functionObjects::fieldValue::execute(const bool postProcess) +{ + return true; +} -void Foam::fieldValue::timeSet() -{} +bool Foam::functionObjects::fieldValue::write(const bool postProcess) +{ + writeFiles::write(); + if (log_) Info<< type() << " " << name() << " output:" << nl; -void Foam::fieldValue::updateMesh(const mapPolyMesh&) -{} - - -void Foam::fieldValue::movePoints(const polyMesh&) -{} + return true; +} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H index 399a2574e..450f0179d 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -38,12 +38,9 @@ SourceFiles #ifndef functionObjects_fieldValue_H #define functionObjects_fieldValue_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "Switch.H" -#include "OFstream.H" -#include "dictionary.H" #include "Field.H" -#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,10 +48,10 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; class fvMesh; -class polyMesh; -class mapPolyMesh; + +namespace functionObjects +{ /*---------------------------------------------------------------------------*\ Class fieldValue Declaration @@ -62,25 +59,16 @@ class mapPolyMesh; class fieldValue : - public functionObjectFiles + public writeFiles { protected: // Protected data - //- Name of this fieldValue object - word name_; - - //- Database this class is registered to - const objectRegistry& obr_; - //- Construction dictionary dictionary dict_; - //- Switch to send output to Info as well as to file - Switch log_; - //- Name of source object word sourceName_; @@ -94,6 +82,17 @@ protected: dictionary resultDict_; + // Protected Member Functions + + //- Combine fields from all processor domains into single field + template + void combineFields(Field& field); + + //- Combine fields from all processor domains into single field + template + void combineFields(tmp>&); + + public: //- Run-time type information @@ -109,103 +108,80 @@ public: ( const word& name, const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const dictionary& dict ), - (name, obr, dict, loadFromFiles) + (name, obr, dict) ); - //- Construct from components - fieldValue - ( - const word& name, - const objectRegistry& obr, - const dictionary& dict, - const word& valueType, - const bool loadFromFiles = false - ); - //- Return a reference to the selected fieldValue - static autoPtr New - ( - const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles = false, - const bool output = true - ); + // Constructors + + //- Construct from Time and dictionary + fieldValue + ( + const word& name, + const Time& runTime, + const dictionary& dict, + const word& valueType + ); + + //- Construct from objectRegistry and dictionary + fieldValue + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const word& valueType + ); + + //- Return a reference to the selected fieldValue + static autoPtr New + ( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool output = true + ); + //- Destructor virtual ~fieldValue(); - // Public Member Functions + // Member Functions - // Access + //- Return the reference to the construction dictionary + inline const dictionary& dict() const; - //- Return the name of the geometric source - inline const word& name() const; + //- Return the source name + inline const word& sourceName() const; - //- Return the reference to the object registry - inline const objectRegistry& obr() const; + //- Return the list of field names + inline const wordList& fields() const; - //- Return the reference to the construction dictionary - inline const dictionary& dict() const; + //- Return the output field values flag + inline const Switch& valueOutput() const; - //- Return the switch to send output to Info as well as to file - inline const Switch& log() const; + //- Helper function to return the reference to the mesh + inline const fvMesh& mesh() const; - //- Return the source name - inline const word& sourceName() const; + //- Return access to the latest set of results + inline const dictionary& resultDict() const; - //- Return the list of field names - inline const wordList& fields() const; + //- Read from dictionary + virtual bool read(const dictionary& dict); - //- Return the output field values flag - inline const Switch& valueOutput() const; + //- Execute + virtual bool execute(const bool postProcess = false); - //- Helper function to return the reference to the mesh - inline const fvMesh& mesh() const; - - //- Return access to the latest set of results - inline const dictionary& resultDict() const; - - - // Function object functions - - //- Read from dictionary - virtual void read(const dictionary& dict); - - //- Write to screen/file - virtual void write(); - - //- Execute - virtual void execute(); - - //- Execute the at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Update mesh - virtual void updateMesh(const mapPolyMesh&); - - //- Move points - virtual void movePoints(const polyMesh&); - - //- Combine fields from all processor domains into single field - template - void combineFields(Field& field); - - //- Combine fields from all processor domains into single field - template - void combineFields(tmp>&); + //- Write to screen/file + virtual bool write(const bool postProcess = false); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace functionObjects } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H index aac9ba419..a5e4c4711 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H @@ -28,55 +28,39 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline const Foam::word& Foam::fieldValue::name() const -{ - return name_; -} - - -inline const Foam::objectRegistry& Foam::fieldValue::obr() const -{ - return obr_; -} - - -inline const Foam::dictionary& Foam::fieldValue::dict() const +inline const Foam::dictionary& Foam::functionObjects::fieldValue::dict() const { return dict_; } -inline const Foam::Switch& Foam::fieldValue::log() const -{ - return log_; -} - - -inline const Foam::word& Foam::fieldValue::sourceName() const +inline const Foam::word& Foam::functionObjects::fieldValue::sourceName() const { return sourceName_; } -inline const Foam::wordList& Foam::fieldValue::fields() const +inline const Foam::wordList& Foam::functionObjects::fieldValue::fields() const { return fields_; } -inline const Foam::Switch& Foam::fieldValue::valueOutput() const +inline const Foam::Switch& +Foam::functionObjects::fieldValue::valueOutput() const { return valueOutput_; } -inline const Foam::fvMesh& Foam::fieldValue::mesh() const +inline const Foam::fvMesh& Foam::functionObjects::fieldValue::mesh() const { return refCast(obr_); } -inline const Foam::dictionary& Foam::fieldValue::resultDict() const +inline const Foam::dictionary& +Foam::functionObjects::fieldValue::resultDict() const { return resultDict_; } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C index 68f272127..07d96c8ba 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueNew.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,12 +27,12 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::autoPtr Foam::fieldValue::New +Foam::autoPtr +Foam::functionObjects::fieldValue::New ( const word& name, const objectRegistry& obr, const dictionary& dict, - const bool loadFromFiles, const bool output ) { @@ -56,16 +56,7 @@ Foam::autoPtr Foam::fieldValue::New << exit(FatalError); } - return autoPtr - ( - cstrIter() - ( - name, - obr, - dict, - loadFromFiles - ) - ); + return autoPtr(cstrIter()(name, obr, dict)); } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C index 78e3142bd..c772ba977 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C @@ -30,7 +30,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -void Foam::fieldValue::combineFields(Field& field) +void Foam::functionObjects::fieldValue::combineFields(Field& field) { List> allValues(Pstream::nProcs()); @@ -51,7 +51,7 @@ void Foam::fieldValue::combineFields(Field& field) template -void Foam::fieldValue::combineFields(tmp>& field) +void Foam::functionObjects::fieldValue::combineFields(tmp>& field) { combineFields(field()); } diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C index 1c4bda542..c0f78798a 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C @@ -24,10 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "fieldValueDelta.H" -#include "ListOps.H" -#include "Time.H" -#include "volFields.H" -#include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -38,6 +35,7 @@ namespace functionObjects namespace fieldValues { defineTypeNameAndDebug(fieldValueDelta, 0); + addToRunTimeSelectionTable(functionObject, fieldValueDelta, dictionary); } } } @@ -104,27 +102,23 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::writeFileHeader Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - loadFromFiles_(loadFromFiles), - log_(true), + writeFiles(name, runTime, dict, name), operation_(opSubtract), source1Ptr_(NULL), source2Ptr_(NULL) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); } read(dict); + resetName(typeName); } @@ -136,20 +130,20 @@ Foam::functionObjects::fieldValues::fieldValueDelta::~fieldValueDelta() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::fieldValues::fieldValueDelta::read +bool Foam::functionObjects::fieldValues::fieldValueDelta::read ( const dictionary& dict ) { - log_ = dict.lookupOrDefault("log", true); + writeFiles::read(dict); + source1Ptr_.reset ( fieldValue::New ( - name_ + ".source1", + name() + ".source1", obr_, dict.subDict("source1"), - loadFromFiles_, false ).ptr() ); @@ -157,21 +151,25 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::read ( fieldValue::New ( - name_ + ".source2", + name() + ".source2", obr_, dict.subDict("source2"), - loadFromFiles_, false ).ptr() ); operation_ = operationTypeNames_.read(dict.lookup("operation")); + + return true; } -void Foam::functionObjects::fieldValues::fieldValueDelta::write() +bool Foam::functionObjects::fieldValues::fieldValueDelta::write +( + const bool postProcess +) { - functionObjectFiles::write(); + writeFiles::write(); source1Ptr_->write(); source2Ptr_->write(); @@ -181,7 +179,7 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::write() writeTime(file()); } - if (log_) Info<< type() << " " << name_ << " output:" << endl; + if (log_) Info<< type() << " " << name() << " output:" << endl; bool found = false; processFields(found); @@ -206,33 +204,18 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::write() Info<< endl; } } + + return true; } -void Foam::functionObjects::fieldValues::fieldValueDelta::execute() -{} - - -void Foam::functionObjects::fieldValues::fieldValueDelta::end() -{} - - -void Foam::functionObjects::fieldValues::fieldValueDelta::timeSet() -{} - - -void Foam::functionObjects::fieldValues::fieldValueDelta::updateMesh +bool Foam::functionObjects::fieldValues::fieldValueDelta::execute ( - const mapPolyMesh& + const bool postProcess ) -{} - - -void Foam::functionObjects::fieldValues::fieldValueDelta::movePoints -( - const polyMesh& -) -{} +{ + return true; +} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H index dcb09c00c..f164c8f9e 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.H @@ -76,9 +76,8 @@ SourceFiles #ifndef functionObjects_fieldValueDelta_H #define functionObjects_fieldValueDelta_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "fieldValue.H" -#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,7 +94,7 @@ namespace fieldValues class fieldValueDelta : - public functionObjectFiles + public writeFiles { public: //- Operation type enumeration @@ -116,18 +115,6 @@ private: // Private data - //- Name of this fieldValue object - word name_; - - //- Database this class is registered to - const objectRegistry& obr_; - - //- Flag to indicate to load from files - bool loadFromFiles_; - - //- Switch to send output to Info as well as to file - Switch log_; - //- Operation to apply to values operationType operation_; @@ -151,7 +138,7 @@ private: protected: - // Functions to be over-ridden from IOoutputFilter class + // Protected Member Functions //- Output file header information virtual void writeFileHeader(const label i); @@ -165,13 +152,12 @@ public: // Constructors - //- Construct from components + //- Construct from Time and dictionary fieldValueDelta ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -181,28 +167,14 @@ public: // Public Member Functions - // Function object functions + //- Read from dictionary + virtual bool read(const dictionary&); - //- Read from dictionary - virtual void read(const dictionary&); + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Calculate and write - virtual void write(); - - //- Execute - virtual void execute(); - - //- Execute the at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Update mesh - virtual void updateMesh(const mapPolyMesh&); - - //- Move points - virtual void movePoints(const polyMesh&); + //- Calculate and write + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C deleted file mode 100644 index 7d093c378..000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "fieldValueDeltaFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - fieldValueDeltaFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - fieldValueDeltaFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.H deleted file mode 100644 index 3a54e034a..000000000 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::fieldValueDeltaFunctionObject - -Description - FunctionObject wrapper around fieldValueDelta to allow it to be - created via the functions entry within controlDict. - -SourceFiles - fieldValueDeltaFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fieldValueDeltaFunctionObject_H -#define fieldValueDeltaFunctionObject_H - -#include "fieldValueDelta.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::fieldValues::fieldValueDelta - > fieldValueDeltaFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/grad/grad.C b/src/postProcessing/functionObjects/field/grad/grad.C index 0fc2c7551..05e0b509b 100644 --- a/src/postProcessing/functionObjects/field/grad/grad.C +++ b/src/postProcessing/functionObjects/field/grad/grad.C @@ -25,8 +25,7 @@ License #include "grad.H" #include "volFields.H" -#include "dictionary.H" -#include "grad.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(grad, 0); + addToRunTimeSelectionTable(functionObject, grad, dictionary); } } @@ -44,17 +44,22 @@ namespace functionObjects Foam::functionObjects::grad::grad ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldName_("undefined-fieldName"), resultName_("undefined-resultName") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -72,7 +77,7 @@ Foam::functionObjects::grad::~grad() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::grad::read(const dictionary& dict) +bool Foam::functionObjects::grad::read(const dictionary& dict) { dict.lookup("fieldName") >> fieldName_; dict.lookup("resultName") >> resultName_; @@ -81,10 +86,12 @@ void Foam::functionObjects::grad::read(const dictionary& dict) { resultName_ = "fvc::grad(" + fieldName_ + ")"; } + + return true; } -void Foam::functionObjects::grad::execute() +bool Foam::functionObjects::grad::execute(const bool postProcess) { bool processed = false; @@ -96,31 +103,25 @@ void Foam::functionObjects::grad::execute() WarningInFunction << "Unprocessed field " << fieldName_ << endl; } + + return true; } -void Foam::functionObjects::grad::end() -{ - execute(); -} - - -void Foam::functionObjects::grad::timeSet() -{} - - -void Foam::functionObjects::grad::write() +bool Foam::functionObjects::grad::write(const bool postProcess) { if (obr_.foundObject(resultName_)) { const regIOobject& field = obr_.lookupObject(resultName_); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << field.name() << nl << endl; field.write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/field/grad/grad.H b/src/postProcessing/functionObjects/field/grad/grad.H index b7f3b6022..2d092f320 100644 --- a/src/postProcessing/functionObjects/field/grad/grad.H +++ b/src/postProcessing/functionObjects/field/grad/grad.H @@ -40,11 +40,8 @@ SourceFiles #ifndef functionObjects_grad_H #define functionObjects_grad_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "pointFieldFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class dimensionSet; namespace functionObjects @@ -66,13 +60,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class grad +: + public functionObject { // Private data - //- Name of this grad object - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of field to process @@ -118,14 +111,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary grad ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -135,34 +126,14 @@ public: // Member Functions - //- Return name of the set of grad - virtual const word& name() const - { - return name_; - } - //- Read the grad data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the gradient field + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the grad and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the gradient field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/grad/gradFunctionObject.C b/src/postProcessing/functionObjects/field/grad/gradFunctionObject.C deleted file mode 100644 index 9a04d4913..000000000 --- a/src/postProcessing/functionObjects/field/grad/gradFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "gradFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(gradFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - gradFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/grad/gradFunctionObject.H b/src/postProcessing/functionObjects/field/grad/gradFunctionObject.H deleted file mode 100644 index 776051beb..000000000 --- a/src/postProcessing/functionObjects/field/grad/gradFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::gradFunctionObject - -Description - FunctionObject wrapper around grad to allow it to be created - via the functions entry within controlDict. - -SourceFiles - gradFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef gradFunctionObject_H -#define gradFunctionObject_H - -#include "grad.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - gradFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/histogram/histogram.C b/src/postProcessing/functionObjects/field/histogram/histogram.C index d797d06f4..8463f6423 100644 --- a/src/postProcessing/functionObjects/field/histogram/histogram.C +++ b/src/postProcessing/functionObjects/field/histogram/histogram.C @@ -25,6 +25,7 @@ License #include "histogram.H" #include "volFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(histogram, 0); + addToRunTimeSelectionTable(functionObject, histogram, dictionary); } } @@ -69,15 +71,13 @@ void Foam::functionObjects::histogram::writeGraph Foam::functionObjects::histogram::histogram ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFile(obr, typeName), - name_(name) + writeFile(name, runTime, dict, name) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -95,7 +95,7 @@ Foam::functionObjects::histogram::~histogram() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::histogram::read(const dictionary& dict) +bool Foam::functionObjects::histogram::read(const dictionary& dict) { dict.lookup("field") >> fieldName_; dict.lookup("max") >> max_; @@ -104,24 +104,20 @@ void Foam::functionObjects::histogram::read(const dictionary& dict) word format(dict.lookup("setFormat")); formatterPtr_ = writer::New(format); + + return true; } -void Foam::functionObjects::histogram::execute() -{} - - -void Foam::functionObjects::histogram::end() -{} - - -void Foam::functionObjects::histogram::timeSet() -{} - - -void Foam::functionObjects::histogram::write() +bool Foam::functionObjects::histogram::execute(const bool postProcess) { - Info<< type() << " " << name_ << " output:" << nl; + return true; +} + + +bool Foam::functionObjects::histogram::write(const bool postProcess) +{ + Info<< type() << " " << name() << " output:" << nl; const fvMesh& mesh = refCast(obr_); @@ -201,6 +197,8 @@ void Foam::functionObjects::histogram::write() writeGraph(coords, field.name(), volFrac); } } + + return true; } diff --git a/src/postProcessing/functionObjects/field/histogram/histogram.H b/src/postProcessing/functionObjects/field/histogram/histogram.H index f1201bd37..48f8f2432 100644 --- a/src/postProcessing/functionObjects/field/histogram/histogram.H +++ b/src/postProcessing/functionObjects/field/histogram/histogram.H @@ -59,7 +59,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFile SourceFiles histogram.C @@ -70,19 +70,12 @@ SourceFiles #define functionObjects_histogram_H #include "writer.H" -#include "volFieldsFwd.H" -#include "functionObjectFile.H" +#include "writeFile.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class mapPolyMesh; -class polyMesh; - namespace functionObjects { @@ -92,13 +85,10 @@ namespace functionObjects class histogram : - public functionObjectFile + public writeFile { // Private data - //- Name of this histogram - word name_; - //- Name of field word fieldName_; @@ -139,52 +129,31 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary histogram ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); // Destructor - - virtual ~histogram(); + virtual ~histogram(); // Member Functions - //- Return name of the set of histogram - virtual const word& name() const - { - return name_; - } - //- Read the histogram data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the histogram and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Calculate the histogram and write. + // postProcess overrides the usual writeControl behaviour and + // forces writing always (used in post-processing mode) + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.C b/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.C deleted file mode 100644 index fbbcf34e4..000000000 --- a/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "histogramFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - histogramFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - histogramFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.H b/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.H deleted file mode 100644 index c246af837..000000000 --- a/src/postProcessing/functionObjects/field/histogram/histogramFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::histogramFunctionObject - -Description - FunctionObject wrapper around histogram to allow it to be - created via the functions list within controlDict. - -SourceFiles - histogramFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef histogramFunctionObject_H -#define histogramFunctionObject_H - -#include "histogram.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - histogramFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/mag/mag.C b/src/postProcessing/functionObjects/field/mag/mag.C index 9816f50df..a51aad91a 100644 --- a/src/postProcessing/functionObjects/field/mag/mag.C +++ b/src/postProcessing/functionObjects/field/mag/mag.C @@ -25,8 +25,7 @@ License #include "mag.H" #include "volFields.H" -#include "dictionary.H" -#include "mag.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(mag, 0); + addToRunTimeSelectionTable(functionObject, mag, dictionary); } } @@ -44,17 +44,22 @@ namespace functionObjects Foam::functionObjects::mag::mag ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldName_("undefined-fieldName"), resultName_("undefined-resultName") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -72,7 +77,7 @@ Foam::functionObjects::mag::~mag() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::mag::read(const dictionary& dict) +bool Foam::functionObjects::mag::read(const dictionary& dict) { dict.lookup("fieldName") >> fieldName_; dict.lookup("resultName") >> resultName_; @@ -81,10 +86,12 @@ void Foam::functionObjects::mag::read(const dictionary& dict) { resultName_ = "mag(" + fieldName_ + ")"; } + + return true; } -void Foam::functionObjects::mag::execute() +bool Foam::functionObjects::mag::execute(const bool postProcess) { bool processed = false; @@ -99,31 +106,25 @@ void Foam::functionObjects::mag::execute() WarningInFunction << "Unprocessed field " << fieldName_ << endl; } + + return true; } -void Foam::functionObjects::mag::end() -{ - execute(); -} - - -void Foam::functionObjects::mag::timeSet() -{} - - -void Foam::functionObjects::mag::write() +bool Foam::functionObjects::mag::write(const bool postProcess) { if (obr_.foundObject(resultName_)) { const regIOobject& field = obr_.lookupObject(resultName_); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << field.name() << nl << endl; field.write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/field/mag/mag.H b/src/postProcessing/functionObjects/field/mag/mag.H index 215b3c7ae..dd4dc1f4f 100644 --- a/src/postProcessing/functionObjects/field/mag/mag.H +++ b/src/postProcessing/functionObjects/field/mag/mag.H @@ -40,11 +40,8 @@ SourceFiles #ifndef functionObjects_mag_H #define functionObjects_mag_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "pointFieldFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class dimensionSet; namespace functionObjects @@ -66,13 +60,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class mag +: + public functionObject { // Private data - //- Name of this mag object - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of field to process @@ -112,14 +105,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary mag ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -129,34 +120,14 @@ public: // Member Functions - //- Return name of the set of mag - virtual const word& name() const - { - return name_; - } - //- Read the mag data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the magnitude field + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the mag and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the magnitude field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/mag/magFunctionObject.C b/src/postProcessing/functionObjects/field/mag/magFunctionObject.C deleted file mode 100644 index b615fb897..000000000 --- a/src/postProcessing/functionObjects/field/mag/magFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "magFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(magFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - magFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/mag/magFunctionObject.H b/src/postProcessing/functionObjects/field/mag/magFunctionObject.H deleted file mode 100644 index f518dd513..000000000 --- a/src/postProcessing/functionObjects/field/mag/magFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::magFunctionObject - -Description - FunctionObject wrapper around mag to allow it to be created - via the functions entry within controlDict. - -SourceFiles - magFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef magFunctionObject_H -#define magFunctionObject_H - -#include "mag.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - magFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C index a0549bfe6..2bf8fb253 100644 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C @@ -28,6 +28,7 @@ License #include "findCellParticle.H" #include "mappedPatchBase.H" #include "OBJstream.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,6 +37,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(nearWallFields, 0); + addToRunTimeSelectionTable(functionObject, nearWallFields, dictionary); } } @@ -224,16 +226,21 @@ void Foam::functionObjects::nearWallFields::calcAddressing() Foam::functionObjects::nearWallFields::nearWallFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_() { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -256,7 +263,7 @@ Foam::functionObjects::nearWallFields::~nearWallFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::nearWallFields::read(const dictionary& dict) +bool Foam::functionObjects::nearWallFields::read(const dictionary& dict) { if (debug) { @@ -295,15 +302,17 @@ void Foam::functionObjects::nearWallFields::read(const dictionary& dict) reverseFieldMap_.insert(sampleFldName, fldName); } - Info<< type() << " " << name_ << ": Sampling " << fieldMap_.size() + Info<< type() << " " << name() << ": Sampling " << fieldMap_.size() << " fields" << endl; // Do analysis calcAddressing(); + + return true; } -void Foam::functionObjects::nearWallFields::execute() +bool Foam::functionObjects::nearWallFields::execute(const bool postProcess) { if (debug) { @@ -320,7 +329,7 @@ void Foam::functionObjects::nearWallFields::execute() && vtf_.empty() ) { - Info<< type() << " " << name_ << ": Creating " << fieldMap_.size() + Info<< type() << " " << name() << ": Creating " << fieldMap_.size() << " fields" << endl; createFields(vsf_); @@ -332,7 +341,7 @@ void Foam::functionObjects::nearWallFields::execute() Info<< endl; } - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; Info<< " Sampling fields to " << obr_.time().timeName() << endl; @@ -342,25 +351,12 @@ void Foam::functionObjects::nearWallFields::execute() sampleFields(vSpheretf_); sampleFields(vSymmtf_); sampleFields(vtf_); + + return true; } -void Foam::functionObjects::nearWallFields::end() -{ - if (debug) - { - InfoInFunction << endl; - } - - execute(); -} - - -void Foam::functionObjects::nearWallFields::timeSet() -{} - - -void Foam::functionObjects::nearWallFields::write() +bool Foam::functionObjects::nearWallFields::write(const bool postProcess) { if (debug) { @@ -392,6 +388,8 @@ void Foam::functionObjects::nearWallFields::write() } Info<< endl; + + return true; } diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H index f6638756e..4ea6f13fd 100644 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H +++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.H @@ -62,7 +62,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles nearWallFields.C @@ -72,7 +71,7 @@ SourceFiles #ifndef functionObjects_nearWallFields_H #define functionObjects_nearWallFields_H -#include "OFstream.H" +#include "functionObject.H" #include "volFields.H" #include "Tuple2.H" #include "interpolationCellPoint.H" @@ -84,8 +83,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; namespace functionObjects { @@ -95,14 +92,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class nearWallFields +: + public functionObject { protected: // Protected data - //- Name of this set of nearWallFields object - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; // Read from dictionary @@ -191,9 +188,8 @@ public: nearWallFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -203,34 +199,14 @@ public: // Member Functions - //- Return name of the nearWallFields object - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the near-wall fields + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the near-wall fields + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C deleted file mode 100644 index 062354f52..000000000 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "nearWallFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - nearWallFieldsFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - nearWallFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H deleted file mode 100644 index 16146c153..000000000 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFieldsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::nearWallFieldsFunctionObject - -Description - FunctionObject wrapper around nearWallFields to allow - them to be created via the functions entry within controlDict. - -SourceFiles - nearWallFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef nearWallFieldsFunctionObject_H -#define nearWallFieldsFunctionObject_H - -#include "nearWallFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - nearWallFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/processorField/processorField.C b/src/postProcessing/functionObjects/field/processorField/processorField.C index 1647afa2e..3a0f57ed2 100644 --- a/src/postProcessing/functionObjects/field/processorField/processorField.C +++ b/src/postProcessing/functionObjects/field/processorField/processorField.C @@ -24,8 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "processorField.H" -#include "dictionary.H" -#include "Pstream.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(processorField, 0); + addToRunTimeSelectionTable(functionObject, processorField, dictionary); } } @@ -43,15 +44,20 @@ namespace functionObjects Foam::functionObjects::processorField::processorField ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr) + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -90,36 +96,32 @@ Foam::functionObjects::processorField::~processorField() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::processorField::read(const dictionary& dict) -{} +bool Foam::functionObjects::processorField::read(const dictionary& dict) +{ + return true; +} -void Foam::functionObjects::processorField::execute() +bool Foam::functionObjects::processorField::execute(const bool postProcess) { const volScalarField& procField = obr_.lookupObject("processorID"); const_cast(procField) == dimensionedScalar("proci", dimless, Pstream::myProcNo()); + + return true; } -void Foam::functionObjects::processorField::end() -{ - execute(); -} - - -void Foam::functionObjects::processorField::timeSet() -{} - - -void Foam::functionObjects::processorField::write() +bool Foam::functionObjects::processorField::write(const bool postProcess) { const volScalarField& procField = obr_.lookupObject("processorID"); procField.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/field/processorField/processorField.H b/src/postProcessing/functionObjects/field/processorField/processorField.H index 478a47184..5e9138f45 100644 --- a/src/postProcessing/functionObjects/field/processorField/processorField.H +++ b/src/postProcessing/functionObjects/field/processorField/processorField.H @@ -49,7 +49,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles processorField.C @@ -59,11 +58,7 @@ SourceFiles #ifndef functionObjects_processorField_H #define functionObjects_processorField_H -#include "OFstream.H" -#include "pointFieldFwd.H" -#include "volFields.H" -#include "surfaceFields.H" -#include "coordinateSystem.H" +#include "functionObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,8 +67,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; namespace functionObjects { @@ -83,15 +76,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class processorField +: + public functionObject { protected: // Protected data - //- Name of this set of nearWallFields object - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; @@ -114,14 +106,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary processorField ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -131,34 +121,14 @@ public: // Member Functions - //- Return name of the processorField object - virtual const word& name() const - { - return name_; - } - //- Read the input data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the processorID field + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the processorID field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.C b/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.C deleted file mode 100644 index 52fb9eafc..000000000 --- a/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "processorFieldFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(processorFieldFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - processorFieldFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.H b/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.H deleted file mode 100644 index 98d6b5f09..000000000 --- a/src/postProcessing/functionObjects/field/processorField/processorFieldFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::processorFieldFunctionObject - -Description - FunctionObject wrapper around processorField to allow - them to be created via the functions entry within controlDict. - -SourceFiles - processorFieldFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef processorFieldFunctionObject_H -#define processorFieldFunctionObject_H - -#include "processorField.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - processorFieldFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/readFields/readFields.C b/src/postProcessing/functionObjects/field/readFields/readFields.C index 4648c252b..6014a7d31 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFields.C +++ b/src/postProcessing/functionObjects/field/readFields/readFields.C @@ -24,7 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "readFields.H" -#include "dictionary.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +35,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(readFields, 0); + addToRunTimeSelectionTable(functionObject, readFields, dictionary); } } @@ -42,16 +45,21 @@ namespace functionObjects Foam::functionObjects::readFields::readFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_() { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -69,13 +77,15 @@ Foam::functionObjects::readFields::~readFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::readFields::read(const dictionary& dict) +bool Foam::functionObjects::readFields::read(const dictionary& dict) { dict.lookup("fields") >> fieldSet_; + + return true; } -void Foam::functionObjects::readFields::execute() +bool Foam::functionObjects::readFields::execute(const bool postProcess) { // Clear out any previously loaded fields vsf_.clear(); @@ -101,21 +111,15 @@ void Foam::functionObjects::readFields::execute() loadField(fieldName, vSymmtf_, sSymmtf_); loadField(fieldName, vtf_, stf_); } + + return true; } -void Foam::functionObjects::readFields::end() +bool Foam::functionObjects::readFields::write(const bool postProcess) { - execute(); + return true; } -void Foam::functionObjects::readFields::timeSet() -{} - - -void Foam::functionObjects::readFields::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/readFields/readFields.H b/src/postProcessing/functionObjects/field/readFields/readFields.H index ed6b0489f..d82ecdf44 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFields.H +++ b/src/postProcessing/functionObjects/field/readFields/readFields.H @@ -55,7 +55,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles readFields.C @@ -65,10 +64,9 @@ SourceFiles #ifndef functionObjects_readFields_H #define functionObjects_readFields_H -#include "OFstream.H" -#include "pointFieldFwd.H" -#include "volFields.H" -#include "surfaceFields.H" +#include "functionObject.H" +#include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -77,8 +75,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; namespace functionObjects { @@ -88,14 +84,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class readFields +: + public functionObject { protected: // Protected data - //- Name of this set of readFields object - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; //- Fields to load @@ -150,9 +146,8 @@ public: readFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -162,34 +157,14 @@ public: // Member Functions - //- Return name of the readFields object - virtual const word& name() const - { - return name_; - } - //- Read the set of fields from dictionary - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Read the fields + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.C deleted file mode 100644 index 31f2542eb..000000000 --- a/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "readFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(readFieldsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - readFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.H b/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.H deleted file mode 100644 index 0256ca3d5..000000000 --- a/src/postProcessing/functionObjects/field/readFields/readFieldsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::readFieldsFunctionObject - -Description - FunctionObject wrapper around readFields to allow them to be created via - the functions entry within controlDict. - -SourceFiles - readFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef readFieldsFunctionObject_H -#define readFieldsFunctionObject_H - -#include "readFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - readFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 7987c141b..2e869137b 100644 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -24,11 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "regionSizeDistribution.H" -#include "volFields.H" -#include "regionSplit.H" #include "fvcVolumeIntegrate.H" -#include "mathematicalConstants.H" -#include "stringListOps.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +34,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(regionSizeDistribution, 0); + + addToRunTimeSelectionTable + ( + functionObject, + regionSizeDistribution, + dictionary + ); } //- Plus op for FixedList @@ -322,18 +326,15 @@ void Foam::functionObjects::regionSizeDistribution::writeGraphs Foam::functionObjects::regionSizeDistribution::regionSizeDistribution ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), + writeFile(name, runTime, dict, name), alphaName_(dict.lookup("field")), patchNames_(dict.lookup("patches")) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -351,7 +352,7 @@ Foam::functionObjects::regionSizeDistribution::~regionSizeDistribution() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) +bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) { dict.lookup("field") >> alphaName_; dict.lookup("patches") >> patchNames_; @@ -372,24 +373,26 @@ void Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) Info<< "Transforming all vectorFields with coordinate system " << coordSysPtr_().name() << endl; } + + return true; } -void Foam::functionObjects::regionSizeDistribution::execute() -{} - - -void Foam::functionObjects::regionSizeDistribution::end() -{} - - -void Foam::functionObjects::regionSizeDistribution::timeSet() -{} - - -void Foam::functionObjects::regionSizeDistribution::write() +bool Foam::functionObjects::regionSizeDistribution::execute +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + return true; +} + + +bool Foam::functionObjects::regionSizeDistribution::write +( + const bool postProcess +) +{ + Info<< type() << " " << name() << " output:" << nl; const fvMesh& mesh = refCast(obr_); @@ -846,6 +849,8 @@ void Foam::functionObjects::regionSizeDistribution::write() } } } + + return true; } diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H index 18b4e36e2..039db7e35 100644 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H +++ b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.H @@ -96,7 +96,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFile SourceFiles regionSizeDistribution.C @@ -106,8 +106,7 @@ SourceFiles #ifndef functionObjects_regionSizeDistribution_H #define functionObjects_regionSizeDistribution_H -#include "functionObjectFiles.H" -#include "pointFieldFwd.H" +#include "writeFile.H" #include "writer.H" #include "Map.H" #include "volFieldsFwd.H" @@ -121,10 +120,7 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; class regionSplit; -class polyMesh; namespace functionObjects { @@ -135,15 +131,10 @@ namespace functionObjects class regionSizeDistribution : - public functionObjectFiles + public writeFile { // Private data - //- Name of this set of regionSizeDistribution objects - word name_; - - const objectRegistry& obr_; - //- Name of field word alphaName_; @@ -250,9 +241,8 @@ public: regionSizeDistribution ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -263,34 +253,14 @@ public: // Member Functions - //- Return name of the set of regionSizeDistribution - virtual const word& name() const - { - return name_; - } - //- Read the regionSizeDistribution data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + //- Do nothing + virtual bool execute(const bool postProcess = false); //- Calculate the regionSizeDistribution and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.C b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.C deleted file mode 100644 index 21e25fd6b..000000000 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "regionSizeDistributionFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - regionSizeDistributionFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - regionSizeDistributionFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.H b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.H deleted file mode 100644 index adb23034a..000000000 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistributionFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::regionSizeDistributionFunctionObject - -Description - FunctionObject wrapper around regionSizeDistribution to allow it to be - created via the functions list within controlDict. - -SourceFiles - regionSizeDistributionFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef regionSizeDistributionFunctionObject_H -#define regionSizeDistributionFunctionObject_H - -#include "regionSizeDistribution.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - regionSizeDistributionFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLine.C b/src/postProcessing/functionObjects/field/streamLine/streamLine.C index 84d985a1d..67d576f91 100644 --- a/src/postProcessing/functionObjects/field/streamLine/streamLine.C +++ b/src/postProcessing/functionObjects/field/streamLine/streamLine.C @@ -36,6 +36,7 @@ License #include "interpolationCellPoint.H" #include "PatchTools.H" #include "mapPolyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -44,6 +45,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(streamLine, 0); + addToRunTimeSelectionTable(functionObject, streamLine, dictionary); } } @@ -101,7 +103,6 @@ Foam::functionObjects::streamLine::wallPatch() const void Foam::functionObjects::streamLine::track() { - const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast(obr_); IDLList initialParticles; @@ -140,118 +141,76 @@ void Foam::functionObjects::streamLine::track() label UIndex = -1; - if (loadFromFiles_) + label nScalar = 0; + label nVector = 0; + + forAll(fields_, i) { - IOobjectList allObjects(mesh, runTime.timeName()); - - IOobjectList objects(2*fields_.size()); - forAll(fields_, i) + if (mesh.foundObject(fields_[i])) { - objects.add(*allObjects[fields_[i]]); + nScalar++; } - - ReadFields(mesh, objects, vsFlds); - vsInterp.setSize(vsFlds.size()); - forAll(vsFlds, i) + else if (mesh.foundObject(fields_[i])) { + nVector++; + } + else + { + FatalErrorInFunction + << "Cannot find field " << fields_[i] << nl + << "Valid scalar fields are:" + << mesh.names(volScalarField::typeName) << nl + << "Valid vector fields are:" + << mesh.names(volVectorField::typeName) + << exit(FatalError); + } + } + vsInterp.setSize(nScalar); + nScalar = 0; + vvInterp.setSize(nVector); + nVector = 0; + + forAll(fields_, i) + { + if (mesh.foundObject(fields_[i])) + { + const volScalarField& f = mesh.lookupObject + ( + fields_[i] + ); vsInterp.set ( - i, + nScalar++, interpolation::New ( interpolationScheme_, - vsFlds[i] + f ) ); } - ReadFields(mesh, objects, vvFlds); - vvInterp.setSize(vvFlds.size()); - forAll(vvFlds, i) + else if (mesh.foundObject(fields_[i])) { + const volVectorField& f = mesh.lookupObject + ( + fields_[i] + ); + + if (f.name() == UName_) + { + UIndex = nVector; + } + vvInterp.set ( - i, + nVector++, interpolation::New ( interpolationScheme_, - vvFlds[i] + f ) ); } } - else - { - label nScalar = 0; - label nVector = 0; - - forAll(fields_, i) - { - if (mesh.foundObject(fields_[i])) - { - nScalar++; - } - else if (mesh.foundObject(fields_[i])) - { - nVector++; - } - else - { - FatalErrorInFunction - << "Cannot find field " << fields_[i] << nl - << "Valid scalar fields are:" - << mesh.names(volScalarField::typeName) << nl - << "Valid vector fields are:" - << mesh.names(volVectorField::typeName) - << exit(FatalError); - } - } - vsInterp.setSize(nScalar); - nScalar = 0; - vvInterp.setSize(nVector); - nVector = 0; - - forAll(fields_, i) - { - if (mesh.foundObject(fields_[i])) - { - const volScalarField& f = mesh.lookupObject - ( - fields_[i] - ); - vsInterp.set - ( - nScalar++, - interpolation::New - ( - interpolationScheme_, - f - ) - ); - } - else if (mesh.foundObject(fields_[i])) - { - const volVectorField& f = mesh.lookupObject - ( - fields_[i] - ); - - if (f.name() == UName_) - { - UIndex = nVector; - } - - vvInterp.set - ( - nVector++, - interpolation::New - ( - interpolationScheme_, - f - ) - ); - } - } - } // Store the names scalarNames_.setSize(vsInterp.size()); @@ -327,18 +286,22 @@ void Foam::functionObjects::streamLine::track() Foam::functionObjects::streamLine::streamLine ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), dict_(dict), - name_(name), - obr_(obr), - loadFromFiles_(loadFromFiles), nSubCycle_(0) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -356,9 +319,9 @@ Foam::functionObjects::streamLine::~streamLine() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::streamLine::read(const dictionary& dict) +bool Foam::functionObjects::streamLine::read(const dictionary& dict) { - Info<< type() << " " << name_ << ":" << nl; + Info<< type() << " " << name() << ":" << nl; dict.lookup("fields") >> fields_; if (dict.found("UName")) @@ -455,24 +418,20 @@ void Foam::functionObjects::streamLine::read(const dictionary& dict) scalarFormatterPtr_ = writer::New(dict.lookup("setFormat")); vectorFormatterPtr_ = writer::New(dict.lookup("setFormat")); + + return true; } -void Foam::functionObjects::streamLine::execute() -{} - - -void Foam::functionObjects::streamLine::end() -{} - - -void Foam::functionObjects::streamLine::timeSet() -{} - - -void Foam::functionObjects::streamLine::write() +bool Foam::functionObjects::streamLine::execute(const bool postProcess) { - Info<< type() << " " << name_ << " output:" << nl; + return true; +} + + +bool Foam::functionObjects::streamLine::write(const bool postProcess) +{ + Info<< type() << " " << name() << " output:" << nl; const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast(obr_); @@ -527,41 +486,54 @@ void Foam::functionObjects::streamLine::write() // Distribute the track positions. Note: use scheduled comms // to prevent buffering. - mapDistribute::distribute + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allTracks_ + false, + allTracks_, + flipOp() ); // Distribute the scalars forAll(allScalars_, scalarI) { - mapDistribute::distribute + allScalars_[scalarI].shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allScalars_[scalarI] + false, + allScalars_[scalarI], + flipOp() ); + allScalars_[scalarI].setCapacity(allScalars_[scalarI].size()); } // Distribute the vectors forAll(allVectors_, vectorI) { - mapDistribute::distribute + allVectors_[vectorI].shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allVectors_[vectorI] + false, + allVectors_[vectorI], + flipOp() ); + allVectors_[vectorI].setCapacity(allVectors_[vectorI].size()); } } @@ -695,6 +667,8 @@ void Foam::functionObjects::streamLine::write() ); } } + + return true; } diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLine.H b/src/postProcessing/functionObjects/field/streamLine/streamLine.H index c47bb9f8c..5a577e666 100644 --- a/src/postProcessing/functionObjects/field/streamLine/streamLine.H +++ b/src/postProcessing/functionObjects/field/streamLine/streamLine.H @@ -91,7 +91,7 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl Foam::sampledSet Foam::wallBoundedStreamLine @@ -103,13 +103,11 @@ SourceFiles #ifndef functionObjects_streamLine_H #define functionObjects_streamLine_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "pointFieldFwd.H" -#include "Switch.H" #include "DynamicList.H" #include "scalarList.H" #include "vectorList.H" -#include "polyMesh.H" #include "writer.H" #include "indirectPrimitivePatch.H" @@ -120,8 +118,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; class meshSearch; class sampledSet; @@ -133,20 +129,16 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class streamLine +: + public functionObject { // Private data - //- Input dictionary - dictionary dict_; - - //- Name of this set of field averages. - word name_; - //- Database this class is registered to const objectRegistry& obr_; - //- Load fields from files (not from objectRegistry) - bool loadFromFiles_; + //- Input dictionary + dictionary dict_; //- List of fields to sample wordList fields_; @@ -233,14 +225,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary streamLine ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -250,26 +240,14 @@ public: // Member Functions - //- Return name of the set of field averages - virtual const word& name() const - { - return name_; - } - //- Read the field average data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute the averaging - virtual void execute(); + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Execute the averaging at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the field average data and write - virtual void write(); + //- Calculate and write the steamlines + virtual bool write(const bool postProcess = false); //- Update for changes of mesh virtual void updateMesh(const mapPolyMesh&); diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.C b/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.C deleted file mode 100644 index 0838c78b9..000000000 --- a/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "streamLineFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(streamLineFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - streamLineFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.H b/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.H deleted file mode 100644 index b40fe13c3..000000000 --- a/src/postProcessing/functionObjects/field/streamLine/streamLineFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::streamLineFunctionObject - -Description - FunctionObject wrapper around streamLines to allow them to be created via - the functions entry within controlDict. - -SourceFiles - streamLineFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef streamLineFunctionObject_H -#define streamLineFunctionObject_H - -#include "streamLine.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - streamLineFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C index 5093b9056..728aafcb5 100644 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.C @@ -24,6 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "surfaceInterpolateFields.H" +#include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -32,6 +34,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(surfaceInterpolateFields, 0); + + addToRunTimeSelectionTable + ( + functionObject, + surfaceInterpolateFields, + dictionary + ); } } @@ -41,16 +50,21 @@ namespace functionObjects Foam::functionObjects::surfaceInterpolateFields::surfaceInterpolateFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_() { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -68,18 +82,23 @@ Foam::functionObjects::surfaceInterpolateFields::~surfaceInterpolateFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::surfaceInterpolateFields::read +bool Foam::functionObjects::surfaceInterpolateFields::read ( const dictionary& dict ) { dict.lookup("fields") >> fieldSet_; + + return true; } -void Foam::functionObjects::surfaceInterpolateFields::execute() +bool Foam::functionObjects::surfaceInterpolateFields::execute +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; // Clear out any previously loaded fields ssf_.clear(); @@ -95,22 +114,17 @@ void Foam::functionObjects::surfaceInterpolateFields::execute() interpolateFields(stf_); Info<< endl; + + return true; } -void Foam::functionObjects::surfaceInterpolateFields::end() +bool Foam::functionObjects::surfaceInterpolateFields::write +( + const bool postProcess +) { - execute(); -} - - -void Foam::functionObjects::surfaceInterpolateFields::timeSet() -{} - - -void Foam::functionObjects::surfaceInterpolateFields::write() -{ - Info<< type() << " " << name_ << " output:" << nl; + Info<< type() << " " << name() << " output:" << nl; Info<< " Writing interpolated surface fields to " << obr_.time().timeName() << endl; @@ -135,6 +149,8 @@ void Foam::functionObjects::surfaceInterpolateFields::write() { stf_[i].write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H index d86d5b5ae..eef1c591f 100644 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H +++ b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFields.H @@ -59,7 +59,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles surfaceInterpolateFields.C @@ -69,8 +69,8 @@ SourceFiles #ifndef functionObjects_surfaceInterpolateFields_H #define functionObjects_surfaceInterpolateFields_H -#include "OFstream.H" -#include "surfaceFields.H" +#include "functionObject.H" +#include "surfaceFieldsFwd.H" #include "Tuple2.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -91,18 +91,17 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class surfaceInterpolateFields +: + public functionObject { protected: // Protected data - //- Name of this set of surfaceInterpolateFields object - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; //- Fields to process - //wordList fieldSet_; List> fieldSet_; //- Locally constructed fields @@ -146,9 +145,8 @@ public: surfaceInterpolateFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -158,34 +156,14 @@ public: // Member Functions - //- Return name of the surfaceInterpolateFields object - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the interpolated fields + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the interpolated fields + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C deleted file mode 100644 index 35e7dedc9..000000000 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "surfaceInterpolateFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - surfaceInterpolateFieldsFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - surfaceInterpolateFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.H b/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.H deleted file mode 100644 index fa10e0678..000000000 --- a/src/postProcessing/functionObjects/field/surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.H +++ /dev/null @@ -1,56 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::surfaceInterpolateFieldsFunctionObject - -Description - FunctionObject wrapper around surfaceInterpolateFields to allow - them to be created via the functions entry within controlDict. - -SourceFiles - surfaceInterpolateFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef surfaceInterpolateFieldsFunctionObject_H -#define surfaceInterpolateFieldsFunctionObject_H - -#include "surfaceInterpolateFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - < - functionObjects::surfaceInterpolateFields - > surfaceInterpolateFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C index 6c42012f9..20724ed84 100644 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C +++ b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C @@ -38,6 +38,7 @@ License #include "meshSearchMeshObject.H" #include "faceSet.H" #include "mapPolyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -46,6 +47,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(wallBoundedStreamLine, 0); + + addToRunTimeSelectionTable + ( + functionObject, + wallBoundedStreamLine, + dictionary + ); } } @@ -162,7 +170,6 @@ Foam::tetIndices Foam::functionObjects::wallBoundedStreamLine::findNearestTet void Foam::functionObjects::wallBoundedStreamLine::track() { - const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast(obr_); @@ -250,118 +257,77 @@ void Foam::functionObjects::wallBoundedStreamLine::track() label UIndex = -1; - if (loadFromFiles_) + label nScalar = 0; + label nVector = 0; + + forAll(fields_, i) { - IOobjectList allObjects(mesh, runTime.timeName()); - - IOobjectList objects(2*fields_.size()); - forAll(fields_, i) + if (mesh.foundObject(fields_[i])) { - objects.add(*allObjects[fields_[i]]); + nScalar++; } - - ReadFields(mesh, objects, vsFlds); - vsInterp.setSize(vsFlds.size()); - forAll(vsFlds, i) + else if (mesh.foundObject(fields_[i])) { + nVector++; + } + else + { + FatalErrorInFunction + << "Cannot find field " << fields_[i] << endl + << "Valid scalar fields are:" + << mesh.names(volScalarField::typeName) << endl + << "Valid vector fields are:" + << mesh.names(volVectorField::typeName) + << exit(FatalError); + } + } + + vsInterp.setSize(nScalar); + nScalar = 0; + vvInterp.setSize(nVector); + nVector = 0; + + forAll(fields_, i) + { + if (mesh.foundObject(fields_[i])) + { + const volScalarField& f = mesh.lookupObject + ( + fields_[i] + ); vsInterp.set ( - i, + nScalar++, interpolation::New ( interpolationScheme_, - vsFlds[i] + f ) ); } - ReadFields(mesh, objects, vvFlds); - vvInterp.setSize(vvFlds.size()); - forAll(vvFlds, i) + else if (mesh.foundObject(fields_[i])) { + const volVectorField& f = mesh.lookupObject + ( + fields_[i] + ); + + if (f.name() == UName_) + { + UIndex = nVector; + } + vvInterp.set ( - i, + nVector++, interpolation::New ( interpolationScheme_, - vvFlds[i] + f ) ); } } - else - { - label nScalar = 0; - label nVector = 0; - - forAll(fields_, i) - { - if (mesh.foundObject(fields_[i])) - { - nScalar++; - } - else if (mesh.foundObject(fields_[i])) - { - nVector++; - } - else - { - FatalErrorInFunction - << "Cannot find field " << fields_[i] << endl - << "Valid scalar fields are:" - << mesh.names(volScalarField::typeName) << endl - << "Valid vector fields are:" - << mesh.names(volVectorField::typeName) - << exit(FatalError); - } - } - vsInterp.setSize(nScalar); - nScalar = 0; - vvInterp.setSize(nVector); - nVector = 0; - - forAll(fields_, i) - { - if (mesh.foundObject(fields_[i])) - { - const volScalarField& f = mesh.lookupObject - ( - fields_[i] - ); - vsInterp.set - ( - nScalar++, - interpolation::New - ( - interpolationScheme_, - f - ) - ); - } - else if (mesh.foundObject(fields_[i])) - { - const volVectorField& f = mesh.lookupObject - ( - fields_[i] - ); - - if (f.name() == UName_) - { - UIndex = nVector; - } - - vvInterp.set - ( - nVector++, - interpolation::New - ( - interpolationScheme_, - f - ) - ); - } - } - } // Store the names scalarNames_.setSize(vsInterp.size()); @@ -439,17 +405,21 @@ void Foam::functionObjects::wallBoundedStreamLine::track() Foam::functionObjects::wallBoundedStreamLine::wallBoundedStreamLine ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - dict_(dict), - name_(name), - obr_(obr), - loadFromFiles_(loadFromFiles) + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), + dict_(dict) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -467,7 +437,7 @@ Foam::functionObjects::wallBoundedStreamLine::~wallBoundedStreamLine() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict) +bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict) { //dict_ = dict; dict.lookup("fields") >> fields_; @@ -613,22 +583,21 @@ void Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict) } } } + + return true; } -void Foam::functionObjects::wallBoundedStreamLine::execute() -{} +bool Foam::functionObjects::wallBoundedStreamLine::execute +( + const bool postProcess +) +{ + return true; +} -void Foam::functionObjects::wallBoundedStreamLine::end() -{} - - -void Foam::functionObjects::wallBoundedStreamLine::timeSet() -{} - - -void Foam::functionObjects::wallBoundedStreamLine::write() +bool Foam::functionObjects::wallBoundedStreamLine::write(const bool postProcess) { const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast(obr_); @@ -680,44 +649,57 @@ void Foam::functionObjects::wallBoundedStreamLine::write() recvMap.xfer() ); - // Distribute the track positions. Note: use scheduled comms // to prevent buffering. - mapDistribute::distribute + allTracks_.shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allTracks_ + false, + allTracks_, + flipOp() ); // Distribute the scalars forAll(allScalars_, scalarI) { - mapDistribute::distribute + allScalars_[scalarI].shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allScalars_[scalarI] + false, + allScalars_[scalarI], + flipOp() ); + allScalars_[scalarI].setCapacity(allScalars_[scalarI].size()); } // Distribute the vectors forAll(allVectors_, vectorI) { - mapDistribute::distribute + allVectors_[vectorI].shrink(); + mapDistributeBase::distribute ( Pstream::scheduled, distMap.schedule(), distMap.constructSize(), distMap.subMap(), + false, distMap.constructMap(), - allVectors_[vectorI] + false, + allVectors_[vectorI], + flipOp() ); + allVectors_[vectorI].setCapacity(allVectors_[vectorI].size()); } } @@ -850,6 +832,8 @@ void Foam::functionObjects::wallBoundedStreamLine::write() ); } } + + return true; } diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.H b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.H index 1a2f7dc4e..0a76cb120 100644 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.H +++ b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.H @@ -91,7 +91,7 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl Foam::sampledSet Foam::streamLine @@ -103,18 +103,15 @@ SourceFiles #ifndef functionObjects_wallBoundedStreamLine_H #define functionObjects_wallBoundedStreamLine_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "pointFieldFwd.H" -#include "Switch.H" #include "DynamicList.H" #include "scalarList.H" #include "vectorList.H" -#include "polyMesh.H" #include "writer.H" #include "indirectPrimitivePatch.H" #include "tetIndices.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -122,8 +119,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; class meshSearch; class sampledSet; @@ -135,20 +130,16 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class wallBoundedStreamLine +: + public functionObject { // Private data - //- Input dictionary - dictionary dict_; - - //- Name of this set of field averages. - word name_; - //- Database this class is registered to const objectRegistry& obr_; - //- Load fields from files (not from objectRegistry) - bool loadFromFiles_; + //- Input dictionary + dictionary dict_; //- List of fields to sample wordList fields_; @@ -239,14 +230,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary wallBoundedStreamLine ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -256,26 +245,14 @@ public: // Member Functions - //- Return name of the set of field averages - virtual const word& name() const - { - return name_; - } - //- Read the field average data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute the averaging - virtual void execute(); + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Execute the averaging at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the field average data and write - virtual void write(); + //- Calculate and write the wall-bounded streamlines + virtual bool write(const bool postProcess = false); //- Update for changes of mesh virtual void updateMesh(const mapPolyMesh&); diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C deleted file mode 100644 index eaa1cc7ea..000000000 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "wallBoundedStreamLineFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(wallBoundedStreamLineFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - wallBoundedStreamLineFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.H b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.H deleted file mode 100644 index 5461d29e6..000000000 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.H +++ /dev/null @@ -1,55 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::wallBoundedStreamLineFunctionObject - -Description - FunctionObject wrapper around wallBoundedStreamLines - to allow them to be created via - the functions entry within controlDict. - -SourceFiles - wallBoundedStreamLineFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef wallBoundedStreamLineFunctionObject_H -#define wallBoundedStreamLineFunctionObject_H - -#include "wallBoundedStreamLine.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - wallBoundedStreamLineFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/Make/files b/src/postProcessing/functionObjects/forces/Make/files index f1384ada7..1e8ec75d0 100644 --- a/src/postProcessing/functionObjects/forces/Make/files +++ b/src/postProcessing/functionObjects/forces/Make/files @@ -1,13 +1,6 @@ pressureTools/pressureTools.C -pressureTools/pressureToolsFunctionObject.C - wallShearStress/wallShearStress.C -wallShearStress/wallShearStressFunctionObject.C - forces/forces.C -forces/forcesFunctionObject.C - forceCoeffs/forceCoeffs.C -forceCoeffs/forceCoeffsFunctionObject.C LIB = $(FOAM_LIBBIN)/libforces diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C index 18fec8f25..733b77def 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -24,11 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "forceCoeffs.H" -#include "dictionary.H" -#include "Time.H" -#include "fvMesh.H" -#include "Pstream.H" -#include "IOmanip.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +33,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(forceCoeffs, 0); + addToRunTimeSelectionTable(functionObject, forceCoeffs, dictionary); } } @@ -126,12 +123,11 @@ void Foam::functionObjects::forceCoeffs::writeFileHeader(const label i) Foam::functionObjects::forceCoeffs::forceCoeffs ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - forces(name, obr, dict, loadFromFiles, false), + forces(name, runTime, dict), liftDir_(Zero), dragDir_(Zero), pitchAxis_(Zero), @@ -139,12 +135,6 @@ Foam::functionObjects::forceCoeffs::forceCoeffs lRef_(0.0), Aref_(0.0) { - if (!isA(obr)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - read(dict); } @@ -157,7 +147,7 @@ Foam::functionObjects::forceCoeffs::~forceCoeffs() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::forceCoeffs::read(const dictionary& dict) +bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict) { forces::read(dict); @@ -172,28 +162,24 @@ void Foam::functionObjects::forceCoeffs::read(const dictionary& dict) // Reference length and area scales dict.lookup("lRef") >> lRef_; dict.lookup("Aref") >> Aref_; + + return true; } -void Foam::functionObjects::forceCoeffs::execute() -{} +bool Foam::functionObjects::forceCoeffs::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::forceCoeffs::end() -{} - - -void Foam::functionObjects::forceCoeffs::timeSet() -{} - - -void Foam::functionObjects::forceCoeffs::write() +bool Foam::functionObjects::forceCoeffs::write(const bool postProcess) { forces::calcForcesMoment(); if (Pstream::master()) { - functionObjectFiles::write(); + writeFiles::write(); scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_; @@ -222,7 +208,7 @@ void Foam::functionObjects::forceCoeffs::write() << tab << Cm << tab << Cd << tab << Cl << tab << Clf << tab << Clr << endl; - if (log_) Info<< type() << " " << name_ << " output:" << nl + if (log_) Info<< type() << " " << name() << " output:" << nl << " Cm = " << Cm << nl << " Cd = " << Cd << nl << " Cl = " << Cl << nl @@ -256,6 +242,8 @@ void Foam::functionObjects::forceCoeffs::write() if (log_) Info<< endl; } + + return true; } diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H index be1a3d385..1470d5784 100644 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H +++ b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffs.H @@ -81,8 +81,8 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject - Foam::forces + Foam::functionObjects::timeControl + Foam::functionObjects::forces SourceFiles forceCoeffs.C @@ -161,14 +161,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary forceCoeffs ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -179,19 +177,13 @@ public: // Member Functions //- Read the forces data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write the forces - virtual void write(); + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.C b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.C deleted file mode 100644 index 1d2b11a52..000000000 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "forceCoeffsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(forceCoeffsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - forceCoeffsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H b/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H deleted file mode 100644 index 7be6eb561..000000000 --- a/src/postProcessing/functionObjects/forces/forceCoeffs/forceCoeffsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::forceCoeffsFunctionObject - -Description - FunctionObject wrapper around forceCoeffs to allow them to be created via - the functions entry within controlDict. - -SourceFiles - forceCoeffsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef forceCoeffsFunctionObject_H -#define forceCoeffsFunctionObject_H - -#include "forceCoeffs.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - forceCoeffsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 5ff699f35..b0fe879e9 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -24,14 +24,11 @@ License \*---------------------------------------------------------------------------*/ #include "forces.H" -#include "volFields.H" -#include "dictionary.H" -#include "Time.H" -#include "wordReList.H" #include "fvcGrad.H" #include "porosityModel.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -40,6 +37,8 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(forces, 0); + + addToRunTimeSelectionTable(functionObject, forces, dictionary); } } @@ -395,7 +394,7 @@ void Foam::functionObjects::forces::applyBins void Foam::functionObjects::forces::writeForces() { if (log_) Info - << type() << " " << name_ << " output:" << nl + << type() << " " << name() << " output:" << nl << " sum of forces:" << nl << " pressure : " << sum(force_[0]) << nl << " viscous : " << sum(force_[1]) << nl @@ -522,16 +521,11 @@ void Foam::functionObjects::forces::writeBins() Foam::functionObjects::forces::forces ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles, - const bool readFields + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, createFileNames(dict)), - name_(name), - obr_(obr), - log_(true), + writeFiles(name, runTime, dict, name), force_(3), moment_(3), patchSet_(), @@ -553,16 +547,14 @@ Foam::functionObjects::forces::forces binCumulative_(true), initialised_(false) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); } - if (readFields) - { - read(dict); - } + read(dict); + resetNames(createFileNames(dict)); } @@ -570,30 +562,21 @@ Foam::functionObjects::forces::forces ( const word& name, const objectRegistry& obr, - const labelHashSet& patchSet, - const word& pName, - const word& UName, - const word& rhoName, - const scalar rhoInf, - const scalar pRef, - const coordinateSystem& coordSys + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - log_(true), + writeFiles(name, obr, dict, name), force_(3), moment_(3), - patchSet_(patchSet), - pName_(pName), - UName_(UName), - rhoName_(rhoName), + patchSet_(), + pName_(word::null), + UName_(word::null), + rhoName_(word::null), directForceDensity_(false), fDName_(""), - rhoRef_(rhoInf), - pRef_(pRef), - coordSys_(coordSys), + rhoRef_(VGREAT), + pRef_(0), + coordSys_(), localSystem_(false), porosity_(false), nBin_(1), @@ -604,11 +587,14 @@ Foam::functionObjects::forces::forces binCumulative_(true), initialised_(false) { - forAll(force_, i) + if (!isA(obr_)) { - force_[i].setSize(nBin_); - moment_[i].setSize(nBin_); + FatalErrorInFunction + << "objectRegistry is not an fvMesh" << exit(FatalError); } + + read(dict); + resetNames(createFileNames(dict)); } @@ -620,13 +606,13 @@ Foam::functionObjects::forces::~forces() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::forces::read(const dictionary& dict) +bool Foam::functionObjects::forces::read(const dictionary& dict) { + writeFiles::read(dict); + initialised_ = false; - log_ = dict.lookupOrDefault("log", false); - - if (log_) Info<< type() << " " << name_ << ":" << nl; + if (log_) Info<< type() << " " << name() << ":" << nl; directForceDensity_ = dict.lookupOrDefault("directForceDensity", false); @@ -747,35 +733,8 @@ void Foam::functionObjects::forces::read(const dictionary& dict) moment_[1].setSize(1); moment_[2].setSize(1); } -} - -void Foam::functionObjects::forces::execute() -{} - - -void Foam::functionObjects::forces::end() -{} - - -void Foam::functionObjects::forces::timeSet() -{} - - -void Foam::functionObjects::forces::write() -{ - calcForcesMoment(); - - if (Pstream::master()) - { - functionObjectFiles::write(); - - writeForces(); - - writeBins(); - - if (log_) Info<< endl; - } + return true; } @@ -931,4 +890,29 @@ Foam::vector Foam::functionObjects::forces::momentEff() const } +bool Foam::functionObjects::forces::execute(const bool postProcess) +{ + return true; +} + + +bool Foam::functionObjects::forces::write(const bool postProcess) +{ + calcForcesMoment(); + + if (Pstream::master()) + { + writeFiles::write(); + + writeForces(); + + writeBins(); + + if (log_) Info<< endl; + } + + return true; +} + + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/forces/forces.H b/src/postProcessing/functionObjects/forces/forces/forces.H index 449f2f620..b8270eba3 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.H +++ b/src/postProcessing/functionObjects/forces/forces/forces.H @@ -101,7 +101,8 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFiles + Foam::functionObjects::timeControl Foam::forceCoeffs SourceFiles @@ -112,28 +113,15 @@ SourceFiles #ifndef functionObjects_forces_H #define functionObjects_forces_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "coordinateSystem.H" -#include "coordinateSystems.H" -#include "primitiveFieldsFwd.H" #include "volFieldsFwd.H" #include "HashSet.H" -#include "Tuple2.H" -#include "OFstream.H" -#include "Switch.H" -#include "writer.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -143,21 +131,12 @@ namespace functionObjects class forces : - public functionObjectFiles + public writeFiles { protected: // Protected data - //- Name of this set of forces, - // Also used as the name of the probes directory. - word name_; - - const objectRegistry& obr_; - - //- Switch to send output to Info as well as to file - Switch log_; - //- Pressure, viscous and porous force per bin List> force_; @@ -281,29 +260,20 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary forces ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false, - const bool readFields = true + const Time& runTime, + const dictionary& dict ); - //- Construct from components + //- Construct from objectRegistry and dictionary forces ( const word& name, - const objectRegistry&, - const labelHashSet& patchSet, - const word& pName, - const word& UName, - const word& rhoName, - const scalar rhoInf, - const scalar pRef, - const coordinateSystem& coordSys + const objectRegistry& obr, + const dictionary& ); @@ -313,26 +283,8 @@ public: // Member Functions - //- Return name of the set of forces - virtual const word& name() const - { - return name_; - } - //- Read the forces data - virtual void read(const dictionary&); - - //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write the forces - virtual void write(); + virtual bool read(const dictionary&); //- Calculate the forces and moments virtual void calcForcesMoment(); @@ -343,13 +295,11 @@ public: //- Return the total moment virtual vector momentEff() const; - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} + //- Execute, currently does nothing + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the forces + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.C b/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.C deleted file mode 100644 index 066e59b95..000000000 --- a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "forcesFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(forcesFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - forcesFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H b/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H deleted file mode 100644 index 518815cc7..000000000 --- a/src/postProcessing/functionObjects/forces/forces/forcesFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::forcesFunctionObject - -Description - FunctionObject wrapper around forces to allow them to be created via the - functions entry within controlDict. - -SourceFiles - forcesFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef forcesFunctionObject_H -#define forcesFunctionObject_H - -#include "forces.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - forcesFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.C b/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.C index b256dafe7..97ab1ddd6 100644 --- a/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.C +++ b/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.C @@ -25,7 +25,7 @@ License #include "pressureTools.H" #include "volFields.H" -#include "dictionary.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(pressureTools, 0); + addToRunTimeSelectionTable(functionObject, pressureTools, dictionary); } } @@ -186,13 +187,18 @@ Foam::functionObjects::pressureTools::convertToCoeff Foam::functionObjects::pressureTools::pressureTools ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), pName_("p"), UName_("U"), rhoName_("rho"), @@ -203,7 +209,7 @@ Foam::functionObjects::pressureTools::pressureTools UInf_(Zero), rhoInf_(0.0) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -249,7 +255,7 @@ Foam::functionObjects::pressureTools::~pressureTools() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::pressureTools::read(const dictionary& dict) +bool Foam::functionObjects::pressureTools::read(const dictionary& dict) { dict.readIfPresent("pName", pName_); dict.readIfPresent("UName", UName_); @@ -278,16 +284,18 @@ void Foam::functionObjects::pressureTools::read(const dictionary& dict) if (mag(zeroCheck) < ROOTVSMALL) { WarningInFunction - << type() << " " << name_ << ": " + << type() << " " << name() << ": " << "Coefficient calculation requested, but reference " << "pressure level is zero. Please check the supplied " << "values of pInf, UInf and rhoInf" << endl; } } + + return true; } -void Foam::functionObjects::pressureTools::execute() +bool Foam::functionObjects::pressureTools::execute(const bool postProcess) { const volScalarField& p = obr_.lookupObject(pName_); @@ -297,29 +305,23 @@ void Foam::functionObjects::pressureTools::execute() ); pResult == convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef()); + + return true; } -void Foam::functionObjects::pressureTools::end() -{ - execute(); -} - - -void Foam::functionObjects::pressureTools::timeSet() -{} - - -void Foam::functionObjects::pressureTools::write() +bool Foam::functionObjects::pressureTools::write(const bool postProcess) { const volScalarField& pResult = obr_.lookupObject(pName()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << pResult.name() << nl << endl; pResult.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.H b/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.H index 404c140c6..ff3fd37ad 100644 --- a/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.H +++ b/src/postProcessing/functionObjects/forces/pressureTools/pressureTools.H @@ -108,6 +108,7 @@ SourceFiles #ifndef functionObjects_pressureTools_H #define functionObjects_pressureTools_H +#include "functionObject.H" #include "volFieldsFwd.H" #include "dimensionedScalar.H" @@ -118,9 +119,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -130,13 +128,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class pressureTools +: + public functionObject { // Private data - //- Name of this set of pressureTools objects - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of pressure field, default is "p" @@ -208,14 +205,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary pressureTools ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -225,34 +220,14 @@ public: // Member Functions - //- Return name of the set of pressureTools - virtual const word& name() const - { - return name_; - } - //- Read the pressureTools data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Calculate the pressureTools and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.C b/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.C deleted file mode 100644 index e4dedce24..000000000 --- a/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "pressureToolsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(pressureToolsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - pressureToolsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.H b/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.H deleted file mode 100644 index 39141da9f..000000000 --- a/src/postProcessing/functionObjects/forces/pressureTools/pressureToolsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::pressureToolsFunctionObject - -Description - FunctionObject wrapper around pressureTools to allow it to be created via - the functions entry within controlDict. - -SourceFiles - pressureToolsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef pressureToolsFunctionObject_H -#define pressureToolsFunctionObject_H - -#include "pressureTools.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - pressureToolsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.C b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.C index 85e605533..e86266f20 100644 --- a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.C +++ b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.C @@ -29,6 +29,7 @@ License #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" #include "wallPolyPatch.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +38,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(wallShearStress, 0); + addToRunTimeSelectionTable(functionObject, wallShearStress, dictionary); } } @@ -97,18 +99,14 @@ void Foam::functionObjects::wallShearStress::calcShearStress Foam::functionObjects::wallShearStress::wallShearStress ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - log_(true), + writeFiles(name, runTime, dict, name), patchSet_() { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -141,6 +139,7 @@ Foam::functionObjects::wallShearStress::wallShearStress mesh.objectRegistry::store(wallShearStressPtr); read(dict); + resetName(typeName); } @@ -152,9 +151,9 @@ Foam::functionObjects::wallShearStress::~wallShearStress() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::wallShearStress::read(const dictionary& dict) +bool Foam::functionObjects::wallShearStress::read(const dictionary& dict) { - log_ = dict.lookupOrDefault("log", true); + writeFiles::read(dict); const fvMesh& mesh = refCast(obr_); const polyBoundaryMesh& pbm = mesh.boundaryMesh(); @@ -165,7 +164,7 @@ void Foam::functionObjects::wallShearStress::read(const dictionary& dict) wordReList(dict.lookupOrDefault("patches", wordReList())) ); - Info<< type() << " " << name_ << ":" << nl; + Info<< type() << " " << name() << ":" << nl; if (patchSet_.empty()) { @@ -203,15 +202,17 @@ void Foam::functionObjects::wallShearStress::read(const dictionary& dict) patchSet_ = filteredPatchSet; } + + return true; } -void Foam::functionObjects::wallShearStress::execute() +bool Foam::functionObjects::wallShearStress::execute(const bool postProcess) { typedef compressible::turbulenceModel cmpModel; typedef incompressible::turbulenceModel icoModel; - functionObjectFiles::write(); + writeFiles::write(); const fvMesh& mesh = refCast(obr_); @@ -221,7 +222,7 @@ void Foam::functionObjects::wallShearStress::execute() mesh.lookupObject(type()) ); - if (log_) Info<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name() << " output:" << nl; tmp Reff; @@ -247,31 +248,25 @@ void Foam::functionObjects::wallShearStress::execute() } calcShearStress(mesh, Reff(), wallShearStress); + + return true; } -void Foam::functionObjects::wallShearStress::end() +bool Foam::functionObjects::wallShearStress::write(const bool postProcess) { - execute(); -} - - -void Foam::functionObjects::wallShearStress::timeSet() -{} - - -void Foam::functionObjects::wallShearStress::write() -{ - functionObjectFiles::write(); + writeFiles::write(); const volVectorField& wallShearStress = obr_.lookupObject(type()); - if (log_) Info<< type() << " " << name_ << " output:" << nl + if (log_) Info<< type() << " " << name() << " output:" << nl << " writing field " << wallShearStress.name() << nl << endl; wallShearStress.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.H b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.H index 486351bff..8c2ffef6e 100644 --- a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.H +++ b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStress.H @@ -64,6 +64,12 @@ Description patches | list of patches to process | no | all wall patches \endtable +SeeAlso + Foam::functionObject + Foam::functionObjects::writeFiles + Foam::functionObjects::pressureTools + Foam::functionObjects::timeControl + SourceFiles wallShearStress.C @@ -72,9 +78,8 @@ SourceFiles #ifndef functionObjects_wallShearStress_H #define functionObjects_wallShearStress_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "volFieldsFwd.H" -#include "Switch.H" #include "HashSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -83,10 +88,6 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class fvMesh; namespace functionObjects @@ -98,20 +99,12 @@ namespace functionObjects class wallShearStress : - public functionObjectFiles + public writeFiles { protected: // Protected data - //- Name of this set of wallShearStress object - word name_; - - const objectRegistry& obr_; - - //- Switch to send output to Info as well as to file - Switch log_; - //- Optional list of patches to process labelHashSet patchSet_; @@ -149,14 +142,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary wallShearStress ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -166,34 +157,14 @@ public: // Member Functions - //- Return name of the set of wallShearStress - virtual const word& name() const - { - return name_; - } - //- Read the wallShearStress data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the wall shear-stress + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the wallShearStress and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the wall shear-stress + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.C b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.C deleted file mode 100644 index a8a05500e..000000000 --- a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "wallShearStressFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(wallShearStressFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - wallShearStressFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.H b/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.H deleted file mode 100644 index 5e15293c5..000000000 --- a/src/postProcessing/functionObjects/forces/wallShearStress/wallShearStressFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::wallShearStressFunctionObject - -Description - FunctionObject wrapper around wallShearStress to allow it to be created - via the functions entry within controlDict. - -SourceFiles - wallShearStressFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef wallShearStressFunctionObject_H -#define wallShearStressFunctionObject_H - -#include "wallShearStress.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - wallShearStressFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/lagrangian/Make/files b/src/postProcessing/functionObjects/lagrangian/Make/files index 3445d2f62..1301f29b4 100644 --- a/src/postProcessing/functionObjects/lagrangian/Make/files +++ b/src/postProcessing/functionObjects/lagrangian/Make/files @@ -1,4 +1,3 @@ cloudInfo/cloudInfo.C -cloudInfo/cloudInfoFunctionObject.C LIB = $(FOAM_LIBBIN)/liblagrangianFunctionObjects diff --git a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.C b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.C index 369804dc9..86db6abc0 100644 --- a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.C +++ b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.C @@ -24,8 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "cloudInfo.H" -#include "dictionary.H" #include "kinematicCloud.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +34,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(cloudInfo, 0); + + addToRunTimeSelectionTable + ( + functionObject, + cloudInfo, + dictionary + ); } } @@ -55,14 +62,11 @@ void Foam::functionObjects::cloudInfo::writeFileHeader(const label i) Foam::functionObjects::cloudInfo::cloudInfo ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name), - name_(name), - obr_(obr) + writeFiles(name, runTime, dict, name) { read(dict); } @@ -76,11 +80,11 @@ Foam::functionObjects::cloudInfo::~cloudInfo() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::cloudInfo::read(const dictionary& dict) +bool Foam::functionObjects::cloudInfo::read(const dictionary& dict) { - functionObjectFiles::resetNames(dict.lookup("clouds")); + writeFiles::resetNames(dict.lookup("clouds")); - Info<< type() << " " << name_ << ": "; + Info<< type() << " " << name() << ": "; if (names().size()) { Info<< "applying to clouds:" << nl; @@ -94,24 +98,20 @@ void Foam::functionObjects::cloudInfo::read(const dictionary& dict) { Info<< "no clouds to be processed" << nl << endl; } + + return true; } -void Foam::functionObjects::cloudInfo::execute() -{} - - -void Foam::functionObjects::cloudInfo::end() -{} - - -void Foam::functionObjects::cloudInfo::timeSet() -{} - - -void Foam::functionObjects::cloudInfo::write() +bool Foam::functionObjects::cloudInfo::execute(const bool postProcess) { - functionObjectFiles::write(); + return true; +} + + +bool Foam::functionObjects::cloudInfo::write(const bool postProcess) +{ + writeFiles::write(); forAll(names(), i) { @@ -133,6 +133,8 @@ void Foam::functionObjects::cloudInfo::write() << massInSystem << endl; } } + + return true; } diff --git a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.H b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.H index 590621559..dfd517127 100644 --- a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.H +++ b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfo.H @@ -61,7 +61,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFiles SourceFiles cloudInfo.C @@ -71,22 +71,12 @@ SourceFiles #ifndef functionObjects_cloudInfo_H #define functionObjects_cloudInfo_H -#include "functionObjectFiles.H" -#include "PtrList.H" -#include "pointFieldFwd.H" -#include "volFields.H" -#include "surfaceFields.H" +#include "writeFiles.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class mapPolyMesh; - namespace functionObjects { @@ -96,19 +86,10 @@ namespace functionObjects class cloudInfo : - public functionObjectFiles + public writeFiles { protected: - // Protected data - - //- Name of this set of cloudInfo object - word name_; - - //- Reference to the database - const objectRegistry& obr_; - - // Protected Member Functions //- File header information @@ -134,14 +115,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary cloudInfo ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& ); @@ -151,34 +130,14 @@ public: // Member Functions - //- Return name of the cloudInfo object - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.C b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.C deleted file mode 100644 index 4ac835ec9..000000000 --- a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "cloudInfoFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(cloudInfoFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - cloudInfoFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.H b/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.H deleted file mode 100644 index 6cfd39830..000000000 --- a/src/postProcessing/functionObjects/lagrangian/cloudInfo/cloudInfoFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::cloudInfoFunctionObject - -Description - FunctionObject wrapper around cloudInfo to allow them to be created via - the functions entry within controlDict. - -SourceFiles - cloudInfoFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef cloudInfoFunctionObject_H -#define cloudInfoFunctionObject_H - -#include "cloudInfo.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - cloudInfoFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C index a7fc210de..298963e58 100644 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C +++ b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C @@ -27,6 +27,7 @@ License #include "surfaceFields.H" #include "fvcSurfaceIntegrate.H" #include "zeroGradientFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +36,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(CourantNo, 0); + + addToRunTimeSelectionTable + ( + functionObject, + CourantNo, + dictionary + ); } } @@ -63,17 +71,22 @@ Foam::functionObjects::CourantNo::byRho Foam::functionObjects::CourantNo::CourantNo ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), phiName_("phi"), rhoName_("rho") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -113,14 +126,16 @@ Foam::functionObjects::CourantNo::~CourantNo() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::CourantNo::read(const dictionary& dict) +bool Foam::functionObjects::CourantNo::read(const dictionary& dict) { phiName_ = dict.lookupOrDefault("phiName", "phi"); rhoName_ = dict.lookupOrDefault("rhoName", "rho"); + + return true; } -void Foam::functionObjects::CourantNo::execute() +bool Foam::functionObjects::CourantNo::execute(const bool postProcess) { const fvMesh& mesh = refCast(obr_); @@ -139,29 +154,23 @@ void Foam::functionObjects::CourantNo::execute() /mesh.V() ); Co.correctBoundaryConditions(); + + return true; } -void Foam::functionObjects::CourantNo::end() -{ - execute(); -} - - -void Foam::functionObjects::CourantNo::timeSet() -{} - - -void Foam::functionObjects::CourantNo::write() +bool Foam::functionObjects::CourantNo::write(const bool postProcess) { const volScalarField& CourantNo = obr_.lookupObject(type()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << CourantNo.name() << nl << endl; CourantNo.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.H b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.H index ca377f1c8..6db5e796e 100644 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.H +++ b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.H @@ -40,19 +40,13 @@ SourceFiles #ifndef functionObjects_CourantNo_H #define functionObjects_CourantNo_H +#include "functionObject.H" #include "volFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -61,12 +55,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class CourantNo +: + public functionObject { // Private data - //- Name of this set of CourantNo objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -100,14 +93,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary CourantNo ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time&, + const dictionary& ); @@ -117,34 +108,14 @@ public: // Member Functions - //- Return name of the set of CourantNo - virtual const word& name() const - { - return name_; - } - //- Read the CourantNo data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Calculate the CourantNo and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.C b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.C deleted file mode 100644 index af57c73e6..000000000 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "CourantNoFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(CourantNoFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - CourantNoFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.H b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.H deleted file mode 100644 index 6bab35fc0..000000000 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNoFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::CourantNoFunctionObject - -Description - FunctionObject wrapper around CourantNo to allow it to be created - via the functions entry within controlDict. - -SourceFiles - CourantNoFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef CourantNoFunctionObject_H -#define CourantNoFunctionObject_H - -#include "CourantNo.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - CourantNoFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C index e6c13e8bd..defbe1841 100644 --- a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C +++ b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C @@ -25,9 +25,9 @@ License #include "Lambda2.H" #include "volFields.H" -#include "dictionary.H" #include "zeroGradientFvPatchFields.H" #include "fvcGrad.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,6 +36,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(Lambda2, 0); + + addToRunTimeSelectionTable + ( + functionObject, + Lambda2, + dictionary + ); } } @@ -45,16 +52,21 @@ namespace functionObjects Foam::functionObjects::Lambda2::Lambda2 ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), UName_("U") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -93,13 +105,15 @@ Foam::functionObjects::Lambda2::~Lambda2() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::Lambda2::read(const dictionary& dict) +bool Foam::functionObjects::Lambda2::read(const dictionary& dict) { UName_ = dict.lookupOrDefault("UName", "U"); + + return true; } -void Foam::functionObjects::Lambda2::execute() +bool Foam::functionObjects::Lambda2::execute(const bool postProcess) { const fvMesh& mesh = refCast(obr_); @@ -121,29 +135,23 @@ void Foam::functionObjects::Lambda2::execute() ); Lambda2 = -eigenValues(SSplusWW)().component(vector::Y); + + return true; } -void Foam::functionObjects::Lambda2::end() -{ - execute(); -} - - -void Foam::functionObjects::Lambda2::timeSet() -{} - - -void Foam::functionObjects::Lambda2::write() +bool Foam::functionObjects::Lambda2::write(const bool postProcess) { const volScalarField& Lambda2 = obr_.lookupObject(type()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << Lambda2.name() << nl << endl; Lambda2.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H index 804bb584f..76d3b6d73 100644 --- a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H +++ b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H @@ -40,10 +40,8 @@ SourceFiles #ifndef functionObjects_Lambda2_H #define functionObjects_Lambda2_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -64,12 +59,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class Lambda2 +: + public functionObject { // Private data - //- Name of this set of Lambda2 objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -94,14 +88,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary Lambda2 ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -111,34 +103,14 @@ public: // Member Functions - //- Return name of the set of Lambda2 - virtual const word& name() const - { - return name_; - } - //- Read the Lambda2 data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate Lambda2 + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the Lambda2 and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write Lambda2 + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.C b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.C deleted file mode 100644 index ced087ce9..000000000 --- a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "Lambda2FunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(Lambda2FunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - Lambda2FunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.H b/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.H deleted file mode 100644 index 63031374c..000000000 --- a/src/postProcessing/functionObjects/utilities/Lambda2/Lambda2FunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::Lambda2FunctionObject - -Description - FunctionObject wrapper around Lambda2 to allow it to be created - via the functions entry within controlDict. - -SourceFiles - Lambda2FunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef Lambda2FunctionObject_H -#define Lambda2FunctionObject_H - -#include "Lambda2.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - Lambda2FunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index b9601ff78..90464e991 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -1,58 +1,22 @@ codedFunctionObject/codedFunctionObject.C - CourantNo/CourantNo.C -CourantNo/CourantNoFunctionObject.C - Lambda2/Lambda2.C -Lambda2/Lambda2FunctionObject.C - Peclet/Peclet.C -Peclet/PecletFunctionObject.C - Q/Q.C -Q/QFunctionObject.C - blendingFactor/blendingFactor.C -blendingFactor/blendingFactorFunctionObject.C - dsmcFields/dsmcFields.C -dsmcFields/dsmcFieldsFunctionObject.C - residuals/residuals.C -residuals/residualsFunctionObject.C - scalarTransport/scalarTransport.C -scalarTransport/scalarTransportFunctionObject.C - timeActivatedFileUpdate/timeActivatedFileUpdate.C -timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C - turbulenceFields/turbulenceFields.C -turbulenceFields/turbulenceFieldsFunctionObject.C - vorticity/vorticity.C -vorticity/vorticityFunctionObject.C - yPlus/yPlus.C -yPlus/yPlusFunctionObject.C - setTimeStep/setTimeStepFunctionObject.C - systemCall/systemCall.C -systemCall/systemCallFunctionObject.C - abort/abort.C - partialWrite/partialWrite.C -partialWrite/partialWriteFunctionObject.C - removeRegisteredObject/removeRegisteredObject.C -removeRegisteredObject/removeRegisteredObjectFunctionObject.C - writeDictionary/writeDictionary.C -writeDictionary/writeDictionaryFunctionObject.C - writeRegisteredObject/writeRegisteredObject.C -writeRegisteredObject/writeRegisteredObjectFunctionObject.C LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects diff --git a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C index 9bc2a62e1..b4560d54e 100644 --- a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C +++ b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.C @@ -30,6 +30,7 @@ License #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" #include "surfaceInterpolate.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -38,6 +39,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(Peclet, 0); + + addToRunTimeSelectionTable + ( + functionObject, + Peclet, + dictionary + ); } } @@ -47,17 +55,22 @@ namespace functionObjects Foam::functionObjects::Peclet::Peclet ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), phiName_("phi"), rhoName_("rho") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -96,14 +109,16 @@ Foam::functionObjects::Peclet::~Peclet() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::Peclet::read(const dictionary& dict) +bool Foam::functionObjects::Peclet::read(const dictionary& dict) { phiName_ = dict.lookupOrDefault("phiName", "phi"); rhoName_ = dict.lookupOrDefault("rhoName", "rho"); + + return true; } -void Foam::functionObjects::Peclet::execute() +bool Foam::functionObjects::Peclet::execute(const bool postProcess) { typedef compressible::turbulenceModel cmpTurbModel; typedef incompressible::turbulenceModel icoTurbModel; @@ -183,28 +198,23 @@ void Foam::functionObjects::Peclet::execute() *mesh.surfaceInterpolation::deltaCoeffs() *fvc::interpolate(nuEff) ); + + return true; } -void Foam::functionObjects::Peclet::end() -{ - execute(); -} - -void Foam::functionObjects::Peclet::timeSet() -{} - - -void Foam::functionObjects::Peclet::write() +bool Foam::functionObjects::Peclet::write(const bool postProcess) { const surfaceScalarField& Peclet = obr_.lookupObject(type()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << Peclet.name() << nl << endl; Peclet.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H index 4b500ec0d..ed829c196 100644 --- a/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H +++ b/src/postProcessing/functionObjects/utilities/Peclet/Peclet.H @@ -39,10 +39,8 @@ SourceFiles #ifndef functionObjects_Peclet_H #define functionObjects_Peclet_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,9 +49,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -63,12 +58,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class Peclet +: + public functionObject { // Private data - //- Name of this set of Peclet objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -101,9 +95,8 @@ public: Peclet ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -113,34 +106,14 @@ public: // Member Functions - //- Return name of the set of Peclet - virtual const word& name() const - { - return name_; - } - //- Read the Peclet data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the Peclet number field + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the Peclet and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the Peclet number field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.C b/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.C deleted file mode 100644 index fdb247703..000000000 --- a/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "PecletFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(PecletFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - PecletFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.H b/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.H deleted file mode 100644 index a740de23d..000000000 --- a/src/postProcessing/functionObjects/utilities/Peclet/PecletFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::PecletFunctionObject - -Description - FunctionObject wrapper around Peclet to allow it to be created - via the functions entry within controlDict. - -SourceFiles - PecletFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef PecletFunctionObject_H -#define PecletFunctionObject_H - -#include "Peclet.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - PecletFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Q/Q.C b/src/postProcessing/functionObjects/utilities/Q/Q.C index cea5d0533..407ce0ba6 100644 --- a/src/postProcessing/functionObjects/utilities/Q/Q.C +++ b/src/postProcessing/functionObjects/utilities/Q/Q.C @@ -25,8 +25,8 @@ License #include "Q.H" #include "volFields.H" -#include "dictionary.H" #include "fvcGrad.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(Q, 0); + + addToRunTimeSelectionTable + ( + functionObject, + Q, + dictionary + ); } } @@ -44,16 +51,21 @@ namespace functionObjects Foam::functionObjects::Q::Q ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), UName_("U") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -92,13 +104,15 @@ Foam::functionObjects::Q::~Q() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::Q::read(const dictionary& dict) +bool Foam::functionObjects::Q::read(const dictionary& dict) { UName_ = dict.lookupOrDefault("UName", "U"); + + return true; } -void Foam::functionObjects::Q::execute() +bool Foam::functionObjects::Q::execute(const bool postProcess) { const fvMesh& mesh = refCast(obr_); @@ -114,29 +128,23 @@ void Foam::functionObjects::Q::execute() ); Q = 0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU)))); + + return true; } -void Foam::functionObjects::Q::end() -{ - execute(); -} - - -void Foam::functionObjects::Q::timeSet() -{} - - -void Foam::functionObjects::Q::write() +bool Foam::functionObjects::Q::write(const bool postProcess) { const volScalarField& Q = obr_.lookupObject(type()); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << Q.name() << nl << endl; Q.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/Q/Q.H b/src/postProcessing/functionObjects/utilities/Q/Q.H index e8395211c..52ec9aaad 100644 --- a/src/postProcessing/functionObjects/utilities/Q/Q.H +++ b/src/postProcessing/functionObjects/utilities/Q/Q.H @@ -43,10 +43,8 @@ SourceFiles #ifndef functionObjects_Q_H #define functionObjects_Q_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -55,9 +53,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -67,12 +62,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class Q +: + public functionObject { // Private data - //- Name of this set of Q objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -97,14 +91,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary Q ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -114,34 +106,14 @@ public: // Member Functions - //- Return name of the set of Q - virtual const word& name() const - { - return name_; - } - //- Read the Q data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the Q-field + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the Q and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the Q-field + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.C b/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.C deleted file mode 100644 index 0fa525f0b..000000000 --- a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "QFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(QFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - QFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H b/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H deleted file mode 100644 index 27d72f6aa..000000000 --- a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::QFunctionObject - -Description - FunctionObject wrapper around Q to allow it to be created - via the functions entry within controlDict. - -SourceFiles - QFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef QFunctionObject_H -#define QFunctionObject_H - -#include "Q.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - QFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/abort/abort.C b/src/postProcessing/functionObjects/utilities/abort/abort.C index 76e71d39a..f0194414c 100644 --- a/src/postProcessing/functionObjects/utilities/abort/abort.C +++ b/src/postProcessing/functionObjects/utilities/abort/abort.C @@ -29,6 +29,7 @@ License #include "Time.H" #include "OSspecific.H" #include "PstreamReduceOps.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +38,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(abort, 0); + + addToRunTimeSelectionTable + ( + functionObject, + abort, + dictionary + ); } } @@ -68,7 +76,7 @@ void Foam::functionObjects::abort::removeFile() const if (hasAbort && Pstream::master()) { - // cleanup ABORT file (on master only) + // Cleanup ABORT file (on master only) rm(abortFile_); } } @@ -79,20 +87,19 @@ void Foam::functionObjects::abort::removeFile() const Foam::functionObjects::abort::abort ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + time_(runTime), abortFile_("$FOAM_CASE/" + name), action_(nextWrite) { abortFile_.expand(); read(dict); - // remove any old files from previous runs + // Remove any old files from previous runs removeFile(); } @@ -105,7 +112,7 @@ Foam::functionObjects::abort::~abort() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::abort::read(const dictionary& dict) +bool Foam::functionObjects::abort::read(const dictionary& dict) { if (dict.found("action")) { @@ -120,10 +127,12 @@ void Foam::functionObjects::abort::read(const dictionary& dict) { abortFile_.expand(); } + + return true; } -void Foam::functionObjects::abort::execute() +bool Foam::functionObjects::abort::execute(const bool postProcess) { bool hasAbort = isFile(abortFile_); reduce(hasAbort, orOp()); @@ -134,10 +143,10 @@ void Foam::functionObjects::abort::execute() { case noWriteNow : { - if (obr_.time().stopAt(Time::saNoWriteNow)) + if (time_.stopAt(Time::saNoWriteNow)) { Info<< "USER REQUESTED ABORT (timeIndex=" - << obr_.time().timeIndex() + << time_.timeIndex() << "): stop without writing data" << endl; } @@ -146,10 +155,10 @@ void Foam::functionObjects::abort::execute() case writeNow : { - if (obr_.time().stopAt(Time::saWriteNow)) + if (time_.stopAt(Time::saWriteNow)) { Info<< "USER REQUESTED ABORT (timeIndex=" - << obr_.time().timeIndex() + << time_.timeIndex() << "): stop+write data" << endl; } @@ -158,10 +167,10 @@ void Foam::functionObjects::abort::execute() case nextWrite : { - if (obr_.time().stopAt(Time::saNextWrite)) + if (time_.stopAt(Time::saNextWrite)) { Info<< "USER REQUESTED ABORT (timeIndex=" - << obr_.time().timeIndex() + << time_.timeIndex() << "): stop after next data write" << endl; } @@ -169,21 +178,22 @@ void Foam::functionObjects::abort::execute() } } } + + return true; } -void Foam::functionObjects::abort::end() +bool Foam::functionObjects::abort::write(const bool postProcess) +{ + return true; +} + + +bool Foam::functionObjects::abort::end() { removeFile(); + return true; } -void Foam::functionObjects::abort::timeSet() -{} - - -void Foam::functionObjects::abort::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/abort/abort.H b/src/postProcessing/functionObjects/utilities/abort/abort.H index 05cb4da4c..e0e5d5aa6 100644 --- a/src/postProcessing/functionObjects/utilities/abort/abort.H +++ b/src/postProcessing/functionObjects/utilities/abort/abort.H @@ -44,19 +44,13 @@ SourceFiles #ifndef functionObjects_abort_H #define functionObjects_abort_H +#include "functionObject.H" #include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -65,6 +59,8 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class abort +: + public functionObject { public: @@ -82,10 +78,8 @@ private: // Private data - //- Name of the abort file unless otherwise specified - word name_; - - const objectRegistry& obr_; + //- Reference to the Time + const Time& time_; //- The fully-qualified name of the abort file fileName abortFile_; @@ -117,13 +111,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. + //- Construct from Time and dictionary abort ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFilesUnused = false + const Time& runTime, + const dictionary& ); @@ -133,34 +126,17 @@ public: // Member Functions - //- Return name of the abort file - virtual const word& name() const - { - return name_; - } - //- Read the dictionary settings - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, check existence of abort file and take action - virtual void execute(); + virtual bool execute(const bool postProcess = false); + + //- Execute, check existence of abort file and take action + virtual bool write(const bool postProcess = false); //- Execute at the final time-loop, used for cleanup - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Execute, check existence of abort file and take action - virtual void write(); - - //- Update for changes of mesh - does nothing - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - does nothing - virtual void movePoints(const polyMesh&) - {} + virtual bool end(); }; diff --git a/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.C b/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.C deleted file mode 100644 index 0e7cb8fe3..000000000 --- a/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "abortFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(abortFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - abortFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.H b/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.H deleted file mode 100644 index cd53ca085..000000000 --- a/src/postProcessing/functionObjects/utilities/abort/abortFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::abortFunctionObject - -Description - FunctionObject wrapper around abort to allow it to be created via - the functions entry within controlDict. - -SourceFiles - abortFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef abortFunctionObject_H -#define abortFunctionObject_H - -#include "abort.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - abortFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C index 96c73367d..e57156c53 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C +++ b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C @@ -24,7 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "blendingFactor.H" -#include "dictionary.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,7 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(blendingFactor, 0); + addToRunTimeSelectionTable(functionObject, blendingFactor, dictionary); } } @@ -42,17 +44,22 @@ namespace functionObjects Foam::functionObjects::blendingFactor::blendingFactor ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), phiName_("unknown-phiName"), fieldName_("unknown-fieldName") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -70,41 +77,38 @@ Foam::functionObjects::blendingFactor::~blendingFactor() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::blendingFactor::read(const dictionary& dict) +bool Foam::functionObjects::blendingFactor::read(const dictionary& dict) { phiName_ = dict.lookupOrDefault("phiName", "phi"); dict.lookup("fieldName") >> fieldName_; + + return true; } -void Foam::functionObjects::blendingFactor::execute() +bool Foam::functionObjects::blendingFactor::execute(const bool postProcess) { calc(); calc(); + + return true; } -void Foam::functionObjects::blendingFactor::end() -{ - execute(); -} - -void Foam::functionObjects::blendingFactor::timeSet() -{} - - -void Foam::functionObjects::blendingFactor::write() +bool Foam::functionObjects::blendingFactor::write(const bool postProcess) { const word fieldName = "blendingFactor:" + fieldName_; const volScalarField& blendingFactor = obr_.lookupObject(fieldName); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << blendingFactor.name() << nl << endl; blendingFactor.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H index 938449e32..f47fc0806 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H +++ b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H @@ -32,7 +32,6 @@ Description the bended convection schemes. The output is a volume field (cells) whose value is calculated via the maximum blending factor for any cell face. - SourceFiles blendingFactor.C @@ -41,10 +40,8 @@ SourceFiles #ifndef functionObjects_blendingFactor_H #define functionObjects_blendingFactor_H +#include "functionObject.H" #include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "OFstream.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +50,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -65,13 +59,12 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class blendingFactor +: + public functionObject { // Private data - //- Name of this set of blendingFactor objects - word name_; - - //- Reference to the database + //- Reference to the objectRegistry const objectRegistry& obr_; //- Name of flux field, default is "phi" @@ -109,14 +102,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary blendingFactor ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -126,34 +117,14 @@ public: // Member Functions - //- Return name of the set of blendingFactor - virtual const word& name() const - { - return name_; - } - //- Read the blendingFactor data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the blending-factor + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the blendingFactor and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the blending-factor + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.C b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.C deleted file mode 100644 index 6f32ea9c6..000000000 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "blendingFactorFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(blendingFactorFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - blendingFactorFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.H b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.H deleted file mode 100644 index 301d365d1..000000000 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::blendingFactorFunctionObject - -Description - FunctionObject wrapper around blendingFactor to allow it to be created - via the functions entry within controlDict. - -SourceFiles - blendingFactorFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef blendingFactorFunctionObject_H -#define blendingFactorFunctionObject_H - -#include "blendingFactor.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - blendingFactorFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index 2e1c78dd6..35342d1b3 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -64,32 +64,30 @@ void Foam::codedFunctionObject::prepare dynCode.setFilterVariable("codeTimeSet", codeTimeSet_); //dynCode.setFilterVariable("codeWrite", codeWrite_); - // compile filtered C template + // Compile filtered C template dynCode.addCompileFile("functionObjectTemplate.C"); - dynCode.addCompileFile("FilterFunctionObjectTemplate.C"); - // copy filtered H template - dynCode.addCopyFile("FilterFunctionObjectTemplate.H"); + // Copy filtered H template dynCode.addCopyFile("functionObjectTemplate.H"); - // debugging: make BC verbose + // Debugging: make BC verbose // dynCode.setFilterVariable("verbose", "true"); // Info<<"compile " << redirectType_ << " sha1: " // << context.sha1() << endl; - // define Make/options + // Define Make/options dynCode.setMakeOptions - ( - "EXE_INC = -g \\\n" - "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" - "-I$(LIB_SRC)/meshTools/lnInclude \\\n" - + context.options() - + "\n\nLIB_LIBS = \\\n" - + " -lOpenFOAM \\\n" - + " -lfiniteVolume \\\n" - + " -lmeshTools \\\n" - + context.libs() - ); + ( + "EXE_INC = -g \\\n" + "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" + "-I$(LIB_SRC)/meshTools/lnInclude \\\n" + + context.options() + + "\n\nLIB_LIBS = \\\n" + + " -lOpenFOAM \\\n" + + " -lfiniteVolume \\\n" + + " -lmeshTools \\\n" + + context.libs() + ); } @@ -123,8 +121,7 @@ Foam::codedFunctionObject::codedFunctionObject ( const word& name, const Time& time, - const dictionary& dict, - bool readNow + const dictionary& dict ) : functionObject(name), @@ -132,10 +129,7 @@ Foam::codedFunctionObject::codedFunctionObject time_(time), dict_(dict) { - if (readNow) - { - read(dict_); - } + read(dict_); updateLibrary(redirectType_); redirectFunctionObject(); @@ -295,12 +289,4 @@ bool Foam::codedFunctionObject::read(const dictionary& dict) } -void Foam::codedFunctionObject::updateMesh(const mapPolyMesh&) -{} - - -void Foam::codedFunctionObject::movePoints(const polyMesh&) -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H index b5a1ec363..462828313 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H @@ -66,7 +66,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject Foam::codedBase SourceFiles @@ -151,14 +150,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary codedFunctionObject ( const word& name, const Time& time, - const dictionary& dict, - bool readNow=true // allow child-classes to avoid compilation + const dictionary& dict ); @@ -190,12 +187,6 @@ public: //- Read and set the function object if its data have changed virtual bool read(const dictionary&); - - //- Update mesh - virtual void updateMesh(const mapPolyMesh&); - - //- Move points - virtual void movePoints(const polyMesh&); }; diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C index 8b519877b..894df64a9 100644 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.C @@ -27,8 +27,8 @@ License #include "volFields.H" #include "dictionary.H" #include "dsmcCloud.H" - #include "constants.H" +#include "addToRunTimeSelectionTable.H" using namespace Foam::constant; @@ -39,6 +39,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(dsmcFields, 0); + + addToRunTimeSelectionTable + ( + functionObject, + dsmcFields, + dictionary + ); } } @@ -48,15 +55,20 @@ namespace functionObjects Foam::functionObjects::dsmcFields::dsmcFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr) + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -74,23 +86,19 @@ Foam::functionObjects::dsmcFields::~dsmcFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::dsmcFields::read(const dictionary& dict) -{} +bool Foam::functionObjects::dsmcFields::read(const dictionary& dict) +{ + return true; +} -void Foam::functionObjects::dsmcFields::execute() -{} +bool Foam::functionObjects::dsmcFields::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::dsmcFields::end() -{} - - -void Foam::functionObjects::dsmcFields::timeSet() -{} - - -void Foam::functionObjects::dsmcFields::write() +bool Foam::functionObjects::dsmcFields::write(const bool postProcess) { word rhoNMeanName = "rhoNMean"; word rhoMMeanName = "rhoMMean"; @@ -254,6 +262,8 @@ void Foam::functionObjects::dsmcFields::write() p.write(); Info<< "dsmcFields written." << nl << endl; + + return true; } else { @@ -261,6 +271,8 @@ void Foam::functionObjects::dsmcFields::write() << ") found in rhoNMean field. " << "Not calculating dsmcFields to avoid division by zero." << endl; + + return false; } } diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H index 08c5cb7f0..9aa5125d4 100644 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H +++ b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFields.H @@ -43,8 +43,7 @@ SourceFiles #ifndef functionObjects_dsmcFields_H #define functionObjects_dsmcFields_H -#include "typeInfo.H" -#include "autoPtr.H" +#include "functionObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,9 +52,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -65,12 +61,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class dsmcFields +: + public functionObject { // Private data - //- Name of this set of dsmcFields objects - word name_; - const objectRegistry& obr_; @@ -91,14 +86,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary dsmcFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -108,34 +101,14 @@ public: // Member Functions - //- Return name of the set of dsmcFields - virtual const word& name() const - { - return name_; - } - //- Read the dsmcFields data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the dsmcFields and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Calculate and write the DSMC fields + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C deleted file mode 100644 index 657243c4b..000000000 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "dsmcFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(dsmcFieldsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - dsmcFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H b/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H deleted file mode 100644 index 7a220c4bb..000000000 --- a/src/postProcessing/functionObjects/utilities/dsmcFields/dsmcFieldsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::dsmcFieldsFunctionObject - -Description - FunctionObject wrapper around dsmcFields to allow it to be created via - the functions entry within controlDict. - -SourceFiles - dsmcFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef dsmcFieldsFunctionObject_H -#define dsmcFieldsFunctionObject_H - -#include "dsmcFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - dsmcFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.C b/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.C index c9eb349bc..734d6197c 100644 --- a/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.C +++ b/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.C @@ -24,11 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "partialWrite.H" -#include "dictionary.H" #include "Time.H" -#include "IOobjectList.H" #include "polyMesh.H" -#include "cloud.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(partialWrite, 0); + + addToRunTimeSelectionTable + ( + functionObject, + partialWrite, + dictionary + ); } } @@ -46,13 +51,18 @@ namespace functionObjects Foam::functionObjects::partialWrite::partialWrite ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr) + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) { read(dict); } @@ -66,7 +76,7 @@ Foam::functionObjects::partialWrite::~partialWrite() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::partialWrite::read(const dictionary& dict) +bool Foam::functionObjects::partialWrite::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; dict.lookup("writeInterval") >> writeInterval_; @@ -110,18 +120,18 @@ void Foam::functionObjects::partialWrite::read(const dictionary& dict) loadField(iter.key(), vSymmtf_, sSymmtf_); loadField(iter.key(), vtf_, stf_); } + + return true; } -void Foam::functionObjects::partialWrite::execute() -{} +bool Foam::functionObjects::partialWrite::execute(const bool postProcess) +{ + return true; +} -void Foam::functionObjects::partialWrite::end() -{} - - -void Foam::functionObjects::partialWrite::timeSet() +bool Foam::functionObjects::partialWrite::timeSet() { if (obr_.time().writeTime()) { @@ -168,12 +178,14 @@ void Foam::functionObjects::partialWrite::timeSet() changeWriteOptions(vtf_, stf_, IOobject::NO_WRITE); } } + + return true; } -void Foam::functionObjects::partialWrite::write() +bool Foam::functionObjects::partialWrite::write(const bool postProcess) { - // Fields are written in the standard manner + return true; } diff --git a/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.H b/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.H index bfd55e89c..d312a78ba 100644 --- a/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.H +++ b/src/postProcessing/functionObjects/utilities/partialWrite/partialWrite.H @@ -54,7 +54,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles partialWrite.C @@ -64,8 +64,8 @@ SourceFiles #ifndef functionObjects_partialWrite_H #define functionObjects_partialWrite_H +#include "functionObject.H" #include "HashSet.H" -#include "runTimeSelectionTables.H" #include "volFields.H" #include "surfaceFields.H" @@ -73,13 +73,6 @@ SourceFiles namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -88,14 +81,14 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class partialWrite +: + public functionObject { protected: - // Private data - - //- Name of this partialWrite functionObject - word name_; + // Protected data + //- Reference to the objectRegistry const objectRegistry& obr_; //- Loaded fields @@ -111,6 +104,7 @@ protected: UPtrList sSymmtf_; UPtrList stf_; + // Read from dictionary //- Names of objects to dump always @@ -120,11 +114,12 @@ protected: label writeInterval_; - //- Current dump instance. If reaches writeInterval do a full write. label writeInstance_; +private: + // Private Member Functions //- Disallow default bitwise copy construct @@ -160,14 +155,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary partialWrite ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -177,34 +170,18 @@ public: // Member Functions - //- Return name of the partialWrite - virtual const word& name() const - { - return name_; - } - //- Read the partialWrite data - virtual void read(const dictionary&); - - //- Execute - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); + virtual bool read(const dictionary&); //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool timeSet(); - //- Write the partialWrite - virtual void write(); + //- Execute + virtual bool execute(const bool postProcess = false); - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing. + // The fields are registered and written automatically + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.C b/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.C deleted file mode 100644 index 993838878..000000000 --- a/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "partialWriteFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - partialWriteFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - partialWriteFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.H b/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.H index a65a095fe..993838878 100644 --- a/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/partialWrite/partialWriteFunctionObject.H @@ -21,34 +21,26 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Typedef - Foam::partialWriteFunctionObject - -Description - FunctionObject wrapper around partialWrite to allow them to be - created via the functions list within controlDict. - -SourceFiles - partialWriteFunctionObject.C - \*---------------------------------------------------------------------------*/ -#ifndef partialWriteFunctionObject_H -#define partialWriteFunctionObject_H +#include "partialWriteFunctionObject.H" -#include "partialWrite.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - typedef OutputFilterFunctionObject - partialWriteFunctionObject; + defineNamedTemplateTypeNameAndDebug + ( + partialWriteFunctionObject, + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + partialWriteFunctionObject, + dictionary + ); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C index 4ecd2a4fe..acae44aae 100644 --- a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C +++ b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.C @@ -24,8 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "removeRegisteredObject.H" -#include "dictionary.H" #include "Time.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(removeRegisteredObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + removeRegisteredObject, + dictionary + ); } } @@ -43,13 +51,18 @@ namespace functionObjects Foam::functionObjects::removeRegisteredObject::removeRegisteredObject ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), objectNames_() { read(dict); @@ -64,13 +77,18 @@ Foam::functionObjects::removeRegisteredObject::~removeRegisteredObject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict) +bool Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; + + return true; } -void Foam::functionObjects::removeRegisteredObject::execute() +bool Foam::functionObjects::removeRegisteredObject::execute +( + const bool postProcess +) { forAll(objectNames_, i) { @@ -81,7 +99,7 @@ void Foam::functionObjects::removeRegisteredObject::execute() if (obj.ownedByRegistry()) { - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " removing object " << obj.name() << nl << endl; @@ -90,21 +108,18 @@ void Foam::functionObjects::removeRegisteredObject::execute() } } } + + return true; } -void Foam::functionObjects::removeRegisteredObject::end() +bool Foam::functionObjects::removeRegisteredObject::write +( + const bool postProcess +) { - execute(); + return true; } -void Foam::functionObjects::removeRegisteredObject::timeSet() -{} - - -void Foam::functionObjects::removeRegisteredObject::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.H b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.H index e3fbe3519..7120edf8a 100644 --- a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.H +++ b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObject.H @@ -50,7 +50,6 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject SourceFiles removeRegisteredObject.C @@ -60,8 +59,8 @@ SourceFiles #ifndef functionObjects_removeRegisteredObject_H #define functionObjects_removeRegisteredObject_H +#include "functionObject.H" #include "wordList.H" -#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,9 +69,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -82,23 +78,17 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class removeRegisteredObject +: + public functionObject { -protected: - // Private data - //- Name of this set of removeRegisteredObject - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; - // Read from dictionary + //- Names of objects to control + wordList objectNames_; - //- Names of objects to control - wordList objectNames_; - - -private: // Private member functions @@ -117,14 +107,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary removeRegisteredObject ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -134,34 +122,14 @@ public: // Member Functions - //- Return name of the removeRegisteredObject - virtual const word& name() const - { - return name_; - } - //- Read the removeRegisteredObject data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Remove the registered objects + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write the removeRegisteredObject - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.C b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.C deleted file mode 100644 index 698b25d7c..000000000 --- a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "removeRegisteredObjectFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - removeRegisteredObjectFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - removeRegisteredObjectFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.H b/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.H deleted file mode 100644 index e166d00be..000000000 --- a/src/postProcessing/functionObjects/utilities/removeRegisteredObject/removeRegisteredObjectFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::removeRegisteredObjectFunctionObject - -Description - FunctionObject wrapper around removeRegisteredObject to allow them to be - created via the functions entry within controlDict. - -SourceFiles - removeRegisteredObjectFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef removeRegisteredObjectFunctionObject_H -#define removeRegisteredObjectFunctionObject_H - -#include "removeRegisteredObject.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - removeRegisteredObjectFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/residuals/residuals.C b/src/postProcessing/functionObjects/utilities/residuals/residuals.C index b7a8d52b9..f7d27d58e 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residuals.C +++ b/src/postProcessing/functionObjects/utilities/residuals/residuals.C @@ -24,9 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "residuals.H" -#include "volFields.H" -#include "dictionary.H" -#include "Time.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +33,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(residuals, 0); + + addToRunTimeSelectionTable + ( + functionObject, + residuals, + dictionary + ); } } @@ -44,23 +49,21 @@ namespace functionObjects Foam::functionObjects::residuals::residuals ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), + writeFiles(name, runTime, dict, name), fieldSet_() { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); } read(dict); + resetName(typeName); } @@ -72,9 +75,11 @@ Foam::functionObjects::residuals::~residuals() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::residuals::read(const dictionary& dict) +bool Foam::functionObjects::residuals::read(const dictionary& dict) { dict.lookup("fields") >> fieldSet_; + + return true; } @@ -101,21 +106,16 @@ void Foam::functionObjects::residuals::writeFileHeader(const label i) } -void Foam::functionObjects::residuals::execute() -{} - - -void Foam::functionObjects::residuals::end() -{} - - -void Foam::functionObjects::residuals::timeSet() -{} - - -void Foam::functionObjects::residuals::write() +bool Foam::functionObjects::residuals::execute(const bool postProcess) { - functionObjectFiles::write(); + + return true; +} + + +bool Foam::functionObjects::residuals::write(const bool postProcess) +{ + writeFiles::write(); if (Pstream::master()) { @@ -134,6 +134,8 @@ void Foam::functionObjects::residuals::write() file() << endl; } + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/residuals/residuals.H b/src/postProcessing/functionObjects/utilities/residuals/residuals.H index 2ffa4641a..7d43de05e 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residuals.H +++ b/src/postProcessing/functionObjects/utilities/residuals/residuals.H @@ -51,7 +51,8 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::writeFiles + Foam::functionObjects::timeControl SourceFiles residuals.C @@ -61,26 +62,12 @@ SourceFiles #ifndef functionObjects_residuals_H #define functionObjects_residuals_H -#include "functionObjectFiles.H" -#include "primitiveFieldsFwd.H" -#include "volFieldsFwd.H" -#include "HashSet.H" -#include "OFstream.H" -#include "Switch.H" -#include "NamedEnum.H" -#include "solverPerformance.H" +#include "writeFiles.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -90,23 +77,17 @@ namespace functionObjects class residuals : - public functionObjectFiles + public writeFiles { protected: // Protected data - //- Name of this set of residuals - // Also used as the name of the output directory - word name_; - - const objectRegistry& obr_; - //- Fields to write residuals wordList fieldSet_; - // Private Member Functions + // Protected Member Functions //- Output field header information template @@ -115,6 +96,10 @@ protected: //- Output file header information virtual void writeFileHeader(const label i); + //- Calculate the field min/max + template + void writeResidual(const word& fieldName); + private: @@ -135,14 +120,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary residuals ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -152,38 +135,14 @@ public: // Member Functions - //- Return name of the functionObject - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the field min/max - template - void writeResidual(const word& fieldName); + virtual bool execute(const bool postProcess = false); //- Write the residuals - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.C b/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.C deleted file mode 100644 index ffec5c460..000000000 --- a/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "residualsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(residualsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - residualsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.H b/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.H deleted file mode 100644 index 3d28368f6..000000000 --- a/src/postProcessing/functionObjects/utilities/residuals/residualsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::residualsFunctionObject - -Description - FunctionObject wrapper around residuals to allow them to be created via - the functions entry within controlDict. - -SourceFiles - residualsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef residualsFunctionObject_H -#define residualsFunctionObject_H - -#include "residuals.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - residualsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C b/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C index b7647242b..3f5f2b128 100644 --- a/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C +++ b/src/postProcessing/functionObjects/utilities/residuals/residualsTemplates.C @@ -25,8 +25,6 @@ License #include "residuals.H" #include "volFields.H" -#include "dictionary.H" -#include "Time.H" #include "ListOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.C b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.C index 1c3d02df2..c494a5b2b 100644 --- a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.C +++ b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.C @@ -36,6 +36,7 @@ License #include "fvmSup.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -44,6 +45,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(scalarTransport, 0); + + addToRunTimeSelectionTable + ( + functionObject, + scalarTransport, + dictionary + ); } } @@ -145,13 +153,21 @@ Foam::tmp Foam::functionObjects::scalarTransport::DT Foam::functionObjects::scalarTransport::scalarTransport ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - mesh_(refCast(obr)), + functionObject(name), + mesh_ + ( + refCast + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ) + ), phiName_(dict.lookupOrDefault("phiName", "phi")), UName_(dict.lookupOrDefault("UName", "U")), rhoName_(dict.lookupOrDefault("rhoName", "rho")), @@ -176,12 +192,6 @@ Foam::functionObjects::scalarTransport::scalarTransport boundaryTypes() ) { - if (!isA(obr)) - { - FatalErrorInFunction - << "objectRegistry is not an fvMesh" << exit(FatalError); - } - read(dict); if (resetOnStartUp_) @@ -199,7 +209,7 @@ Foam::functionObjects::scalarTransport::~scalarTransport() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::scalarTransport::read(const dictionary& dict) +bool Foam::functionObjects::scalarTransport::read(const dictionary& dict) { Info<< type() << ":" << nl; @@ -220,10 +230,12 @@ void Foam::functionObjects::scalarTransport::read(const dictionary& dict) dict.lookup("autoSchemes") >> autoSchemes_; fvOptions_.reset(dict.subDict("fvOptions")); + + return true; } -void Foam::functionObjects::scalarTransport::execute() +bool Foam::functionObjects::scalarTransport::execute(const bool postProcess) { Info<< type() << " output:" << endl; @@ -304,21 +316,15 @@ void Foam::functionObjects::scalarTransport::execute() } Info<< endl; + + return true; } -void Foam::functionObjects::scalarTransport::end() +bool Foam::functionObjects::scalarTransport::write(const bool postProcess) { - execute(); + return true; } -void Foam::functionObjects::scalarTransport::timeSet() -{} - - -void Foam::functionObjects::scalarTransport::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.H b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.H index 29b5fb0e6..2508ce721 100644 --- a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.H +++ b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransport.H @@ -47,10 +47,9 @@ SourceFiles #ifndef functionObjects_scalarTransport_H #define functionObjects_scalarTransport_H +#include "functionObject.H" #include "volFields.H" #include "surfaceFieldsFwd.H" -#include "pointFieldFwd.H" -#include "fvMatricesFwd.H" #include "fvOptionList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,8 +59,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class mapPolyMesh; namespace functionObjects { @@ -71,12 +68,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class scalarTransport +: + public functionObject { // Private data - //- Name of this set of scalarTransport objects - word name_; - //- Reference to the mesh database const fvMesh& mesh_; @@ -134,14 +130,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary scalarTransport ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -151,34 +145,15 @@ public: // Member Functions - //- Return name of the set of scalarTransport - virtual const word& name() const - { - return name_; - } - //- Read the scalarTransport data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate the scalarTransport + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the scalarTransport and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing. + // The volScalarField is registered and written automatically + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.C b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.C deleted file mode 100644 index 3f9ba1b3a..000000000 --- a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "scalarTransportFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(scalarTransportFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - scalarTransportFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.H b/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.H deleted file mode 100644 index cea384054..000000000 --- a/src/postProcessing/functionObjects/utilities/scalarTransport/scalarTransportFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::scalarTransportFunctionObject - -Description - FunctionObject wrapper around scalarTransport to allow it to be - created via the functions entry within controlDict. - -SourceFiles - scalarTransportFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef scalarTransportFunctionObject_H -#define scalarTransportFunctionObject_H - -#include "scalarTransport.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - scalarTransportFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C index 760db856d..37f045832 100644 --- a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C @@ -75,36 +75,6 @@ Foam::functionObjects::setTimeStepFunctionObject::time() const } -bool Foam::functionObjects::setTimeStepFunctionObject::execute -( - const bool postProcess -) -{ - return true; -} - - -bool Foam::functionObjects::setTimeStepFunctionObject::write -( - const bool postProcess -) -{ - return true; -} - - -bool Foam::functionObjects::setTimeStepFunctionObject::end() -{ - return true; -} - - -bool Foam::functionObjects::setTimeStepFunctionObject::timeSet() -{ - return true; -} - - bool Foam::functionObjects::setTimeStepFunctionObject::adjustTimeStep() { const_cast(time()).setDeltaT @@ -143,18 +113,22 @@ bool Foam::functionObjects::setTimeStepFunctionObject::read } -void Foam::functionObjects::setTimeStepFunctionObject::updateMesh +bool Foam::functionObjects::setTimeStepFunctionObject::execute ( - const mapPolyMesh& + const bool postProcess ) -{} +{ + return true; +} -void Foam::functionObjects::setTimeStepFunctionObject::movePoints +bool Foam::functionObjects::setTimeStepFunctionObject::write ( - const polyMesh& + const bool postProcess ) -{} +{ + return true; +} // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H index 6a31dedbc..62f12c8cc 100644 --- a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H @@ -101,41 +101,24 @@ public: // Member Functions - // Access + //- Return time database + const Time& time() const; - //- Return time database - const Time& time() const; + //- Called at the end of Time::adjustDeltaT() if adjustTime is true + virtual bool adjustTimeStep(); + //- Read and set the function object if its data have changed + virtual bool read(const dictionary&); - // Function object control + //- Called at each ++ or += of the time-loop. + // postProcess overrides the usual executeControl behaviour and + // forces execution (used in post-processing mode) + virtual bool execute(const bool postProcess = false); - //- Called at each ++ or += of the time-loop. - // postProcess overrides the usual executeControl behaviour and - // forces execution (used in post-processing mode) - virtual bool execute(const bool postProcess = false); - - //- Called at each ++ or += of the time-loop. - // postProcess overrides the usual writeControl behaviour and - // forces writing always (used in post-processing mode) - virtual bool write(const bool postProcess = false); - - //- Called when Time::run() determines that the time-loop exits - virtual bool end(); - - //- Called when time was set at the end of the Time::operator++ - virtual bool timeSet(); - - //- Called at the end of Time::adjustDeltaT() if adjustTime is true - virtual bool adjustTimeStep(); - - //- Read and set the function object if its data have changed - virtual bool read(const dictionary&); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&); - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&); + //- Called at each ++ or += of the time-loop. + // postProcess overrides the usual writeControl behaviour and + // forces writing always (used in post-processing mode) + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/systemCall/systemCall.C b/src/postProcessing/functionObjects/utilities/systemCall/systemCall.C index 1d1796af9..9d3645ba4 100644 --- a/src/postProcessing/functionObjects/utilities/systemCall/systemCall.C +++ b/src/postProcessing/functionObjects/utilities/systemCall/systemCall.C @@ -26,6 +26,7 @@ License #include "systemCall.H" #include "Time.H" #include "dynamicCode.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(systemCall, 0); + + addToRunTimeSelectionTable + ( + functionObject, + systemCall, + dictionary + ); } } @@ -43,12 +51,11 @@ namespace functionObjects Foam::functionObjects::systemCall::systemCall ( const word& name, - const objectRegistry&, - const dictionary& dict, - const bool + const Time&, + const dictionary& dict ) : - name_(name), + functionObject(name), executeCalls_(), endCalls_(), writeCalls_() @@ -65,7 +72,7 @@ Foam::functionObjects::systemCall::~systemCall() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::systemCall::read(const dictionary& dict) +bool Foam::functionObjects::systemCall::read(const dictionary& dict) { dict.readIfPresent("executeCalls", executeCalls_); dict.readIfPresent("endCalls", endCalls_); @@ -93,37 +100,41 @@ void Foam::functionObjects::systemCall::read(const dictionary& dict) << " $WM_PROJECT_DIR/etc/controlDict" << nl << nl << exit(FatalError); } + + return true; } -void Foam::functionObjects::systemCall::execute() +bool Foam::functionObjects::systemCall::execute(const bool postProcess) { forAll(executeCalls_, callI) { Foam::system(executeCalls_[callI]); } + + return true; } -void Foam::functionObjects::systemCall::end() +bool Foam::functionObjects::systemCall::end() { forAll(endCalls_, callI) { Foam::system(endCalls_[callI]); } + + return true; } -void Foam::functionObjects::systemCall::timeSet() -{} - - -void Foam::functionObjects::systemCall::write() +bool Foam::functionObjects::systemCall::write(const bool postProcess) { forAll(writeCalls_, callI) { Foam::system(writeCalls_[callI]); } + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/systemCall/systemCall.H b/src/postProcessing/functionObjects/utilities/systemCall/systemCall.H index e12da2497..a1dd56046 100644 --- a/src/postProcessing/functionObjects/utilities/systemCall/systemCall.H +++ b/src/postProcessing/functionObjects/utilities/systemCall/systemCall.H @@ -76,7 +76,7 @@ Note SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles systemCall.C @@ -86,19 +86,13 @@ SourceFiles #ifndef functionObjects_systemCall_H #define functionObjects_systemCall_H +#include "functionObject.H" #include "stringList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; - namespace functionObjects { @@ -107,14 +101,13 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class systemCall +: + public functionObject { protected: // Private data - //- Name of this set of system calls - word name_; - //- List of calls to execute - every step stringList executeCalls_; @@ -144,14 +137,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary systemCall ( const word& name, - const objectRegistry& unused, - const dictionary&, - const bool loadFromFilesUnused = false + const Time& runTime, + const dictionary& dict ); @@ -161,34 +152,17 @@ public: // Member Functions - //- Return name of the system call set - virtual const word& name() const - { - return name_; - } - //- Read the system calls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute the "executeCalls" at each time-step - virtual void execute(); + virtual bool execute(const bool postProcess = false); //- Execute the "endCalls" at the final time-loop - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool end(); //- Write, execute the "writeCalls" - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.C b/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.C deleted file mode 100644 index 0dfd7b6b0..000000000 --- a/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "systemCallFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(systemCallFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - systemCallFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.H b/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.H deleted file mode 100644 index b0fdf35ea..000000000 --- a/src/postProcessing/functionObjects/utilities/systemCall/systemCallFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::systemCallFunctionObject - -Description - FunctionObject wrapper around systemCall to allow them to be created via - the functions entry within controlDict. - -SourceFiles - systemCallFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef systemCallFunctionObject_H -#define systemCallFunctionObject_H - -#include "systemCall.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - systemCallFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C index f571185f1..9b8af9d7b 100644 --- a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C +++ b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C @@ -24,9 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "timeActivatedFileUpdate.H" -#include "objectRegistry.H" #include "Time.H" -#include "dictionary.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(timeActivatedFileUpdate, 0); + + addToRunTimeSelectionTable + ( + functionObject, + timeActivatedFileUpdate, + dictionary + ); } } @@ -47,7 +54,7 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile() while ( i < timeVsFile_.size()-1 - && timeVsFile_[i+1].first() < obr_.time().value() + && timeVsFile_[i+1].first() < time_.value() ) { i++; @@ -69,13 +76,12 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile() Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + time_(runTime), fileToUpdate_(dict.lookup("fileToUpdate")), timeVsFile_(), lastIndex_(-1) @@ -92,7 +98,7 @@ Foam::functionObjects::timeActivatedFileUpdate::~timeActivatedFileUpdate() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::timeActivatedFileUpdate::read +bool Foam::functionObjects::timeActivatedFileUpdate::read ( const dictionary& dict ) @@ -120,27 +126,29 @@ void Foam::functionObjects::timeActivatedFileUpdate::read Info<< endl; updateFile(); + + return true; } -void Foam::functionObjects::timeActivatedFileUpdate::execute() +bool Foam::functionObjects::timeActivatedFileUpdate::execute +( + const bool postProcess +) { updateFile(); + + return true; } -void Foam::functionObjects::timeActivatedFileUpdate::end() +bool Foam::functionObjects::timeActivatedFileUpdate::write +( + const bool postProcess +) { - execute(); + return true; } -void Foam::functionObjects::timeActivatedFileUpdate::timeSet() -{} - - -void Foam::functionObjects::timeActivatedFileUpdate::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H index 1b2b1d879..e72fb38b7 100644 --- a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H +++ b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H @@ -59,6 +59,7 @@ SourceFiles #ifndef functionObjects_timeActivatedFileUpdate_H #define functionObjects_timeActivatedFileUpdate_H +#include "functionObject.H" #include "Tuple2.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,10 +68,7 @@ namespace Foam { // Forward declaration of classes -class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; +class Time; namespace functionObjects { @@ -80,14 +78,13 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class timeActivatedFileUpdate +: + public functionObject { // Private data - //- Name of this set of timeActivatedFileUpdate objects - word name_; - - //- Owner database - const objectRegistry& obr_; + //- Reference to Time + const Time& time_; //- Name of file to update fileName fileToUpdate_; @@ -119,14 +116,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary timeActivatedFileUpdate ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -136,34 +131,14 @@ public: // Member Functions - //- Return name of the set of timeActivatedFileUpdate - virtual const word& name() const - { - return name_; - } - //- Read the timeActivatedFileUpdate data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Execute file updates + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Calculate the timeActivatedFileUpdate and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C deleted file mode 100644 index 7b6498065..000000000 --- a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "timeActivatedFileUpdateFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - timeActivatedFileUpdateFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - timeActivatedFileUpdateFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.H b/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.H deleted file mode 100644 index af8d9e4cc..000000000 --- a/src/postProcessing/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::timeActivatedFileUpdateFunctionObject - -Description - FunctionObject wrapper around timeActivatedFileUpdate to allow it to be - created via the functions list within controlDict. - -SourceFiles - timeActivatedFileUpdateFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef timeActivatedFileUpdateFunctionObject_H -#define timeActivatedFileUpdateFunctionObject_H - -#include "timeActivatedFileUpdate.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - timeActivatedFileUpdateFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.C b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.C index 41a1de210..5992908a7 100644 --- a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.C +++ b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.C @@ -24,9 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "turbulenceFields.H" -#include "dictionary.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(turbulenceFields, 0); + + addToRunTimeSelectionTable + ( + functionObject, + turbulenceFields, + dictionary + ); } } @@ -116,16 +123,21 @@ bool Foam::functionObjects::turbulenceFields::compressible() Foam::functionObjects::turbulenceFields::turbulenceFields ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), fieldSet_() { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -133,8 +145,8 @@ Foam::functionObjects::turbulenceFields::turbulenceFields if ( - !obr.foundObject(modelName) - && !obr.foundObject(modelName) + !obr_.foundObject(modelName) + && !obr_.foundObject(modelName) ) { FatalErrorInFunction @@ -154,11 +166,11 @@ Foam::functionObjects::turbulenceFields::~turbulenceFields() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::turbulenceFields::read(const dictionary& dict) +bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict) { fieldSet_.insert(wordList(dict.lookup("fields"))); - Info<< type() << " " << name_ << ": "; + Info<< type() << " " << name() << ": "; if (fieldSet_.size()) { Info<< "storing fields:" << nl; @@ -172,10 +184,12 @@ void Foam::functionObjects::turbulenceFields::read(const dictionary& dict) { Info<< "no fields requested to be stored" << nl << endl; } + + return true; } -void Foam::functionObjects::turbulenceFields::execute() +bool Foam::functionObjects::turbulenceFields::execute(const bool postProcess) { bool comp = compressible(); @@ -285,21 +299,15 @@ void Foam::functionObjects::turbulenceFields::execute() } } } + + return true; } -void Foam::functionObjects::turbulenceFields::end() +bool Foam::functionObjects::turbulenceFields::write(const bool postProcess) { - execute(); + return true; } -void Foam::functionObjects::turbulenceFields::timeSet() -{} - - -void Foam::functionObjects::turbulenceFields::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.H b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.H index f578022b8..bd480dfdf 100644 --- a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.H +++ b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFields.H @@ -77,7 +77,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles turbulenceFields.C @@ -87,6 +87,7 @@ SourceFiles #ifndef functionObjects_turbulenceFields_H #define functionObjects_turbulenceFields_H +#include "functionObject.H" #include "HashSet.H" #include "NamedEnum.H" #include "volFieldsFwd.H" @@ -98,9 +99,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -110,6 +108,8 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class turbulenceFields +: + public functionObject { public: @@ -144,9 +144,7 @@ protected: // Protected data - //- Name of this set of turbulenceFields object - word name_; - + //- Reference to the objectRegistry const objectRegistry& obr_; //- Fields to load @@ -186,14 +184,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary turbulenceFields ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -203,34 +199,15 @@ public: // Member Functions - //- Return name of the turbulenceFields object - virtual const word& name() const - { - return name_; - } - //- Read the controls - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Calculate turbulence fields + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Do nothing. + // The turbulence fields are registered and written automatically + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.C b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.C deleted file mode 100644 index 4f779363f..000000000 --- a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "turbulenceFieldsFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(turbulenceFieldsFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - turbulenceFieldsFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.H b/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.H deleted file mode 100644 index 6d600f7ce..000000000 --- a/src/postProcessing/functionObjects/utilities/turbulenceFields/turbulenceFieldsFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::turbulenceFieldsFunctionObject - -Description - FunctionObject wrapper around turbulenceFields to allow them to be created - via the functions entry within controlDict. - -SourceFiles - turbulenceFieldsFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef turbulenceFieldsFunctionObject_H -#define turbulenceFieldsFunctionObject_H - -#include "turbulenceFields.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - turbulenceFieldsFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/vorticity/vorticity.C b/src/postProcessing/functionObjects/utilities/vorticity/vorticity.C index 89cb38d2c..ac9828f8e 100644 --- a/src/postProcessing/functionObjects/utilities/vorticity/vorticity.C +++ b/src/postProcessing/functionObjects/utilities/vorticity/vorticity.C @@ -25,8 +25,8 @@ License #include "vorticity.H" #include "volFields.H" -#include "dictionary.H" #include "fvcCurl.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(vorticity, 0); + + addToRunTimeSelectionTable + ( + functionObject, + vorticity, + dictionary + ); } } @@ -44,17 +51,22 @@ namespace functionObjects Foam::functionObjects::vorticity::vorticity ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), UName_("U"), outputName_(typeName) { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -93,17 +105,19 @@ Foam::functionObjects::vorticity::~vorticity() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::vorticity::read(const dictionary& dict) +bool Foam::functionObjects::vorticity::read(const dictionary& dict) { UName_ = dict.lookupOrDefault("UName", "U"); if (UName_ != "U") { outputName_ = typeName + "(" + UName_ + ")"; } + + return true; } -void Foam::functionObjects::vorticity::execute() +bool Foam::functionObjects::vorticity::execute(const bool postProcess) { const volVectorField& U = obr_.lookupObject(UName_); @@ -113,29 +127,23 @@ void Foam::functionObjects::vorticity::execute() ); vorticity = fvc::curl(U); + + return true; } -void Foam::functionObjects::vorticity::end() -{ - execute(); -} - - -void Foam::functionObjects::vorticity::timeSet() -{} - - -void Foam::functionObjects::vorticity::write() +bool Foam::functionObjects::vorticity::write(const bool postProcess) { const volVectorField& vorticity = obr_.lookupObject(outputName_); - Info<< type() << " " << name_ << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " writing field " << vorticity.name() << nl << endl; vorticity.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/vorticity/vorticity.H b/src/postProcessing/functionObjects/utilities/vorticity/vorticity.H index e430924a1..942926a94 100644 --- a/src/postProcessing/functionObjects/utilities/vorticity/vorticity.H +++ b/src/postProcessing/functionObjects/utilities/vorticity/vorticity.H @@ -38,6 +38,7 @@ SourceFiles #ifndef functionObjects_vorticity_H #define functionObjects_vorticity_H +#include "functionObject.H" #include "volFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,9 +48,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -59,12 +57,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class vorticity +: + public functionObject { // Private data - //- Name of this set of vorticity objects - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -92,14 +89,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary vorticity ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -109,34 +104,14 @@ public: // Member Functions - //- Return name of the set of vorticity - virtual const word& name() const - { - return name_; - } - //- Read the vorticity data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Calculate the vorticity and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.C b/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.C deleted file mode 100644 index 51b7c2f1e..000000000 --- a/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "vorticityFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(vorticityFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - vorticityFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.H b/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.H deleted file mode 100644 index aee3f04f8..000000000 --- a/src/postProcessing/functionObjects/utilities/vorticity/vorticityFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::vorticityFunctionObject - -Description - FunctionObject wrapper around vorticity to allow it to be created - via the functions entry within controlDict. - -SourceFiles - vorticityFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef vorticityFunctionObject_H -#define vorticityFunctionObject_H - -#include "vorticity.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - vorticityFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.C b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.C index 7fdc21fba..38a293efe 100644 --- a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.C +++ b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.C @@ -24,9 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "writeDictionary.H" -#include "dictionary.H" #include "Time.H" -#include "HashSet.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(writeDictionary, 0); + + addToRunTimeSelectionTable + ( + functionObject, + writeDictionary, + dictionary + ); } } @@ -66,7 +73,7 @@ bool Foam::functionObjects::writeDictionary::tryDirectory { if (firstDict) { - Info<< type() << " " << name_ << " output:" << nl << endl; + Info<< type() << " " << name() << " output:" << nl << endl; IOobject::writeDivider(Info); Info<< endl; @@ -92,13 +99,18 @@ bool Foam::functionObjects::writeDictionary::tryDirectory Foam::functionObjects::writeDictionary::writeDictionary ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), - obr_(obr), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), dictNames_(), digests_() { @@ -115,7 +127,7 @@ Foam::functionObjects::writeDictionary::~writeDictionary() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::writeDictionary::read(const dictionary& dict) +bool Foam::functionObjects::writeDictionary::read(const dictionary& dict) { wordList dictNames(dict.lookup("dictNames")); HashSet uniqueNames(dictNames); @@ -123,7 +135,7 @@ void Foam::functionObjects::writeDictionary::read(const dictionary& dict) digests_.setSize(dictNames_.size(), SHA1Digest()); - Info<< type() << " " << name_ << ": monitoring dictionaries:" << nl; + Info<< type() << " " << name() << ": monitoring dictionaries:" << nl; if (dictNames_.size()) { forAll(dictNames_, i) @@ -136,10 +148,12 @@ void Foam::functionObjects::writeDictionary::read(const dictionary& dict) Info<< " none" << nl; } Info<< endl; + + return true; } -void Foam::functionObjects::writeDictionary::execute() +bool Foam::functionObjects::writeDictionary::execute(const bool postProcess) { bool firstDict = true; forAll(dictNames_, i) @@ -153,7 +167,7 @@ void Foam::functionObjects::writeDictionary::execute() { if (firstDict) { - Info<< type() << " " << name_ << " output:" << nl << endl; + Info<< type() << " " << name() << " output:" << nl << endl; IOobject::writeDivider(Info); Info<< endl; @@ -192,21 +206,15 @@ void Foam::functionObjects::writeDictionary::execute() } } } + + return true; } -void Foam::functionObjects::writeDictionary::end() +bool Foam::functionObjects::writeDictionary::write(const bool postProcess) { - execute(); + return true; } -void Foam::functionObjects::writeDictionary::timeSet() -{} - - -void Foam::functionObjects::writeDictionary::write() -{} - - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.H b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.H index 5a3f81f9d..6cee9467a 100644 --- a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.H +++ b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionary.H @@ -38,8 +38,8 @@ SourceFiles #ifndef functionObjects_writeDictionary_H #define functionObjects_writeDictionary_H +#include "functionObject.H" #include "wordList.H" -#include "runTimeSelectionTables.H" #include "SHA1Digest.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,9 +49,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -61,14 +58,11 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class writeDictionary +: + public functionObject { -protected: - // Private data - //- Name of this set of writeDictionary - word name_; - //- Reference to the database const objectRegistry& obr_; @@ -109,14 +103,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary writeDictionary ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -126,34 +118,14 @@ public: // Member Functions - //- Return name of the writeDictionary - virtual const word& name() const - { - return name_; - } - //- Read the writeDictionary data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Write the writeDictionary - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.C b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.C deleted file mode 100644 index f16f5921b..000000000 --- a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "writeDictionaryFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(writeDictionaryFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - writeDictionaryFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.H b/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.H deleted file mode 100644 index f75e01271..000000000 --- a/src/postProcessing/functionObjects/utilities/writeDictionary/writeDictionaryFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::writeDictionaryFunctionObject - -Description - FunctionObject wrapper around writeDictionary to allow them to be - created via the functions entry within controlDict. - -SourceFiles - writeDictionaryFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef writeDictionaryFunctionObject_H -#define writeDictionaryFunctionObject_H - -#include "writeDictionary.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - writeDictionaryFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.C b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.C index 837ddd35f..0963320db 100644 --- a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.C +++ b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.C @@ -24,8 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "writeRegisteredObject.H" -#include "dictionary.H" #include "Time.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,6 +35,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(writeRegisteredObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + writeRegisteredObject, + dictionary + ); } } @@ -43,14 +51,19 @@ namespace functionObjects Foam::functionObjects::writeRegisteredObject::writeRegisteredObject ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - name_(name), + functionObject(name), + obr_ + ( + runTime.lookupObject + ( + dict.lookupOrDefault("region", polyMesh::defaultRegion) + ) + ), exclusiveWriting_(false), - obr_(obr), objectNames_() { read(dict); @@ -65,28 +78,30 @@ Foam::functionObjects::writeRegisteredObject::~writeRegisteredObject() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::writeRegisteredObject::read(const dictionary& dict) +bool Foam::functionObjects::writeRegisteredObject::read(const dictionary& dict) { dict.lookup("objectNames") >> objectNames_; dict.readIfPresent("exclusiveWriting", exclusiveWriting_); + + return true; } -void Foam::functionObjects::writeRegisteredObject::execute() -{} - - -void Foam::functionObjects::writeRegisteredObject::end() -{} - - -void Foam::functionObjects::writeRegisteredObject::timeSet() -{} - - -void Foam::functionObjects::writeRegisteredObject::write() +bool Foam::functionObjects::writeRegisteredObject::execute +( + const bool postProcess +) { - Info<< type() << " " << name_ << " output:" << nl; + return true; +} + + +bool Foam::functionObjects::writeRegisteredObject::write +( + const bool postProcess +) +{ + Info<< type() << " " << name() << " output:" << nl; DynamicList allNames(obr_.toc().size()); forAll(objectNames_, i) @@ -124,6 +139,8 @@ void Foam::functionObjects::writeRegisteredObject::write() obj.write(); } + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.H b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.H index 012b35f67..a9979dfa0 100644 --- a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.H +++ b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObject.H @@ -64,7 +64,7 @@ Description SeeAlso Foam::functionObject - Foam::OutputFilterFunctionObject + Foam::functionObjects::timeControl SourceFiles writeRegisteredObject.C @@ -74,8 +74,8 @@ SourceFiles #ifndef functionObjects_writeRegisteredObject_H #define functionObjects_writeRegisteredObject_H +#include "functionObject.H" #include "wordReList.H" -#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -84,9 +84,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; namespace functionObjects { @@ -96,27 +93,23 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class writeRegisteredObject +: + public functionObject { // Private data - //- Name of this set of writeRegisteredObject - word name_; - - //- Takes over the writing from Db - bool exclusiveWriting_; - //- Refererence to Db const objectRegistry& obr_; - // Read from dictionary + //- Takes over the writing from Db + bool exclusiveWriting_; - //- Names of objects to control - wordReList objectNames_; + //- Names of objects to control + wordReList objectNames_; // Private Member Functions - //- Disallow default bitwise copy construct writeRegisteredObject(const writeRegisteredObject&); @@ -132,14 +125,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary writeRegisteredObject ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -149,34 +140,14 @@ public: // Member Functions - //- Return name of the writeRegisteredObject - virtual const word& name() const - { - return name_; - } - //- Read the writeRegisteredObject data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); - //- Execute, currently does nothing - virtual void execute(); + //- Do nothing + virtual bool execute(const bool postProcess = false); - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); - - //- Write the writeRegisteredObject - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + //- Write the registered objects + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.C b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.C deleted file mode 100644 index 1eebe9cef..000000000 --- a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.C +++ /dev/null @@ -1,46 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "writeRegisteredObjectFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug - ( - writeRegisteredObjectFunctionObject, - 0 - ); - - addToRunTimeSelectionTable - ( - functionObject, - writeRegisteredObjectFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.H b/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.H deleted file mode 100644 index dd45776f4..000000000 --- a/src/postProcessing/functionObjects/utilities/writeRegisteredObject/writeRegisteredObjectFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::writeRegisteredObjectFunctionObject - -Description - FunctionObject wrapper around writeRegisteredObject to allow them to be - created via the functions entry within controlDict. - -SourceFiles - writeRegisteredObjectFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef writeRegisteredObjectFunctionObject_H -#define writeRegisteredObjectFunctionObject_H - -#include "writeRegisteredObject.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - writeRegisteredObjectFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C index 4384c47ac..0becd46aa 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.C @@ -27,6 +27,7 @@ License #include "volFields.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -35,6 +36,13 @@ namespace Foam namespace functionObjects { defineTypeNameAndDebug(yPlus, 0); + + addToRunTimeSelectionTable + ( + functionObject, + yPlus, + dictionary + ); } } @@ -59,18 +67,14 @@ void Foam::functionObjects::yPlus::writeFileHeader(const label i) Foam::functionObjects::yPlus::yPlus ( const word& name, - const objectRegistry& obr, - const dictionary& dict, - const bool loadFromFiles + const Time& runTime, + const dictionary& dict ) : - functionObjectFiles(obr, name, typeName), - name_(name), - obr_(obr), - log_(true), + writeFiles(name, runTime, dict, name), phiName_("phi") { - if (!isA(obr)) + if (!isA(obr_)) { FatalErrorInFunction << "objectRegistry is not an fvMesh" << exit(FatalError); @@ -96,6 +100,8 @@ Foam::functionObjects::yPlus::yPlus ); mesh.objectRegistry::store(yPlusPtr); + + resetName(typeName); } @@ -107,19 +113,21 @@ Foam::functionObjects::yPlus::~yPlus() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::functionObjects::yPlus::read(const dictionary& dict) +bool Foam::functionObjects::yPlus::read(const dictionary& dict) { - log_ = dict.lookupOrDefault("log", true); + writeFiles::read(dict); phiName_ = dict.lookupOrDefault("phiName", "phi"); + + return true; } -void Foam::functionObjects::yPlus::execute() +bool Foam::functionObjects::yPlus::execute(const bool postProcess) { typedef compressible::turbulenceModel cmpModel; typedef incompressible::turbulenceModel icoModel; - functionObjectFiles::write(); + writeFiles::write(); const fvMesh& mesh = refCast(obr_); @@ -129,7 +137,7 @@ void Foam::functionObjects::yPlus::execute() mesh.lookupObject(type()) ); - if (log_) Info<< type() << " " << name_ << " output:" << nl; + if (log_) Info<< type() << " " << name() << " output:" << nl; tmp Reff; if (mesh.foundObject(turbulenceModel::propertiesName)) @@ -152,22 +160,14 @@ void Foam::functionObjects::yPlus::execute() << "Unable to find turbulence model in the " << "database" << exit(FatalError); } + + return true; } -void Foam::functionObjects::yPlus::end() +bool Foam::functionObjects::yPlus::write(const bool postProcess) { - execute(); -} - - -void Foam::functionObjects::yPlus::timeSet() -{} - - -void Foam::functionObjects::yPlus::write() -{ - functionObjectFiles::write(); + writeFiles::write(); const volScalarField& yPlus = obr_.lookupObject(type()); @@ -175,6 +175,8 @@ void Foam::functionObjects::yPlus::write() if (log_) Info<< " writing field " << yPlus.name() << nl << endl; yPlus.write(); + + return true; } diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H index a40e3b3db..8674fa156 100644 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H +++ b/src/postProcessing/functionObjects/utilities/yPlus/yPlus.H @@ -31,6 +31,11 @@ Description Evaluates and outputs turbulence y+ for models. Values written to time directories as field 'yPlus' +SeeAlso + Foam::functionObject + Foam::functionObjects::writeFiles + Foam::functionObjects::timeControl + SourceFiles yPlus.C @@ -39,10 +44,8 @@ SourceFiles #ifndef functionObjects_yPlus_H #define functionObjects_yPlus_H -#include "functionObjectFiles.H" +#include "writeFiles.H" #include "volFieldsFwd.H" -#include "Switch.H" -#include "OFstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,9 +54,6 @@ namespace Foam // Forward declaration of classes class objectRegistry; -class dictionary; -class polyMesh; -class mapPolyMesh; class fvMesh; namespace functionObjects @@ -65,18 +65,10 @@ namespace functionObjects class yPlus : - public functionObjectFiles + public writeFiles { // Private data - //- Name of this set of yPlus objects - word name_; - - const objectRegistry& obr_; - - //- Switch to send output to Info as well as to file - Switch log_; - //- Name of mass/volume flux field (optional, default = phi) word phiName_; @@ -110,14 +102,12 @@ public: // Constructors - //- Construct for given objectRegistry and dictionary. - // Allow the possibility to load fields from files + //- Construct from Time and dictionary yPlus ( const word& name, - const objectRegistry&, - const dictionary&, - const bool loadFromFiles = false + const Time& runTime, + const dictionary& dict ); @@ -127,34 +117,14 @@ public: // Member Functions - //- Return name of the set of yPlus - virtual const word& name() const - { - return name_; - } - //- Read the yPlus data - virtual void read(const dictionary&); + virtual bool read(const dictionary&); //- Execute, currently does nothing - virtual void execute(); - - //- Execute at the final time-loop, currently does nothing - virtual void end(); - - //- Called when time was set at the end of the Time::operator++ - virtual void timeSet(); + virtual bool execute(const bool postProcess = false); //- Calculate the yPlus and write - virtual void write(); - - //- Update for changes of mesh - virtual void updateMesh(const mapPolyMesh&) - {} - - //- Update for changes of mesh - virtual void movePoints(const polyMesh&) - {} + virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.C b/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.C deleted file mode 100644 index a8d98b7cf..000000000 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.C +++ /dev/null @@ -1,42 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation - \\/ 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 . - -\*---------------------------------------------------------------------------*/ - -#include "yPlusFunctionObject.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineNamedTemplateTypeNameAndDebug(yPlusFunctionObject, 0); - - addToRunTimeSelectionTable - ( - functionObject, - yPlusFunctionObject, - dictionary - ); -} - -// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.H b/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.H deleted file mode 100644 index 7075ea272..000000000 --- a/src/postProcessing/functionObjects/utilities/yPlus/yPlusFunctionObject.H +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ 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 . - -Typedef - Foam::yPlusFunctionObject - -Description - FunctionObject wrapper around yPlus to allow it to be created - via the functions entry within controlDict. - -SourceFiles - yPlusFunctionObject.C - -\*---------------------------------------------------------------------------*/ - -#ifndef yPlusFunctionObject_H -#define yPlusFunctionObject_H - -#include "yPlus.H" -#include "OutputFilterFunctionObject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - typedef OutputFilterFunctionObject - yPlusFunctionObject; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 8bbc898dd..5aec62bba 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -1,7 +1,6 @@ probes/probes.C probes/patchProbes.C probes/probesGrouping.C -probes/probesFunctionObject/probesFunctionObject.C sampledSet/circle/circleSet.C sampledSet/cloud/cloudSet.C @@ -14,7 +13,6 @@ sampledSet/patchSeed/patchSeedSet.C sampledSet/sampledSet/sampledSet.C sampledSet/sampledSets/sampledSets.C sampledSet/sampledSets/sampledSetsGrouping.C -sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C sampledSet/uniform/uniformSet.C sampledSet/array/arraySet.C @@ -33,7 +31,6 @@ sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C sampledSurface/sampledSurface/sampledSurface.C sampledSurface/sampledSurfaces/sampledSurfaces.C sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C -sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C sampledSurface/thresholdCellFaces/thresholdCellFaces.C sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C diff --git a/src/sampling/Make/options b/src/sampling/Make/options index 23e6bc81a..8e006e099 100644 --- a/src/sampling/Make/options +++ b/src/sampling/Make/options @@ -4,6 +4,7 @@ EXE_INC = \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/conversion/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude @@ -14,4 +15,5 @@ LIB_LIBS = \ -lfileFormats \ -ltriSurface \ -llagrangian \ + -ldynamicMesh \ -lconversion diff --git a/src/sampling/meshToMesh/meshToMesh.C b/src/sampling/meshToMesh/meshToMesh.C index 6f2c5c0f5..b49ae2a7b 100644 --- a/src/sampling/meshToMesh/meshToMesh.C +++ b/src/sampling/meshToMesh/meshToMesh.C @@ -265,28 +265,34 @@ void Foam::meshToMesh::calculate(const word& methodName) } // set up as a reverse distribute - mapDistribute::distribute + mapDistributeBase::distribute ( Pstream::nonBlocking, List(), tgtRegion_.nCells(), map.constructMap(), + false, map.subMap(), + false, tgtToSrcCellAddr_, ListPlusEqOp