Back to index

salome-med  6.5.0
Public Member Functions
test_StructuredCoincidentDEC.ParaMEDMEMBasicsTest2 Class Reference

List of all members.

Public Member Functions

def testStructuredCoincidentDEC

Detailed Description

Definition at line 27 of file test_StructuredCoincidentDEC.py.


Member Function Documentation

Definition at line 28 of file test_StructuredCoincidentDEC.py.

00028 
00029     def testStructuredCoincidentDEC(self):
00030         MPI_Init(sys.argv)
00031         #
00032         size = MPI_Comm_size(MPI_COMM_WORLD)
00033         rank = MPI_Comm_rank(MPI_COMM_WORLD)
00034         #
00035         if size < 4:
00036             raise RuntimeError, "Expect MPI_COMM_WORLD size >= 4"
00037         #
00038         interface = CommInterface()
00039         #
00040         self_group   = MPIProcessorGroup(interface, rank, rank)
00041         target_group = MPIProcessorGroup(interface, 3, size-1)
00042         source_group = MPIProcessorGroup(interface, 0, 2)
00043         #
00044         mesh      = 0
00045         support   = 0
00046         paramesh  = 0
00047         parafield = 0
00048         comptopo  = 0
00049         icocofield= 0
00050         #
00051         data_dir = os.environ['MED_ROOT_DIR']
00052         tmp_dir  = os.environ['TMP']
00053         if tmp_dir == '':
00054             tmp_dir = "/tmp"
00055             pass
00056         
00057         filename_xml1    = data_dir + "/share/salome/resources/med/square1_split"
00058         filename_2       = data_dir + "/share/salome/resources/med/square1.med"
00059         filename_seq_wr  = tmp_dir + "/"
00060         filename_seq_med = tmp_dir + "/myWrField_seq_pointe221.med"
00061         
00062         dec = StructuredCoincidentDEC(source_group, target_group)
00063         MPI_Barrier(MPI_COMM_WORLD)
00064         if source_group.containsMyRank():
00065             filename = filename_xml1 + str(rank+1) + ".med"
00066             meshname = "Mesh_2_" + str(rank+1)
00067             mesh=MEDLoader.ReadUMeshFromFile(filename,meshname,0)
00068             paramesh=ParaMESH(mesh,source_group,"source mesh")
00069             comptopo=ComponentTopology(6)
00070             parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh,comptopo)
00071             parafield.getField().setNature(ConservativeVolumic)
00072             nb_local=mesh.getNumberOfCells()
00073             global_numbering=paramesh.getGlobalNumberingCell2()
00074             value = []
00075             for ielem in range(nb_local):
00076                 for icomp in range(6):
00077                     value.append(global_numbering[ielem]*6.0+icomp);
00078                     pass
00079                 pass
00080             parafield.getField().setValues(value)
00081             icocofield = ICoCoMEDField(mesh,parafield.getField())
00082             dec.setMethod("P0")  
00083             dec.attachLocalField(parafield)      
00084             dec.synchronize()
00085             dec.sendData()
00086             pass
00087 
00088         if target_group.containsMyRank():
00089             meshname2 = "Mesh_2"
00090             mesh=MEDLoader.ReadUMeshFromFile(filename_2, meshname2,0)
00091             paramesh=ParaMESH(mesh, self_group, "target mesh")
00092             comptopo=ComponentTopology(6,target_group)
00093             parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo)
00094             parafield.getField().setNature(ConservativeVolumic)
00095             nb_local=mesh.getNumberOfCells()
00096             value = [0.0]*(nb_local*comptopo.nbLocalComponents())
00097             parafield.getField().setValues(value)
00098             icocofield = ICoCoMEDField(mesh,parafield.getField())
00099             dec.setMethod("P0")
00100             dec.attachLocalField(parafield)
00101             dec.synchronize()
00102             dec.recvData()
00103             recv_value = parafield.getField().getArray().getValues()
00104             for i in range(nb_local):
00105                 first=comptopo.firstLocalComponent()
00106                 for icomp in range(comptopo.nbLocalComponents()):
00107                     self.failUnless(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]-
00108                                               (float)(i*6+icomp+first))<1e-12)
00109                     pass
00110                 pass
00111             pass
00112         comptopo=0
00113         interface = 0
00114         mesh       =0
00115         support    =0
00116         paramesh   =0
00117         parafield  =0
00118         icocofield =0
00119         dec=0
00120         self_group =0
00121         target_group = 0
00122         source_group = 0
00123         MPI_Barrier(MPI_COMM_WORLD)
00124         MPI_Finalize()
00125         print "End of test StructuredCoincidentDEC"
00126         pass
00127 
00128     
00129 unittest.main()

Here is the call graph for this function:


The documentation for this class was generated from the following file: