diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index 356c74b40f..aef073e17a 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -15,7 +15,6 @@ EXE_LIBS = \ -ldecompositionMethods \ -L$(FOAM_LIBBIN)/dummy \ -lkahipDecomp -lmetisDecomp -lscotchDecomp \ - -lfiniteArea \ -llagrangian \ -ldynamicMesh \ -lregionModels diff --git a/src/Allwmake b/src/Allwmake index 51ddcf05cc..c91fb6de5c 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -40,9 +40,8 @@ wmakeLnInclude -u fvOptions wmake $targetType finiteVolume wmake $targetType lagrangian/basic wmake $targetType lagrangian/distributionModels -wmake $targetType genericPatchFields - wmake $targetType finiteArea +wmake $targetType genericPatchFields conversion/Allwmake $targetType $* wmake $targetType mesh/extrudeModel diff --git a/src/finiteArea/fields/faPatchFields/basic/calculated/calculatedFaPatchField.C b/src/finiteArea/fields/faPatchFields/basic/calculated/calculatedFaPatchField.C index f990a7df4c..50c6a626e2 100644 --- a/src/finiteArea/fields/faPatchFields/basic/calculated/calculatedFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/basic/calculated/calculatedFaPatchField.C @@ -140,8 +140,8 @@ Foam::calculatedFaPatchField::valueInternalCoeffs FatalErrorInFunction << "valueInternalCoeffs cannot be called for a calculatedFaPatchField" << "\n on patch " << this->patch().name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << "\n You are probably trying to solve for a field with a " "default boundary condition." << exit(FatalError); @@ -160,8 +160,8 @@ Foam::calculatedFaPatchField::valueBoundaryCoeffs FatalErrorInFunction << "valueBoundaryCoeffs cannot be called for a calculatedFaPatchField" << "\n on patch " << this->patch().name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << "\n You are probably trying to solve for a field with a " "default boundary condition." << exit(FatalError); @@ -178,8 +178,8 @@ Foam::calculatedFaPatchField::gradientInternalCoeffs() const << "gradientInternalCoeffs cannot be called for a " "calculatedFaPatchField" << "\n on patch " << this->patch().name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << "\n You are probably trying to solve for a field with a " "default boundary condition." << exit(FatalError); @@ -197,8 +197,8 @@ Foam::calculatedFaPatchField::gradientBoundaryCoeffs() const "gradientBoundaryCoeffs cannot be called for a " "calculatedFaPatchField" << "\n on patch " << this->patch().name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << "\n You are probably trying to solve for a field with a " "default boundary condition." << exit(FatalError); diff --git a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C index 0144dc0625..f192714258 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C @@ -59,8 +59,8 @@ Foam::cyclicFaPatchField::cyclicFaPatchField << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << exit(FatalIOError); } } @@ -83,8 +83,8 @@ Foam::cyclicFaPatchField::cyclicFaPatchField << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << exit(FatalIOError); } @@ -122,7 +122,7 @@ template Foam::tmp> Foam::cyclicFaPatchField::patchNeighbourField() const { - const Field& iField = this->internalField(); + const Field& iField = this->primitiveField(); const labelUList& faceCells = cyclicPatch_.faceCells(); tmp> tpnf(new Field(this->size())); diff --git a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C index 02bded4b5e..a99d568691 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C @@ -59,8 +59,8 @@ Foam::emptyFaPatchField::emptyFaPatchField << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << exit(FatalIOError); } } @@ -82,8 +82,8 @@ Foam::emptyFaPatchField::emptyFaPatchField << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << exit(FatalIOError); } } @@ -98,7 +98,7 @@ Foam::emptyFaPatchField::emptyFaPatchField faPatchField ( ptf.patch(), - ptf.dimensionedInternalField(), + ptf.internalField(), Field(0) ) {} @@ -120,12 +120,12 @@ Foam::emptyFaPatchField::emptyFaPatchField template void Foam::emptyFaPatchField::updateCoeffs() { - if (this->dimensionedInternalField().mesh().nFaces()) + if (this->internalField().mesh().nFaces()) { if ( this->patch().faPatch::size() - % this->dimensionedInternalField().mesh().nFaces() + % this->internalField().mesh().nFaces() ) { FatalErrorInFunction diff --git a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.C index 8780b845a6..b9bfdb2f1a 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/processor/processorFaPatchField.C @@ -76,8 +76,8 @@ Foam::processorFaPatchField::processorFaPatchField << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << exit(FatalIOError); } } @@ -100,8 +100,8 @@ Foam::processorFaPatchField::processorFaPatchField << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << exit(FatalIOError); } } diff --git a/src/finiteArea/fields/faPatchFields/constraint/symmetry/symmetryFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/symmetry/symmetryFaPatchField.C index 45e2cb5c0e..0dbfee058b 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/symmetry/symmetryFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/symmetry/symmetryFaPatchField.C @@ -57,8 +57,8 @@ Foam::symmetryFaPatchField::symmetryFaPatchField << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << exit(FatalIOError); } } @@ -80,8 +80,8 @@ Foam::symmetryFaPatchField::symmetryFaPatchField << "\n patch type '" << p.type() << "' not constraint type '" << typeName << "'" << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() << exit(FatalIOError); } } diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H index 231033d12a..17f3b1ceb6 100644 --- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H +++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H @@ -270,14 +270,13 @@ public: } //- Return dimensioned internal field reference - const DimensionedField& - dimensionedInternalField() const + const DimensionedField& internalField() const { return internalField_; } //- Return internal field reference - const Field& internalField() const + const Field& primitiveField() const { return internalField_; } diff --git a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C index 69d00f7e95..f59044e0ed 100644 --- a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C +++ b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C @@ -93,7 +93,7 @@ Foam::emptyFaePatchField::emptyFaePatchField faePatchField ( ptf.patch(), - ptf.dimensionedInternalField(), + ptf.internalField(), Field(0) ) {} diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H index 4c1ebed492..820a7833f4 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H @@ -270,14 +270,13 @@ public: } //- Return dimensioned internal field reference - const DimensionedField& - dimensionedInternalField() const + const DimensionedField& internalField() const { return internalField_; } //- Return internal field reference - const Field& internalField() const + const Field& primitiveField() const { return internalField_; } diff --git a/src/genericPatchFields/Make/files b/src/genericPatchFields/Make/files index 333d154a6d..2ab759cf0c 100644 --- a/src/genericPatchFields/Make/files +++ b/src/genericPatchFields/Make/files @@ -1,3 +1,4 @@ +genericFaPatchField/genericFaPatchFields.C genericFvPatchField/genericFvPatchFields.C genericPointPatchField/genericPointPatchFields.C diff --git a/src/genericPatchFields/Make/options b/src/genericPatchFields/Make/options index 71b7873964..e528ab39ae 100644 --- a/src/genericPatchFields/Make/options +++ b/src/genericPatchFields/Make/options @@ -1,5 +1,7 @@ EXE_INC = \ + -I$(LIB_SRC)/finiteArea/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude LIB_LIBS = \ + -lfiniteArea \ -lfiniteVolume diff --git a/src/genericPatchFields/genericFaPatchField/genericFaPatchField.C b/src/genericPatchFields/genericFaPatchField/genericFaPatchField.C new file mode 100644 index 0000000000..5d5e7ccc04 --- /dev/null +++ b/src/genericPatchFields/genericFaPatchField/genericFaPatchField.C @@ -0,0 +1,828 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "genericFaPatchField.H" +#include "faPatchFieldMapper.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::genericFaPatchField::genericFaPatchField +( + const faPatch& p, + const DimensionedField& iF +) +: + calculatedFaPatchField(p, iF) +{ + FatalErrorInFunction + << "Trying to construct an genericFaPatchField on patch " + << this->patch().name() + << " of field " << this->internalField().name() + << abort(FatalError); +} + + +template +Foam::genericFaPatchField::genericFaPatchField +( + const faPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + calculatedFaPatchField(p, iF, dict), + actualTypeName_(dict.lookup("type")), + dict_(dict) +{ + if (!dict.found("value")) + { + FatalIOErrorInFunction + ( + dict + ) << "\n Cannot find 'value' entry" + << " on patch " << this->patch().name() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() + << nl + << " which is required to set the" + " values of the generic patch field." << nl + << " (Actual type " << actualTypeName_ << ")" << nl + << "\n Please add the 'value' entry to the write function " + "of the user-defined boundary-condition\n" + << exit(FatalIOError); + } + + forAllConstIter(dictionary, dict_, iter) + { + if (iter().keyword() != "type" && iter().keyword() != "value") + { + if + ( + iter().isStream() + && iter().stream().size() + ) + { + ITstream& is = iter().stream(); + + // Read first token + token firstToken(is); + + if + ( + firstToken.isWord() + && firstToken.wordToken() == "nonuniform" + ) + { + token fieldToken(is); + + if (!fieldToken.isCompound()) + { + if + ( + fieldToken.isLabel() + && fieldToken.labelToken() == 0 + ) + { + scalarFields_.insert + ( + iter().keyword(), + new scalarField(0) + ); + } + else + { + FatalIOErrorInFunction + ( + dict + ) << "\n token following 'nonuniform' " + "is not a compound" + << "\n on patch " << this->patch().name() + << " of field " + << this->internalField().name() + << " in file " + << this->internalField().objectPath() + << exit(FatalIOError); + } + } + else if + ( + fieldToken.compoundToken().type() + == token::Compound>::typeName + ) + { + scalarField* fPtr = new scalarField; + fPtr->transfer + ( + dynamicCast>> + ( + fieldToken.transferCompoundToken(is) + ) + ); + + if (fPtr->size() != this->size()) + { + FatalIOErrorInFunction + ( + dict + ) << "\n size of field " << iter().keyword() + << " (" << fPtr->size() << ')' + << " is not the same size as the patch (" + << this->size() << ')' + << "\n on patch " << this->patch().name() + << " of field " + << this->internalField().name() + << " in file " + << this->internalField().objectPath() + << exit(FatalIOError); + } + + scalarFields_.insert(iter().keyword(), fPtr); + } + else if + ( + fieldToken.compoundToken().type() + == token::Compound>::typeName + ) + { + vectorField* fPtr = new vectorField; + fPtr->transfer + ( + dynamicCast>> + ( + fieldToken.transferCompoundToken(is) + ) + ); + + if (fPtr->size() != this->size()) + { + FatalIOErrorInFunction + ( + dict + ) << "\n size of field " << iter().keyword() + << " (" << fPtr->size() << ')' + << " is not the same size as the patch (" + << this->size() << ')' + << "\n on patch " << this->patch().name() + << " of field " + << this->internalField().name() + << " in file " + << this->internalField().objectPath() + << exit(FatalIOError); + } + + vectorFields_.insert(iter().keyword(), fPtr); + } + else if + ( + fieldToken.compoundToken().type() + == token::Compound>::typeName + ) + { + sphericalTensorField* fPtr = new sphericalTensorField; + fPtr->transfer + ( + dynamicCast + < + token::Compound> + > + ( + fieldToken.transferCompoundToken(is) + ) + ); + + if (fPtr->size() != this->size()) + { + FatalIOErrorInFunction + ( + dict + ) << "\n size of field " << iter().keyword() + << " (" << fPtr->size() << ')' + << " is not the same size as the patch (" + << this->size() << ')' + << "\n on patch " << this->patch().name() + << " of field " + << this->internalField().name() + << " in file " + << this->internalField().objectPath() + << exit(FatalIOError); + } + + sphericalTensorFields_.insert(iter().keyword(), fPtr); + } + else if + ( + fieldToken.compoundToken().type() + == token::Compound>::typeName + ) + { + symmTensorField* fPtr = new symmTensorField; + fPtr->transfer + ( + dynamicCast + < + token::Compound> + > + ( + fieldToken.transferCompoundToken(is) + ) + ); + + if (fPtr->size() != this->size()) + { + FatalIOErrorInFunction + ( + dict + ) << "\n size of field " << iter().keyword() + << " (" << fPtr->size() << ')' + << " is not the same size as the patch (" + << this->size() << ')' + << "\n on patch " << this->patch().name() + << " of field " + << this->internalField().name() + << " in file " + << this->internalField().objectPath() + << exit(FatalIOError); + } + + symmTensorFields_.insert(iter().keyword(), fPtr); + } + else if + ( + fieldToken.compoundToken().type() + == token::Compound>::typeName + ) + { + tensorField* fPtr = new tensorField; + fPtr->transfer + ( + dynamicCast>> + ( + fieldToken.transferCompoundToken(is) + ) + ); + + if (fPtr->size() != this->size()) + { + FatalIOErrorInFunction + ( + dict + ) << "\n size of field " << iter().keyword() + << " (" << fPtr->size() << ')' + << " is not the same size as the patch (" + << this->size() << ')' + << "\n on patch " << this->patch().name() + << " of field " + << this->internalField().name() + << " in file " + << this->internalField().objectPath() + << exit(FatalIOError); + } + + tensorFields_.insert(iter().keyword(), fPtr); + } + else + { + FatalIOErrorInFunction + ( + dict + ) << "\n compound " << fieldToken.compoundToken() + << " not supported" + << "\n on patch " << this->patch().name() + << " of field " + << this->internalField().name() + << " in file " + << this->internalField().objectPath() + << exit(FatalIOError); + } + } + else if + ( + firstToken.isWord() + && firstToken.wordToken() == "uniform" + ) + { + token fieldToken(is); + + if (!fieldToken.isPunctuation()) + { + scalarFields_.insert + ( + iter().keyword(), + new scalarField + ( + this->size(), + fieldToken.number() + ) + ); + } + else + { + // Read as scalarList. + is.putBack(fieldToken); + + scalarList l(is); + + if (l.size() == vector::nComponents) + { + vector vs(l[0], l[1], l[2]); + + vectorFields_.insert + ( + iter().keyword(), + new vectorField(this->size(), vs) + ); + } + else if (l.size() == sphericalTensor::nComponents) + { + sphericalTensor vs(l[0]); + + sphericalTensorFields_.insert + ( + iter().keyword(), + new sphericalTensorField(this->size(), vs) + ); + } + else if (l.size() == symmTensor::nComponents) + { + symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]); + + symmTensorFields_.insert + ( + iter().keyword(), + new symmTensorField(this->size(), vs) + ); + } + else if (l.size() == tensor::nComponents) + { + tensor vs + ( + l[0], l[1], l[2], + l[3], l[4], l[5], + l[6], l[7], l[8] + ); + + tensorFields_.insert + ( + iter().keyword(), + new tensorField(this->size(), vs) + ); + } + else + { + FatalIOErrorInFunction + ( + dict + ) << "\n unrecognised native type " << l + << "\n on patch " << this->patch().name() + << " of field " + << this->internalField().name() + << " in file " + << this->internalField().objectPath() + << exit(FatalIOError); + } + } + } + } + } + } +} + + +template +Foam::genericFaPatchField::genericFaPatchField +( + const genericFaPatchField& ptf, + const faPatch& p, + const DimensionedField& iF, + const faPatchFieldMapper& mapper +) +: + calculatedFaPatchField(ptf, p, iF, mapper), + actualTypeName_(ptf.actualTypeName_), + dict_(ptf.dict_) +{ + forAllConstIter + ( + HashPtrTable, + ptf.scalarFields_, + iter + ) + { + scalarFields_.insert + ( + iter.key(), + new scalarField(*iter(), mapper) + ); + } + + forAllConstIter + ( + HashPtrTable, + ptf.vectorFields_, + iter + ) + { + vectorFields_.insert + ( + iter.key(), + new vectorField(*iter(), mapper) + ); + } + + forAllConstIter + ( + HashPtrTable, + ptf.sphericalTensorFields_, + iter + ) + { + sphericalTensorFields_.insert + ( + iter.key(), + new sphericalTensorField(*iter(), mapper) + ); + } + + forAllConstIter + ( + HashPtrTable, + ptf.symmTensorFields_, + iter + ) + { + symmTensorFields_.insert + ( + iter.key(), + new symmTensorField(*iter(), mapper) + ); + } + + forAllConstIter + ( + HashPtrTable, + ptf.tensorFields_, + iter + ) + { + tensorFields_.insert + ( + iter.key(), + new tensorField(*iter(), mapper) + ); + } +} + + +template +Foam::genericFaPatchField::genericFaPatchField +( + const genericFaPatchField& ptf +) +: + calculatedFaPatchField(ptf), + actualTypeName_(ptf.actualTypeName_), + dict_(ptf.dict_), + scalarFields_(ptf.scalarFields_), + vectorFields_(ptf.vectorFields_), + sphericalTensorFields_(ptf.sphericalTensorFields_), + symmTensorFields_(ptf.symmTensorFields_), + tensorFields_(ptf.tensorFields_) +{} + + +template +Foam::genericFaPatchField::genericFaPatchField +( + const genericFaPatchField& ptf, + const DimensionedField& iF +) +: + calculatedFaPatchField(ptf, iF), + actualTypeName_(ptf.actualTypeName_), + dict_(ptf.dict_), + scalarFields_(ptf.scalarFields_), + vectorFields_(ptf.vectorFields_), + sphericalTensorFields_(ptf.sphericalTensorFields_), + symmTensorFields_(ptf.symmTensorFields_), + tensorFields_(ptf.tensorFields_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::genericFaPatchField::autoMap +( + const faPatchFieldMapper& m +) +{ + calculatedFaPatchField::autoMap(m); + + forAllIter + ( + HashPtrTable, + scalarFields_, + iter + ) + { + iter()->autoMap(m); + } + + forAllIter + ( + HashPtrTable, + vectorFields_, + iter + ) + { + iter()->autoMap(m); + } + + forAllIter + ( + HashPtrTable, + sphericalTensorFields_, + iter + ) + { + iter()->autoMap(m); + } + + forAllIter + ( + HashPtrTable, + symmTensorFields_, + iter + ) + { + iter()->autoMap(m); + } + + forAllIter + ( + HashPtrTable, + tensorFields_, + iter + ) + { + iter()->autoMap(m); + } +} + + +template +void Foam::genericFaPatchField::rmap +( + const faPatchField& ptf, + const labelList& addr +) +{ + calculatedFaPatchField::rmap(ptf, addr); + + const genericFaPatchField& dptf = + refCast>(ptf); + + forAllIter + ( + HashPtrTable, + scalarFields_, + iter + ) + { + HashPtrTable::const_iterator dptfIter = + dptf.scalarFields_.find(iter.key()); + + if (dptfIter != dptf.scalarFields_.end()) + { + iter()->rmap(*dptfIter(), addr); + } + } + + forAllIter + ( + HashPtrTable, + vectorFields_, + iter + ) + { + HashPtrTable::const_iterator dptfIter = + dptf.vectorFields_.find(iter.key()); + + if (dptfIter != dptf.vectorFields_.end()) + { + iter()->rmap(*dptfIter(), addr); + } + } + + forAllIter + ( + HashPtrTable, + sphericalTensorFields_, + iter + ) + { + HashPtrTable::const_iterator dptfIter = + dptf.sphericalTensorFields_.find(iter.key()); + + if (dptfIter != dptf.sphericalTensorFields_.end()) + { + iter()->rmap(*dptfIter(), addr); + } + } + + forAllIter + ( + HashPtrTable, + symmTensorFields_, + iter + ) + { + HashPtrTable::const_iterator dptfIter = + dptf.symmTensorFields_.find(iter.key()); + + if (dptfIter != dptf.symmTensorFields_.end()) + { + iter()->rmap(*dptfIter(), addr); + } + } + + forAllIter + ( + HashPtrTable, + tensorFields_, + iter + ) + { + HashPtrTable::const_iterator dptfIter = + dptf.tensorFields_.find(iter.key()); + + if (dptfIter != dptf.tensorFields_.end()) + { + iter()->rmap(*dptfIter(), addr); + } + } +} + + +template +Foam::tmp> +Foam::genericFaPatchField::valueInternalCoeffs +( + const tmp& +) const +{ + FatalErrorInFunction + << "cannot be called for a genericFaPatchField" + " (actual type " << actualTypeName_ << ")" + << "\n on patch " << this->patch().name() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() + << "\n You are probably trying to solve for a field with a " + "generic boundary condition." + << abort(FatalError); + + return *this; +} + + +template +Foam::tmp> +Foam::genericFaPatchField::valueBoundaryCoeffs +( + const tmp& +) const +{ + FatalErrorInFunction + << "cannot be called for a genericFaPatchField" + " (actual type " << actualTypeName_ << ")" + << "\n on patch " << this->patch().name() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() + << "\n You are probably trying to solve for a field with a " + "generic boundary condition." + << abort(FatalError); + + return *this; +} + + +template +Foam::tmp> +Foam::genericFaPatchField::gradientInternalCoeffs() const +{ + FatalErrorInFunction + << "cannot be called for a genericFaPatchField" + " (actual type " << actualTypeName_ << ")" + << "\n on patch " << this->patch().name() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() + << "\n You are probably trying to solve for a field with a " + "generic boundary condition." + << abort(FatalError); + + return *this; +} + +template +Foam::tmp> +Foam::genericFaPatchField::gradientBoundaryCoeffs() const +{ + FatalErrorInFunction + << "cannot be called for a genericFaPatchField" + " (actual type " << actualTypeName_ << ")" + << "\n on patch " << this->patch().name() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() + << "\n You are probably trying to solve for a field with a " + "generic boundary condition." + << abort(FatalError); + + return *this; +} + + +template +const Foam::word& Foam::genericFaPatchField::actualType() const +{ + return actualTypeName_; +} + + +template +void Foam::genericFaPatchField::write(Ostream& os) const +{ + os.writeEntry("type", actualTypeName_); + + forAllConstIter(dictionary, dict_, iter) + { + if (iter().keyword() != "type" && iter().keyword() != "value") + { + if + ( + iter().isStream() + && iter().stream().size() + && iter().stream()[0].isWord() + && iter().stream()[0].wordToken() == "nonuniform" + ) + { + if (scalarFields_.found(iter().keyword())) + { + scalarFields_.find(iter().keyword())() + ->writeEntry(iter().keyword(), os); + } + else if (vectorFields_.found(iter().keyword())) + { + vectorFields_.find(iter().keyword())() + ->writeEntry(iter().keyword(), os); + } + else if (sphericalTensorFields_.found(iter().keyword())) + { + sphericalTensorFields_.find(iter().keyword())() + ->writeEntry(iter().keyword(), os); + } + else if (symmTensorFields_.found(iter().keyword())) + { + symmTensorFields_.find(iter().keyword())() + ->writeEntry(iter().keyword(), os); + } + else if (tensorFields_.found(iter().keyword())) + { + tensorFields_.find(iter().keyword())() + ->writeEntry(iter().keyword(), os); + } + } + else + { + iter().write(os); + } + } + } + + this->writeEntry("value", os); +} + + +// ************************************************************************* // diff --git a/src/genericPatchFields/genericFaPatchField/genericFaPatchField.H b/src/genericPatchFields/genericFaPatchField/genericFaPatchField.H new file mode 100644 index 0000000000..af00c43e10 --- /dev/null +++ b/src/genericPatchFields/genericFaPatchField/genericFaPatchField.H @@ -0,0 +1,204 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::genericFaPatchField + +Description + This boundary condition provides a generic version of the \c calculated + condition, useful as a fallback for handling unknown patch types. Not + generally applicable as a user-specified condition. + +See also + Foam::calculatedFaPatchField + +SourceFiles + genericFaPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef genericFaPatchField_H +#define genericFaPatchField_H + +#include "calculatedFaPatchField.H" +#include "HashPtrTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class genericFaPatch Declaration +\*---------------------------------------------------------------------------*/ + +template +class genericFaPatchField +: + public calculatedFaPatchField +{ + // Private data + + const word actualTypeName_; + dictionary dict_; + + HashPtrTable scalarFields_; + HashPtrTable vectorFields_; + HashPtrTable sphericalTensorFields_; + HashPtrTable symmTensorFields_; + HashPtrTable tensorFields_; + + +public: + + //- Runtime type information + TypeName("generic"); + + + // Constructors + + //- Construct from patch and internal field + genericFaPatchField + ( + const faPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + genericFaPatchField + ( + const faPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given patchField onto a new patch + genericFaPatchField + ( + const genericFaPatchField&, + const faPatch&, + const DimensionedField&, + const faPatchFieldMapper& + ); + + //- Construct as copy + genericFaPatchField + ( + const genericFaPatchField& + ); + + //- Construct and return a clone + virtual tmp> clone() const + { + return tmp> + ( + new genericFaPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + genericFaPatchField + ( + const genericFaPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp> clone + ( + const DimensionedField& iF + ) const + { + return tmp> + ( + new genericFaPatchField(*this, iF) + ); + } + + + // Member functions + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const faPatchFieldMapper& + ); + + //- Reverse map the given faPatchField onto this faPatchField + virtual void rmap + ( + const faPatchField&, + const labelList& + ); + + + // Evaluation functions + + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the value of this patchField with given weights + virtual tmp> valueInternalCoeffs + ( + const tmp& + ) const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the value of this patchField with given weights + virtual tmp> valueBoundaryCoeffs + ( + const tmp& + ) const; + + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the gradient of this patchField + tmp> gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the gradient of this patchField + tmp> gradientBoundaryCoeffs() const; + + + //- Return the actual type + const word& actualType() const; + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "genericFaPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/genericPatchFields/genericFaPatchField/genericFaPatchFields.C b/src/genericPatchFields/genericFaPatchField/genericFaPatchFields.C new file mode 100644 index 0000000000..b7952ebcb7 --- /dev/null +++ b/src/genericPatchFields/genericFaPatchField/genericFaPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "genericFaPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "areaFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makeFaPatchFields(generic); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/genericPatchFields/genericFaPatchField/genericFaPatchFields.H b/src/genericPatchFields/genericFaPatchField/genericFaPatchFields.H new file mode 100644 index 0000000000..bce3dc3aa2 --- /dev/null +++ b/src/genericPatchFields/genericFaPatchField/genericFaPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef genericFaPatchFields_H +#define genericFaPatchFields_H + +#include "genericFaPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFaPatchTypeFieldTypedefs(generic); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //