Salome HOME
MEDCoupling python module is expected to be replaced by medcoupling python module
[tools/medcoupling.git] / src / RENUMBER_Swig / UsersGuideExamplesTest.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016  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 from MEDCoupling import *
22 from math import pi, sqrt
23
24 import MEDCoupling
25
26 from MEDCouplingDataForTest import MEDCouplingDataForTest
27 m=MEDCouplingDataForTest.build2DTargetMesh_1();
28 #! [UG_Optimization_0]
29 from MEDRenumber import RenumberingFactory
30 ren=RenumberingFactory("BOOST")
31 a,b=m.computeNeighborsOfCells()
32 n2o,_=ren.renumber(a,b)
33 mrenum=m[n2o]
34 #! [UG_Optimization_0]
35
36 #! [UG_Optimization_1]
37 from MEDCoupling import MEDCouplingSkyLineArray
38 import MEDPartitioner
39 # prepare a MEDPartitioner
40 a,b=m.computeNeighborsOfCells()
41 sk=MEDCouplingSkyLineArray(b,a)
42 g=MEDPartitioner.MEDPartitioner.Graph(sk)
43 # compute partitioning into 4 parts
44 g.partGraph(4)
45 # get the 1st of parts of m
46 procIdOnCells=g.getPartition().getValuesArray()
47 p0=procIdOnCells.findIdsEqual(0)
48 part0=m[p0]
49 #! [UG_Optimization_1]
50 #! [UG_Optimization_2]
51 boundary_nodes_part0=part0.findBoundaryNodes()
52 boundary_cells_part0=p0[part0.getCellIdsLyingOnNodes(boundary_nodes_part0,False)]
53 # starting from knowledge of neighborhood it s possible to know the neighbors of boundary_cells_part0
54 neighbors_boundary_cells_part0=MEDCouplingUMesh.ExtractFromIndexedArrays(boundary_cells_part0,a,b)[0]
55 neighbors_boundary_cells_part0.sort()
56 neighbors_boundary_cells_part0=neighbors_boundary_cells_part0.buildUnique()
57 #
58 layer_of_part0=neighbors_boundary_cells_part0.buildSubstraction(p0)
59 #
60 whole_part_with_layer=DataArrayInt.Aggregate([p0,layer_of_part0])
61 whole_part_with_layer.sort()
62 part0_with_layer=m[whole_part_with_layer]
63 #! [UG_Optimization_2]
64