From a32ea42d4106df6ca89e5a11953e62732850aa7d Mon Sep 17 00:00:00 2001 From: abn Date: Mon, 3 Apr 2017 12:04:19 +0200 Subject: [PATCH] Porting tutorial exercise on the new API --- doc/tutorial/atestMEDLoaderSplitAndMerge1.rst | 17 ++++++++--------- doc/tutorial/medloader_SplitAndMerge1_fr.rst | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/doc/tutorial/atestMEDLoaderSplitAndMerge1.rst b/doc/tutorial/atestMEDLoaderSplitAndMerge1.rst index 20231f119..70d4e5ebb 100644 --- a/doc/tutorial/atestMEDLoaderSplitAndMerge1.rst +++ b/doc/tutorial/atestMEDLoaderSplitAndMerge1.rst @@ -7,7 +7,6 @@ Splitting and Merging a MED file using MEDLoader :: import MEDLoader as ml - from MEDLoader import MEDLoader m0 = ml.MEDCouplingCMesh() arr = ml.DataArrayDouble(31,1) ; arr.iota(0.) @@ -41,25 +40,25 @@ Splitting and Merging a MED file using MEDLoader nodeField1 = nodeField[proc1] ; cellField1 = cellField[proc1] ; cellField1.setMesh(nodeField1.getMesh()) proc0_fname = "proc0.med" - MEDLoader.WriteField(proc0_fname, nodeField0, True) - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(proc0_fname, cellField0) + ml.WriteField(proc0_fname, nodeField0, True) + ml.WriteFieldUsingAlreadyWrittenMesh(proc0_fname, cellField0) proc1_fname = "proc1.med" - MEDLoader.WriteField(proc1_fname,nodeField1,True) - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(proc1_fname,cellField1) + ml.WriteField(proc1_fname,nodeField1,True) + ml.WriteFieldUsingAlreadyWrittenMesh(proc1_fname,cellField1) # # Merging - Sub-optimal method # - cellField0_read = MEDLoader.ReadFieldCell("proc0.med","mesh",0,"CellField",5,6) - cellField1_read = MEDLoader.ReadFieldCell("proc1.med","mesh",0,"CellField",5,6) + cellField0_read = ml.ReadFieldCell("proc0.med","mesh",0,"CellField",5,6) + cellField1_read = ml.ReadFieldCell("proc1.med","mesh",0,"CellField",5,6) cellField_read = ml.MEDCouplingFieldDouble.MergeFields([cellField0_read,cellField1_read]) cellFieldCpy = cellField.deepCopy() cellFieldCpy.substractInPlaceDM(cellField_read,10,1e-12) cellFieldCpy.getArray().abs() print cellFieldCpy.getArray().isUniform(0.,1e-12) # - nodeField0_read = MEDLoader.ReadFieldNode("proc0.med","mesh",0,"NodeField",5,6) - nodeField1_read = MEDLoader.ReadFieldNode("proc1.med","mesh",0,"NodeField",5,6) + nodeField0_read = ml.ReadFieldNode("proc0.med","mesh",0,"NodeField",5,6) + nodeField1_read = ml.ReadFieldNode("proc1.med","mesh",0,"NodeField",5,6) nodeField_read = ml.MEDCouplingFieldDouble.MergeFields([nodeField0_read, nodeField1_read]) nodeField_read.mergeNodes(1e-10) nodeFieldCpy = nodeField.deepCopy() diff --git a/doc/tutorial/medloader_SplitAndMerge1_fr.rst b/doc/tutorial/medloader_SplitAndMerge1_fr.rst index a08d860cd..811ec18dc 100644 --- a/doc/tutorial/medloader_SplitAndMerge1_fr.rst +++ b/doc/tutorial/medloader_SplitAndMerge1_fr.rst @@ -21,7 +21,6 @@ Créer un unstructured mesh ``m0`` issu d'un maillage structuré (meshDim=2, spa Chacune des cellules paires du maillage sera *simplexisée* (i.e. coupée en triangle - méthode ``MEDCouplingUMesh.simplexize(0)``) :: import MEDLoader as ml - from MEDLoader import MEDLoader m0 = ml.MEDCouplingCMesh() arr = ml.DataArrayDouble(31,1) ; arr.iota(0.) @@ -80,12 +79,12 @@ En partant du partitionnement ``proc0`` et ``proc1`` créer 2 fichiers MED appel nodeField1 = nodeField[proc1] ; cellField1 = cellField[proc1] ; cellField1.setMesh(nodeField1.getMesh()) proc0_fname = "proc0.med" - MEDLoader.WriteField(proc0_fname, nodeField0, True) - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(proc0_fname, cellField0) + ml.WriteField(proc0_fname, nodeField0, True) + ml.WriteFieldUsingAlreadyWrittenMesh(proc0_fname, cellField0) proc1_fname = "proc1.med" - MEDLoader.WriteField(proc1_fname,nodeField1,True) - MEDLoader.WriteFieldUsingAlreadyWrittenMesh(proc1_fname,cellField1) + ml.WriteField(proc1_fname,nodeField1,True) + ml.WriteFieldUsingAlreadyWrittenMesh(proc1_fname,cellField1) Lecture et fusion des 2 fichiers MED séparés (non optimal) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -93,8 +92,8 @@ Lecture et fusion des 2 fichiers MED séparés (non optimal) Partant de "proc0.med" et de "proc1.med" lire leur "CellField" respectif avec l'API basique, agréger les deux et mettre le résultat dans ``cellField_read`` : :: - cellField0_read = MEDLoader.ReadFieldCell("proc0.med","mesh",0,"CellField",5,6) - cellField1_read = MEDLoader.ReadFieldCell("proc1.med","mesh",0,"CellField",5,6) + cellField0_read = ml.ReadFieldCell("proc0.med","mesh",0,"CellField",5,6) + cellField1_read = ml.ReadFieldCell("proc1.med","mesh",0,"CellField",5,6) cellField_read = ml.MEDCouplingFieldDouble.MergeFields([cellField0_read,cellField1_read]) .. note:: On peut avoir l'impression que l'information Cell (méthode ``ReadFieldCell``) est répétée de manière abusive @@ -120,8 +119,8 @@ Opérons le même travail sur "NodeField" que celui réalisé plus haut sur "Cel La différence ici c'est qu'il va y avoir duplication de l'information à la frontière, car les noeuds limites sont partagés des deux côtés : :: - nodeField0_read = MEDLoader.ReadFieldNode("proc0.med","mesh",0,"NodeField",5,6) - nodeField1_read = MEDLoader.ReadFieldNode("proc1.med","mesh",0,"NodeField",5,6) + nodeField0_read = ml.ReadFieldNode("proc0.med","mesh",0,"NodeField",5,6) + nodeField1_read = ml.ReadFieldNode("proc1.med","mesh",0,"NodeField",5,6) nodeField_read = ml.MEDCouplingFieldDouble.MergeFields([nodeField0_read, nodeField1_read]) .. note:: Dans cette partie, on a donc relu le maillage une deuxième fois ce qui peut être pénalisant ... -- 2.39.2