Salome HOME
Updated copyright comment
[modules/hexablock.git] / src / HEXABLOCK / test_hexa5.cxx
1
2 // C++ : Tests unitaires sur les creations h'hexaedres
3
4 // Copyright (C) 2009-2024  CEA, EDF
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, or (at your option) any later version.
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/ or email : webmaster.salome@opencascade.com
21 //
22 #include "Hex.hxx"
23
24 #include <unistd.h>
25
26 #include "HexDocument.hxx"
27 #include "HexElements.hxx"
28
29 #include "HexHexa.hxx"
30 #include "HexQuad.hxx"
31 #include "HexEdge.hxx"
32 #include "HexVertex.hxx"
33
34 #include "HexCramer.hxx"
35
36 // ======================================================== test_hexa_quads_5
37 int test_replace5 (int nbargs, cpchar tabargs[])
38 {
39    const int size_x = 4;
40    const int size_y = 4;
41    const int size_z = 2;
42
43    double lgcell = 3;
44    double decal  = lgcell/sqrt (2.0);
45
46    int nvtk = 0;
47    cpchar son_nom = "replace5";
48
49    Hex::Hex mon_ex;
50    Hex::Document* doc = mon_ex.addDocument (son_nom);
51
52    Hex::Vector* vx   = doc->addVector (3,0,0);
53    Hex::Vector* vz   = doc->addVector (0,0,1);
54
55    Hex::Elements* grid1 = doc->makeCartesianTop (size_x,size_y,size_z);
56    doc->saveVtk (son_nom, nvtk);
57
58    for (int nz=0 ; nz<=size_z ; ++nz)
59        {
60        grid1->getVertexIJK (1, 1, nz)->setX (-decal);
61        grid1->getVertexIJK (1, 1, nz)->setY (-decal);
62
63        grid1->getVertexIJK (1, 3, nz)->setX (-decal);
64        grid1->getVertexIJK (1, 3, nz)->setY ( decal);
65
66        grid1->getVertexIJK (3, 1, nz)->setX ( decal);
67        grid1->getVertexIJK (3, 1, nz)->setY (-decal);
68
69        grid1->getVertexIJK (3, 3, nz)->setX ( decal);
70        grid1->getVertexIJK (3, 3, nz)->setY ( decal);
71        }
72
73    doc->saveVtk (son_nom, nvtk);
74
75    Hex::Vertex* ori0 = doc->addVertex (0,-10,0);
76    Hex::Vertex* ori2 = doc->addVertex (0,0,0);
77    const double da = 360;
78    const double dl = 1;
79    const int    nr = 2;
80    const int    na = 8;
81    const int    nl = 3;
82
83
84    Hex::Elements* grid0 = doc->makePipeUni (ori0, vx, vz, 
85                                             1.0,5.0, da, dl, nr, na, nl);
86
87    doc->saveVtk (son_nom, nvtk);
88
89    // Hex::Elements* grid2 = 
90    doc->makePipeUni (ori2, vx, vz, 1.0,5.0, da, dl, nr, na, nl);
91
92    doc->saveVtk (son_nom, nvtk);
93    grid0->remove ();
94    doc->saveVtk (son_nom, nvtk);
95    return HOK;
96 }
97 // ======================================================== test_get
98 int test_get (int nbargs, cpchar tabargs[])
99 {
100    const int size_x = 2;
101    const int size_y = 2;
102    const int size_z = 2;
103
104    int nvtk = 0;
105    cpchar son_nom = "test_get";
106
107    Hex::Hex mon_ex;
108    Hex::Document* doc = mon_ex.addDocument (son_nom);
109
110    Hex::Elements* grid = doc->makeCartesianTop (size_x,size_y,size_z);
111    doc->saveVtk (son_nom, nvtk);
112    grid->getVertexIJK (2, 1, 1)->setColor (4);
113    doc->saveVtk (son_nom, nvtk);
114
115    grid->getVertexIJK (2, 1, 1)->setColor (0);
116    grid->getEdgeK     (1, 0, 1)->setColor (4);
117    doc->saveVtk (son_nom, nvtk);
118
119    grid->getEdgeK     (1, 0, 1)->setColor (0);
120    grid->getQuadIJ    (1, 0, 2)->setColor (4);
121    doc->saveVtk (son_nom, nvtk);
122
123    grid->getHexaIJK   (1, 0, 1)->setColor (4);
124    doc->saveVtk (son_nom, nvtk);
125    doc->saveVtk (son_nom, nvtk);
126    doc->saveVtk (son_nom, nvtk);
127    doc->saveVtk (son_nom, nvtk);
128    doc->saveVtk (son_nom, nvtk);
129    doc->saveVtk (son_nom, nvtk);
130    doc->saveVtk (son_nom, nvtk);
131    doc->saveVtk (son_nom, nvtk);
132    return HOK;
133 }
134 // ======================================================== test_dump
135 int test_dump (int nbargs, cpchar tabargs[])
136 {
137    const int size_x = 4;
138    const int size_y = 4;
139    const int size_z = 2;
140
141    int nvtk = 0;
142    cpchar son_nom = "test_dump";
143
144    Hex::Hex mon_ex;
145    Hex::Document* doc = mon_ex.addDocument (son_nom);
146
147    doc->makeCartesianTop (size_x,size_y,size_z);
148    doc->saveVtk (son_nom, nvtk);
149    return HOK;
150 }