Skip to content
Snippets Groups Projects
Commit 864271b1 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BUG: generic point patch fails (fixes #2062)

- the generic constructor could be called twice in pointPatchField::New,
  which results in an attempt to transfer tokens twice.
parent 5790fbe2
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -26,7 +26,7 @@ License ...@@ -26,7 +26,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
...@@ -55,20 +55,22 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New ...@@ -55,20 +55,22 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
if if
( (
actualPatchType == word::null actualPatchType.empty()
|| actualPatchType != p.type() || actualPatchType != p.type()
) )
{ {
if (pfPtr().constraintType() != p.constraintType()) if (pfPtr().constraintType() != p.constraintType())
{ {
// Use default constraint type // Incompatible (constraint-wise) with the patch type
// - use default constraint type
auto patchTypeCstrIter = auto patchTypeCstrIter =
pointPatchConstructorTablePtr_->cfind(p.type()); pointPatchConstructorTablePtr_->cfind(p.type());
if (!patchTypeCstrIter.found()) if (!patchTypeCstrIter.found())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "inconsistent patch and patchField types for \n" << "Inconsistent patch and patchField types for\n"
<< " patch type " << p.type() << " patch type " << p.type()
<< " and patchField type " << patchFieldType << " and patchField type " << patchFieldType
<< exit(FatalError); << exit(FatalError);
...@@ -138,20 +140,17 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New ...@@ -138,20 +140,17 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
if if
( (
!dict.found("patchType") !dict.found("patchType")
|| dict.get<word>("patchType") != p.type() || dict.get<word>("patchType") != p.type()
) )
{ {
if (pfPtr().constraintType() == p.constraintType()) if (pfPtr().constraintType() != p.constraintType())
{
// Compatible (constraint-wise) with the patch type
return pfPtr;
}
else
{ {
// Use default constraint type // Incompatible (constraint-wise) with the patch type
auto patchTypeCstrIter // - use default constraint type
= dictionaryConstructorTablePtr_->cfind(p.type());
auto patchTypeCstrIter =
dictionaryConstructorTablePtr_->cfind(p.type());
if (!patchTypeCstrIter.found()) if (!patchTypeCstrIter.found())
{ {
...@@ -166,7 +165,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New ...@@ -166,7 +165,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
} }
} }
return cstrIter()(p, iF, dict); return pfPtr;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment