ENH: Initial commit of arbitrary mesh interface boundary handling

This commit is contained in:
andy
2011-07-20 18:19:36 +01:00
parent 81d380ddac
commit 4ee5d991b8
20 changed files with 2786 additions and 0 deletions

View File

@ -1,4 +1,12 @@
AMIInterpolationName.C
faceAreaIntersect/faceAreaIntersect.C
patches/cyclicAMILduInterfaceField/cyclicAMILduInterface.C
patches/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.C
patches/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
patches/cyclicAMIFvPatch/cyclicAMIFvPatch.C
patches/cyclicAMIFvPatchField/cyclicAMIFvPatchFields.C
patches/cyclicAMIFvsPatchField/cyclicAMIFvsPatchFields.C
LIB = $(FOAM_USER_LIBBIN)/libAMIInterpolation

View File

@ -1,6 +1,8 @@
EXE_INC = \
-DFULLDEBUG -g -O0 \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMIFvPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "fvMesh.H"
#include "transform.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cyclicAMIFvPatch, 0);
addToRunTimeSelectionTable(fvPatch, cyclicAMIFvPatch, polyPatch);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const
{
const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
const scalarField deltas(nf() & fvPatch::delta());
const scalarField nbrDeltas
(
interpolateToSource(nbrPatch.nf() & nbrPatchDelta())
);
forAll(deltas, faceI)
{
scalar di = deltas[faceI];
scalar dni = nbrDeltas[faceI];
w[faceI] = dni/(di + dni);
}
}
void Foam::cyclicAMIFvPatch::makeDeltaCoeffs(scalarField& dc) const
{
const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
const scalarField deltas(nf() & fvPatch::delta());
const scalarField nbrDeltas
(
interpolateToSource(nbrPatch.nf() & nbrPatchDelta())
);
forAll(deltas, faceI)
{
scalar di = deltas[faceI];
scalar dni = nbrDeltas[faceI];
dc[faceI] = 1.0/(di + dni);
}
}
Foam::tmp<Foam::vectorField> Foam::cyclicAMIFvPatch::delta() const
{
const vectorField patchD(fvPatch::delta());
const vectorField& nbrPatchD(interpolateToSource(nbrPatchDelta()));
tmp<vectorField> tpdv(new vectorField(patchD.size()));
vectorField& pdv = tpdv();
// To the transformation if necessary
if (parallel())
{
forAll(patchD, faceI)
{
vector ddi = patchD[faceI];
vector dni = nbrPatchD[faceI];
pdv[faceI] = ddi - dni;
}
}
else
{
forAll(patchD, faceI)
{
vector ddi = patchD[faceI];
vector dni = nbrPatchD[faceI];
pdv[faceI] = ddi - transform(forwardT()[0], dni);
}
}
return tpdv;
}
Foam::tmp<Foam::labelField> Foam::cyclicAMIFvPatch::interfaceInternalField
(
const labelUList& internalData
) const
{
return patchInternalField(internalData);
}
Foam::tmp<Foam::labelField> Foam::cyclicAMIFvPatch::internalFieldTransfer
(
const Pstream::commsTypes commsType,
const labelUList& iF
) const
{
tmp<labelField> tnpif(neighbFvPatch().patchInternalField(iF));
labelField& npif = tnpif();
interpolateToSource(npif);
return tnpif;
}
// ************************************************************************* //

View File

@ -0,0 +1,193 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cyclicAMIFvPatch
Description
Cyclic patch for Arbitrary Mesh Interface (AMI)
SourceFiles
cyclicAMIFvPatch.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvPatch_H
#define cyclicAMIFvPatch_H
#include "coupledFvPatch.H"
#include "cyclicAMILduInterface.H"
#include "cyclicAMIPolyPatch.H"
#include "fvBoundaryMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicAMIFvPatch Declaration
\*---------------------------------------------------------------------------*/
class cyclicAMIFvPatch
:
public coupledFvPatch,
public cyclicAMILduInterface
{
// Private data
const cyclicAMIPolyPatch& cyclicAMIPolyPatch_;
protected:
// Protected Member functions
//- Make patch weighting factors
void makeWeights(scalarField&) const;
//- Make patch face - neighbour cell distances
void makeDeltaCoeffs(scalarField&) const;
public:
//- Runtime type information
TypeName(cyclicAMIPolyPatch::typeName_());
// Constructors
//- Construct from polyPatch
cyclicAMIFvPatch(const polyPatch& patch, const fvBoundaryMesh& bm)
:
coupledFvPatch(patch, bm),
cyclicAMILduInterface(),
cyclicAMIPolyPatch_(refCast<const cyclicAMIPolyPatch>(patch))
{}
// Member functions
// Access
//- Return local reference cast into the cyclic patch
const cyclicAMIPolyPatch& cyclicAMIPatch() const
{
return cyclicAMIPolyPatch_;
}
//- Return neighbour
virtual label neighbPatchID() const
{
return cyclicAMIPolyPatch_.nbrPatchID();
}
virtual bool owner() const
{
return cyclicAMIPolyPatch_.owner();
}
//- Return processor number
virtual const cyclicAMIFvPatch& neighbPatch() const
{
return refCast<const cyclicAMIFvPatch>
(
this->boundaryMesh()[cyclicAMIPolyPatch_.nbrPatchID()]
);
}
//- Are the cyclic planes parallel
virtual bool parallel() const
{
return cyclicAMIPolyPatch_.parallel();
}
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return cyclicAMIPolyPatch_.forwardT();
}
//- Return neighbour-cell transformation tensor
virtual const tensorField& reverseT() const
{
return cyclicAMIPolyPatch_.reverseT();
}
const cyclicAMIFvPatch& neighbFvPatch() const
{
return refCast<const cyclicAMIFvPatch>
(
this->boundaryMesh()[cyclicAMIPolyPatch_.nbrPatchID()]
);
}
//- Return delta (P to N) vectors across coupled patch
virtual tmp<vectorField> delta() const;
template<class Type>
tmp<Field<Type> > interpolateToSource(const Field<Type>& fld) const
{
return cyclicAMIPolyPatch_.interpolateToSource(fld);
}
template<class Type>
tmp<Field<Type> > interpolateToSource(const tmp<Field<Type> >& tFld) const
{
return cyclicAMIPolyPatch_.interpolateToSource(tFld);
}
const vectorField& nbrPatchDelta() const
{
return cyclicAMIPolyPatch_.nbrPatchDelta();
}
// 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
// ************************************************************************* //

View File

@ -0,0 +1,234 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMIFvPatchField.H"
#include "transformField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF
)
:
cyclicAMILduInterfaceField(),
coupledFvPatchField<Type>(p, iF),
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
{}
template<class Type>
Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
(
const cyclicAMIFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
cyclicAMILduInterfaceField(),
coupledFvPatchField<Type>(ptf, p, iF, mapper),
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
{
if (!isA<cyclicAMIFvPatch>(this->patch()))
{
FatalErrorIn
(
"cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField"
"("
"const cyclicAMIFvPatchField<Type>& ,"
"const fvPatch&, "
"const DimensionedField<Type, volMesh>&, "
"const fvPatchFieldMapper&"
")"
) << " patch type '" << p.type()
<< "' not constraint type '" << typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalIOError);
}
}
template<class Type>
Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
cyclicAMILduInterfaceField(),
coupledFvPatchField<Type>(p, iF, dict),
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
{
if (!isA<cyclicAMIFvPatch>(p))
{
FatalIOErrorIn
(
"cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField"
"("
"const fvPatch&, "
"const Field<Type>&, "
"const dictionary&"
")",
dict
) << " patch type '" << p.type()
<< "' not constraint type '" << typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalIOError);
}
this->evaluate(Pstream::blocking);
}
template<class Type>
Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
(
const cyclicAMIFvPatchField<Type>& ptf
)
:
cyclicAMILduInterfaceField(),
coupledFvPatchField<Type>(ptf),
cyclicAMIPatch_(ptf.cyclicAMIPatch_)
{}
template<class Type>
Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
(
const cyclicAMIFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF
)
:
cyclicAMILduInterfaceField(),
coupledFvPatchField<Type>(ptf, iF),
cyclicAMIPatch_(ptf.cyclicAMIPatch_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const
{
const Field<Type>& iField = this->internalField();
const labelUList& nbrFaceCells =
cyclicAMIPatch_.cyclicAMIPatch().nbrPatch().faceCells();
tmp<Field<Type> > tpnf(new Field<Type>(nbrFaceCells.size()));
Field<Type>& pnf = tpnf();
if (doTransform())
{
forAll(pnf, faceI)
{
pnf[faceI] = transform
(
forwardT()[0], iField[nbrFaceCells[faceI]]
);
}
}
else
{
forAll(pnf, faceI)
{
pnf[faceI] = iField[nbrFaceCells[faceI]];
}
}
return cyclicAMIPatch_.interpolateToSource(pnf);
}
template<class Type>
const Foam::cyclicAMIFvPatchField<Type>&
Foam::cyclicAMIFvPatchField<Type>::neighbourPatchField() const
{
const GeometricField<Type, fvPatchField, volMesh>& fld =
static_cast<const GeometricField<Type, fvPatchField, volMesh>&>
(
this->internalField()
);
return refCast<const cyclicAMIFvPatchField<Type> >
(
fld.boundaryField()[cyclicAMIPatch_.neighbPatchID()]
);
}
template<class Type>
void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
(
const scalarField& psiInternal,
scalarField& result,
const lduMatrix&,
const scalarField& coeffs,
const direction cmpt,
const Pstream::commsTypes
) const
{
const labelUList& nbrFaceCells =
cyclicAMIPatch_.cyclicAMIPatch().nbrPatch().faceCells();
scalarField pnf(nbrFaceCells.size());
forAll(pnf, faceI)
{
pnf[faceI] = psiInternal[nbrFaceCells[faceI]];
}
// Transform according to the transformation tensors
transformCoupleField(pnf, cmpt);
pnf = cyclicAMIPatch_.interpolateToSource(pnf);
// Multiply the field by coefficients and add into the result
const labelUList& faceCells = cyclicAMIPatch_.faceCells();
forAll(faceCells, elemI)
{
result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
}
}
template<class Type>
void Foam::cyclicAMIFvPatchField<Type>::write(Ostream& os) const
{
fvPatchField<Type>::write(os);
}
// ************************************************************************* //

View File

@ -0,0 +1,216 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cyclicAMIFvPatchField
Description
Foam::cyclicAMIFvPatchField
SourceFiles
cyclicAMIFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvPatchField_H
#define cyclicAMIFvPatchField_H
#include "coupledFvPatchField.H"
#include "cyclicAMILduInterfaceField.H"
#include "cyclicAMIFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicAMIFvPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class cyclicAMIFvPatchField
:
virtual public cyclicAMILduInterfaceField,
public coupledFvPatchField<Type>
{
// Private data
//- Local reference cast into the cyclic patch
const cyclicAMIFvPatch& cyclicAMIPatch_;
// Private Member Functions
//- Return neighbour side field given internal fields
template<class Type2>
tmp<Field<Type2> > neighbourSideField
(
const Field<Type2>&
) const;
public:
//- Runtime type information
TypeName(cyclicAMIFvPatch::typeName_());
// Constructors
//- Construct from patch and internal field
cyclicAMIFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Construct from patch, internal field and dictionary
cyclicAMIFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const dictionary&
);
//- Construct by mapping given cyclicAMIFvPatchField onto a new patch
cyclicAMIFvPatchField
(
const cyclicAMIFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
cyclicAMIFvPatchField(const cyclicAMIFvPatchField<Type>&);
//- Construct and return a clone
virtual tmp<fvPatchField<Type> > clone() const
{
return tmp<fvPatchField<Type> >
(
new cyclicAMIFvPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
cyclicAMIFvPatchField
(
const cyclicAMIFvPatchField<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 cyclicAMIFvPatchField<Type>(*this, iF)
);
}
// Member functions
// Access
//- Return local reference cast into the cyclic AMI patch
const cyclicAMIFvPatch& cyclicAMIPatch() const
{
return cyclicAMIPatch_;
}
// Evaluation functions
//- Return neighbour coupled internal cell data
tmp<Field<Type> > patchNeighbourField() const;
//- Return reference to neighbour patchField
const cyclicAMIFvPatchField<Type>& neighbourPatchField() const;
//- Update result field based on interface functionality
virtual void updateInterfaceMatrix
(
const scalarField& psiInternal,
scalarField& result,
const lduMatrix&,
const scalarField& coeffs,
const direction cmpt,
const Pstream::commsTypes commsType
) const;
// Cyclic AMI coupled interface functions
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return !(cyclicAMIPatch_.parallel() || pTraits<Type>::rank == 0);
}
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return cyclicAMIPatch_.forwardT();
}
//- Return neighbour-cell transformation tensor
virtual const tensorField& reverseT() const
{
return cyclicAMIPatch_.reverseT();
}
//- Return rank of component for transform
virtual int rank() const
{
return pTraits<Type>::rank;
}
// I-O
//- Write
virtual void write(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "cyclicAMIFvPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMIFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePatchFields(cyclicAMI);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvPatchFields_H
#define cyclicAMIFvPatchFields_H
#include "cyclicAMIFvPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeFieldTypedefs(cyclicAMI);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvPatchFieldsFwd_H
#define cyclicAMIFvPatchFieldsFwd_H
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> class cyclicAMIFvPatchField;
makePatchTypeFieldTypedefs(cyclicAMI);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMIFvsPatchField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::cyclicAMIFvsPatchField<Type>::cyclicAMIFvsPatchField
(
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF
)
:
coupledFvsPatchField<Type>(p, iF),
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
{}
template<class Type>
Foam::cyclicAMIFvsPatchField<Type>::cyclicAMIFvsPatchField
(
const cyclicAMIFvsPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
coupledFvsPatchField<Type>(ptf, p, iF, mapper),
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
{
if (!isA<cyclicAMIFvPatch>(this->patch()))
{
FatalErrorIn
(
"cyclicAMIFvsPatchField<Type>::cyclicAMIFvsPatchField\n"
"("
"const cyclicAMIFvsPatchField<Type>&, "
"const fvPatch&, "
"const DimensionedField<Type, surfaceMesh>&, "
"const fvPatchFieldMapper&"
")"
) << "Field type does not correspond to patch type for patch "
<< this->patch().index() << "." << endl
<< "Field type: " << typeName << endl
<< "Patch type: " << this->patch().type()
<< exit(FatalError);
}
}
template<class Type>
Foam::cyclicAMIFvsPatchField<Type>::cyclicAMIFvsPatchField
(
const fvPatch& p,
const DimensionedField<Type, surfaceMesh>& iF,
const dictionary& dict
)
:
coupledFvsPatchField<Type>(p, iF, dict),
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
{
if (!isA<cyclicAMIFvPatch>(p))
{
FatalIOErrorIn
(
"cyclicAMIFvsPatchField<Type>::cyclicAMIFvsPatchField"
"("
"const fvPatch&, "
"const Field<Type>&, "
"const dictionary&"
")",
dict
) << "patch " << this->patch().index() << " not cyclicAMI type. "
<< "Patch type = " << p.type()
<< exit(FatalIOError);
}
}
template<class Type>
Foam::cyclicAMIFvsPatchField<Type>::cyclicAMIFvsPatchField
(
const cyclicAMIFvsPatchField<Type>& ptf
)
:
coupledFvsPatchField<Type>(ptf),
cyclicAMIPatch_(ptf.cyclicAMIPatch_)
{}
template<class Type>
Foam::cyclicAMIFvsPatchField<Type>::cyclicAMIFvsPatchField
(
const cyclicAMIFvsPatchField<Type>& ptf,
const DimensionedField<Type, surfaceMesh>& iF
)
:
coupledFvsPatchField<Type>(ptf, iF),
cyclicAMIPatch_(ptf.cyclicAMIPatch_)
{}
// ************************************************************************* //

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cyclicAMIFvsPatchField
Description
Foam::cyclicAMIFvsPatchField
SourceFiles
cyclicAMIFvsPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvsPatchField_H
#define cyclicAMIFvsPatchField_H
#include "coupledFvsPatchField.H"
#include "cyclicAMIFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicAMIFvsPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class cyclicAMIFvsPatchField
:
public coupledFvsPatchField<Type>
{
// Private data
//- Local reference cast into the cyclic patch
const cyclicAMIFvPatch& cyclicAMIPatch_;
public:
//- Runtime type information
TypeName(cyclicAMIFvPatch::typeName_());
// Constructors
//- Construct from patch and internal field
cyclicAMIFvsPatchField
(
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&
);
//- Construct from patch, internal field and dictionary
cyclicAMIFvsPatchField
(
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&,
const dictionary&
);
//- Construct by mapping given cyclicAMIFvsPatchField onto a new patch
cyclicAMIFvsPatchField
(
const cyclicAMIFvsPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, surfaceMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
cyclicAMIFvsPatchField
(
const cyclicAMIFvsPatchField<Type>&
);
//- Construct and return a clone
virtual tmp<fvsPatchField<Type> > clone() const
{
return tmp<fvsPatchField<Type> >
(
new cyclicAMIFvsPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
cyclicAMIFvsPatchField
(
const cyclicAMIFvsPatchField<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 cyclicAMIFvsPatchField<Type>(*this, iF)
);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "cyclicAMIFvsPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMIFvsPatchFields.H"
#include "fvsPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeFvsPatchFields(cyclicAMI);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvsPatchFields_H
#define cyclicAMIFvsPatchFields_H
#include "cyclicAMIFvsPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makeFvsPatchTypeFieldTypedefs(cyclicAMI);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvsPatchFieldsFwd_H
#define cyclicAMIFvsPatchFieldsFwd_H
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> class cyclicAMIFvsPatchField;
makeFvsPatchTypeFieldTypedefs(cyclicAMI);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMILduInterface.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::cyclicAMILduInterface, 0);
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cyclicAMILduInterface::~cyclicAMILduInterface()
{}
// ************************************************************************* //

View File

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cyclicAMILduInterface
Description
An abstract base class for cyclic AMI coupled interfaces
SourceFiles
cyclicAMILduInterface.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMILduInterface_H
#define cyclicAMILduInterface_H
#include "primitiveFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicAMILduInterface Declaration
\*---------------------------------------------------------------------------*/
class cyclicAMILduInterface
{
public:
//- Runtime type information
TypeName("cyclicAMILduInterface");
// Constructors
//- Construct null
cyclicAMILduInterface()
{}
//- Destructor
virtual ~cyclicAMILduInterface();
// Member Functions
// Access
//- Return neighbour
virtual label neighbPatchID() const = 0;
virtual bool owner() const = 0;
//- Return processor number
virtual const cyclicAMILduInterface& neighbPatch() const = 0;
//- Return face transformation tensor
virtual const tensorField& forwardT() const = 0;
//- Return face reverse transformation tensor
virtual const tensorField& reverseT() const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMILduInterfaceField.H"
#include "diagTensorField.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::cyclicAMILduInterfaceField, 0);
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cyclicAMILduInterfaceField::~cyclicAMILduInterfaceField()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cyclicAMILduInterfaceField::transformCoupleField
(
scalarField& f,
const direction cmpt
) const
{
if (doTransform())
{
if (forwardT().size() == 1)
{
f *= pow(diag(forwardT()[0]).component(cmpt), rank());
}
else
{
f *= pow(diag(forwardT())().component(cmpt), rank());
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,103 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cyclicAMILduInterfaceField
Description
Abstract base class for cyclic AMI coupled interfaces
SourceFiles
cyclicAMILduInterfaceField.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMILduInterfaceField_H
#define cyclicAMILduInterfaceField_H
#include "primitiveFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicAMILduInterfaceField Declaration
\*---------------------------------------------------------------------------*/
class cyclicAMILduInterfaceField
{
public:
//- Runtime type information
TypeName("cyclicAMILduInterfaceField");
// Constructors
//- Construct null
cyclicAMILduInterfaceField()
{}
//- Destructor
virtual ~cyclicAMILduInterfaceField();
// Member Functions
// Access
//- Is the transform required
virtual bool doTransform() const = 0;
//- Return face transformation tensor
virtual const tensorField& forwardT() const = 0;
//- Return neighbour-cell transformation tensor
virtual const tensorField& reverseT() const = 0;
//- Return rank of component for transform
virtual int rank() const = 0;
//- Transform given patch internal field
void transformCoupleField
(
scalarField& psiInternal,
const direction cmpt
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,754 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cyclicAMIPolyPatch.H"
#include "transformField.H"
#include "SubField.H"
#include "polyMesh.H"
#include "Time.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cyclicAMIPolyPatch, 0);
addToRunTimeSelectionTable(polyPatch, cyclicAMIPolyPatch, word);
addToRunTimeSelectionTable(polyPatch, cyclicAMIPolyPatch, dictionary);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::label Foam::cyclicAMIPolyPatch::findFaceMaxRadius
(
const pointField& faceCentres
) const
{
// Determine a face furthest away from the axis
const scalarField magRadSqr
(
magSqr((faceCentres - rotationCentre_) ^ rotationAxis_)
);
label faceI = findMax(magRadSqr);
if (debug)
{
Info<< "findFaceMaxRadius(const pointField&)" << nl
<< " rotFace = " << faceI << nl
<< " point = " << faceCentres[faceI] << nl
<< " distance = " << Foam::sqrt(magRadSqr[faceI])
<< endl;
}
return faceI;
}
// * * * * * * * * * * * Protecetd Member Functions * * * * * * * * * * * * //
void Foam::cyclicAMIPolyPatch::calcTransforms()
{
if (size())
{
// Half0
const cyclicAMIPolyPatch& half0 = *this;
vectorField half0Areas(half0.size());
forAll(half0, facei)
{
half0Areas[facei] = half0[facei].normal(half0.points());
}
// Half1
const cyclicAMIPolyPatch& half1 = nbrPatch();
vectorField half1Areas(half1.size());
forAll(half1, facei)
{
half1Areas[facei] = half1[facei].normal(half1.points());
}
calcTransforms
(
half0,
half0.faceCentres(),
half0Areas,
half1.faceCentres(),
half1Areas
);
}
}
void Foam::cyclicAMIPolyPatch::calcTransforms
(
const primitivePatch& half0,
const pointField& half0Ctrs,
const vectorField& half0Areas,
const pointField& half1Ctrs,
const vectorField& half1Areas
)
{
if (transform_ != nbrPatch().transform_)
{
FatalErrorIn("cyclicAMIPolyPatch::calcTransforms()")
<< "Patch " << name()
<< " has transform type " << transformTypeNames[transform_]
<< ", neighbour patch " << nbrPatchName_
<< " has transform type "
<< nbrPatch().transformTypeNames[transform_]
<< exit(FatalError);
}
// Calculate transformation tensors
if ((half0Ctrs.size() <= 0) || (half1Ctrs.size() <= 0))
{
return;
}
switch (transform_)
{
case ROTATIONAL:
{
label face0 = findFaceMaxRadius(half0Ctrs);
label face1 = findFaceMaxRadius(half1Ctrs);
vector n0 = ((half0Ctrs[face0] - rotationCentre_) ^ rotationAxis_);
vector n1 = ((half1Ctrs[face1] - rotationCentre_) ^ -rotationAxis_);
n0 /= mag(n0) + VSMALL;
n1 /= mag(n1) + VSMALL;
if (debug)
{
Pout<< "cyclicAMIPolyPatch::calcTransforms :"
<< " Specified rotation :"
<< " n0:" << n0 << " n1:" << n1 << endl;
}
// Extended tensor from two local coordinate systems calculated
// using normal and rotation axis
const tensor E0
(
rotationAxis_,
(n0 ^ rotationAxis_),
n0
);
const tensor E1
(
rotationAxis_,
(-n1 ^ rotationAxis_),
-n1
);
const tensor revT(E1.T() & E0);
const_cast<tensorField&>(forwardT()) = tensorField(1, revT.T());
const_cast<tensorField&>(reverseT()) = tensorField(1, revT);
const_cast<vectorField&>(separation()).setSize(0);
const_cast<boolList&>(collocated()) = boolList(1, false);
break;
}
case TRANSLATIONAL:
{
// Transform 0 points.
if (debug)
{
Pout<< "cyclicAMIPolyPatch::calcTransforms :"
<< "Specified translation : " << separationVector_
<< endl;
}
const_cast<tensorField&>(forwardT()).clear();
const_cast<tensorField&>(reverseT()).clear();
const_cast<vectorField&>(separation()) = vectorField
(
1,
separationVector_
);
const_cast<boolList&>(collocated()) = boolList(1, false);
break;
}
default:
{
/*
// Assumes that cyclic is planar. This is also the initial
// condition for patches without faces.
// Determine the face with max area on both halves. These
// two faces are used to determine the transformation tensors
label max0I = findMaxArea(pp0.points(), pp0);
vector n0 = pp0[max0I].normal(pp0.points());
n0 /= mag(n0) + VSMALL;
label max1I = findMaxArea(pp1.points(), pp1);
vector n1 = pp1[max1I].normal(pp1.points());
n1 /= mag(n1) + VSMALL;
if (mag(n0 & n1) < 1 - matchTolerance())
{
if (debug)
{
Pout<< "cyclicAMIPolyPatch::calcTransforms :"
<< " Detected rotation :"
<< " n0:" << n0 << " n1:" << n1 << endl;
}
// Rotation (around origin)
const tensor revT(rotationTensor(n0, -n1));
const_cast<tensorField&>(forwardT()) = tensorField(1, revT.T());
const_cast<tensorField&>(reverseT()) = tensorField(1, revT);
const_cast<vectorField&>(separation()).setSize(0);
const_cast<boolList&>(collocated()) = boolList(1, false);
}
else
{
// Parallel translation
const_cast<tensorField&>(forwardT()).clear();
const_cast<tensorField&>(reverseT()).clear();
const_cast<vectorField&>(separation()) = vectorField
(
1,
separationVector_
);
const_cast<boolList&>(collocated()) = boolList(1, false);
}
*/
notImplemented("calcTransforms - unknown transform clause");
break;
}
}
// Calculate typical distance per face
// tols = calcFaceTol(matchTolerance(), pp1, pp1.points(), half1Ctrs);
}
const Foam::AMIPatchToPatchInterpolation& Foam::cyclicAMIPolyPatch::AMI()
{
if (!AMIPtr_)
{
const polyPatch& nbr = nbrPatch();
pointField nbrPoints = nbrPatch().localPoints();
const word myName = nbrPatch().nbrPatch().nbrPatchName();
OFstream osNorg(myName + "_neighbourPatch-org.obj");
meshTools::writeOBJ(osNorg, nbrPatch().localFaces(), nbrPoints);
transformPosition(nbrPoints);
primitivePatch nbrPatch0
(
SubList<face>
(
nbr.localFaces(),
nbr.size()
),
nbrPoints
);
OFstream osN(myName + "_neighbourPatch-trans.obj");
meshTools::writeOBJ(osN, nbrPatch0.localFaces(), nbrPoints);
OFstream osO(myName + "_ownerPatch.obj");
meshTools::writeOBJ(osO, this->localFaces(), localPoints());
// Construct/apply AMI interpolation to determine addressing and weights
AMIPtr_ = new AMIPatchToPatchInterpolation
(
*this,
nbrPatch0,
surfPtr_()
);
vectorField nbrPatchNf
(
nbrPatch().faceAreas()/mag(nbrPatch().faceAreas())
);
nbrPatchDelta_ =
nbrPatch0.faceCentres() - nbrPatch().faceCellCentres();
nbrPatchDelta_ = nbrPatchNf*(nbrPatchNf & nbrPatchDelta_);
}
return *AMIPtr_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::cyclicAMIPolyPatch::initGeometry(PstreamBuffers& pBufs)
{
polyPatch::initGeometry(pBufs);
}
void Foam::cyclicAMIPolyPatch::calcGeometry(PstreamBuffers& pBufs)
{
calcGeometry
(
*this,
faceCentres(),
faceAreas(),
faceCellCentres(),
nbrPatch().faceCentres(),
nbrPatch().faceAreas(),
nbrPatch().faceCellCentres()
);
}
void Foam::cyclicAMIPolyPatch::initMovePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{
polyPatch::initMovePoints(pBufs, p);
}
void Foam::cyclicAMIPolyPatch::movePoints
(
PstreamBuffers& pBufs,
const pointField& p
)
{
polyPatch::movePoints(pBufs, p);
calcTransforms();
deleteDemandDrivenData(AMIPtr_);
AMI();
}
void Foam::cyclicAMIPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
{
polyPatch::initUpdateMesh(pBufs);
}
void Foam::cyclicAMIPolyPatch::updateMesh(PstreamBuffers& pBufs)
{
polyPatch::updateMesh(pBufs);
deleteDemandDrivenData(AMIPtr_);
// deleteDemandDrivenData(surfPtr_);
}
// * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * //
Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const polyBoundaryMesh& bm
)
:
coupledPolyPatch(name, size, start, index, bm),
nbrPatchName_(word::null),
nbrPatchID_(-1),
transform_(UNKNOWN),
rotationAxis_(vector::zero),
rotationCentre_(point::zero),
separationVector_(vector::zero),
AMIPtr_(NULL),
surfPtr_(NULL)
{
// Neighbour patch might not be valid yet so no transformation
// calculation possible
}
Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
(
const word& name,
const dictionary& dict,
const label index,
const polyBoundaryMesh& bm
)
:
coupledPolyPatch(name, dict, index, bm),
nbrPatchName_(dict.lookup("neighbourPatch")),
nbrPatchID_(-1),
transform_(UNKNOWN),
rotationAxis_(vector::zero),
rotationCentre_(point::zero),
separationVector_(vector::zero),
AMIPtr_(NULL),
surfPtr_
(
searchableSurface::New
(
dict.lookup("projectionSurfaceType"),
IOobject
(
dict.lookup("projectionSurfaceName"),
bm.mesh().time().constant(),
"triSurface",
bm.mesh(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
dict
)
)
{
if (nbrPatchName_ == name)
{
FatalIOErrorIn
(
"cyclicAMIPolyPatch::cyclicAMIPolyPatch"
"("
"const word&, "
"const dictionary&, "
"const label, "
"const polyBoundaryMesh&"
")",
dict
) << "Neighbour patch name " << nbrPatchName_
<< " cannot be the same as this patch " << name
<< exit(FatalIOError);
}
if (dict.found("transform"))
{
transform_ = transformTypeNames.read(dict.lookup("transform"));
switch (transform_)
{
case ROTATIONAL:
{
dict.lookup("rotationAxis") >> rotationAxis_;
dict.lookup("rotationCentre") >> rotationCentre_;
scalar magRot = mag(rotationAxis_);
if (magRot < SMALL)
{
FatalIOErrorIn
(
"cyclicAMIPolyPatch::cyclicAMIPolyPatch"
"("
"const word&, "
"const dictionary&, "
"const label, "
"const polyBoundaryMesh&"
")",
dict
) << "Illegal rotationAxis " << rotationAxis_ << endl
<< "Please supply a non-zero vector."
<< exit(FatalIOError);
}
rotationAxis_ /= magRot;
break;
}
case TRANSLATIONAL:
{
dict.lookup("separationVector") >> separationVector_;
break;
}
default:
{
// no additional info required
}
}
}
// Neighbour patch might not be valid yet so no transformation
// calculation possible
}
Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
(
const cyclicAMIPolyPatch& pp,
const polyBoundaryMesh& bm
)
:
coupledPolyPatch(pp, bm),
nbrPatchName_(pp.nbrPatchName_),
nbrPatchID_(-1),
transform_(UNKNOWN),
rotationAxis_(vector::zero),
rotationCentre_(point::zero),
separationVector_(vector::zero),
AMIPtr_(NULL),
surfPtr_(NULL)
{
// Neighbour patch might not be valid yet so no transformation
// calculation possible
}
Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
(
const cyclicAMIPolyPatch& pp,
const polyBoundaryMesh& bm,
const label index,
const label newSize,
const label newStart,
const word& nbrPatchName
)
:
coupledPolyPatch(pp, bm, index, newSize, newStart),
nbrPatchName_(nbrPatchName),
nbrPatchID_(-1),
transform_(UNKNOWN),
rotationAxis_(vector::zero),
rotationCentre_(point::zero),
separationVector_(vector::zero),
AMIPtr_(NULL),
surfPtr_(NULL)
{
if (nbrPatchName_ == name())
{
FatalErrorIn
(
"const cyclicAMIPolyPatch& "
"const polyBoundaryMesh&, "
"const label, "
"const label, "
"const label, "
"const word&"
) << "Neighbour patch name " << nbrPatchName_
<< " cannot be the same as this patch " << name()
<< exit(FatalError);
}
// Neighbour patch might not be valid yet so no transformation
// calculation possible
}
Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
(
const cyclicAMIPolyPatch& pp,
const polyBoundaryMesh& bm,
const label index,
const labelUList& mapAddressing,
const label newStart
)
:
coupledPolyPatch(pp, bm, index, mapAddressing, newStart),
nbrPatchName_(pp.nbrPatchName_),
nbrPatchID_(-1),
transform_(pp.transform_),
rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_),
AMIPtr_(NULL),
surfPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cyclicAMIPolyPatch::~cyclicAMIPolyPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::cyclicAMIPolyPatch::nbrPatchID() const
{
if (nbrPatchID_ == -1)
{
nbrPatchID_ = this->boundaryMesh().findPatchID(nbrPatchName_);
if (nbrPatchID_ == -1)
{
FatalErrorIn("cyclicPolyAMIPatch::nbrPatchID() const")
<< "Illegal neighbourPatch name " << nbrPatchName_
<< nl << "Valid patch names are "
<< this->boundaryMesh().names()
<< exit(FatalError);
}
// Check that it is a cyclic AMI patch
const cyclicAMIPolyPatch& nbrPatch =
refCast<const cyclicAMIPolyPatch>
(
this->boundaryMesh()[nbrPatchID_]
);
if (nbrPatch.nbrPatchName() != name())
{
WarningIn("cyclicAMIPolyPatch::nbrPatchID() const")
<< "Patch " << name()
<< " specifies neighbour patch " << nbrPatchName()
<< nl << " but that in return specifies "
<< nbrPatch.nbrPatchName() << endl;
}
}
return nbrPatchID_;
}
void Foam::cyclicAMIPolyPatch::transformPosition(pointField& l) const
{
if (!parallel())
{
if (transform_ == ROTATIONAL)
{
l = Foam::transform(forwardT(), l - rotationCentre_)
+ rotationCentre_;
}
else
{
l = Foam::transform(forwardT(), l);
}
}
else if (separated())
{
// transformPosition gets called on the receiving side,
// separation gets calculated on the sending side so subtract
const vectorField& s = separation();
if (s.size() == 1)
{
forAll(l, i)
{
l[i] -= s[0];
}
}
else
{
l -= s;
}
}
}
void Foam::cyclicAMIPolyPatch::transformPosition
(
point& l,
const label faceI
) const
{
if (!parallel())
{
const tensor& T =
(
forwardT().size() == 1
? forwardT()[0]
: forwardT()[faceI]
);
if (transform_ == ROTATIONAL)
{
l = Foam::transform(T, l - rotationCentre_) + rotationCentre_;
}
else
{
l = Foam::transform(T, l);
}
}
else if (separated())
{
const vector& s =
(
separation().size() == 1
? separation()[0]
: separation()[faceI]
);
l -= s;
}
}
void Foam::cyclicAMIPolyPatch::calcGeometry
(
const primitivePatch& referPatch,
const pointField& thisCtrs,
const vectorField& thisAreas,
const pointField& thisCc,
const pointField& nbrCtrs,
const vectorField& nbrAreas,
const pointField& nbrCc
)
{
calcTransforms
(
referPatch,
thisCtrs,
thisAreas,
nbrCtrs,
nbrAreas
);
deleteDemandDrivenData(AMIPtr_);
AMI();
}
void Foam::cyclicAMIPolyPatch::initOrder
(
PstreamBuffers& pBufs,
const primitivePatch& pp
) const
{}
bool Foam::cyclicAMIPolyPatch::order
(
PstreamBuffers& pBufs,
const primitivePatch& pp,
labelList& faceMap,
labelList& rotation
) const
{
faceMap.setSize(pp.size());
faceMap = -1;
rotation.setSize(pp.size());
rotation = 0;
// do nothing
return false;
}
void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
{
coupledPolyPatch::write(os);
}
// ************************************************************************* //

View File

@ -0,0 +1,382 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cyclicAMIPolyPatch
Description
Cyclic patch for Arbitrary Mesh Interface (AMI)
SourceFiles
cyclicAMIPolyPatch.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIPolyPatch_H
#define cyclicAMIPolyPatch_H
#include "coupledPolyPatch.H"
#include "AMIPatchToPatchInterpolation.H"
#include "polyBoundaryMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicAMIPolyPatch Declaration
\*---------------------------------------------------------------------------*/
class cyclicAMIPolyPatch
:
public coupledPolyPatch
{
private:
// Private data
//- Name of other half
const word nbrPatchName_;
//- Index of other half
mutable label nbrPatchID_;
//- Neighbour delta field to *this patch
vectorField nbrPatchDelta_;
// Transformations
//- Type of transformation - rotational or translational
transformType transform_;
// For rotation
//- Axis of rotation for rotational cyclics
vector rotationAxis_;
//- point on axis of rotation for rotational cyclics
point rotationCentre_;
// For translation
//- Translation vector
vector separationVector_;
//- AMI interpolation class
AMIPatchToPatchInterpolation* AMIPtr_;
//- Projection surface
autoPtr<searchableSurface> surfPtr_;
// Private Member Functions
//- Return face ID of face at max distance from rotation axis
label findFaceMaxRadius(const pointField& faceCentres) const;
void calcTransforms
(
const primitivePatch& half0,
const pointField& half0Ctrs,
const vectorField& half0Areas,
const pointField& half1Ctrs,
const vectorField& half1Areas
);
protected:
// Protected Member Functions
//- Recalculate the transformation tensors
virtual void calcTransforms();
//- Initialise the calculation of the patch geometry
virtual void initGeometry(PstreamBuffers&);
//- Calculate the patch geometry
virtual void calcGeometry(PstreamBuffers&);
//- Initialise the patches for moving points
virtual void initMovePoints(PstreamBuffers& pBufs, const pointField&);
//- Correct patches after moving points
virtual void movePoints(PstreamBuffers& pBufs, const pointField&);
//- Initialise the update of the patch topology
virtual void initUpdateMesh(PstreamBuffers&);
//- Update of the patch topology
virtual void updateMesh(PstreamBuffers&);
public:
// //- Declare friendship with processorCyclicPolyPatch
// friend class processorCyclicPolyPatch;
//- Runtime type information
TypeName("cyclicAMI");
// Constructors
//- Construct from (base couped patch) components
cyclicAMIPolyPatch
(
const word& name,
const label size,
const label start,
const label index,
const polyBoundaryMesh& bm
);
//- Construct from dictionary
cyclicAMIPolyPatch
(
const word& name,
const dictionary& dict,
const label index,
const polyBoundaryMesh& bm
);
//- Construct as copy, resetting the boundary mesh
cyclicAMIPolyPatch(const cyclicAMIPolyPatch&, const polyBoundaryMesh&);
//- Construct given the original patch and resetting the
// face list and boundary mesh information
cyclicAMIPolyPatch
(
const cyclicAMIPolyPatch& pp,
const polyBoundaryMesh& bm,
const label index,
const label newSize,
const label newStart,
const word& nbrPatchName
);
//- Construct given the original patch and a map
cyclicAMIPolyPatch
(
const cyclicAMIPolyPatch& pp,
const polyBoundaryMesh& bm,
const label index,
const labelUList& mapAddressing,
const label newStart
);
//- Construct and return a clone, resetting the boundary mesh
virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
{
return autoPtr<polyPatch>(new cyclicAMIPolyPatch(*this, bm));
}
//- Construct and return a clone, resetting the face list
// and boundary mesh
virtual autoPtr<polyPatch> clone
(
const polyBoundaryMesh& bm,
const label index,
const label newSize,
const label newStart
) const
{
return autoPtr<polyPatch>
(
new cyclicAMIPolyPatch
(
*this,
bm,
index,
newSize,
newStart,
nbrPatchName_
)
);
}
//- Construct and return a clone, resetting the face list
// and boundary mesh
virtual autoPtr<polyPatch> clone
(
const polyBoundaryMesh& bm,
const label index,
const labelUList& mapAddressing,
const label newStart
) const
{
return autoPtr<polyPatch>
(
new cyclicAMIPolyPatch
(
*this,
bm,
index,
mapAddressing,
newStart
)
);
}
//- Destructor
virtual ~cyclicAMIPolyPatch();
// Member Functions
// Access
//- Neighbour patch name
const word& nbrPatchName() const
{
return nbrPatchName_;
}
//- Neighbour patch ID
virtual label nbrPatchID() const;
//- Does this side own the patch ?
virtual bool owner() const
{
return index() < nbrPatchID();
}
const cyclicAMIPolyPatch& nbrPatch() const
{
const polyPatch& pp = this->boundaryMesh()[nbrPatchID()];
return refCast<const cyclicAMIPolyPatch>(pp);
}
const vectorField& nbrPatchDelta() const
{
return nbrPatchDelta_;
}
const AMIPatchToPatchInterpolation& AMI();
// Transformations
//- Type of transform
transformType transform() const
{
return transform_;
}
//- Axis of rotation for rotational cyclic AMI
const vector& rotationAxis() const
{
return rotationAxis_;
}
//- point on axis of rotation for rotational cyclic AMI
const point& rotationCentre() const
{
return rotationCentre_;
}
//- Translation vector for translational cyclic AMI
const vector& separationVector() const
{
return separationVector_;
}
//- Transform patch-based positions from nbr side to this side
virtual void transformPosition(pointField&) const;
//- Transform a patch-based position from nbr side to this side
virtual void transformPosition
(
point& l,
const label faceI
) const;
template<class Type>
tmp<Field<Type> > interpolateToSource(const Field<Type>& fld) const
{
return AMIPtr_->interpolateToSource(fld);
}
template<class Type>
tmp<Field<Type> > interpolateToSource(const tmp<Field<Type> >& tFld) const
{
return AMIPtr_->interpolateToSource(tFld);
}
//- Calculate the patch geometry
virtual void calcGeometry
(
const primitivePatch& referPatch,
const pointField& thisCtrs,
const vectorField& thisAreas,
const pointField& thisCc,
const pointField& nbrCtrs,
const vectorField& nbrAreas,
const pointField& nbrCc
);
//- Initialize ordering for primitivePatch. Does not
// refer to *this (except for name() and type() etc.)
virtual void initOrder
(
PstreamBuffers&,
const primitivePatch&
) const;
//- Return new ordering for primitivePatch.
// Ordering is -faceMap: for every face
// index of the new face -rotation:for every new face the clockwise
// shift of the original face. Return false if nothing changes
// (faceMap is identity, rotation is 0), true otherwise.
virtual bool order
(
PstreamBuffers&,
const primitivePatch&,
labelList& faceMap,
labelList& rotation
) const;
//- Write the polyPatch data as a dictionary
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //