diff --git a/etc/caseDicts/setConstraintTypes b/etc/caseDicts/setConstraintTypes index 257a095b7afc34b551581a38d0f7a88b4cd604dc..4cebbcaddc76e68be68530858191fc9e5bcaab9f 100644 --- a/etc/caseDicts/setConstraintTypes +++ b/etc/caseDicts/setConstraintTypes @@ -16,6 +16,12 @@ cyclicAMI type cyclicAMI; } +cyclicPeriodicAMI +{ + type cyclicPeriodicAMI; + value $internalField; +} + cyclicACMI { type cyclicACMI; diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index e0300c915241a01b3da3e105bf007550d57528a9..e45596fac49d1c6631bdb9878bec88b5ae1acda4 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -33,6 +33,7 @@ constraintFvPatches = $(fvPatches)/constraint $(constraintFvPatches)/cyclic/cyclicFvPatch.C $(constraintFvPatches)/cyclicAMI/cyclicAMIFvPatch.C $(constraintFvPatches)/cyclicACMI/cyclicACMIFvPatch.C +$(constraintFvPatches)/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatch.C $(constraintFvPatches)/cyclicSlip/cyclicSlipFvPatch.C $(constraintFvPatches)/empty/emptyFvPatch.C $(constraintFvPatches)/nonuniformTransformCyclic/nonuniformTransformCyclicFvPatch.C @@ -135,6 +136,7 @@ constraintFvPatchFields = $(fvPatchFields)/constraint $(constraintFvPatchFields)/cyclic/cyclicFvPatchFields.C $(constraintFvPatchFields)/cyclicAMI/cyclicAMIFvPatchFields.C $(constraintFvPatchFields)/cyclicACMI/cyclicACMIFvPatchFields.C +$(constraintFvPatchFields)/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFields.C $(constraintFvPatchFields)/cyclicSlip/cyclicSlipFvPatchFields.C $(constraintFvPatchFields)/empty/emptyFvPatchFields.C $(constraintFvPatchFields)/jumpCyclic/jumpCyclicFvPatchFields.C @@ -259,6 +261,7 @@ constraintFvsPatchFields = $(fvsPatchFields)/constraint $(constraintFvsPatchFields)/cyclic/cyclicFvsPatchFields.C $(constraintFvsPatchFields)/cyclicAMI/cyclicAMIFvsPatchFields.C $(constraintFvsPatchFields)/cyclicACMI/cyclicACMIFvsPatchFields.C +$(constraintFvsPatchFields)/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFields.C $(constraintFvsPatchFields)/cyclicSlip/cyclicSlipFvsPatchFields.C $(constraintFvsPatchFields)/empty/emptyFvsPatchFields.C $(constraintFvsPatchFields)/nonuniformTransformCyclic/nonuniformTransformCyclicFvsPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchField.C new file mode 100644 index 0000000000000000000000000000000000000000..8658b9247275cf2e78317c12f84ac341199ac3ed --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchField.C @@ -0,0 +1,291 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::cyclicPeriodicAMIFvPatchField<Type>::cyclicPeriodicAMIFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF +) +: + cyclicPeriodicAMILduInterfaceField(), + coupledFvPatchField<Type>(p, iF), + cyclicPeriodicAMIPatch_(refCast<const cyclicPeriodicAMIFvPatch>(p)) +{} + + +template<class Type> +Foam::cyclicPeriodicAMIFvPatchField<Type>::cyclicPeriodicAMIFvPatchField +( + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const dictionary& dict +) +: + cyclicPeriodicAMILduInterfaceField(), + coupledFvPatchField<Type>(p, iF, dict, dict.found("value")), + cyclicPeriodicAMIPatch_(refCast<const cyclicPeriodicAMIFvPatch>(p, dict)) +{ + if (!isA<cyclicPeriodicAMIFvPatch>(p)) + { + FatalIOErrorInFunction(dict) + << " patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() + << exit(FatalIOError); + } + + if (!dict.found("value")) + { + if (this->coupled()) + { + this->evaluate(Pstream::commsTypes::blocking); + } + else + { + fvPatchField<Type>::operator=(this->patchInternalField()); + } + } +} + + +template<class Type> +Foam::cyclicPeriodicAMIFvPatchField<Type>::cyclicPeriodicAMIFvPatchField +( + const cyclicPeriodicAMIFvPatchField<Type>& ptf, + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + cyclicPeriodicAMILduInterfaceField(), + coupledFvPatchField<Type>(ptf, p, iF, mapper), + cyclicPeriodicAMIPatch_(refCast<const cyclicPeriodicAMIFvPatch>(p)) +{ + if (!isA<cyclicPeriodicAMIFvPatch>(this->patch())) + { + FatalErrorInFunction + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() + << exit(FatalIOError); + } +} + + +template<class Type> +Foam::cyclicPeriodicAMIFvPatchField<Type>::cyclicPeriodicAMIFvPatchField +( + const cyclicPeriodicAMIFvPatchField<Type>& ptf +) +: + cyclicPeriodicAMILduInterfaceField(), + coupledFvPatchField<Type>(ptf), + cyclicPeriodicAMIPatch_(ptf.cyclicPeriodicAMIPatch_) +{} + + +template<class Type> +Foam::cyclicPeriodicAMIFvPatchField<Type>::cyclicPeriodicAMIFvPatchField +( + const cyclicPeriodicAMIFvPatchField<Type>& ptf, + const DimensionedField<Type, volMesh>& iF +) +: + cyclicPeriodicAMILduInterfaceField(), + coupledFvPatchField<Type>(ptf, iF), + cyclicPeriodicAMIPatch_(ptf.cyclicPeriodicAMIPatch_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +//template<class Type> +//bool Foam::cyclicPeriodicAMIFvPatchField<Type>::coupled() const +//{ +// return cyclicPeriodicAMIPatch_.coupled(); +//} + + +template<class Type> +Foam::tmp<Foam::Field<Type>> +Foam::cyclicPeriodicAMIFvPatchField<Type>::patchNeighbourField() const +{ + const Field<Type>& iField = this->primitiveField(); + const labelUList& nbrFaceCells = + cyclicPeriodicAMIPatch_.neighbPatch().faceCells(); + + Field<Type> pnf(iField, nbrFaceCells); + + if (debug&2) + { + Pout<< "cyclicPeriodicAMIFvPatchField<Type>::patchNeighbourField() :" + << " field:" << this->internalField().name() + << " patch:" << cyclicPeriodicAMIPatch_.name() + << endl; + } + + tmp<Field<Type>> tpnf; + if (cyclicPeriodicAMIPatch_.applyLowWeightCorrection()) + { + tpnf = cyclicPeriodicAMIPatch_.interpolate + ( + pnf, + this->patchInternalField()() + ); + } + else + { + tpnf = cyclicPeriodicAMIPatch_.interpolate(pnf); + } + + if (this->doTransform()) + { + tpnf.ref() = transform(this->forwardT(), tpnf()); + } + return tpnf; +} + + +//template<class Type> +//const Foam::cyclicPeriodicAMIFvPatchField<Type>& +//Foam::cyclicPeriodicAMIFvPatchField<Type>::neighbourPatchField() const +//{ +// const GeometricField<Type, fvPatchField, volMesh>& fld = +// static_cast<const GeometricField<Type, fvPatchField, volMesh>&> +// ( +// this->primitiveField() +// ); +// +// return refCast<const cyclicPeriodicAMIFvPatchField<Type>> +// ( +// fld.boundaryField()[cyclicPeriodicAMIPatch_.neighbPatchID()] +// ); +//} + + +template<class Type> +void Foam::cyclicPeriodicAMIFvPatchField<Type>::updateInterfaceMatrix +( + solveScalarField& result, + const bool add, + const solveScalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes +) const +{ + // Problem: for vectorFields this routine gets called one component at + // a time. Hence we cannot apply any transformation into cylindrical + // coordinate system before we do the interpolation. Instead use the + // component-coupled linear solver. In fvSolution: + // type coupled; + // solver PBiCCCG; //PBiCGStab; + + const labelUList& nbrFaceCells = + cyclicPeriodicAMIPatch_.neighbPatch().faceCells(); + + solveScalarField pnf(psiInternal, nbrFaceCells); + + if (debug&2) + { + Pout<< "cyclicPeriodicAMIFvPatchField<Type>::updateInterfaceMatrix() :" + << " field:" << this->internalField().name() + << " patch:" << cyclicPeriodicAMIPatch_.name() + << " cmpt:" << cmpt + << endl; + } + + // Transform according to the transformation tensors + this->transformCoupleField(pnf, cmpt); + + if (cyclicPeriodicAMIPatch_.applyLowWeightCorrection()) + { + solveScalarField pif(psiInternal, cyclicPeriodicAMIPatch_.faceCells()); + pnf = cyclicPeriodicAMIPatch_.interpolate(pnf, pif); + } + else + { + pnf = cyclicPeriodicAMIPatch_.interpolate(pnf); + } + + // Multiply the field by coefficients and add into the result + this->addToInternalField(result, !add, coeffs, pnf); +} + + +template<class Type> +void Foam::cyclicPeriodicAMIFvPatchField<Type>::updateInterfaceMatrix +( + Field<Type>& result, + const bool add, + const Field<Type>& psiInternal, + const scalarField& coeffs, + const Pstream::commsTypes +) const +{ + // For use in the component-coupled linear solver. In fvSolution: + // type coupled; + // solver PBiCCCG; //PBiCGStab; + + const labelUList& nbrFaceCells = + cyclicPeriodicAMIPatch_.neighbPatch().faceCells(); + + Field<Type> pnf(psiInternal, nbrFaceCells); + + if (debug&2) + { + Pout<< "cyclicPeriodicAMIFvPatchField<Type>::updateInterfaceMatrix() :" + << " field:" << this->internalField().name() + << " patch:" << cyclicPeriodicAMIPatch_.name() + << endl; + } + + // Transform according to the transformation tensors + this->transformCoupleField(pnf); + + if (cyclicPeriodicAMIPatch_.applyLowWeightCorrection()) + { + Field<Type> pif(psiInternal, cyclicPeriodicAMIPatch_.faceCells()); + pnf = cyclicPeriodicAMIPatch_.interpolate(pnf, pif); + } + else + { + pnf = cyclicPeriodicAMIPatch_.interpolate(pnf); + } + + // Multiply the field by coefficients and add into the result + this->addToInternalField(result, !add, coeffs, pnf); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchField.H new file mode 100644 index 0000000000000000000000000000000000000000..2afe2551e99638fafeff0a5953f644055425d145 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchField.H @@ -0,0 +1,247 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::cyclicPeriodicAMIFvPatchField + +Group + grpCoupledBoundaryConditions + +Description + Version of cyclicAMI. Automatically duplicates itself to obtain full + coverage. + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + type cyclicPeriodicAMI; + } + \endverbatim + +Note + The outer boundary of the patch pairs must be similar, i.e. if the owner + patch is transformed to the neighbour patch, the outer perimiter of each + patch should be identical (or very similar). + +See also + Foam::cyclicAMIFvPatchField + Foam::AMIInterpolation + +SourceFiles + cyclicPeriodicAMIFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIFvPatchField_H +#define cyclicPeriodicAMIFvPatchField_H + +#include "coupledFvPatchField.H" +#include "cyclicPeriodicAMILduInterfaceField.H" +#include "cyclicPeriodicAMIFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicPeriodicAMIFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class cyclicPeriodicAMIFvPatchField +: + virtual public cyclicPeriodicAMILduInterfaceField, + public coupledFvPatchField<Type> +{ + // Private data + + //- Local reference cast into the cyclic patch + const cyclicPeriodicAMIFvPatch& cyclicPeriodicAMIPatch_; + + +public: + + //- Runtime type information + TypeName(cyclicPeriodicAMIFvPatch::typeName_()); + + + // Constructors + + //- Construct from patch and internal field + cyclicPeriodicAMIFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + cyclicPeriodicAMIFvPatchField + ( + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given cyclicPeriodicAMIFvPatchField onto a new + // patch + cyclicPeriodicAMIFvPatchField + ( + const cyclicPeriodicAMIFvPatchField<Type>&, + const fvPatch&, + const DimensionedField<Type, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + cyclicPeriodicAMIFvPatchField + ( + const cyclicPeriodicAMIFvPatchField<Type>& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<Type>> clone() const + { + return tmp<fvPatchField<Type>> + ( + new cyclicPeriodicAMIFvPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + cyclicPeriodicAMIFvPatchField + ( + const cyclicPeriodicAMIFvPatchField<Type>&, + const DimensionedField<Type, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<Type>> clone + ( + const DimensionedField<Type, volMesh>& iF + ) const + { + return tmp<fvPatchField<Type>> + ( + new cyclicPeriodicAMIFvPatchField<Type>(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return local reference cast into the fv patch + const cyclicPeriodicAMIFvPatch& cyclicPeriodicAMIPatch() const + { + return cyclicPeriodicAMIPatch_; + } + + + // 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<Field<Type>> patchNeighbourField() const; + + //- Return reference to neighbour patchField + const cyclicPeriodicAMIFvPatchField<Type>& neighbourPatchField() + const; + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + solveScalarField& result, + const bool add, + const solveScalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType + ) const; + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field<Type>&, + const bool add, + const Field<Type>&, + const scalarField&, + const Pstream::commsTypes commsType + ) const; + + + // Cyclic AMI coupled interface functions + + //- Does the patch field perform the transformation + virtual bool doTransform() const + { + return + !( + cyclicPeriodicAMIPatch_.parallel() + || pTraits<Type>::rank == 0 + ); + } + + //- Return face transformation tensor + virtual const tensorField& forwardT() const + { + return cyclicPeriodicAMIPatch_.forwardT(); + } + + //- Return neighbour-cell transformation tensor + virtual const tensorField& reverseT() const + { + return cyclicPeriodicAMIPatch_.reverseT(); + } + + //- Return rank of component for transform + virtual int rank() const + { + return pTraits<Type>::rank; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "cyclicPeriodicAMIFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..064a138c029a0f00d7ea24bb9a2068669ac59e9b --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFields.C @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cyclicPeriodicAMIFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(cyclicPeriodicAMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFields.H new file mode 100644 index 0000000000000000000000000000000000000000..fae04c8fc499ed23448acc630bb01d961a1b2a35 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFields.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIFvPatchFields_H +#define cyclicPeriodicAMIFvPatchFields_H + +#include "cyclicPeriodicAMIFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(cyclicPeriodicAMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFieldsFwd.H new file mode 100644 index 0000000000000000000000000000000000000000..5d4114de616720e29404dc75c905cfecd2bd7826 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatchFieldsFwd.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIFvPatchFieldsFwd_H +#define cyclicPeriodicAMIFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> class cyclicPeriodicAMIFvPatchField; + +makePatchTypeFieldTypedefs(cyclicPeriodicAMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchField.C new file mode 100644 index 0000000000000000000000000000000000000000..9e136bfe8d758bf94aeb50da876788c398289bcb --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchField.C @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cyclicPeriodicAMIFvsPatchField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::cyclicPeriodicAMIFvsPatchField<Type>::cyclicPeriodicAMIFvsPatchField +( + const fvPatch& p, + const DimensionedField<Type, surfaceMesh>& iF +) +: + coupledFvsPatchField<Type>(p, iF), + cyclicPeriodicAMIPatch_(refCast<const cyclicPeriodicAMIFvPatch>(p)) +{} + + +template<class Type> +Foam::cyclicPeriodicAMIFvsPatchField<Type>::cyclicPeriodicAMIFvsPatchField +( + const cyclicPeriodicAMIFvsPatchField<Type>& ptf, + const fvPatch& p, + const DimensionedField<Type, surfaceMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + coupledFvsPatchField<Type>(ptf, p, iF, mapper), + cyclicPeriodicAMIPatch_(refCast<const cyclicPeriodicAMIFvPatch>(p)) +{ + if (!isA<cyclicPeriodicAMIFvPatch>(this->patch())) + { + FatalErrorInFunction + << "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<class Type> +Foam::cyclicPeriodicAMIFvsPatchField<Type>::cyclicPeriodicAMIFvsPatchField +( + const fvPatch& p, + const DimensionedField<Type, surfaceMesh>& iF, + const dictionary& dict +) +: + coupledFvsPatchField<Type>(p, iF, dict), + cyclicPeriodicAMIPatch_(refCast<const cyclicPeriodicAMIFvPatch>(p, dict)) +{ + if (!isA<cyclicPeriodicAMIFvPatch>(p)) + { + FatalIOErrorInFunction(dict) + << "patch " << this->patch().index() + << " not cyclicPeriodicAMI type. " + << "Patch type = " << p.type() + << exit(FatalIOError); + } +} + + +template<class Type> +Foam::cyclicPeriodicAMIFvsPatchField<Type>::cyclicPeriodicAMIFvsPatchField +( + const cyclicPeriodicAMIFvsPatchField<Type>& ptf +) +: + coupledFvsPatchField<Type>(ptf), + cyclicPeriodicAMIPatch_(ptf.cyclicPeriodicAMIPatch_) +{} + + +template<class Type> +Foam::cyclicPeriodicAMIFvsPatchField<Type>::cyclicPeriodicAMIFvsPatchField +( + const cyclicPeriodicAMIFvsPatchField<Type>& ptf, + const DimensionedField<Type, surfaceMesh>& iF +) +: + coupledFvsPatchField<Type>(ptf, iF), + cyclicPeriodicAMIPatch_(ptf.cyclicPeriodicAMIPatch_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +bool Foam::cyclicPeriodicAMIFvsPatchField<Type>::coupled() const +{ + const auto& cpp = this->cyclicPeriodicAMIPatch_; + + if + ( + Pstream::parRun() + || ( + cpp.size() + && cpp.cyclicPeriodicAMIPatch().neighbPatch().size() + ) + ) + { + return true; + } + + return false; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchField.H new file mode 100644 index 0000000000000000000000000000000000000000..5d421c912b341990680a9f0a6d9577bf1df38a83 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchField.H @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::cyclicPeriodicAMIFvsPatchField + +SourceFiles + cyclicPeriodicAMIFvsPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIFvsPatchField_H +#define cyclicPeriodicAMIFvsPatchField_H + +#include "coupledFvsPatchField.H" +#include "cyclicPeriodicAMIFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicPeriodicAMIFvsPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class cyclicPeriodicAMIFvsPatchField +: + public coupledFvsPatchField<Type> +{ + // Private data + + //- Local reference cast into the cyclic patch + const cyclicPeriodicAMIFvPatch& cyclicPeriodicAMIPatch_; + + +public: + + //- Runtime type information + TypeName(cyclicPeriodicAMIFvPatch::typeName_()); + + + // Constructors + + //- Construct from patch and internal field + cyclicPeriodicAMIFvsPatchField + ( + const fvPatch&, + const DimensionedField<Type, surfaceMesh>& + ); + + //- Construct from patch, internal field and dictionary + cyclicPeriodicAMIFvsPatchField + ( + const fvPatch&, + const DimensionedField<Type, surfaceMesh>&, + const dictionary& + ); + + //- Construct by mapping given cyclicPeriodicAMIFvsPatchField onto + // a new patch + cyclicPeriodicAMIFvsPatchField + ( + const cyclicPeriodicAMIFvsPatchField<Type>&, + const fvPatch&, + const DimensionedField<Type, surfaceMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + cyclicPeriodicAMIFvsPatchField + ( + const cyclicPeriodicAMIFvsPatchField<Type>& + ); + + //- Construct and return a clone + virtual tmp<fvsPatchField<Type>> clone() const + { + return tmp<fvsPatchField<Type>> + ( + new cyclicPeriodicAMIFvsPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + cyclicPeriodicAMIFvsPatchField + ( + const cyclicPeriodicAMIFvsPatchField<Type>&, + const DimensionedField<Type, surfaceMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvsPatchField<Type>> clone + ( + const DimensionedField<Type, surfaceMesh>& iF + ) const + { + return tmp<fvsPatchField<Type>> + ( + new cyclicPeriodicAMIFvsPatchField<Type>(*this, iF) + ); + } + + // Member functions + + // Access + + //- Return true if running parallel + virtual bool coupled() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "cyclicPeriodicAMIFvsPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFields.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..2ec05458527cf9998f400d62b4d5a57cd1060411 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFields.C @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cyclicPeriodicAMIFvsPatchFields.H" +//#include "cyclicAMIFvsPatchFields.H" +#include "fvsPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makeFvsPatchFields(cyclicPeriodicAMI); + +//// Redirect cyclicPeriodicAMI to cyclicAMI for now +// +//#define addNamedToFvsPatchFieldRunTimeSelection\ +//(PatchTypeField,typePatchTypeField,lookup) \ +// addNamedToRunTimeSelectionTable \ +// ( \ +// PatchTypeField, \ +// typePatchTypeField, \ +// patch, \ +// lookup \ +// ); \ +// addNamedToRunTimeSelectionTable \ +// ( \ +// PatchTypeField, \ +// typePatchTypeField, \ +// patchMapper, \ +// lookup \ +// ); \ +// addNamedToRunTimeSelectionTable \ +// ( \ +// PatchTypeField, \ +// typePatchTypeField, \ +// dictionary, \ +// lookup \ +// ); +// +//#define makeNamedFvsPatchFields(type,lookupType)\ +// addNamedToFvsPatchFieldRunTimeSelection \ +// ( \ +// fvsPatchScalarField, \ +// type##FvsPatchScalarField, \ +// lookupType \ +// ); \ +// addNamedToFvsPatchFieldRunTimeSelection \ +// ( \ +// fvsPatchVectorField, \ +// type##FvsPatchVectorField, \ +// lookupType \ +// ); \ +// addNamedToFvsPatchFieldRunTimeSelection \ +// ( \ +// fvsPatchSphericalTensorField, \ +// type##FvsPatchSphericalTensorField, \ +// lookupType \ +// ); \ +// addNamedToFvsPatchFieldRunTimeSelection \ +// ( \ +// fvsPatchSymmTensorField, \ +// type##FvsPatchSymmTensorField, \ +// lookupType \ +// ); \ +// addNamedToFvsPatchFieldRunTimeSelection \ +// ( \ +// fvsPatchTensorField, \ +// type##FvsPatchTensorField, \ +// lookupType \ +//); +// +//makeNamedFvsPatchFields(cyclicAMI, cyclicPeriodicAMI); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFields.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFields.H new file mode 100644 index 0000000000000000000000000000000000000000..9723a6d223c15c80330b47e8ada0aec58fba9edd --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFields.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIFvsPatchFields_H +#define cyclicPeriodicAMIFvsPatchFields_H + +#include "cyclicPeriodicAMIFvsPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFvsPatchTypeFieldTypedefs(cyclicPeriodicAMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFieldsFwd.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFieldsFwd.H new file mode 100644 index 0000000000000000000000000000000000000000..0d65bbeada682fc3013ab86e9f9b0eb3b3652af6 --- /dev/null +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvsPatchFieldsFwd.H @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIFvsPatchFieldsFwd_H +#define cyclicPeriodicAMIFvsPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> class cyclicPeriodicAMIFvsPatchField; + +makeFvsPatchTypeFieldTypedefs(cyclicPeriodicAMI); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C index 86d45f1637ca2efbc0508f412776d42a6f71ddf7..d1ab66c7d4d0dd0c0cbd27202122dc5821024ff3 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,13 +39,6 @@ namespace Foam { defineTypeNameAndDebug(cyclicAMIFvPatch, 0); addToRunTimeSelectionTable(fvPatch, cyclicAMIFvPatch, polyPatch); - addNamedToRunTimeSelectionTable - ( - fvPatch, - cyclicAMIFvPatch, - polyPatch, - cyclicPeriodicAMI - ); } diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatch.C new file mode 100644 index 0000000000000000000000000000000000000000..78494a42084df030dafa24542833b4089795901f --- /dev/null +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatch.C @@ -0,0 +1,293 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cyclicPeriodicAMIFvPatch.H" +#include "addToRunTimeSelectionTable.H" +#include "fvMesh.H" +#include "Time.H" +#include "transform.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cyclicPeriodicAMIFvPatch, 0); + addToRunTimeSelectionTable(fvPatch, cyclicPeriodicAMIFvPatch, polyPatch); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::cyclicPeriodicAMIFvPatch::coupled() const +{ + return + Pstream::parRun() + || !this->boundaryMesh().mesh().time().processorCase(); +} + + +void Foam::cyclicPeriodicAMIFvPatch::makeWeights(scalarField& w) const +{ + if (coupled()) + { + const cyclicPeriodicAMIFvPatch& nbrPatch = neighbFvPatch(); + + const scalarField deltas(nf() & coupledFvPatch::delta()); + + if (debug&2) + { + Pout<< "cyclicPeriodicAMIFvPatch::makeWeights :" + << " patch:" << this->name() + << " nbrPatch:" << nbrPatch.name() + << endl; + } + + tmp<scalarField> tnbrDeltas; + if (applyLowWeightCorrection()) + { + tnbrDeltas = + interpolate + ( + nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(), + scalarField(this->size(), 1.0) + ); + } + else + { + tnbrDeltas = + interpolate(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta()); + } + + const scalarField& nbrDeltas = tnbrDeltas(); + + forAll(deltas, facei) + { + // Note use of mag + scalar di = mag(deltas[facei]); + scalar dni = mag(nbrDeltas[facei]); + + w[facei] = dni/(di + dni); + } + } + else + { + // Behave as uncoupled patch + fvPatch::makeWeights(w); + } +} + + +void Foam::cyclicPeriodicAMIFvPatch::makeDeltaCoeffs(scalarField& coeffs) const +{ + // Apply correction to default coeffs +} + + +void Foam::cyclicPeriodicAMIFvPatch::makeNonOrthoDeltaCoeffs +( + scalarField& coeffs +) const +{ + // Apply correction to default coeffs + //coeffs = Zero; +} + + +void Foam::cyclicPeriodicAMIFvPatch::makeNonOrthoCorrVectors +( + vectorField& vecs +) const +{ + // Apply correction to default vectors + //vecs = Zero; +} + + +Foam::tmp<Foam::vectorField> Foam::cyclicPeriodicAMIFvPatch::delta() const +{ + const cyclicPeriodicAMIFvPatch& nbrPatch = neighbFvPatch(); + + if (coupled()) + { + const vectorField patchD(coupledFvPatch::delta()); + + if (debug&2) + { + Pout<< "cyclicPeriodicAMIFvPatch::delta :" + << " patch:" << this->name() + << " nbrPatch:" << nbrPatch.name() + << endl; + } + + tmp<vectorField> tnbrPatchD; + if (applyLowWeightCorrection()) + { + tnbrPatchD = + interpolate + ( + nbrPatch.coupledFvPatch::delta(), + vectorField(this->size(), Zero) + ); + } + else + { + tnbrPatchD = interpolate(nbrPatch.coupledFvPatch::delta()); + } + + const vectorField& nbrPatchD = tnbrPatchD(); + + auto tpdv = tmp<vectorField>::New(patchD.size()); + vectorField& pdv = tpdv.ref(); + + // 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 coupledFvPatch::delta(); + } +} + + +Foam::tmp<Foam::labelField> +Foam::cyclicPeriodicAMIFvPatch::interfaceInternalField +( + const labelUList& internalData +) const +{ + return patchInternalField(internalData); +} + + +Foam::tmp<Foam::labelField> +Foam::cyclicPeriodicAMIFvPatch::internalFieldTransfer +( + const Pstream::commsTypes commsType, + const labelUList& iF +) const +{ + return neighbFvPatch().patchInternalField(iF); +} + + +void Foam::cyclicPeriodicAMIFvPatch::movePoints() +{ + const auto& cyclicAMI = cyclicPeriodicAMIPolyPatch_; + + if (!owner() || !cyclicAMI.createAMIFaces()) + { + // Only manipulating patch face areas and mesh motion flux if the AMI + // creates additional faces + return; + } + + // Update face data based on values set by the AMI manipulations + const_cast<vectorField&>(Sf()) = cyclicAMI.faceAreas(); + const_cast<vectorField&>(Cf()) = cyclicAMI.faceCentres(); + const_cast<scalarField&>(magSf()) = mag(Sf()); + + const cyclicPeriodicAMIFvPatch& nbr = neighbPatch(); + const cyclicPeriodicAMIPolyPatch& nbrPp = nbr.cyclicPeriodicAMIPatch(); + const_cast<vectorField&>(nbr.Sf()) = nbrPp.faceAreas(); + const_cast<vectorField&>(nbr.Cf()) = nbrPp.faceCentres(); + const_cast<scalarField&>(nbr.magSf()) = mag(nbr.Sf()); + + + // Set consitent mesh motion flux + // TODO: currently maps src mesh flux to tgt - update to + // src = src + mapped(tgt) and tgt = tgt + mapped(src)? + + const fvMesh& mesh = boundaryMesh().mesh(); + surfaceScalarField& meshPhi = const_cast<fvMesh&>(mesh).setPhi(); + surfaceScalarField::Boundary& meshPhiBf = meshPhi.boundaryFieldRef(); + + if (cyclicAMI.owner()) + { + scalarField& phip = meshPhiBf[patch().index()]; + forAll(phip, facei) + { + const face& f = cyclicAMI.localFaces()[facei]; + + // Note: using raw point locations to calculate the geometric + // area - faces areas are currently scaled by the AMI weights + // (decoupled from mesh points) + const scalar geomArea = f.mag(cyclicAMI.localPoints()); + + const scalar scaledArea = magSf()[facei]; + phip[facei] *= scaledArea/geomArea; + } + + scalarField srcMeshPhi(phip); + if (AMI().distributed()) + { + AMI().srcMap().distribute(srcMeshPhi); + } + + const labelListList& tgtToSrcAddr = AMI().tgtAddress(); + scalarField& nbrPhip = meshPhiBf[nbr.index()]; + + forAll(tgtToSrcAddr, tgtFacei) + { + // Note: now have 1-to-1 mapping so tgtToSrcAddr[tgtFacei] is size 1 + const label srcFacei = tgtToSrcAddr[tgtFacei][0]; + nbrPhip[tgtFacei] = -srcMeshPhi[srcFacei]; + } + + DebugInfo + << "patch:" << patch().name() + << " sum(area):" << gSum(magSf()) + << " min(mag(faceAreas):" << gMin(magSf()) + << " sum(meshPhi):" << gSum(phip) << nl + << " sum(nbrMeshPhi):" << gSum(nbrPhip) << nl + << endl; + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatch.H new file mode 100644 index 0000000000000000000000000000000000000000..b1e6ea5fc54c85912e23738269aa3164149e7320 --- /dev/null +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicPeriodicAMI/cyclicPeriodicAMIFvPatch.H @@ -0,0 +1,247 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::cyclicPeriodicAMIFvPatch + +Description + Periodic cyclic patch for Arbitrary Mesh Interface (AMI) + +SourceFiles + cyclicPeriodicAMIFvPatch.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIFvPatch_H +#define cyclicPeriodicAMIFvPatch_H + +#include "coupledFvPatch.H" +#include "cyclicPeriodicAMILduInterface.H" +#include "cyclicPeriodicAMIPolyPatch.H" +#include "fvBoundaryMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicPeriodicAMIFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class cyclicPeriodicAMIFvPatch +: + public coupledFvPatch, + public cyclicPeriodicAMILduInterface +{ + // Private data + + const cyclicPeriodicAMIPolyPatch& cyclicPeriodicAMIPolyPatch_; + + +protected: + + // Protected Member functions + + //- Note: straight copy of cyclicAMIFvPatch + + //- Make patch weighting factors + void makeWeights(scalarField&) const; + + //- Correct patch deltaCoeffs + virtual void makeDeltaCoeffs(scalarField&) const; + + //- Correct patch non-ortho deltaCoeffs + virtual void makeNonOrthoDeltaCoeffs(scalarField&) const; + + //- Correct patch non-ortho correction vectors + virtual void makeNonOrthoCorrVectors(vectorField&) const; + + //- Correct patches after moving points + virtual void movePoints(); + + +public: + + //- Runtime type information + TypeName(cyclicPeriodicAMIPolyPatch::typeName_()); + + + // Constructors + + //- Construct from polyPatch + cyclicPeriodicAMIFvPatch + ( + const polyPatch& patch, + const fvBoundaryMesh& bm + ) + : + coupledFvPatch(patch, bm), + cyclicPeriodicAMILduInterface(), + cyclicPeriodicAMIPolyPatch_ + ( + refCast<const cyclicPeriodicAMIPolyPatch>(patch) + ) + {} + + + // Member functions + + // Access + + //- Return local reference cast into the cyclic patch + const cyclicPeriodicAMIPolyPatch& cyclicPeriodicAMIPatch() const + { + return cyclicPeriodicAMIPolyPatch_; + } + + //- Return neighbour + virtual label neighbPatchID() const + { + return cyclicPeriodicAMIPolyPatch_.neighbPatchID(); + } + + virtual bool owner() const + { + return cyclicPeriodicAMIPolyPatch_.owner(); + } + + //- Return processor number + virtual const cyclicPeriodicAMIFvPatch& neighbPatch() const + { + return refCast<const cyclicPeriodicAMIFvPatch> + ( + this->boundaryMesh() + [ + cyclicPeriodicAMIPolyPatch_.neighbPatchID() + ] + ); + } + + //- Return a reference to the AMI interpolator + virtual const AMIPatchToPatchInterpolation& AMI() const + { + return cyclicPeriodicAMIPolyPatch_.AMI(); + } + + //- Return true if applying the low weight correction + virtual bool applyLowWeightCorrection() const + { + return cyclicPeriodicAMIPolyPatch_.applyLowWeightCorrection(); + } + + //- Are the cyclic planes parallel + virtual bool parallel() const + { + return cyclicPeriodicAMIPolyPatch_.parallel(); + } + + //- Return face transformation tensor + virtual const tensorField& forwardT() const + { + return cyclicPeriodicAMIPolyPatch_.forwardT(); + } + + //- Return neighbour-cell transformation tensor + virtual const tensorField& reverseT() const + { + return cyclicPeriodicAMIPolyPatch_.reverseT(); + } + + const cyclicPeriodicAMIFvPatch& neighbFvPatch() const + { + return refCast<const cyclicPeriodicAMIFvPatch> + ( + this->boundaryMesh() + [ + cyclicPeriodicAMIPolyPatch_.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<vectorField> delta() const; + + template<class Type> + tmp<Field<Type>> interpolate + ( + const Field<Type>& fld, + const UList<Type>& defaultValues = UList<Type>() + ) const + { + return cyclicPeriodicAMIPolyPatch_.interpolate + ( + fld, + defaultValues + ); + } + + template<class Type> + tmp<Field<Type>> interpolate + ( + const tmp<Field<Type>>& tFld, + const UList<Type>& defaultValues = UList<Type>() + ) const + { + return cyclicPeriodicAMIPolyPatch_.interpolate + ( + tFld, + defaultValues + ); + } + + + // Interface transfer functions + + //- Return the values of the given internal data adjacent to + //- the interface as a field + virtual tmp<labelField> interfaceInternalField + ( + const labelUList& internalData + ) const; + + //- Return neighbour field + virtual tmp<labelField> internalFieldTransfer + ( + const Pstream::commsTypes commsType, + const labelUList& internalData + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicPeriodicAMIGAMGInterfaceField/cyclicPeriodicAMIGAMGInterfaceField.C b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicPeriodicAMIGAMGInterfaceField/cyclicPeriodicAMIGAMGInterfaceField.C new file mode 100644 index 0000000000000000000000000000000000000000..76d46801c5bc2502e91666d3f65d3187bc5cd822 --- /dev/null +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicPeriodicAMIGAMGInterfaceField/cyclicPeriodicAMIGAMGInterfaceField.C @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cyclicPeriodicAMIGAMGInterfaceField.H" +#include "addToRunTimeSelectionTable.H" +#include "lduMatrix.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cyclicPeriodicAMIGAMGInterfaceField, 0); + addToRunTimeSelectionTable + ( + GAMGInterfaceField, + cyclicPeriodicAMIGAMGInterfaceField, + lduInterface + ); + addToRunTimeSelectionTable + ( + GAMGInterfaceField, + cyclicPeriodicAMIGAMGInterfaceField, + lduInterfaceField + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cyclicPeriodicAMIGAMGInterfaceField::cyclicPeriodicAMIGAMGInterfaceField +( + const GAMGInterface& GAMGCp, + const lduInterfaceField& fineInterface +) +: + GAMGInterfaceField(GAMGCp, fineInterface), + cyclicPeriodicAMIInterface_ + ( + refCast<const cyclicPeriodicAMIGAMGInterface>(GAMGCp) + ), + doTransform_(false), + rank_(0) +{ + const cyclicPeriodicAMILduInterfaceField& p = + refCast<const cyclicPeriodicAMILduInterfaceField>(fineInterface); + + doTransform_ = p.doTransform(); + rank_ = p.rank(); +} + + +Foam::cyclicPeriodicAMIGAMGInterfaceField::cyclicPeriodicAMIGAMGInterfaceField +( + const GAMGInterface& GAMGCp, + const bool doTransform, + const int rank +) +: + GAMGInterfaceField(GAMGCp, doTransform, rank), + cyclicPeriodicAMIInterface_ + ( + refCast<const cyclicPeriodicAMIGAMGInterface>(GAMGCp) + ), + doTransform_(doTransform), + rank_(rank) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cyclicPeriodicAMIGAMGInterfaceField:: +~cyclicPeriodicAMIGAMGInterfaceField() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::cyclicPeriodicAMIGAMGInterfaceField::updateInterfaceMatrix +( + solveScalarField& result, + const bool add, + const solveScalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes +) const +{ + const auto& neighbPatch = cyclicPeriodicAMIInterface_.neighbPatch(); + + // Get neighbouring field + solveScalarField pnf + ( + neighbPatch.interfaceInternalField + ( + psiInternal + ) + ); + + // Transform according to the transformation tensors + transformCoupleField(pnf, cmpt); + + if (debug&2) + { + Pout<< "cyclicPeriodicAMIGAMGInterfaceField::updateInterfaceMatrix :" + //<< " field:" << this->internalField().name() + //<< " interface:" << cyclicPeriodicAMIInterface_.name() + << " cmpt:" << cmpt + << endl; + } + + if (cyclicPeriodicAMIInterface_.owner()) + { + pnf = cyclicPeriodicAMIInterface_.AMI().interpolateToSource(pnf); + } + else + { + pnf = neighbPatch.AMI().interpolateToTarget(pnf); + } + + this->addToInternalField(result, !add, coeffs, pnf); +} + + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicPeriodicAMIGAMGInterfaceField/cyclicPeriodicAMIGAMGInterfaceField.H b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicPeriodicAMIGAMGInterfaceField/cyclicPeriodicAMIGAMGInterfaceField.H new file mode 100644 index 0000000000000000000000000000000000000000..befed036e7ce0b7005eb1a3fc9956c27b5b27e96 --- /dev/null +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicPeriodicAMIGAMGInterfaceField/cyclicPeriodicAMIGAMGInterfaceField.H @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::cyclicPeriodicAMIGAMGInterfaceField + +Description + GAMG agglomerated cyclic interface for cyclic AMI fields. + +SourceFiles + cyclicPeriodicAMIGAMGInterfaceField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIGAMGInterfaceField_H +#define cyclicPeriodicAMIGAMGInterfaceField_H + +#include "GAMGInterfaceField.H" +#include "cyclicPeriodicAMIGAMGInterface.H" +#include "cyclicPeriodicAMILduInterfaceField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicPeriodicAMIGAMGInterfaceField Declaration +\*---------------------------------------------------------------------------*/ + +class cyclicPeriodicAMIGAMGInterfaceField +: + public GAMGInterfaceField, + virtual public cyclicPeriodicAMILduInterfaceField +{ + // Private data + + //- Local reference cast into the cyclic interface + const cyclicPeriodicAMIGAMGInterface& cyclicPeriodicAMIInterface_; + + //- Is the transform required + bool doTransform_; + + //- Rank of component for transformation + int rank_; + + + // Private Member Functions + + //- No copy construct + cyclicPeriodicAMIGAMGInterfaceField + ( + const cyclicPeriodicAMIGAMGInterfaceField& + ) = delete; + + //- No copy assignment + void operator=(const cyclicPeriodicAMIGAMGInterfaceField&) = delete; + + +public: + + //- Runtime type information + TypeName("cyclicPeriodicAMI"); + + + // Constructors + + //- Construct from GAMG interface and fine level interface field + cyclicPeriodicAMIGAMGInterfaceField + ( + const GAMGInterface& GAMGCp, + const lduInterfaceField& fineInterfaceField + ); + + //- Construct from GAMG interface and fine level interface field + cyclicPeriodicAMIGAMGInterfaceField + ( + const GAMGInterface& GAMGCp, + const bool doTransform, + const int rank + ); + + + //- Destructor + virtual ~cyclicPeriodicAMIGAMGInterfaceField(); + + + // Member Functions + + // Access + + //- Return size + label size() const + { + return cyclicPeriodicAMIInterface_.size(); + } + + + // Interface matrix update + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + solveScalarField& result, + const bool add, + const solveScalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType + ) const; + + + //- Cyclic interface functions + + //- Does the interface field perform the transformation + virtual bool doTransform() const + { + return doTransform_; + } + + //- Return face transformation tensor + virtual const tensorField& forwardT() const + { + return cyclicPeriodicAMIInterface_.forwardT(); + } + + //- Return neighbour-cell transformation tensor + virtual const tensorField& reverseT() const + { + return cyclicPeriodicAMIInterface_.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/cyclicPeriodicAMIGAMGInterface/cyclicPeriodicAMIGAMGInterface.C b/src/meshTools/AMIInterpolation/GAMG/interfaces/cyclicPeriodicAMIGAMGInterface/cyclicPeriodicAMIGAMGInterface.C new file mode 100644 index 0000000000000000000000000000000000000000..cf0169935df02a997c49063261e6f06ee89208e8 --- /dev/null +++ b/src/meshTools/AMIInterpolation/GAMG/interfaces/cyclicPeriodicAMIGAMGInterface/cyclicPeriodicAMIGAMGInterface.C @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "AMIInterpolation.H" +#include "cyclicPeriodicAMIGAMGInterface.H" +#include "addToRunTimeSelectionTable.H" +#include "Map.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cyclicPeriodicAMIGAMGInterface, 0); + addToRunTimeSelectionTable + ( + GAMGInterface, + cyclicPeriodicAMIGAMGInterface, + lduInterface + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cyclicPeriodicAMIGAMGInterface::cyclicPeriodicAMIGAMGInterface +( + const label index, + const lduInterfacePtrsList& coarseInterfaces, + const lduInterface& fineInterface, + const labelField& localRestrictAddressing, + const labelField& neighbourRestrictAddressing, + const label fineLevelIndex, + const label coarseComm +) +: + GAMGInterface + ( + index, + coarseInterfaces + ), + fineCyclicPeriodicAMIInterface_ + ( + refCast<const cyclicPeriodicAMILduInterface>(fineInterface) + ) +{ + // Construct face agglomeration from cell agglomeration + { + // From coarse face to cell + DynamicList<label> dynFaceCells(localRestrictAddressing.size()); + + // From face to coarse face + DynamicList<label> dynFaceRestrictAddressing + ( + localRestrictAddressing.size() + ); + + Map<label> masterToCoarseFace(localRestrictAddressing.size()); + + for (const label curMaster : localRestrictAddressing) + { + const auto iter = masterToCoarseFace.cfind(curMaster); + + if (iter.found()) + { + // Already have coarse face + dynFaceRestrictAddressing.append(iter.val()); + } + else + { + // New coarse face + const label coarseI = dynFaceCells.size(); + dynFaceRestrictAddressing.append(coarseI); + dynFaceCells.append(curMaster); + masterToCoarseFace.insert(curMaster, coarseI); + } + } + + faceCells_.transfer(dynFaceCells); + faceRestrictAddressing_.transfer(dynFaceRestrictAddressing); + } + + + // On the owner side construct the AMI + + if (fineCyclicPeriodicAMIInterface_.owner()) + { + // Construct the neighbour side agglomeration (as the neighbour would + // do it so it the exact loop above using neighbourRestrictAddressing + // instead of localRestrictAddressing) + + labelList nbrFaceRestrictAddressing; + { + // From face to coarse face + DynamicList<label> dynNbrFaceRestrictAddressing + ( + neighbourRestrictAddressing.size() + ); + + Map<label> masterToCoarseFace(neighbourRestrictAddressing.size()); + + for (const label curMaster : neighbourRestrictAddressing) + { + const auto iter = masterToCoarseFace.cfind(curMaster); + + if (iter.found()) + { + // Already have coarse face + dynNbrFaceRestrictAddressing.append(iter.val()); + } + else + { + // New coarse face + const label coarseI = masterToCoarseFace.size(); + dynNbrFaceRestrictAddressing.append(coarseI); + masterToCoarseFace.insert(curMaster, coarseI); + } + } + + nbrFaceRestrictAddressing.transfer(dynNbrFaceRestrictAddressing); + } + + amiPtr_.reset + ( + new AMIPatchToPatchInterpolation + ( + fineCyclicPeriodicAMIInterface_.AMI(), + faceRestrictAddressing_, + nbrFaceRestrictAddressing + ) + ); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cyclicPeriodicAMIGAMGInterface::~cyclicPeriodicAMIGAMGInterface() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp<Foam::labelField> +Foam::cyclicPeriodicAMIGAMGInterface::internalFieldTransfer +( + const Pstream::commsTypes, + const labelUList& iF +) const +{ + const cyclicPeriodicAMIGAMGInterface& nbr = + dynamic_cast<const cyclicPeriodicAMIGAMGInterface&>(neighbPatch()); + const labelUList& nbrFaceCells = nbr.faceCells(); + + tmp<labelField> tpnf(new labelField(nbrFaceCells.size())); + labelField& pnf = tpnf.ref(); + + forAll(pnf, facei) + { + pnf[facei] = iF[nbrFaceCells[facei]]; + } + + return tpnf; +} + + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaces/cyclicPeriodicAMIGAMGInterface/cyclicPeriodicAMIGAMGInterface.H b/src/meshTools/AMIInterpolation/GAMG/interfaces/cyclicPeriodicAMIGAMGInterface/cyclicPeriodicAMIGAMGInterface.H new file mode 100644 index 0000000000000000000000000000000000000000..d2293c6c2ff53bb3c4153b092652b885712fed18 --- /dev/null +++ b/src/meshTools/AMIInterpolation/GAMG/interfaces/cyclicPeriodicAMIGAMGInterface/cyclicPeriodicAMIGAMGInterface.H @@ -0,0 +1,174 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::cyclicPeriodicAMIGAMGInterface + +Description + GAMG agglomerated cyclic periodic AMI interface. + +SourceFiles + cyclicPeriodicAMIGAMGInterface.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMIGAMGInterface_H +#define cyclicPeriodicAMIGAMGInterface_H + +#include "GAMGInterface.H" +#include "cyclicPeriodicAMILduInterface.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicPeriodicAMIGAMGInterface Declaration +\*---------------------------------------------------------------------------*/ + +class cyclicPeriodicAMIGAMGInterface +: + public GAMGInterface, + virtual public cyclicPeriodicAMILduInterface +{ + // Private data + + //- Reference for the cyclicLduInterface from which this is + // agglomerated + const cyclicPeriodicAMILduInterface& fineCyclicPeriodicAMIInterface_; + + //- AMI interface + autoPtr<AMIPatchToPatchInterpolation> amiPtr_; + + + // Private Member Functions + + //- No copy construct + cyclicPeriodicAMIGAMGInterface(const cyclicPeriodicAMIGAMGInterface&) = + delete; + + //- No copy assignment + void operator=(const cyclicPeriodicAMIGAMGInterface&) = delete; + + +public: + + //- Runtime type information + TypeName("cyclicPeriodicAMI"); + + + // Constructors + + //- Construct from fine level interface, + //- local and neighbour restrict addressing + cyclicPeriodicAMIGAMGInterface + ( + const label index, + const lduInterfacePtrsList& coarseInterfaces, + const lduInterface& fineInterface, + const labelField& restrictAddressing, + const labelField& neighbourRestrictAddressing, + const label fineLevelIndex, + const label coarseComm + ); + + + //- Destructor + virtual ~cyclicPeriodicAMIGAMGInterface(); + + + // Member Functions + + // Interface transfer functions + + //- Transfer and return internal field adjacent to the interface + virtual tmp<labelField> internalFieldTransfer + ( + const Pstream::commsTypes commsType, + const labelUList& iF + ) const; + + + //- Cyclic interface functions + + //- Return neighbour processor number + virtual label neighbPatchID() const + { + return fineCyclicPeriodicAMIInterface_.neighbPatchID(); + } + + virtual bool owner() const + { + return fineCyclicPeriodicAMIInterface_.owner(); + } + + virtual const cyclicPeriodicAMIGAMGInterface& neighbPatch() const + { + return dynamic_cast<const cyclicPeriodicAMIGAMGInterface&> + ( + coarseInterfaces_[neighbPatchID()] + ); + } + + virtual const AMIPatchToPatchInterpolation& AMI() const + { + return *amiPtr_; + } + + //- Return face transformation tensor + virtual const tensorField& forwardT() const + { + return fineCyclicPeriodicAMIInterface_.forwardT(); + } + + //- Return neighbour-cell transformation tensor + virtual const tensorField& reverseT() const + { + return fineCyclicPeriodicAMIInterface_.reverseT(); + } + + + // I/O + + //- Write to stream + virtual void write(Ostream&) const + { + //TBD. How to serialise the AMI such that we can stream + // cyclicPeriodicAMIGAMGInterface. + NotImplemented; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterface.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterface.C new file mode 100644 index 0000000000000000000000000000000000000000..b9d6a45e529b1df3994b23630b282c3acc1060a8 --- /dev/null +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterface.C @@ -0,0 +1,38 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cyclicPeriodicAMILduInterface.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +defineTypeNameAndDebug(cyclicPeriodicAMILduInterface, 0); +} + + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterface.H b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterface.H new file mode 100644 index 0000000000000000000000000000000000000000..0a25b9b748e540aa942b8d512c81f77ff1a2202e --- /dev/null +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterface.H @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::cyclicPeriodicAMILduInterface + +Description + An abstract base class for cyclic periodic AMI coupled interfaces + +SourceFiles + cyclicPeriodicAMILduInterface.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMILduInterface_H +#define cyclicPeriodicAMILduInterface_H + +#include "cyclicAMILduInterface.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicPeriodicAMILduInterface Declaration +\*---------------------------------------------------------------------------*/ + +class cyclicPeriodicAMILduInterface +: + public cyclicAMILduInterface +{ +public: + + //- Runtime type information + TypeName("cyclicPeriodicAMILduInterface"); + + + // Constructors + + //- Construct null + cyclicPeriodicAMILduInterface() = default; + + + //- Destructor + virtual ~cyclicPeriodicAMILduInterface() = default; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterfaceField.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterfaceField.C new file mode 100644 index 0000000000000000000000000000000000000000..a3d0de9baa0979e4c97ef4951473e2822dedddac --- /dev/null +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterfaceField.C @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cyclicPeriodicAMILduInterfaceField.H" +#include "diagTensorField.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +defineTypeNameAndDebug(cyclicPeriodicAMILduInterfaceField, 0); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cyclicPeriodicAMILduInterfaceField::~cyclicPeriodicAMILduInterfaceField() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::cyclicPeriodicAMILduInterfaceField::transformCoupleField +( + solveScalarField& f, + const direction cmpt +) const +{ + cyclicAMILduInterfaceField::transformCoupleField(f, cmpt); +} + + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterfaceField.H b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterfaceField.H new file mode 100644 index 0000000000000000000000000000000000000000..fe74d4f8c48bb9a94ae94ab3b50978836b4b9f67 --- /dev/null +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterfaceField.H @@ -0,0 +1,110 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::cyclicPeriodicAMILduInterfaceField + +Description + Abstract base class for cyclic periodic AMI coupled interfaces + +SourceFiles + cyclicPeriodicAMILduInterfaceField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicPeriodicAMILduInterfaceField_H +#define cyclicPeriodicAMILduInterfaceField_H + +#include "cyclicAMILduInterfaceField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicPeriodicAMILduInterfaceField Declaration +\*---------------------------------------------------------------------------*/ + +class cyclicPeriodicAMILduInterfaceField +: + public cyclicAMILduInterfaceField +{ + +public: + + //- Runtime type information + TypeName("cyclicPeriodicAMILduInterfaceField"); + + + // Constructors + + //- Construct null + cyclicPeriodicAMILduInterfaceField() + {} + + + //- Destructor + virtual ~cyclicPeriodicAMILduInterfaceField(); + + + // Member Functions + + //- Transform given patch field + template<class Type> + void transformCoupleField(Field<Type>& f) const; + + //- Transform given patch internal field + void transformCoupleField + ( + solveScalarField& psiInternal, + const direction cmpt + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "tensorField.H" + +template<class Type> +void Foam::cyclicPeriodicAMILduInterfaceField::transformCoupleField +( + Field<Type>& f +) const +{ + cyclicAMILduInterfaceField::transformCoupleField(f); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPointPatchField/cyclicPeriodicAMIPointPatchFields.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPointPatchField/cyclicPeriodicAMIPointPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..cc926c5f8d69d03afd9ceed2d9605c3eada93536 --- /dev/null +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPointPatchField/cyclicPeriodicAMIPointPatchFields.C @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cyclicAMIPointPatchFields.H" +#include "pointPatchFields.H" +#include "addToRunTimeSelectionTable.H" +//#include "cyclicPeriodicAMIPointPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +//makePointPatchFields(cyclicPeriodicAMI); + + +// Redirect cyclicPeriodicAMI to cyclicAMI for now +#define addNamedToPointPatchFieldRunTimeSelection\ +(PatchTypeField,typePatchTypeField,lookup) \ + addNamedToRunTimeSelectionTable \ + ( \ + PatchTypeField, \ + typePatchTypeField, \ + pointPatch, \ + lookup \ + ); \ + addNamedToRunTimeSelectionTable \ + ( \ + PatchTypeField, \ + typePatchTypeField, \ + patchMapper, \ + lookup \ + ); \ + addNamedToRunTimeSelectionTable \ + ( \ + PatchTypeField, \ + typePatchTypeField, \ + dictionary, \ + lookup \ + ); + +#define makeNamedPointPatchFields(type,lookupType) \ + addNamedToPointPatchFieldRunTimeSelection \ + ( \ + pointPatchScalarField, \ + type##PointPatchScalarField, \ + lookupType \ + ); \ + addNamedToPointPatchFieldRunTimeSelection \ + ( \ + pointPatchVectorField, \ + type##PointPatchVectorField, \ + lookupType \ + ); \ + addNamedToPointPatchFieldRunTimeSelection \ + ( \ + pointPatchSphericalTensorField, \ + type##PointPatchSphericalTensorField, \ + lookupType \ + ); \ + addNamedToPointPatchFieldRunTimeSelection \ + ( \ + pointPatchSymmTensorField, \ + type##PointPatchSymmTensorField, \ + lookupType \ + ); \ + addNamedToPointPatchFieldRunTimeSelection \ + ( \ + pointPatchTensorField, \ + type##PointPatchTensorField, \ + lookupType \ +); + +makeNamedPointPatchFields(cyclicAMI, cyclicPeriodicAMI); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.H index 297c5c3189310d8ef90faf64244c4b0332005075..b9cd0098b2a502ed008234a71c8c0923de87afbd 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.H @@ -214,6 +214,25 @@ public: //- Write the polyPatch data as a dictionary virtual void write(Ostream&) const; + + + // Interpolations + + //- Interpolate field + template<class Type> + tmp<Field<Type>> interpolate + ( + const Field<Type>& fld, + const UList<Type>& defaultValues = UList<Type>() + ) const; + + //- Interpolate tmp field + template<class Type> + tmp<Field<Type>> interpolate + ( + const tmp<Field<Type>>& tFld, + const UList<Type>& defaultValues = UList<Type>() + ) const; }; @@ -223,6 +242,9 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository + #include "cyclicPeriodicAMIPolyPatchTemplates.C" +#endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatchTemplates.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatchTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..05d286cb8b4b9372eb7e8d8f8e5cba9b5ffe97e4 --- /dev/null +++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatchTemplates.C @@ -0,0 +1,223 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "transformField.H" +#include "cyclicPolyPatch.H" +#include "cyclicAMIPolyPatch.H" +#include "cylindricalCS.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +Foam::tmp<Foam::Field<Type>> Foam::cyclicPeriodicAMIPolyPatch::interpolate +( + const Field<Type>& fld, + const UList<Type>& defaultValues +) const +{ + // Get the periodic patch + const coupledPolyPatch& pp + ( + refCast<const coupledPolyPatch> + ( + boundaryMesh()[periodicPatchID()] + ) + ); + + if (debug & 2) + { + Pout<< "For patch " << this->name() + << " found periodic:" << pp.name() + //<< " own:" << pp.owner() + << " rank:" << pTraits<Type>::rank + << " parallel:" << pp.parallel() + //<< " forwardT:" << pp.forwardT() + //<< " reverseT:" << pp.reverseT() + << endl; + } + + if (pTraits<Type>::rank == 0 || pp.parallel()) + { + // No need for rotation. Pass up to default AMI interpolation. + return cyclicAMIPolyPatch::interpolate(fld, defaultValues); + } + else + { + // Transform + // ~~~~~~~~~ + // - transform to cylindrical coords + // - do AMI interpolation + // - transform back to cartesian + + const cyclicAMIPolyPatch& nbrPp = this->neighbPatch(); + + if (fld.size() != nbrPp.size()) + { + FatalErrorInFunction + << "Patch:" << this->name() + << " size:" << this->size() + << " neighbour patch:" << nbrPp.name() + << " size:" << nbrPp.size() + << " fld size:" << fld.size() + << exit(FatalError); + } + + vector axis(Zero); + point axisPoint(Zero); + if (isA<cyclicPolyPatch>(pp)) + { + axis = refCast<const cyclicPolyPatch>(pp).rotationAxis(); + axisPoint = refCast<const cyclicPolyPatch>(pp).rotationCentre(); + } + else if (isA<cyclicAMIPolyPatch>(pp)) + { + axis = refCast<const cyclicAMIPolyPatch>(pp).rotationAxis(); + axisPoint = refCast<const cyclicAMIPolyPatch>(pp).rotationCentre(); + } + else + { + FatalErrorInFunction << "On patch " << name() + << " have unsupported periodicPatch " << pp.name() + << exit(FatalError); + } + + const coordSystem::cylindrical cs(axisPoint, axis); + + auto tlocalFld(tmp<Field<Type>>::New(fld.size())); + auto& localFld = tlocalFld.ref(); + List<Type> localDeflt(defaultValues.size()); + + // Transform to cylindrical coords + { + tmp<tensorField> nbrT(cs.R(nbrPp.faceCentres())); + localFld = Foam::invTransform(nbrT, fld); + if (defaultValues.size()) + { + // We get in UList (why? Copied from cyclicAMI). Convert to + // Field so we can use transformField routines. + const SubField<Type> defaultSubFld(defaultValues); + const Field<Type>& defaultFld(defaultSubFld); + localDeflt = Foam::invTransform(nbrT, defaultFld); + } + } + + + if (debug&2) + { + const pointField& nbrFc = nbrPp.faceCentres(); + + Pout<< "On patch:" << this->name() + << " size:" << this->size() + << " fc:" << gAverage(this->faceCentres()) + << " getting remote data from:" << nbrPp.name() + << " size:" << nbrPp.size() + << " fc:" << gAverage(nbrFc) + << endl; + + forAll(fld, i) + { + Pout<< "At:" << nbrFc[i] << nl + << " cart:" << fld[i] << nl + << " cyli:" << localFld[i] << nl + << endl; + } + + if (defaultValues.size()) + { + forAll(defaultValues, i) + { + Pout<< "Defaults At:" << nbrFc[i] << nl + << " cart:" << defaultValues[i] << nl + << " cyli:" << localDeflt[i] << nl + << endl; + } + } + } + + + // Do the actual interpolation + auto tinterp = cyclicAMIPolyPatch::interpolate(localFld, localDeflt); + + // Transform back. Result is now at *this + List<Type> oldResult; + if (debug&2) + { + oldResult = tinterp(); + } + + const pointField& fc = this->faceCentres(); + tmp<tensorField> T(cs.R(fc)); + auto tresult = Foam::transform(T, tinterp); + + if (debug&2) + { + const pointField& fc = this->faceCentres(); + forAll(fc, i) + { + Pout<< "Results: At local :" << fc[i] << nl + << " cyli:" << oldResult[i] << nl + << " cart:" << tresult()[i] << nl + << endl; + } + } + + return tresult; + } +} + + +template<class Type> +Foam::tmp<Foam::Field<Type>> Foam::cyclicPeriodicAMIPolyPatch::interpolate +( + const tmp<Field<Type>>& tFld, + const UList<Type>& defaultValues +) const +{ + // Get the periodic patch + const coupledPolyPatch& pp + ( + refCast<const coupledPolyPatch> + ( + boundaryMesh()[periodicPatchID()] + ) + ); + + if (pTraits<Type>::rank == 0 || pp.parallel()) + { + // No need for rotation. Pass up to default AMI interpolation. + return cyclicAMIPolyPatch::interpolate(tFld, defaultValues); + } + else + { + return interpolate(tFld(), defaultValues); + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 09b7191723513790075d096bd98171e42c3ca822..ec5b663e54adf595db795135a866e82c213a0de8 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -275,6 +275,8 @@ $(AMI)/GAMG/interfaces/cyclicAMIGAMGInterface/cyclicAMIGAMGInterface.C $(AMI)/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C $(AMI)/GAMG/interfaces/cyclicACMIGAMGInterface/cyclicACMIGAMGInterface.C $(AMI)/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C +$(AMI)/GAMG/interfaces/cyclicPeriodicAMIGAMGInterface/cyclicPeriodicAMIGAMGInterface.C +$(AMI)/GAMG/interfaceFields/cyclicPeriodicAMIGAMGInterfaceField/cyclicPeriodicAMIGAMGInterfaceField.C $(AMI)/triangle2D/triangle2D.C $(AMI)/AMIInterpolation/faceAreaWeightAMI2D/faceAreaWeightAMI2D.C @@ -296,7 +298,15 @@ $(ACMICycPatches)/cyclicACMIPointPatch/cyclicACMIPointPatch.C $(ACMICycPatches)/cyclicACMIPointPatchField/cyclicACMIPointPatchFields.C PeriodicAMICycPatches=$(AMI)/patches/cyclicPeriodicAMI +$(PeriodicAMICycPatches)/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterface.C +$(PeriodicAMICycPatches)/cyclicPeriodicAMILduInterfaceField/cyclicPeriodicAMILduInterfaceField.C $(PeriodicAMICycPatches)/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C +/* +$(PeriodicAMICycPatches)/cyclicPeriodicAMIPointPatch/cyclicPeriodicAMIPointPatch.C +*/ +$(PeriodicAMICycPatches)/cyclicPeriodicAMIPointPatchField/cyclicPeriodicAMIPointPatchFields.C + + multiWorld/multiWorldConnectionsObject.C