diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 35a308ff00..7316c116cb 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -18,6 +18,7 @@ $(basicFvPatches)/generic/genericFvPatch.C constraintFvPatches = $(fvPatches)/constraint $(constraintFvPatches)/cyclic/cyclicFvPatch.C $(constraintFvPatches)/cyclicAMI/cyclicAMIFvPatch.C +$(constraintFvPatches)/cyclicACMI/cyclicACMIFvPatch.C $(constraintFvPatches)/cyclicSlip/cyclicSlipFvPatch.C $(constraintFvPatches)/empty/emptyFvPatch.C $(constraintFvPatches)/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatch.C @@ -109,6 +110,7 @@ $(basicFvPatchFields)/zeroGradient/zeroGradientFvPatchFields.C constraintFvPatchFields = $(fvPatchFields)/constraint $(constraintFvPatchFields)/cyclic/cyclicFvPatchFields.C $(constraintFvPatchFields)/cyclicAMI/cyclicAMIFvPatchFields.C +$(constraintFvPatchFields)/cyclicACMI/cyclicACMIFvPatchFields.C $(constraintFvPatchFields)/cyclicSlip/cyclicSlipFvPatchFields.C $(constraintFvPatchFields)/empty/emptyFvPatchFields.C $(constraintFvPatchFields)/jumpCyclic/jumpCyclicFvPatchFields.C @@ -203,6 +205,7 @@ $(basicFvsPatchFields)/sliced/slicedFvsPatchFields.C constraintFvsPatchFields = $(fvsPatchFields)/constraint $(constraintFvsPatchFields)/cyclic/cyclicFvsPatchFields.C $(constraintFvsPatchFields)/cyclicAMI/cyclicAMIFvsPatchFields.C +$(constraintFvsPatchFields)/cyclicACMI/cyclicACMIFvsPatchFields.C $(constraintFvsPatchFields)/cyclicSlip/cyclicSlipFvsPatchFields.C $(constraintFvsPatchFields)/empty/emptyFvsPatchFields.C $(constraintFvsPatchFields)/nonuniformTransformCyclic/nonuniformTransformCyclicFvsPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C new file mode 100644 index 0000000000..bc3bab534d --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -0,0 +1,387 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cyclicACMIFvPatchField.H" +#include "transformField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + cyclicACMILduInterfaceField(), + coupledFvPatchField(p, iF), + cyclicACMIPatch_(refCast(p)) +{} + + +template +Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField +( + const cyclicACMIFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + cyclicACMILduInterfaceField(), + coupledFvPatchField(ptf, p, iF, mapper), + cyclicACMIPatch_(refCast(p)) +{ + if (!isA(this->patch())) + { + FatalErrorIn + ( + "cyclicACMIFvPatchField::cyclicACMIFvPatchField" + "(" + "const cyclicACMIFvPatchField& ," + "const fvPatch&, " + "const DimensionedField&, " + "const fvPatchFieldMapper&" + ")" + ) << " patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } +} + + +template +Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + cyclicACMILduInterfaceField(), + coupledFvPatchField(p, iF, dict), + cyclicACMIPatch_(refCast(p)) +{ + if (!isA(p)) + { + FatalIOErrorIn + ( + "cyclicACMIFvPatchField::cyclicACMIFvPatchField" + "(" + "const fvPatch&, " + "const DimensionedField&, " + "const dictionary&" + ")", + dict + ) << " patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + + if (!dict.found("value") && this->coupled()) + { + this->evaluate(Pstream::blocking); + } +} + + +template +Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField +( + const cyclicACMIFvPatchField& ptf +) +: + cyclicACMILduInterfaceField(), + coupledFvPatchField(ptf), + cyclicACMIPatch_(ptf.cyclicACMIPatch_) +{} + + +template +Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField +( + const cyclicACMIFvPatchField& ptf, + const DimensionedField& iF +) +: + cyclicACMILduInterfaceField(), + coupledFvPatchField(ptf, iF), + cyclicACMIPatch_(ptf.cyclicACMIPatch_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::cyclicACMIFvPatchField::coupled() const +{ + return cyclicACMIPatch_.coupled(); +} + + +template +Foam::tmp > +Foam::cyclicACMIFvPatchField::patchNeighbourField() const +{ + const Field& iField = this->internalField(); + const labelUList& nbrFaceCellsCoupled = + cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells(); + const labelUList& nbrFaceCellsNonOverlap = + cyclicACMIPatch_.cyclicACMIPatch().nonOverlapPatch().faceCells(); + + Field pnfCoupled(iField, nbrFaceCellsCoupled); + Field pnfNonOverlap(iField, nbrFaceCellsNonOverlap); + + tmp > tpnf + ( + new Field + ( + cyclicACMIPatch_.interpolate + ( + pnfCoupled, + pnfNonOverlap + ) + ) + ); + + if (doTransform()) + { + tpnf() = transform(forwardT(), tpnf()); + } + + return tpnf; +} + + +template +const Foam::cyclicACMIFvPatchField& +Foam::cyclicACMIFvPatchField::neighbourPatchField() const +{ + const GeometricField& fld = + static_cast&> + ( + this->internalField() + ); + + return refCast > + ( + fld.boundaryField()[cyclicACMIPatch_.neighbPatchID()] + ); +} + + +template +const Foam::fvPatchField& +Foam::cyclicACMIFvPatchField::nonOverlapPatchField() const +{ + const GeometricField& fld = + static_cast&> + ( + this->internalField() + ); + + return fld.boundaryField()[cyclicACMIPatch_.nonOverlapPatchID()]; +} + + +template +void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix +( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes +) const +{ + // note: only applying coupled contribution + + const labelUList& nbrFaceCellsCoupled = + cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells(); + + scalarField pnf(psiInternal, nbrFaceCellsCoupled); + + // Transform according to the transformation tensors + transformCoupleField(pnf, cmpt); + + const labelUList& faceCells = cyclicACMIPatch_.faceCells(); + + pnf = cyclicACMIPatch_.interpolate(pnf); + + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; + } +} + + +template +void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix +( + Field& result, + const Field& psiInternal, + const scalarField& coeffs, + const Pstream::commsTypes +) const +{ + // note: only applying coupled contribution + + const labelUList& nbrFaceCellsCoupled = + cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells(); + + Field pnf(psiInternal, nbrFaceCellsCoupled); + + // Transform according to the transformation tensors + transformCoupleField(pnf); + + const labelUList& faceCells = cyclicACMIPatch_.faceCells(); + + pnf = cyclicACMIPatch_.interpolate(pnf); + + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; + } +} + + +template +Foam::tmp > Foam::cyclicACMIFvPatchField::snGrad +( + const scalarField& deltaCoeffs +) const +{ + // note: only applying coupled contribution + return coupledFvPatchField::snGrad(deltaCoeffs); +} + + +template +void Foam::cyclicACMIFvPatchField::evaluate +( + const Pstream::commsTypes comms +) +{ + // blend contrubutions from the coupled and non-overlap patches + const fvPatchField& npf = nonOverlapPatchField(); + const_cast&>(npf).evaluate(); + + coupledFvPatchField::evaluate(comms); + const Field& cpf = *this; + + const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); + Field::operator=(mask*cpf + (1.0 - mask)*npf); + + fvPatchField::evaluate(); +} + + +template +Foam::tmp > +Foam::cyclicACMIFvPatchField::valueInternalCoeffs +( + const tmp& w +) const +{ + // note: do not blend based on mask field + // - when applied this is scaled by the areas which area already scaled + return coupledFvPatchField::valueInternalCoeffs(w); +} + + +template +Foam::tmp > +Foam::cyclicACMIFvPatchField::valueBoundaryCoeffs +( + const tmp& w +) const +{ + // note: do not blend based on mask field + // - when applied this is scaled by the areas which area already scaled + return coupledFvPatchField::valueBoundaryCoeffs(w); +} + + +template +Foam::tmp > +Foam::cyclicACMIFvPatchField::gradientInternalCoeffs +( + const scalarField& deltaCoeffs +) const +{ + // note: do not blend based on mask field + // - when applied this is scaled by the areas which area already scaled + return coupledFvPatchField::gradientInternalCoeffs(deltaCoeffs); +} + + +template +Foam::tmp > +Foam::cyclicACMIFvPatchField::gradientInternalCoeffs() const +{ + // note: do not blend based on mask field + // - when applied this is scaled by the areas which area already scaled + return coupledFvPatchField::gradientInternalCoeffs(); +} + + +template +Foam::tmp > +Foam::cyclicACMIFvPatchField::gradientBoundaryCoeffs +( + const scalarField& deltaCoeffs +) const +{ + // note: do not blend based on mask field + // - when applied this is scaled by the areas which area already scaled + return coupledFvPatchField::gradientBoundaryCoeffs(deltaCoeffs); +} + + +template +Foam::tmp > +Foam::cyclicACMIFvPatchField::gradientBoundaryCoeffs() const +{ + // note: do not blend based on mask field + // - when applied this is scaled by the areas which area already scaled + return coupledFvPatchField::gradientBoundaryCoeffs(); +} + + +template +void Foam::cyclicACMIFvPatchField::write(Ostream& os) const +{ + fvPatchField::write(os); + this->writeEntry("value", os); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H new file mode 100644 index 0000000000..9848505be1 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H @@ -0,0 +1,298 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Class + Foam::cyclicACMIFvPatchField + +Group + grpCoupledBoundaryConditions + +Description + This boundary condition enforces a cyclic condition between a pair of + boundaries, whereby communication between the patches is performed using + an arbitrarily coupled mesh interface (ACMI) interpolation. + + \heading Patch usage + + Example of the boundary condition specification: + \verbatim + myPatch + { + type cyclicACMI; + } + \endverbatim + +SeeAlso + Foam::AMIInterpolation + +SourceFiles + cyclicACMIFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicACMIFvPatchField_H +#define cyclicACMIFvPatchField_H + +#include "coupledFvPatchField.H" +#include "cyclicACMILduInterfaceField.H" +#include "cyclicACMIFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicACMIFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class cyclicACMIFvPatchField +: + virtual public cyclicACMILduInterfaceField, + public coupledFvPatchField +{ + // Private data + + //- Local reference cast into the cyclic patch + const cyclicACMIFvPatch& cyclicACMIPatch_; + + + // Private Member Functions + + //- Return neighbour side field given internal fields + template + tmp > neighbourSideField + ( + const Field& + ) const; + + +public: + + //- Runtime type information + TypeName(cyclicACMIFvPatch::typeName_()); + + + // Constructors + + //- Construct from patch and internal field + cyclicACMIFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + cyclicACMIFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given cyclicACMIFvPatchField onto a new patch + cyclicACMIFvPatchField + ( + const cyclicACMIFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + cyclicACMIFvPatchField(const cyclicACMIFvPatchField&); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new cyclicACMIFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + cyclicACMIFvPatchField + ( + const cyclicACMIFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new cyclicACMIFvPatchField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return local reference cast into the cyclic AMI patch + const cyclicACMIFvPatch& cyclicACMIPatch() const + { + return cyclicACMIPatch_; + } + + + // Evaluation functions + + //- Return true if coupled. Note that the underlying patch + // is not coupled() - the points don't align. + virtual bool coupled() const; + + //- Return neighbour coupled internal cell data + virtual tmp > patchNeighbourField() const; + + //- Return reference to neighbour patchField + const cyclicACMIFvPatchField& neighbourPatchField() const; + + //- Return reference to non-overlapping patchField + const fvPatchField& nonOverlapPatchField() const; + + //- Return patch-normal gradient + virtual tmp > snGrad + ( + const scalarField& deltaCoeffs + ) const; + + //- Evaluate the patch field + virtual void evaluate + ( + const Pstream::commsTypes commsType + ); + + //- 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 + virtual tmp > gradientInternalCoeffs + ( + const scalarField& deltaCoeffs + ) const; + + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp > gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp > gradientBoundaryCoeffs + ( + const scalarField& deltaCoeffs + ) const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp > gradientBoundaryCoeffs() const; + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType + ) const; + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field&, + const Field&, + const scalarField&, + const Pstream::commsTypes commsType + ) const; + + + // Cyclic AMI coupled interface functions + + //- Does the patch field perform the transformation + virtual bool doTransform() const + { + return + !(cyclicACMIPatch_.parallel() || pTraits::rank == 0); + } + + //- Return face transformation tensor + virtual const tensorField& forwardT() const + { + return cyclicACMIPatch_.forwardT(); + } + + //- Return neighbour-cell transformation tensor + virtual const tensorField& reverseT() const + { + return cyclicACMIPatch_.reverseT(); + } + + //- Return rank of component for transform + virtual int rank() const + { + return pTraits::rank; + } + + + // I-O + + //- Write + virtual void write(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "cyclicACMIFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFields.C new file mode 100644 index 0000000000..470a1613d3 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cyclicACMIFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(cyclicACMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFields.H new file mode 100644 index 0000000000..13aee99a84 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicACMIFvPatchFields_H +#define cyclicACMIFvPatchFields_H + +#include "cyclicACMIFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(cyclicACMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFieldsFwd.H new file mode 100644 index 0000000000..155d6a8f2b --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchFieldsFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicACMIFvPatchFieldsFwd_H +#define cyclicACMIFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class cyclicACMIFvPatchField; + +makePatchTypeFieldTypedefs(cyclicACMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C new file mode 100644 index 0000000000..7fc9d7688c --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.C @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cyclicACMIFvsPatchField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + coupledFvsPatchField(p, iF), + cyclicACMIPatch_(refCast(p)) +{} + + +template +Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField +( + const cyclicACMIFvsPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + coupledFvsPatchField(ptf, p, iF, mapper), + cyclicACMIPatch_(refCast(p)) +{ + if (!isA(this->patch())) + { + FatalErrorIn + ( + "cyclicACMIFvsPatchField::cyclicACMIFvsPatchField\n" + "(" + "const cyclicACMIFvsPatchField&, " + "const fvPatch&, " + "const DimensionedField&, " + "const fvPatchFieldMapper&" + ")" + ) << "Field type does not correspond to patch type for patch " + << this->patch().index() << "." << endl + << "Field type: " << typeName << endl + << "Patch type: " << this->patch().type() + << exit(FatalError); + } +} + + +template +Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + coupledFvsPatchField(p, iF, dict), + cyclicACMIPatch_(refCast(p)) +{ + if (!isA(p)) + { + FatalIOErrorIn + ( + "cyclicACMIFvsPatchField::cyclicACMIFvsPatchField" + "(" + "const fvPatch&, " + "const Field&, " + "const dictionary&" + ")", + dict + ) << "patch " << this->patch().index() << " not cyclicACMI type. " + << "Patch type = " << p.type() + << exit(FatalIOError); + } +} + + +template +Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField +( + const cyclicACMIFvsPatchField& ptf +) +: + coupledFvsPatchField(ptf), + cyclicACMIPatch_(ptf.cyclicACMIPatch_) +{} + + +template +Foam::cyclicACMIFvsPatchField::cyclicACMIFvsPatchField +( + const cyclicACMIFvsPatchField& ptf, + const DimensionedField& iF +) +: + coupledFvsPatchField(ptf, iF), + cyclicACMIPatch_(ptf.cyclicACMIPatch_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::cyclicACMIFvsPatchField::coupled() const +{ + if + ( + Pstream::parRun() + || ( + this->cyclicACMIPatch_.size() + && this->cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().size() + ) + ) + { + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H new file mode 100644 index 0000000000..edd7b9bf15 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchField.H @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Class + Foam::cyclicACMIFvsPatchField + +Description + Foam::cyclicACMIFvsPatchField + +SourceFiles + cyclicACMIFvsPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicACMIFvsPatchField_H +#define cyclicACMIFvsPatchField_H + +#include "coupledFvsPatchField.H" +#include "cyclicACMIFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicACMIFvsPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class cyclicACMIFvsPatchField +: + public coupledFvsPatchField +{ + // Private data + + //- Local reference cast into the cyclic patch + const cyclicACMIFvPatch& cyclicACMIPatch_; + + +public: + + //- Runtime type information + TypeName(cyclicACMIFvPatch::typeName_()); + + + // Constructors + + //- Construct from patch and internal field + cyclicACMIFvsPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + cyclicACMIFvsPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given cyclicACMIFvsPatchField onto a new patch + cyclicACMIFvsPatchField + ( + const cyclicACMIFvsPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + cyclicACMIFvsPatchField + ( + const cyclicACMIFvsPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new cyclicACMIFvsPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + cyclicACMIFvsPatchField + ( + const cyclicACMIFvsPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new cyclicACMIFvsPatchField(*this, iF) + ); + } + + // Member functions + + // Access + + //- Return true if running parallel + virtual bool coupled() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "cyclicACMIFvsPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.C new file mode 100644 index 0000000000..efe05703d9 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cyclicACMIFvsPatchFields.H" +#include "fvsPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makeFvsPatchFields(cyclicACMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.H new file mode 100644 index 0000000000..11801d8cd2 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicACMIFvsPatchFields_H +#define cyclicACMIFvsPatchFields_H + +#include "cyclicACMIFvsPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFvsPatchTypeFieldTypedefs(cyclicACMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFieldsFwd.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFieldsFwd.H new file mode 100644 index 0000000000..41b42881b9 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicACMI/cyclicACMIFvsPatchFieldsFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicACMIFvsPatchFieldsFwd_H +#define cyclicACMIFvsPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class cyclicACMIFvsPatchField; + +makeFvsPatchTypeFieldTypedefs(cyclicACMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C new file mode 100644 index 0000000000..fe674cf98e --- /dev/null +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.C @@ -0,0 +1,202 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cyclicACMIFvPatch.H" +#include "addToRunTimeSelectionTable.H" +#include "fvMesh.H" +#include "transform.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cyclicACMIFvPatch, 0); + addToRunTimeSelectionTable(fvPatch, cyclicACMIFvPatch, polyPatch); +} + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void Foam::cyclicACMIFvPatch::updateAreas() const +{ + if (cyclicACMIPolyPatch_.updated()) + { + // Set Sf and magSf for both sides' coupled and non-overlapping patches + + // owner couple + const_cast(Sf()) = patch().faceAreas(); + const_cast(magSf()) = mag(patch().faceAreas()); + + // owner non-overlapping + const fvPatch& nonOverlapPatch = this->nonOverlapPatch(); + const_cast(nonOverlapPatch.Sf()) = + nonOverlapPatch.patch().faceAreas(); + const_cast(nonOverlapPatch.magSf()) = + mag(nonOverlapPatch.patch().faceAreas()); + + // neighbour couple + const cyclicACMIFvPatch& nbrACMI = neighbPatch(); + const_cast(nbrACMI.Sf()) = + nbrACMI.patch().faceAreas(); + const_cast(nbrACMI.magSf()) = + mag(nbrACMI.patch().faceAreas()); + + // neighbour non-overlapping + const fvPatch& nbrNonOverlapPatch = nbrACMI.nonOverlapPatch(); + const_cast(nbrNonOverlapPatch.Sf()) = + nbrNonOverlapPatch.patch().faceAreas(); + const_cast(nbrNonOverlapPatch.magSf()) = + mag(nbrNonOverlapPatch.patch().faceAreas()); + + // set the updated flag + cyclicACMIPolyPatch_.setUpdated(false); + } +} + + +void Foam::cyclicACMIFvPatch::makeWeights(scalarField& w) const +{ + if (coupled()) + { + const cyclicACMIFvPatch& nbrPatch = neighbFvPatch(); + const fvPatch& nbrPatchNonOverlap = nonOverlapPatch(); + + const scalarField deltas(nf() & fvPatch::delta()); + + const scalarField nbrDeltas + ( + interpolate + ( + nbrPatch.nf() & nbrPatch.fvPatch::delta(), + nbrPatchNonOverlap.nf() & nbrPatchNonOverlap.delta() + ) + ); + + forAll(deltas, faceI) + { + scalar di = deltas[faceI]; + scalar dni = nbrDeltas[faceI]; + + w[faceI] = dni/(di + dni); + } + } + else + { + // Behave as uncoupled patch + fvPatch::makeWeights(w); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::cyclicACMIFvPatch::coupled() const +{ + return Pstream::parRun() || (this->size() && neighbFvPatch().size()); +} + + +Foam::tmp Foam::cyclicACMIFvPatch::delta() const +{ + if (coupled()) + { + const cyclicACMIFvPatch& nbrPatchCoupled = neighbFvPatch(); + const fvPatch& nbrPatchNonOverlap = nonOverlapPatch(); + + const vectorField patchD(fvPatch::delta()); + + vectorField nbrPatchD + ( + interpolate + ( + nbrPatchCoupled.fvPatch::delta(), + nbrPatchNonOverlap.delta() + ) + ); + + const vectorField nbrPatchD0 + ( + interpolate + ( + vectorField(nbrPatchCoupled.size(), vector::zero), + nbrPatchNonOverlap.delta()() + ) + ); + + nbrPatchD -= nbrPatchD0; + + tmp tpdv(new vectorField(patchD.size())); + vectorField& pdv = tpdv(); + + // do the transformation if necessary + if (parallel()) + { + forAll(patchD, faceI) + { + const vector& ddi = patchD[faceI]; + const vector& dni = nbrPatchD[faceI]; + + pdv[faceI] = ddi - dni; + } + } + else + { + forAll(patchD, faceI) + { + const vector& ddi = patchD[faceI]; + const vector& dni = nbrPatchD[faceI]; + + pdv[faceI] = ddi - transform(forwardT()[0], dni); + } + } + + return tpdv; + } + else + { + return fvPatch::delta(); + } +} + + +Foam::tmp Foam::cyclicACMIFvPatch::interfaceInternalField +( + const labelUList& internalData +) const +{ + return patchInternalField(internalData); +} + + +Foam::tmp Foam::cyclicACMIFvPatch::internalFieldTransfer +( + const Pstream::commsTypes commsType, + const labelUList& iF +) const +{ + return neighbFvPatch().patchInternalField(iF); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H new file mode 100644 index 0000000000..7ed1693696 --- /dev/null +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H @@ -0,0 +1,268 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Class + Foam::cyclicACMIFvPatch + +Description + Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI) + +SourceFiles + cyclicACMIFvPatch.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicACMIFvPatch_H +#define cyclicACMIFvPatch_H + +#include "coupledFvPatch.H" +#include "cyclicACMILduInterface.H" +#include "cyclicACMIPolyPatch.H" +#include "fvBoundaryMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicACMIFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class cyclicACMIFvPatch +: + public coupledFvPatch, + public cyclicACMILduInterface +{ + // Private data + + const cyclicACMIPolyPatch& cyclicACMIPolyPatch_; + + +protected: + + // Protected Member functions + + //- Update the patch areas after AMI update + void updateAreas() const; + + //- Make patch weighting factors + void makeWeights(scalarField&) const; + + +public: + + //- Runtime type information + TypeName(cyclicACMIPolyPatch::typeName_()); + + + // Constructors + + //- Construct from polyPatch + cyclicACMIFvPatch(const polyPatch& patch, const fvBoundaryMesh& bm) + : + coupledFvPatch(patch, bm), + cyclicACMILduInterface(), + cyclicACMIPolyPatch_(refCast(patch)) + {} + + + // Member functions + + // Access + + //- Return local reference cast into the cyclic patch + const cyclicACMIPolyPatch& cyclicACMIPatch() const + { + return cyclicACMIPolyPatch_; + } + + //- Return neighbour + virtual label neighbPatchID() const + { + return cyclicACMIPolyPatch_.neighbPatchID(); + } + + virtual bool owner() const + { + return cyclicACMIPolyPatch_.owner(); + } + + //- Return neighbour fvPatch + virtual const cyclicACMIFvPatch& neighbPatch() const + { + return refCast + ( + this->boundaryMesh()[cyclicACMIPolyPatch_.neighbPatchID()] + ); + } + + //- Return neighbour + virtual label nonOverlapPatchID() const + { + return cyclicACMIPolyPatch_.nonOverlapPatchID(); + } + + //- Return non-overlapping fvPatch + virtual const fvPatch& nonOverlapPatch() const + { + return this->boundaryMesh()[nonOverlapPatchID()]; + } + + //- Return a reference to the AMI interpolator + virtual const AMIPatchToPatchInterpolation& AMI() const + { + const AMIPatchToPatchInterpolation& AMI = + cyclicACMIPolyPatch_.AMI(); + + updateAreas(); + + return AMI; + } + + //- Are the cyclic planes parallel + virtual bool parallel() const + { + return cyclicACMIPolyPatch_.parallel(); + } + + //- Return face transformation tensor + virtual const tensorField& forwardT() const + { + return cyclicACMIPolyPatch_.forwardT(); + } + + //- Return neighbour-cell transformation tensor + virtual const tensorField& reverseT() const + { + return cyclicACMIPolyPatch_.reverseT(); + } + + const cyclicACMIFvPatch& neighbFvPatch() const + { + return refCast + ( + this->boundaryMesh()[cyclicACMIPolyPatch_.neighbPatchID()] + ); + } + + //- Return true if this patch is coupled. This is equivalent + // to the coupledPolyPatch::coupled() if parallel running or + // both sides present, false otherwise + virtual bool coupled() const; + + //- Return delta (P to N) vectors across coupled patch + virtual tmp delta() const; + + template + tmp > interpolate + ( + const Field& fldCoupled + ) const + { + updateAreas(); + + return + cyclicACMIPolyPatch_.cyclicAMIPolyPatch::interpolate + ( + fldCoupled + ); + } + + template + tmp > interpolate + ( + const tmp >& tfldCoupled + ) const + { + updateAreas(); + + return + cyclicACMIPolyPatch_.cyclicAMIPolyPatch::interpolate + ( + tfldCoupled + ); + } + + template + tmp > interpolate + ( + const Field& fldCoupled, + const Field& fldNonOverlap + ) const + { + updateAreas(); + + return + cyclicACMIPolyPatch_.interpolate + ( + fldCoupled, + fldNonOverlap + ); + } + + template + tmp > interpolate + ( + const tmp >& tFldCoupled, + const tmp >& tFldNonOverlap + ) const + { + updateAreas(); + + return + cyclicACMIPolyPatch_.interpolate + ( + tFldCoupled, + tFldNonOverlap + ); + } + + + // Interface transfer functions + + //- Return the values of the given internal data adjacent to + // the interface as a field + virtual tmp interfaceInternalField + ( + const labelUList& internalData + ) const; + + //- Return neighbour field + virtual tmp internalFieldTransfer + ( + const Pstream::commsTypes commsType, + const labelUList& internalData + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C new file mode 100644 index 0000000000..4963d926cd --- /dev/null +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C @@ -0,0 +1,129 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "cyclicACMIGAMGInterfaceField.H" +#include "addToRunTimeSelectionTable.H" +#include "lduMatrix.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cyclicACMIGAMGInterfaceField, 0); + addToRunTimeSelectionTable + ( + GAMGInterfaceField, + cyclicACMIGAMGInterfaceField, + lduInterface + ); + addToRunTimeSelectionTable + ( + GAMGInterfaceField, + cyclicACMIGAMGInterfaceField, + lduInterfaceField + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cyclicACMIGAMGInterfaceField::cyclicACMIGAMGInterfaceField +( + const GAMGInterface& GAMGCp, + const lduInterfaceField& fineInterface +) +: + GAMGInterfaceField(GAMGCp, fineInterface), + cyclicACMIInterface_(refCast(GAMGCp)), + doTransform_(false), + rank_(0) +{ + const cyclicAMILduInterfaceField& p = + refCast(fineInterface); + + doTransform_ = p.doTransform(); + rank_ = p.rank(); +} + + +Foam::cyclicACMIGAMGInterfaceField::cyclicACMIGAMGInterfaceField +( + const GAMGInterface& GAMGCp, + const bool doTransform, + const int rank +) +: + GAMGInterfaceField(GAMGCp, doTransform, rank), + cyclicACMIInterface_(refCast(GAMGCp)), + doTransform_(doTransform), + rank_(rank) +{} + + +// * * * * * * * * * * * * * * * * Desstructor * * * * * * * * * * * * * * * // + +Foam::cyclicACMIGAMGInterfaceField::~cyclicACMIGAMGInterfaceField() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::cyclicACMIGAMGInterfaceField::updateInterfaceMatrix +( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes +) const +{ + // Get neighbouring field + scalarField pnf + ( + cyclicACMIInterface_.neighbPatch().interfaceInternalField(psiInternal) + ); + + // Transform according to the transformation tensors + transformCoupleField(pnf, cmpt); + + if (cyclicACMIInterface_.owner()) + { + pnf = cyclicACMIInterface_.AMI().interpolateToSource(pnf); + } + else + { + pnf = cyclicACMIInterface_.neighbPatch().AMI().interpolateToTarget(pnf); + } + + const labelUList& faceCells = cyclicACMIInterface_.faceCells(); + + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.H b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.H new file mode 100644 index 0000000000..e06d76328d --- /dev/null +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.H @@ -0,0 +1,166 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Class + Foam::cyclicACMIGAMGInterfaceField + +Description + GAMG agglomerated cyclic interface for Arbitrarily Coupled Mesh Interface + (ACMI) fields. + +SourceFiles + cyclicACMIGAMGInterfaceField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicACMIGAMGInterfaceField_H +#define cyclicACMIGAMGInterfaceField_H + +#include "GAMGInterfaceField.H" +#include "cyclicACMIGAMGInterface.H" +#include "cyclicACMILduInterfaceField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicACMIGAMGInterfaceField Declaration +\*---------------------------------------------------------------------------*/ + +class cyclicACMIGAMGInterfaceField +: + public GAMGInterfaceField, + virtual public cyclicACMILduInterfaceField +{ + // Private data + + //- Local reference cast into the cyclic interface + const cyclicACMIGAMGInterface& cyclicACMIInterface_; + + //- Is the transform required + bool doTransform_; + + //- Rank of component for transformation + int rank_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + cyclicACMIGAMGInterfaceField(const cyclicACMIGAMGInterfaceField&); + + //- Disallow default bitwise assignment + void operator=(const cyclicACMIGAMGInterfaceField&); + + +public: + + //- Runtime type information + TypeName("cyclicACMI"); + + + // Constructors + + //- Construct from GAMG interface and fine level interface field + cyclicACMIGAMGInterfaceField + ( + const GAMGInterface& GAMGCp, + const lduInterfaceField& fineInterfaceField + ); + + //- Construct from GAMG interface and fine level interface field + cyclicACMIGAMGInterfaceField + ( + const GAMGInterface& GAMGCp, + const bool doTransform, + const int rank + ); + + + //- Destructor + virtual ~cyclicACMIGAMGInterfaceField(); + + + // Member Functions + + // Access + + //- Return size + label size() const + { + return cyclicACMIInterface_.size(); + } + + + // Interface matrix update + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType + ) const; + + + //- Cyclic interface functions + + //- Does the interface field perform the transfromation + virtual bool doTransform() const + { + return doTransform_; + } + + //- Return face transformation tensor + virtual const tensorField& forwardT() const + { + return cyclicACMIInterface_.forwardT(); + } + + //- Return neighbour-cell transformation tensor + virtual const tensorField& reverseT() const + { + return cyclicACMIInterface_.reverseT(); + } + + //- Return rank of component for transform + virtual int rank() const + { + return rank_; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaces/cyclicACMIGAMGInterface/cyclicACMIGAMGInterface.C b/src/meshTools/AMIInterpolation/GAMG/interfaces/cyclicACMIGAMGInterface/cyclicACMIGAMGInterface.C new file mode 100644 index 0000000000..d9e3a0fb77 --- /dev/null +++ b/src/meshTools/AMIInterpolation/GAMG/interfaces/cyclicACMIGAMGInterface/cyclicACMIGAMGInterface.C @@ -0,0 +1,198 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "AMIInterpolation.H" +#include "cyclicACMIGAMGInterface.H" +#include "addToRunTimeSelectionTable.H" +#include "Map.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cyclicACMIGAMGInterface, 0); + addToRunTimeSelectionTable + ( + GAMGInterface, + cyclicACMIGAMGInterface, + lduInterface + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface +( + const label index, + const lduInterfacePtrsList& coarseInterfaces, + const lduInterface& fineInterface, + const labelField& localRestrictAddressing, + const labelField& neighbourRestrictAddressing, + const label fineLevelIndex, + const label coarseComm +) +: + GAMGInterface + ( + index, + coarseInterfaces + ), + fineCyclicACMIInterface_ + ( + refCast(fineInterface) + ) +{ + // Construct face agglomeration from cell agglomeration + { + // From coarse face to cell + DynamicList