Bugfix: Finite Area bugfixes + WedgePointPatchField bugfix. Vanja Skuric

This commit is contained in:
Hrvoje Jasak 2017-09-21 14:09:46 +01:00
commit 3b612e6748
5 changed files with 253 additions and 233 deletions

View file

@ -422,12 +422,13 @@ void faMatrix<Type>::setValues
}
else
{
label patchi = mesh.boundary().whichPatch(edgei);
const label& curEdgeIndex = mesh.edgeIndex()[edgei];
label patchi = mesh.boundary().whichPatch(curEdgeIndex);
if (internalCoeffs_[patchi].size())
{
label patchEdgei =
mesh.boundary()[patchi].whichEdge(edgei);
mesh.boundary()[patchi].whichEdge(curEdgeIndex);
internalCoeffs_[patchi][patchEdgei] =
pTraits<Type>::zero;

View file

@ -71,6 +71,7 @@ void Foam::faMesh::setPrimitiveMeshData()
// Set faMesh edges
edges_.setSize(bp.nEdges());
edgeIndex_.setSize(bp.nEdges());
label edgeI = -1;
@ -80,6 +81,7 @@ void Foam::faMesh::setPrimitiveMeshData()
for (label curEdge = 0; curEdge < nIntEdges; curEdge++)
{
edges_[++edgeI] = bp.edges()[curEdge];
edgeIndex_[curEdge] = edgeI;
}
forAll (boundary(), patchI)
@ -89,6 +91,7 @@ void Foam::faMesh::setPrimitiveMeshData()
forAll (curP, eI)
{
edges_[++edgeI] = bp.edges()[curP[eI]];
edgeIndex_[curP[eI]] = edgeI;
}
}

View file

@ -82,6 +82,9 @@ class faMesh
//- Boundary mesh
faBoundaryMesh boundary_;
//- Edge index
labelList edgeIndex_;
// Primitive mesh data
@ -397,6 +400,11 @@ public:
return faceLabels_;
}
//- Return faMesh edge indices
const labelList& edgeIndex() const
{
return edgeIndex_;
}
//- Return parallel info
const faGlobalMeshData& globalData() const;

View file

@ -1185,7 +1185,11 @@ void faMesh::calcPointAreaNormals() const
// Processor patch points correction
forAll (boundary(), patchI)
{
if(boundary()[patchI].type() == processorFaPatch::typeName)
if
(
Pstream::parRun()
&& boundary()[patchI].type() == processorFaPatch::typeName
)
{
const processorFaPatch& procPatch =
refCast<const processorFaPatch>(boundary()[patchI]);

View file

@ -1,230 +1,234 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "WedgePointPatchField.H"
#include "transformField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const PointPatch& p,
const DimensionedField<Type, Mesh>& iF
)
:
PatchField<Type>(p, iF)
{}
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const PointPatch& p,
const DimensionedField<Type, Mesh>& iF,
const dictionary& dict
)
:
PatchField<Type>(p, iF)
{
if (!isType<WedgePointPatch>(p))
{
FatalIOErrorIn
(
"WedgePointPatchField"
"<PatchField, Mesh, PointPatch, WedgePointPatch, "
"MatrixType, Type>::WedgePointPatchField\n"
"(\n"
" const PointPatch& p,\n"
" const DimensionedField<Type, Mesh>& field,\n"
" const dictionary& dict\n"
")\n",
dict
) << "patch " << this->patch().index() << " not wedge type. "
<< "Patch type = " << p.type()
<< exit(FatalIOError);
}
}
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>&,
const PointPatch& p,
const DimensionedField<Type, Mesh>& iF,
const PointPatchFieldMapper&
)
:
PatchField<Type>(p, iF)
{
if (!isType<WedgePointPatch>(this->patch()))
{
FatalErrorIn
(
"WedgePointPatchField"
"<PatchField, Mesh, PointPatch, WedgePointPatch, "
"MatrixType, Type>::WedgePointPatchField\n"
"(\n"
" const WedgePointPatchField"
" <PatchField, Mesh, PointPatch, WedgePointPatch, "
"MatrixType, Type>&,\n"
" const PointPatch& p,\n"
" const DimensionedField<Type, Mesh>& iF,\n"
" const PointPatchFieldMapper& mapper\n"
")\n"
) << "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
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>& ptf
)
:
PatchField<Type>(ptf)
{}
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>& ptf,
const DimensionedField<Type, Mesh>& iF
)
:
PatchField<Type>(ptf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Evaluate patch field
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
void
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::evaluate
(
const Pstream::commsTypes commsType
)
{
// In order to ensure that the wedge patch is always flat, take the
// normal vector from the first point
const vector& nHat = this->patch().pointNormals()[0];
tmp<Field<Type> > tvalues =
transform(I - nHat*nHat, this->patchInternalField());
const Field<Type>& values = tvalues();
// Get internal field to insert values into
Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
// Get addressing
const labelList& meshPoints = this->patch().meshPoints();
forAll (meshPoints, pointI)
{
iF[meshPoints[pointI]] = values[pointI];
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "WedgePointPatchField.H"
#include "transformField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const PointPatch& p,
const DimensionedField<Type, Mesh>& iF
)
:
PatchField<Type>(p, iF)
{}
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const PointPatch& p,
const DimensionedField<Type, Mesh>& iF,
const dictionary& dict
)
:
PatchField<Type>(p, iF)
{
if (!isType<WedgePointPatch>(p))
{
FatalIOErrorIn
(
"WedgePointPatchField"
"<PatchField, Mesh, PointPatch, WedgePointPatch, "
"MatrixType, Type>::WedgePointPatchField\n"
"(\n"
" const PointPatch& p,\n"
" const DimensionedField<Type, Mesh>& field,\n"
" const dictionary& dict\n"
")\n",
dict
) << "patch " << this->patch().index() << " not wedge type. "
<< "Patch type = " << p.type()
<< exit(FatalIOError);
}
}
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>&,
const PointPatch& p,
const DimensionedField<Type, Mesh>& iF,
const PointPatchFieldMapper&
)
:
PatchField<Type>(p, iF)
{
if (!isType<WedgePointPatch>(this->patch()))
{
FatalErrorIn
(
"WedgePointPatchField"
"<PatchField, Mesh, PointPatch, WedgePointPatch, "
"MatrixType, Type>::WedgePointPatchField\n"
"(\n"
" const WedgePointPatchField"
" <PatchField, Mesh, PointPatch, WedgePointPatch, "
"MatrixType, Type>&,\n"
" const PointPatch& p,\n"
" const DimensionedField<Type, Mesh>& iF,\n"
" const PointPatchFieldMapper& mapper\n"
")\n"
) << "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
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>& ptf
)
:
PatchField<Type>(ptf)
{}
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::
WedgePointPatchField
(
const WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>& ptf,
const DimensionedField<Type, Mesh>& iF
)
:
PatchField<Type>(ptf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Evaluate patch field
template
<
template<class> class PatchField,
class Mesh,
class PointPatch,
class WedgePointPatch,
template<class> class MatrixType,
class Type
>
void
WedgePointPatchField
<PatchField, Mesh, PointPatch, WedgePointPatch, MatrixType, Type>::evaluate
(
const Pstream::commsTypes commsType
)
{
// ZT, 26/02/2017: Size of the patch could be zero in parallel runs
if (this->patch().meshPoints().size())
{
// In order to ensure that the wedge patch is always flat, take the
// normal vector from the first point
const vector& nHat = this->patch().pointNormals()[0];
tmp<Field<Type> > tvalues =
transform(I - nHat*nHat, this->patchInternalField());
const Field<Type>& values = tvalues();
// Get internal field to insert values into
Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
// Get addressing
const labelList& meshPoints = this->patch().meshPoints();
forAll (meshPoints, pointI)
{
iF[meshPoints[pointI]] = values[pointI];
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //