openfoam/applications/test/xfer/xferListTest.C
Mark Olesen 41bbcb6337 DynamicList changes.
- setSize() adjusts the addressable length only.
  Changed setSize(label) usage to setCapacity(label) or reserve(label)
  throughout. The final name (capacity vs. storageSize() vs. whatever) can
  easily be decided at a later date.
- added setSize(label, const T&), which may still not be really useful, but
  is at least now meaningful
- made shrink() a bit more legible.
- added append(UList<T>&)
- copying from a UList avoids reallocations where possible

The following bits of code continue to use the DynamicList::setSize(), but
appear to be legitimate (or the corresponding code itself needs rethinking).

  src/OpenFOAM/meshes/primitiveMesh/primitiveMeshPointCells.C:167: error: within this context
  src/OpenFOAM/lnInclude/faceTemplates.C:44: error: within this context
  src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C:178: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:737: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:741: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:745: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:749: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:754: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:935: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:940: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:1041: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:1046: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2161: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2162: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2201: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2205: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2261: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2262: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2263: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2264: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:2265: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:3011: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:3076: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:3244: error: within this context
  src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C:3371: error: within this context
  src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C:73: error: within this context
  src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C:91: error: within this context
  src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C:73: error: within this context
  src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C:91: error: within this context
2008-11-24 17:22:37 +01:00

125 lines
3.4 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "labelList.H"
#include "DynamicList.H"
#include "face.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
List<label> lstA(10);
List<label> lstC(IStringStream("(1 2 3 4)")());
forAll(lstA, i)
{
lstA[i] = i;
}
Info<< "lstA: " << lstA << endl;
Info<< "lstC: " << lstC << endl;
xfer<List<label> > xA = xferMove(lstA);
xfer<List<label> > xB;
List<label> lstB( xA );
Info<< "xA: " << xA() << endl;
Info<< "xB: " << xB() << endl;
Info<< "lstA: " << lstA << endl;
Info<< "lstB: " << lstB << endl;
Info<< "lstC: " << lstC << endl;
xA = lstB;
Info<< "xA: " << xA() << endl;
Info<< "xB: " << xB() << endl;
Info<< "lstA: " << lstA << endl;
Info<< "lstB: " << lstB << endl;
Info<< "lstC: " << lstC << endl;
xB = xA;
List<label> lstD(xferCopy(lstC));
List<label> lstE(xferMove(lstC));
// this must be empty
List<label> lstF = xferCopy(lstC);
Info<< "xA: " << xA() << endl;
Info<< "xB: " << xB() << endl;
Info<< "lstA: " << lstA << endl;
Info<< "lstB: " << lstB << endl;
Info<< "lstC: " << lstC << endl;
Info<< "lstD: " << lstD << endl;
Info<< "lstE: " << lstE << endl;
Info<< "lstF: " << lstF << endl;
Info<< "xB[" << xB->size() << "]\n";
// clear the underlying List
xB->clear();
Info<< "xB[" << xB->size() << "]\n";
DynamicList<label> dl(10);
for (label i = 0; i < 5; i++)
{
dl.append(i);
}
face f1(dl);
face f2(xferCopy<labelList>(dl));
Info<< "dl[" << dl.size() << "/" << dl.capacity() << "] " << dl << endl;
Info<< "f1: " << f1 << endl;
Info<< "f2: " << f2 << endl;
// note: using xferMoveTo to ensure the correct transfer() method is called
face f3( xferMoveTo<labelList>(dl) );
Info<< "dl[" << dl.size() << "/" << dl.capacity() << "] " << dl << endl;
Info<< "f3: " << f3 << endl;
return 0;
}
// ************************************************************************* //