diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C index 1f6cc537e11d26110b3759868c6ee130a5e96938..e3755efbb8bc319dd712b21fff771411c30cf24f 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C @@ -198,11 +198,10 @@ void Foam::fieldValues::cellSource::write() if (active_) { + scalar totalVolume = gSum(filterField(mesh().V())); if (Pstream::master()) { - outputFilePtr_() - << obr_.time().value() << tab - << sum(filterField(mesh().V())); + outputFilePtr_() << obr_.time().value() << tab << totalVolume; } forAll(fields_, i) diff --git a/src/postProcessing/functionObjects/field/fieldValues/controlDict b/src/postProcessing/functionObjects/field/fieldValues/controlDict index 7605d4afc11a477335bc5d2ed5dad1d6bf8b4669..58a73493717e7092a1baf052c8da9ec7e37703dd 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/controlDict +++ b/src/postProcessing/functionObjects/field/fieldValues/controlDict @@ -61,11 +61,23 @@ functions // Output field values as well valueOutput true; - // Patch or faceZone to sample + // Type of source: patch/faceZone/sampledSurface source patch; + + // if patch or faceZone: name of patch or faceZone sourceName movingWall; -// source faceZone; -// sourceName f0; + + //// if sampledSurface: dictionary with a sampledSurface + //sampledSurfaceDict + //{ + // type cuttingPlane; + // planeType pointAndNormal; + // pointAndNormalDict + // { + // basePoint (0 0.099 0); + // normalVector (0 1 0); + // } + //} // Operation: areaAverage/sum/weightedAverage ... operation areaAverage; @@ -73,7 +85,7 @@ functions fields ( p - phi + phi // surface fields not supported for sampledSurface U ); } diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index f30d80f7160197fb5abe96d3460f6a8e86915e8b..472f725dc4275c011a627f813db216f5b9f6de4a 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -28,21 +28,20 @@ License #include "cyclicPolyPatch.H" #include "emptyPolyPatch.H" #include "coupledPolyPatch.H" -#include "surfaceFields.H" -#include "volFields.H" +#include "sampledSurface.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(Foam::fieldValues::faceSource, 0); template<> -const char* Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 2>:: +const char* Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>:: names[] = { - "faceZone", "patch" + "faceZone", "patch", "sampledSurface" }; -const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 2> +const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3> Foam::fieldValues::faceSource::sourceTypeNames_; @@ -188,6 +187,19 @@ void Foam::fieldValues::faceSource::setPatchFaces() } +void Foam::fieldValues::faceSource::sampledSurfaceFaces(const dictionary& dict) +{ + surfacePtr_ = sampledSurface::New + ( + name_, + mesh(), + dict.subDict("sampledSurfaceDict") + ); + surfacePtr_().update(); + nFaces_ = returnReduce(surfacePtr_().faces().size(), sumOp<label>()); +} + + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void Foam::fieldValues::faceSource::initialise(const dictionary& dict) @@ -204,20 +216,37 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict) setPatchFaces(); break; } + case stSampledSurface: + { + sampledSurfaceFaces(dict); + break; + } default: { FatalErrorIn("faceSource::initialise()") << type() << " " << name_ << ": " << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << " Unknown source type. Valid source types are:" - << sourceTypeNames_ << nl << exit(FatalError); + << sourceTypeNames_.sortedToc() << nl << exit(FatalError); } } + scalar totalArea; + + if (surfacePtr_.valid()) + { + surfacePtr_().update(); + totalArea = gSum(surfacePtr_().magSf()); + } + else + { + totalArea = gSum(filterField(mesh().magSf(), false)); + } + Info<< type() << " " << name_ << ":" << nl << " total faces = " << nFaces_ << nl - << " total area = " << gSum(filterField(mesh().magSf(), false)) + << " total area = " << totalArea << nl; if (operation_ == opWeightedAverage) @@ -280,11 +309,11 @@ Foam::fieldValues::faceSource::faceSource fieldValue(name, obr, dict, loadFromFiles), source_(sourceTypeNames_.read(dict.lookup("source"))), operation_(operationTypeNames_.read(dict.lookup("operation"))), + weightFieldName_("undefinedWeightedFieldName"), nFaces_(0), faceId_(), facePatchId_(), - faceSign_(), - weightFieldName_("undefinedWeightedFieldName") + faceSign_() { read(dict); } @@ -315,11 +344,22 @@ void Foam::fieldValues::faceSource::write() if (active_) { + scalar totalArea; + + if (surfacePtr_.valid()) + { + surfacePtr_().update(); + totalArea = gSum(surfacePtr_().magSf()); + } + else + { + totalArea = gSum(filterField(mesh().magSf(), false)); + } + + if (Pstream::master()) { - outputFilePtr_() - << obr_.time().value() << tab - << sum(filterField(mesh().magSf(), false)); + outputFilePtr_() << obr_.time().value() << tab << totalArea; } forAll(fields_, i) diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index 3789aaadb45cd55842fccdb41ce254648d2323ff..9d10cdcfce5719d34a211fc9b250c2f1664790e0 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -36,8 +36,9 @@ Description outputControl outputTime; log true; // log to screen? valueOutput true; // Write values at run-time output times? - source faceZone; // Type of face source: faceZone, patch - sourceName f0; + source faceZone; // Type of face source: + // faceZone,patch,sampledSurface + sourceName f0; // faceZone name, see below operation sum; fields ( @@ -47,7 +48,13 @@ Description ); } - where operation is one of: + source: + - faceZone : requires a 'sourceName' entry to specify the faceZone + - patch : "" patch + - sampledSurface : requires a 'sampledSurfaceDict' subdictionary. See e.g. + sampleDict. + + operation is one of: - none - sum - areaAverage @@ -80,6 +87,9 @@ SourceFiles namespace Foam { + +class sampledSurface; + namespace fieldValues { @@ -100,11 +110,12 @@ public: enum sourceType { stFaceZone, - stPatch + stPatch, + stSampledSurface }; //- Source type names - static const NamedEnum<sourceType, 2> sourceTypeNames_; + static const NamedEnum<sourceType, 3> sourceTypeNames_; //- Operation type enumeration @@ -133,6 +144,9 @@ private: //- Set faces to evaluate based on a patch void setPatchFaces(); + //- Set faces according to sampledSurface + void sampledSurfaceFaces(const dictionary&); + protected: @@ -144,20 +158,30 @@ protected: //- Operation to apply to values operationType operation_; + //- Weight field name - only used for opWeightedAverage mode + word weightFieldName_; + //- Global number of faces label nFaces_; - //- Local list of face IDs - labelList faceId_; - //- Local list of patch ID per face - labelList facePatchId_; + // If operating on mesh faces (faceZone,patch) - //- List of +1/-1 representing face flip map (1 use as is, -1 negate) - labelList faceSign_; + //- Local list of face IDs + labelList faceId_; + + //- Local list of patch ID per face + labelList facePatchId_; + + //- List of +1/-1 representing face flip map + // (1 use as is, -1 negate) + labelList faceSign_; + + // If operating on sampledSurface + + //- underlying sampledSurface + autoPtr<sampledSurface> surfacePtr_; - //- Weight field name - only used for opWeightedAverage mode - word weightFieldName_; // Protected Member Functions @@ -171,7 +195,7 @@ protected: //- Return field values by looking up field name template<class Type> - tmp<Field<Type> > setFieldValues(const word& fieldName) const; + tmp<Field<Type> > getFieldValues(const word& fieldName) const; //- Apply the 'operation' to the values template<class Type> diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index 3f6c9bd3c9bb7b05e71723dc7aeea929a694a249..9999860a62313f130feadf16df04c45422539831 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -26,7 +26,7 @@ License #include "faceSource.H" #include "surfaceFields.H" #include "volFields.H" -#include "ListListOps.H" +#include "sampledSurface.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -36,7 +36,7 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf; typedef GeometricField<Type, fvPatchField, volMesh> vf; - if (obr_.foundObject<sf>(fieldName)) + if (source_ != stSampledSurface && obr_.foundObject<sf>(fieldName)) { return true; } @@ -50,7 +50,7 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const template<class Type> -Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::setFieldValues +Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues ( const word& fieldName ) const @@ -58,13 +58,20 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::setFieldValues typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf; typedef GeometricField<Type, fvPatchField, volMesh> vf; - if (obr_.foundObject<sf>(fieldName)) + if (source_ != stSampledSurface && obr_.foundObject<sf>(fieldName)) { return filterField(obr_.lookupObject<sf>(fieldName), true); } else if (obr_.foundObject<vf>(fieldName)) { - return filterField(obr_.lookupObject<vf>(fieldName), true); + if (surfacePtr_.valid()) + { + return surfacePtr_().sample(obr_.lookupObject<vf>(fieldName)); + } + else + { + return filterField(obr_.lookupObject<vf>(fieldName), true); + } } return tmp<Field<Type> >(new Field<Type>(0)); @@ -131,15 +138,26 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName) if (ok) { - // Get (correctly oriented) field - Field<Type> values = combineFields(setFieldValues<Type>(fieldName)); + Field<Type> values = getFieldValues<Type>(fieldName); + scalarField weightField = getFieldValues<scalar>(weightFieldName_); + scalarField magSf; + + if (surfacePtr_.valid()) + { + // Get unoriented magSf + magSf = surfacePtr_().magSf(); + } + else + { + // Get unoriented magSf + magSf = combineFields(filterField(mesh().magSf(), false)); + } - // Get unoriented magSf - scalarField magSf = combineFields(filterField(mesh().magSf(), false)); + // Combine onto master + values = combineFields(values); + magSf = combineFields(magSf); + weightField = combineFields(weightField); - // Get (correctly oriented) weighting field - scalarField weightField = - combineFields(setFieldValues<scalar>(weightFieldName_)); if (Pstream::master()) { diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C index 1c5af36ad7bd4311bbb3199f58de54fb443deebf..0f4ead7444be55dd87707cc92757d606bd12cf25 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -130,7 +130,7 @@ Foam::fieldValue::fieldValue obr_(obr), active_(true), log_(false), - sourceName_(dict.lookup("sourceName")), + sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")), fields_(dict.lookup("fields")), valueOutput_(dict.lookup("valueOutput")), outputFilePtr_(NULL) diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H index ab32927dc9271ada2829afe4f82b3ccf33e20972..179b96ae94c7f1f2d054dd62009c559708f543c1 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -164,12 +164,14 @@ public: //- Execute the at the final time-loop, currently does nothing virtual void end(); - //- Comnbine fields from all processor domains into single field + //- Combine fields from all processor domains into single field template<class Type> - tmp<Field<Type> > combineFields - ( - const tmp<Field<Type> >& field - ) const; + tmp<Field<Type> > combineFields(const Field<Type>& field) const; + + //- Combine fields from all processor domains into single field + template<class Type> + tmp<Field<Type> > combineFields(const tmp<Field<Type> >&) const; + }; diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C index 0aff19c8affeae9aab482ceb97d73c7dfbbd082d..3df599081d315f7eea038b67b99bfd483a6f5414 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C @@ -32,12 +32,12 @@ License template<class Type> Foam::tmp<Foam::Field<Type> > Foam::fieldValue::combineFields ( - const tmp<Field<Type> >& field + const Field<Type>& field ) const { List<Field<Type> > allValues(Pstream::nProcs()); - allValues[Pstream::myProcNo()] = field(); + allValues[Pstream::myProcNo()] = field; Pstream::gatherList(allValues); @@ -57,9 +57,19 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValue::combineFields } else { - return field(); + return field; } } +template<class Type> +Foam::tmp<Foam::Field<Type> > Foam::fieldValue::combineFields +( + const tmp<Field<Type> >& field +) const +{ + return combineFields(field()); +} + + // ************************************************************************* //