File: Test-ListOps.C

package info (click to toggle)
openfoam 4.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 163,028 kB
  • ctags: 58,990
  • sloc: cpp: 830,760; sh: 10,227; ansic: 8,215; xml: 745; lex: 437; awk: 194; sed: 91; makefile: 77; python: 18
file content (120 lines) | stat: -rw-r--r-- 4,136 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2012-2013 OpenFOAM Foundation
     \\/     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 3 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, see <http://www.gnu.org/licenses/>.

Application
    Test-ListOps

Description

\*---------------------------------------------------------------------------*/

#include "argList.H"
#include "List.H"
#include "SubList.H"
#include "ListOps.H"
#include "face.H"

using namespace Foam;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

int main(int argc, char *argv[])
{
    Info<< "Test Rotations:" << nl << endl;

    List<label> forwardRotate(identity(5));
    face testFace(identity(4));

    for (label i = 0; i < 8; ++i)
    {
        Info<< "Rotate forward by " << i << " : "
            << rotateList(forwardRotate, i) << endl;
    }

    for (label i = 0; i < 8; ++i)
    {
        Info<< "Rotate backward by " << i << " : "
            << rotateList(forwardRotate, -i) << endl;
    }

    Info<< nl << "Face                 : " << testFace << endl;
    Info<< "Rotate by 2          : " << rotateList(testFace, 2) << endl;
    inplaceRotateList<List, label>(testFace, -6);
    Info<< "Rotate inplace by -6 : " << testFace << nl << endl;

    Info<< "Test inplace rotate      : " << forwardRotate << endl;
    inplaceRotateList(forwardRotate, 2);
    Info<< "Rotate to the right by 2 : " << forwardRotate << endl;
    inplaceRotateList(forwardRotate, -2);
    Info<< "Rotate to the left by 2  : " << forwardRotate << endl;

    List<label> subRotate(identity(10));
    SubList<label> subL(subRotate, 5, 3);

    Info<< "Test inplace rotate on sublist : " << subRotate << endl;
    inplaceRotateList(subL, 3);
    Info<< "Rotate to the right by 3       : " << subRotate << endl;
    inplaceRotateList(subL, -8);
    Info<< "Rotate to the left by 3        : " << subRotate << endl;

    Info<< nl << nl << "Test Reversing:" << nl << endl;

    Info<< "List    : " << identity(5) << endl;
    Info<< "Reverse : " << reverseList(identity(5)) << endl;
    Info<< "List    : " << identity(6) << endl;
    Info<< "Reverse : " << reverseList(identity(6)) << nl << endl;

    List<label> test1(identity(5));
    Info<< "List            : " << test1 << endl;
    inplaceReverseList(test1);
    Info<< "Inplace Reverse : " << test1 << nl << endl;

    List<label> test2(identity(6));
    Info<< "List            : " << test2 << endl;
    inplaceReverseList(test2);
    Info<< "Inplace Reverse : " << test2 << nl << endl;

    face test3(identity(6));
    Info<< "Face            : " << test3 << endl;
    inplaceReverseList(test3);
    Info<< "Inplace Reverse : " << test3 << nl << endl;

    FixedList<label, 6> test4(identity(6));
    Info<< "FixedList       : " << test4 << endl;
    inplaceReverseList(test4);
    Info<< "Inplace Reverse : " << test4 << nl << endl;

    List<label> test5(identity(9));
    SubList<label> test5SubList(test5, 4, 3);
    Info<< "List                            : " << test5 << endl;
    inplaceReverseList(test5SubList);
    Info<< "Reverse Sublist between 3 and 6 : " << test5 << endl;

    Info<< "\nEnd\n" << endl;

    return 0;
}


// ************************************************************************* //