1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 if sys.platform == "win32":
24 from MEDCouplingCompat import *
26 from MEDCoupling import *
28 from math import pi, sqrt
30 if sys.platform == "win32":
31 import MEDCouplingCompat as MEDCoupling
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)
43 #! [UG_Optimization_0]
45 #! [UG_Optimization_1]
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
53 # get the 1st of parts of m
54 procIdOnCells=g.getPartition().getValuesArray()
55 p0=procIdOnCells.findIdsEqual(0)
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()
66 layer_of_part0=neighbors_boundary_cells_part0.buildSubstraction(p0)
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]