Salome HOME
Update copyrights
[tools/medcoupling.git] / src / RENUMBER_Swig / UsersGuideExamplesTest.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2019  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import sys
22
23 if sys.platform == "win32":
24     from MEDCouplingCompat import *
25 else:
26     from MEDCoupling import *
27
28 from math import pi, sqrt
29
30 if sys.platform == "win32":
31     import MEDCouplingCompat as MEDCoupling
32 else:
33     import MEDCoupling
34
35 from MEDCouplingDataForTest import MEDCouplingDataForTest
36 m=MEDCouplingDataForTest.build2DTargetMesh_1();
37 #! [UG_Optimization_0]
38 from MEDRenumber import RenumberingFactory
39 ren=RenumberingFactory("BOOST")
40 a,b=m.computeNeighborsOfCells()
41 n2o,_=ren.renumber(a,b)
42 mrenum=m[n2o]
43 #! [UG_Optimization_0]
44
45 #! [UG_Optimization_1]
46 import MEDPartitioner
47 # prepare a MEDPartitioner
48 a,b=m.computeNeighborsOfCells()
49 sk=MEDCouplingSkyLineArray(b,a)
50 g=MEDPartitioner.MEDPartitioner.Graph(sk)
51 # compute partitioning into 4 parts
52 g.partGraph(4)
53 # get the 1st of parts of m
54 procIdOnCells=g.getPartition().getValuesArray()
55 p0=procIdOnCells.findIdsEqual(0)
56 part0=m[p0]
57 #! [UG_Optimization_1]
58 #! [UG_Optimization_2]
59 boundary_nodes_part0=part0.findBoundaryNodes()
60 boundary_cells_part0=p0[part0.getCellIdsLyingOnNodes(boundary_nodes_part0,False)]
61 # starting from knowledge of neighborhood it s possible to know the neighbors of boundary_cells_part0
62 neighbors_boundary_cells_part0=MEDCouplingUMesh.ExtractFromIndexedArrays(boundary_cells_part0,a,b)[0]
63 neighbors_boundary_cells_part0.sort()
64 neighbors_boundary_cells_part0=neighbors_boundary_cells_part0.buildUnique()
65 #
66 layer_of_part0=neighbors_boundary_cells_part0.buildSubstraction(p0)
67 #
68 whole_part_with_layer=DataArrayInt.Aggregate([p0,layer_of_part0])
69 whole_part_with_layer.sort()
70 part0_with_layer=m[whole_part_with_layer]
71 #! [UG_Optimization_2]
72