Commit 4ee5d991 authored by andy's avatar andy
Browse files

ENH: Initial commit of arbitrary mesh interface boundary handling

parent 81d380dd
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
EXE_INC = \
-DFULLDEBUG -g -O0 \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |