]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCK/test_hexa5.cxx
Salome HOME
Undef max Visual Studio definition.
[modules/hexablock.git] / src / HEXABLOCK / test_hexa5.cxx
1
2 // C++ : Tests unitaires sur les creations h'hexaedres
3
4 //  Copyright (C) 2009-2011  CEA/DEN, EDF R&D
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ 
21 //  or email : webmaster.salome@opencascade.com
22 //
23 #include "Hex.hxx"
24
25 #include <unistd.h>
26
27 #include "HexDocument.hxx"
28 #include "HexElements.hxx"
29 #include "HexCrossElements.hxx"
30
31 #include "HexHexa.hxx"
32 #include "HexQuad.hxx"
33 #include "HexEdge.hxx"
34 #include "HexVertex.hxx"
35
36 #include "HexCramer.hxx"
37
38 // ======================================================== test_hexa_quads_5
39 int test_replace5 (int nbargs, cpchar tabargs[])
40 {
41    const int size_x = 4;
42    const int size_y = 4;
43    const int size_z = 2;
44
45    double lgcell = 3;
46    double cray   = lgcell*size_x/2;
47    double decal  = lgcell/sqrt (2.0);
48
49    int nvtk = 0;
50    cpchar son_nom = "replace5";
51
52    Hex::Hex mon_ex;
53    Hex::Document* doc = mon_ex.addDocument (son_nom);
54
55    Hex::Vertex* ori1 = doc->addVertex (-cray, -cray, 0);
56    Hex::Vector* vx   = doc->addVector (3,0,0);
57    Hex::Vector* vy   = doc->addVector (0,3,0);
58    Hex::Vector* vz   = doc->addVector (0,0,1);
59
60    Hex::Elements* grid1 = doc->makeCartesian (ori1, vx, vy, vz, 
61                                               size_x,size_y,size_z);
62    doc->saveVtk (son_nom, nvtk);
63
64 /************************
65    for (int nz=0 ; nz<size_z ; ++nz)
66        for (int ny=1 ; ny<3 ; ++ny)
67            for (int nx=1 ; nx<3 ; ++nx)
68                grid1->getHexaIJK (nx,ny,nz)->remove ();
69
70    doc->saveVtk (son_nom, nvtk);
71 ********************/
72
73    for (int nz=0 ; nz<=size_z ; ++nz)
74        {
75        grid1->getVertexIJK (1, 1, nz)->setX (-decal);
76        grid1->getVertexIJK (1, 1, nz)->setY (-decal);
77
78        grid1->getVertexIJK (1, 3, nz)->setX (-decal);
79        grid1->getVertexIJK (1, 3, nz)->setY ( decal);
80
81        grid1->getVertexIJK (3, 1, nz)->setX ( decal);
82        grid1->getVertexIJK (3, 1, nz)->setY (-decal);
83
84        grid1->getVertexIJK (3, 3, nz)->setX ( decal);
85        grid1->getVertexIJK (3, 3, nz)->setY ( decal);
86        }
87
88    doc->saveVtk (son_nom, nvtk);
89
90    Hex::Vertex* ori0 = doc->addVertex (0,-10,0);
91    Hex::Vertex* ori2 = doc->addVertex (0,0,0);
92    const double dr = 1;
93    const double da = 360;
94    const double dl = 1;
95    const int    nr = 2;
96    const int    na = 8;
97    const int    nl = 3;
98
99
100    Hex::Elements* grid0 = doc->makeCylindrical (ori0, vx, vz, 
101                                                 dr, da, dl, nr, na, 1, false);
102
103    doc->saveVtk (son_nom, nvtk);
104
105    // Hex::Elements* grid2 = 
106    doc->makeCylindrical (ori2, vx, vz, dr, da, dl, nr, na, nl, false);
107
108    doc->saveVtk (son_nom, nvtk);
109    grid0->remove ();
110    doc->saveVtk (son_nom, nvtk);
111    return HOK;
112 }
113 // ======================================================== test_get
114 int test_get (int nbargs, cpchar tabargs[])
115 {
116    const int size_x = 2;
117    const int size_y = 2;
118    const int size_z = 2;
119
120    int nvtk = 0;
121    cpchar son_nom = "test_get";
122
123    Hex::Hex mon_ex;
124    Hex::Document* doc = mon_ex.addDocument (son_nom);
125
126    Hex::Vertex* ori1 = doc->addVertex (0,0,0);
127    Hex::Vector* vx   = doc->addVector (1,0,0);
128    Hex::Vector* vy   = doc->addVector (0,1,0);
129    Hex::Vector* vz   = doc->addVector (0,0,1);
130
131    Hex::Elements* grid = doc->makeCartesian (ori1, vx, vy, vz, 
132                                               size_x,size_y,size_z);
133    doc->saveVtk (son_nom, nvtk);
134    grid->getVertexIJK (2, 1, 1)->setColor (4);
135    doc->saveVtk (son_nom, nvtk);
136
137    grid->getVertexIJK (2, 1, 1)->setColor (0);
138    grid->getEdgeK     (1, 0, 1)->setColor (4);
139    doc->saveVtk (son_nom, nvtk);
140
141    grid->getEdgeK     (1, 0, 1)->setColor (0);
142    grid->getQuadIJ    (1, 0, 2)->setColor (4);
143    doc->saveVtk (son_nom, nvtk);
144
145    grid->getHexaIJK   (1, 0, 1)->setColor (4);
146    doc->saveVtk (son_nom, nvtk);
147    doc->saveVtk (son_nom, nvtk);
148    doc->saveVtk (son_nom, nvtk);
149    doc->saveVtk (son_nom, nvtk);
150    doc->saveVtk (son_nom, nvtk);
151    doc->saveVtk (son_nom, nvtk);
152    doc->saveVtk (son_nom, nvtk);
153    doc->saveVtk (son_nom, nvtk);
154    return HOK;
155 }
156 // ======================================================== test_dump
157 int test_dump (int nbargs, cpchar tabargs[])
158 {
159    const int size_x = 4;
160    const int size_y = 4;
161    const int size_z = 2;
162
163    double lgcell = 3;
164    double cray   = lgcell*size_x/2;
165    // double decal  = lgcell/sqrt (2.0);
166
167    int nvtk = 0;
168    cpchar son_nom = "test_dump";
169
170    Hex::Hex mon_ex;
171    Hex::Document* doc = mon_ex.addDocument (son_nom);
172
173    Hex::Vertex* ori1 = doc->addVertex (-cray, -cray, 0);
174    Hex::Vector* vx   = doc->addVector (3,0,0);
175    Hex::Vector* vy   = doc->addVector (0,3,0);
176    Hex::Vector* vz   = doc->addVector (0,0,1);
177
178    //Hex::Elements* grid1 = 
179    doc->makeCartesian (ori1, vx, vy, vz, size_x,size_y,size_z);
180    doc->saveVtk (son_nom, nvtk);
181    return HOK;
182 }