# test29.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
    00004  *  MED is free software: you can redistribute it and/or modify
    00005  *  it under the terms of the GNU Lesser General Public License as published by
    00006  *  the Free Software Foundation, either version 3 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  MED is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Lesser General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Lesser General Public License
    00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00018 /******************************************************************************
    00019  * - Nom du fichier : test29.c
    00020  *
    00021  * - Description : ecriture d'un joint dans un maillage MED
    00022  *
    00023  *****************************************************************************/
    00024
    00025 #include <med.h>
    00026 #define MESGERR 1
    00027 #include <med_utils.h>
    00028
    00029 #ifdef DEF_LECT_ECR
    00030 #define MODE_ACCES MED_ACC_RDWR
    00031 #elif DEF_LECT_AJOUT
    00032 #define MODE_ACCES MED_ACC_RDEXT
    00033 #else
    00034 #define MODE_ACCES MED_ACC_CREAT
    00035 #endif
    00036
    00037 int main (int argc, char **argv)
    00038
    00039
    00040 {
    00041   med_idt fid;
    00042
    00043   char maa[MED_NAME_SIZE+1]= "maa1";
    00044   char jnt[MED_NAME_SIZE+1] = "joint";
    00045   char des_jnt[MED_COMMENT_SIZE+1] = "joint avec le sous-domaine 2";
    00046   char maa_distant[MED_NAME_SIZE+1]= "maa1";
    00047   med_int dom_dist = 2;
    00048
    00049   med_int mdim = 3;
    00050   med_int ncor = 3;
    00051   med_int cor[6] = {1,2,3,4,5,6};
    00052   med_int cor2[6] = {10,20,30,40,50,60};
    00053   char nomcoo[3*MED_SNAME_SIZE+1] = "x               y               z               ";
    00054   char unicoo[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
    00055
    00056
    00057   /* Creation du fichier "test29.med" */
    00058   if ((fid = MEDfileOpen("test29.med",MODE_ACCES)) < 0) {
    00059     MESSAGE("Erreur a la creation du fichier test29.med");
    00060     return -1;
    00061   }
    00062
    00063   if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
    00064                  "un maillage pour test29","s", MED_SORT_DTIT,
    00065                  MED_CARTESIAN, nomcoo, unicoo) < 0) {
    00066     MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
    00067     return -1;
    00068   }
    00069
    00070   /* Creation du joint */
    00071   if (MEDsubdomainJointCr(fid,maa,jnt,des_jnt,dom_dist,maa_distant) < 0) {
    00072     MESSAGE("Erreur a la creation du joint");
    00073     return -1;
    00074   }
    00075
    00076   /* Ecriture de la correspondance Noeud, Noeud */
    00077   if (MEDsubdomainCorrespondenceWr(fid,maa,jnt,MED_NO_DT,MED_NO_IT,
    00078                                    MED_NODE,MED_NONE,MED_NODE,MED_NONE,ncor,cor) < 0) {
    00079     MESSAGE("Erreur a l'ecriture du tableau des correspondances (noeud,noeud)");
    00080     return -1;
    00081   }
    00082
    00083   /* Ecriture de la correspondance Noeud Maille */
    00084   if (MEDsubdomainCorrespondenceWr(fid,maa,jnt,MED_NO_DT,MED_NO_IT,
    00085                                    MED_NODE,MED_NONE,MED_CELL,MED_TRIA3,ncor,cor2) < 0) {
    00086     MESSAGE("Erreur a l'ecriture du tableau des correspondances (noeud,maille TRIA3)");
    00087     return -1;
    00088   }
    00089
    00090   /* Fermeture du fichier */
    00091   if (MEDfileClose(fid) < 0) {
    00092     MESSAGE("Erreur a la fermeture du fichier");
    00093     return -1;
    00094   }
    00095
    00096   return 0;
    00097 }
    00098
    00099
    00100
    00101