mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Field construct from Xfer<Field> fails (issued #298)
- Cannot pass through to underlying list constructor directly.
- As this constructor was broken, there seem to be a number of
workarounds scattered in the code. Could revisit them in the future
as part of code-style:
edgeMesh(const Xfer<pointField>&, const Xfer<edgeList>&);
CompactIOField(const IOobject&, const Xfer<Field<T>>&);
GlobalIOField(const IOobject&, const Xfer<Field<Type>>&);
IOField(const IOobject&, const Xfer<Field<Type>>&);
This commit is contained in:
@ -34,6 +34,8 @@ Description
|
||||
#include "labelList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "face.H"
|
||||
#include "pointField.H"
|
||||
#include "DynamicField.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -45,7 +47,10 @@ using namespace Foam;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
List<label> lstA(10);
|
||||
List<label> lstC(IStringStream("(1 2 3 4)")());
|
||||
List<label> lstC
|
||||
{
|
||||
1, 2, 3, 4
|
||||
};
|
||||
|
||||
forAll(lstA, i)
|
||||
{
|
||||
@ -128,6 +133,57 @@ int main(int argc, char *argv[])
|
||||
Info<< "f1: " << f1 << endl;
|
||||
Info<< "f3: " << f3 << endl;
|
||||
|
||||
|
||||
{
|
||||
Info<<"\nTest xfer with fields:" << endl;
|
||||
List<point> list1
|
||||
{
|
||||
{ 0, 1, 2 },
|
||||
{ 3, 4, 5 },
|
||||
{ 6, 7, 8 },
|
||||
{ 9, 10, 11 },
|
||||
};
|
||||
|
||||
// Field from Xfer<List>
|
||||
pointField field1(list1.xfer());
|
||||
Info<<nl
|
||||
<< "xfer construct from List" << nl
|
||||
<<"input (list) = " << list1 << nl
|
||||
<<"output (field) = " << field1 << nl;
|
||||
|
||||
|
||||
// Field from Xfer<List> ... again
|
||||
pointField field2(field1.xfer());
|
||||
Info<<nl
|
||||
<<"xfer construct from Field (as List): " << nl
|
||||
<<"input (field) = " << field1 << nl
|
||||
<<"output (field) = " << field2 << nl;
|
||||
|
||||
|
||||
// Field from Xfer<Field>
|
||||
pointField field3(xferMove(field2));
|
||||
Info<<nl
|
||||
<<"xfer construct from Field (as Field): " << nl
|
||||
<<"input (field) = " << field2 << nl
|
||||
<<"output (field) = " << field3 << nl;
|
||||
|
||||
|
||||
// Field from Xfer<Field> .. again
|
||||
pointField field4(xferCopy(field3));
|
||||
Info<<nl
|
||||
<<"xfer copy construct from Field (as Field): " << nl
|
||||
<<"input (field) = " << field3 << nl
|
||||
<<"output (field) = " << field4 << nl;
|
||||
|
||||
|
||||
DynamicField<point> dyfield1(xferCopy(field4));
|
||||
Info<<nl
|
||||
<<"xfer copy construct from Field (as Field): " << nl
|
||||
<<"input (field) = " << field4 << nl
|
||||
<<"output (dyn-field) = " << dyfield1 << nl;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -114,6 +114,9 @@ public:
|
||||
//- Construct by transferring the parameter contents
|
||||
explicit inline DynamicField(const Xfer<List<T>>&);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
explicit inline DynamicField(const Xfer<Field<T>>&);
|
||||
|
||||
//- Construct by 1 to 1 mapping from the given field
|
||||
inline DynamicField
|
||||
(
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -69,6 +69,17 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||
{}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||
(
|
||||
const Xfer<Field<T>>& lst
|
||||
)
|
||||
:
|
||||
Field<T>(lst),
|
||||
capacity_(Field<T>::size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||
(
|
||||
|
||||
@ -233,8 +233,10 @@ Foam::Field<Type>::Field(const Xfer<List<Type>>& f)
|
||||
template<class Type>
|
||||
Foam::Field<Type>::Field(const Xfer<Field<Type>>& f)
|
||||
:
|
||||
List<Type>(f)
|
||||
{}
|
||||
List<Type>()
|
||||
{
|
||||
List<Type>::transfer(f());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
|
||||
Reference in New Issue
Block a user