ENH: patchCloud: return pTraits<Type>::max for unfound points
[OpenFOAM-1.7.x.git] / applications / test / UIndirectListTest / UIndirectListTest.C
blobb9063d587edfd5b5232d21d7869527b98d0754e4
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "UIndirectList.H"
29 #include "DynamicList.H"
30 #include "IOstreams.H"
31 #include "ListOps.H"
32 #include "OFstream.H"
34 using namespace Foam;
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // Main program:
39 int main(int argc, char *argv[])
41     List<double> completeList(10);
43     forAll(completeList, i)
44     {
45         completeList[i] = 0.1*i;
46     }
48     List<label> addresses(5);
49     addresses[0] = 1;
50     addresses[1] = 0;
51     addresses[2] = 7;
52     addresses[3] = 8;
53     addresses[4] = 5;
55     UIndirectList<double> idl(completeList, addresses);
57     Info<< idl << "\n";
59     idl[1] = -666;
61     Info<< "idl[1] changed: " << idl << endl;
63     idl = -999;
65     Info<< "idl changed: " << idl << endl;
67     UIndirectList<double> idl2(idl);
69     Info<< "idl2: " << idl2 << endl;
72     {
73         List<double> ident(idl.size());
75         forAll(ident, i)
76         {
77             ident[i] = ident.size() - i;
78         }
79         idl = ident;
80     }
82     Info<< "idl assigned from UList: " << idl << endl;
84     // test List operations
86     List<double> flatList = UIndirectList<double>(completeList, addresses);
87     Info<< "List assigned from UIndirectList: " << flatList << endl;
89     List<double> flatList2(UIndirectList<double>(completeList, addresses));
90     Info<< "List constructed from UIndirectList: " << flatList2 << endl;
92     flatList.append(UIndirectList<double>(completeList, addresses));
93     Info<< "List::append(UIndirectList): " << flatList << endl;
96     DynamicList<double> dynList(UIndirectList<double>(completeList, addresses));
97     Info<< "DynamicList constructed from UIndirectList: " << dynList << endl;
99     dynList.append(UIndirectList<double>(completeList, addresses));
100     Info<< "DynamicList::append(UIndirectList): " << dynList << endl;
102     Info << "\nEnd\n" << endl;
104     return 0;
108 // ************************************************************************* //