6 #include "GmshConfig.h"
20 const std::map<
int, std::vector<double> > &data,
21 int step,
double time,
int partition,
int numComp)
23 if(data.empty())
return false;
24 if(step < 0)
return false;
28 for(
auto it = data.begin(); it != data.end(); it++)
29 numComp = std::min(numComp, (
int)it->second.size());
32 while(step >= (
int)
_steps.size())
34 _steps[step]->fillEntities();
35 _steps[step]->computeBoundingBox();
36 _steps[step]->setTime(time);
40 _steps[step]->resizeData(numEnt);
42 for(
auto it = data.begin(); it != data.end(); it++) {
43 int mult = it->second.size() / numComp;
44 double *d =
_steps[step]->getData(it->first,
true,
mult);
45 for(
int j = 0; j < numComp *
mult; j++) d[j] = it->second[j];
47 if(partition >= 0)
_steps[step]->getPartitions().insert(partition);
53 const std::vector<std::size_t> &
tags,
54 const std::vector<std::vector<double> > &data,
55 int step,
double time,
int partition,
int numComp)
57 if(data.empty() ||
tags.empty() || data.size() !=
tags.size())
return false;
65 for(std::size_t i = 0; i < data.size(); i++)
66 numComp = std::min(numComp, (
int)data[i].size());
70 while(step >= (
int)
_steps.size())
72 _steps[step]->fillEntities();
73 _steps[step]->computeBoundingBox();
74 _steps[step]->setTime(time);
78 _steps[step]->resizeData(numEnt);
80 for(std::size_t i = 0; i < data.size(); i++) {
81 int mult = data[i].size() / numComp;
83 for(
int j = 0; j < numComp *
mult; j++) d[j] = data[i][j];
85 if(partition >= 0)
_steps[step]->getPartitions().insert(partition);
91 const std::vector<std::size_t> &
tags,
92 const std::vector<double> &data,
int step,
93 double time,
int partition,
int numComp)
95 if(data.empty() ||
tags.empty())
return false;
97 std::size_t stride = data.size() /
tags.size();
98 if(stride < 1)
return false;
105 numComp = (int)stride;
109 while(step >= (
int)
_steps.size())
111 _steps[step]->fillEntities();
112 _steps[step]->computeBoundingBox();
113 _steps[step]->setTime(time);
117 _steps[step]->resizeData(numEnt);
119 int mult = stride / numComp;
120 for(std::size_t i = 0; i <
tags.size(); i++) {
123 for(std::size_t j = 0; j < stride; j++) d[j] = data[k + j];
125 if(partition >= 0)
_steps[step]->getPartitions().insert(partition);
136 const std::string &fileName,
int fileIndex,
137 FILE *fp,
bool binary,
bool swap,
int step,
138 double time,
int partition,
int numComp,
140 const std::string &interpolationScheme)
142 Msg::Debug(
"Reading view `%s' step %d (time %g) partition %d: %d records",
143 viewName.c_str(), step, time, partition, numEnt);
145 while(step >= (
int)
_steps.size())
147 _steps[step]->fillEntities();
148 _steps[step]->computeBoundingBox();
149 _steps[step]->setFileName(fileName);
150 _steps[step]->setFileIndex(fileIndex);
151 _steps[step]->setTime(time);
161 _steps[step]->resizeData(numEnt);
164 for(
int i = 0; i < numEnt; i++) {
167 if(fread(&num,
sizeof(
int), 1, fp) != 1)
return false;
171 if(fscanf(fp,
"%d", &num) != 1)
return false;
173 if(num < 0)
return false;
177 if(fread(&
mult,
sizeof(
int), 1, fp) != 1)
return false;
181 if(fscanf(fp,
"%d", &
mult) != 1)
return false;
184 double *d =
_steps[step]->getData(num,
true,
mult);
186 if((
int)fread(d,
sizeof(
double), numComp *
mult, fp) != numComp *
mult)
191 for(
int j = 0; j < numComp *
mult; j++)
192 if(fscanf(fp,
"%lf", &d[j]) != 1)
return false;
199 for(
int j = 0; j <
mult; j++) {
209 if(partition >= 0)
_steps[step]->getPartitions().insert(partition);
211 finalize(
false, interpolationScheme);
216 bool binary,
bool saveMesh,
bool multipleView,
217 int partitionNum,
bool saveInterpolationMatrices,
218 bool forceNodeData,
bool forceElementData)
220 if(
_steps.empty())
return true;
223 Msg::Info(
"Exporting multi-mesh view in separate files");
227 Msg::Warning(
"Cannot force NodeData for this dataset: saving native data");
232 "Cannot force ElementData for this dataset: saving native data");
239 for(std::size_t step = 0; step <
_steps.size(); step++) {
240 int numEnt = 0, numComp =
_steps[step]->getNumComponents();
241 for(std::size_t i = 0; i <
_steps[step]->getNumData(); i++)
242 if(
_steps[step]->getData(i)) numEnt++;
243 if(!numEnt)
continue;
248 std::string stepFileName = fileName;
250 std::ostringstream sstream;
252 sstream << n[0] << n[1] <<
"_" << numFile++ << n[2];
253 stepFileName = sstream.str();
254 model0 =
_steps[step]->getModel();
258 false,
false, 1.0, 0, 0,
262 fp =
Fopen(stepFileName.c_str(), binary ?
"ab" :
"a");
264 Msg::Error(
"Unable to open file '%s'", stepFileName.c_str());
270 fp =
Fopen(stepFileName.c_str(), binary ?
"ab" :
"a");
272 Msg::Error(
"Unable to open file '%s'", stepFileName.c_str());
277 fp =
Fopen(stepFileName.c_str(), binary ?
"wb" :
"w");
279 Msg::Error(
"Unable to open file '%s'", stepFileName.c_str());
282 fprintf(fp,
"$MeshFormat\n");
283 fprintf(fp,
"%g %d %d\n", version, binary ? 1 : 0,
284 (
int)
sizeof(
double));
287 fwrite(&one,
sizeof(
int), 1, fp);
290 fprintf(fp,
"$EndMeshFormat\n");
295 fprintf(fp,
"$InterpolationScheme\n");
296 fprintf(fp,
"\"INTERPOLATION_SCHEME\"\n");
300 if(it->second.size() >= 2) {
301 fprintf(fp,
"%d\n2\n", it->first);
302 for(
int mat = 0; mat < 2; mat++) {
303 int m = it->second[mat]->size1(), n = it->second[mat]->size2();
304 fprintf(fp,
"%d %d\n", m, n);
305 for(
int i = 0; i < m; i++) {
306 for(
int j = 0; j < n; j++)
307 fprintf(fp,
"%.16g ", it->second[mat]->get(i, j));
313 fprintf(fp,
"$EndInterpolationScheme\n");
319 fprintf(fp,
"$NodeData\n");
320 fprintf(fp,
"1\n\"%s\"\n",
getName().c_str());
322 if(partitionNum > 0) {
323 fprintf(fp,
"4\n%lu\n%d\n%d\n%d\n", step, numComp, numEnt,
326 else if(
_steps[step]->getPartitions().size() == 1) {
327 int p = *
_steps[step]->getPartitions().begin();
328 fprintf(fp,
"4\n%lu\n%d\n%d\n%d\n", step, numComp, numEnt, p);
331 fprintf(fp,
"3\n%lu\n%d\n%d\n", step, numComp, numEnt);
333 for(std::size_t i = 0; i <
_steps[step]->getNumData(); i++) {
334 if(
_steps[step]->getData(i)) {
335 MVertex *v =
_steps[step]->getModel()->getMeshVertexByTag(i);
343 fwrite(&num,
sizeof(
int), 1, fp);
344 fwrite(
_steps[step]->getData(i),
sizeof(
double), numComp, fp);
347 fprintf(fp,
"%d", num);
348 for(
int k = 0; k < numComp; k++)
349 fprintf(fp,
" %.16g",
_steps[step]->getData(i)[k]);
354 if(binary) fprintf(fp,
"\n");
355 fprintf(fp,
"$EndNodeData\n");
359 fprintf(fp,
"$ElementNodeData\n");
361 fprintf(fp,
"$ElementData\n");
363 fprintf(fp,
"2\n\"%s\"\n\"INTERPOLATION_SCHEME\"\n",
getName().c_str());
365 fprintf(fp,
"1\n\"%s\"\n",
getName().c_str());
368 if(partitionNum > 0) {
369 fprintf(fp,
"4\n%lu\n%d\n%d\n%d\n", step, numComp, numEnt,
372 else if(
_steps[step]->getPartitions().size() == 1) {
373 int p = *
_steps[step]->getPartitions().begin();
374 fprintf(fp,
"4\n%lu\n%d\n%d\n%d\n", step, numComp, numEnt, p);
377 fprintf(fp,
"3\n%lu\n%d\n%d\n", step, numComp, numEnt);
379 for(std::size_t i = 0; i <
_steps[step]->getNumData(); i++) {
380 if(
_steps[step]->getData(i)) {
388 int num = (version >= 3.0) ?
390 _steps[step]->getModel()->getMeshElementIndex(e);
392 fwrite(&num,
sizeof(
int), 1, fp);
394 fwrite(
_steps[step]->getData(i),
sizeof(
double), numComp *
mult,
398 fprintf(fp,
"%d", num);
400 for(
int k = 0; k < numComp *
mult; k++)
401 fprintf(fp,
" %.16g",
_steps[step]->getData(i)[k]);
406 if(binary) fprintf(fp,
"\n");
408 fprintf(fp,
"$EndElementNodeData\n");
410 fprintf(fp,
"$EndElementData\n");
420 for(
int idxtype = 0; idxtype < 24; idxtype++) {
421 int nbe = N[idxtype];
423 std::vector<double> *list = V[idxtype];
523 int stride = list->size() / nbe;
524 int numSteps = (stride - 1) / nc / nn;
525 for(
int step = 0; step < numSteps; step++) {
527 _steps[step]->fillEntities();
528 _steps[step]->computeBoundingBox();
529 _steps[step]->setTime(step);
530 _steps[step]->resizeData(nbe);
531 for(std::size_t j = 0; j < list->size(); j += stride) {
532 double *tmp = &(*list)[j];
533 int num = (int)tmp[0];
534 double *d =
_steps[step]->getData(num,
true, nn);
535 for(
int k = 0; k < nc * nn; k++) { d[k] = tmp[1 + nc * nn * step + k]; }
543 #if defined(HAVE_MED)
547 #if(MED_MAJOR_NUM >= 3)
552 #define med_geometrie_element med_geometry_type
553 #define med_entite_maillage med_entity_type
554 #define med_type_champ med_field_type
555 #define MED_TAILLE_NOM MED_NAME_SIZE
556 #define MED_TAILLE_PNOM MED_SNAME_SIZE
557 #define MED_LECTURE MED_ACC_RDONLY
558 #define MED_LECTURE_AJOUT MED_ACC_RDEXT
559 #define MED_NOEUD MED_NODE
560 #define MED_MAILLE MED_CELL
561 #define MED_NOEUD_MAILLE MED_NODE_ELEMENT
562 #define MED_NOPFL MED_NO_PROFILE
563 #define MEDouvrir MEDfileOpen
564 #define MEDfermer MEDfileClose
565 #define MEDnChamp MEDfieldnComponent
566 #define MEDnValProfil MEDprofileSizeByName
569 extern int med2mshElementType(med_geometrie_element med);
570 extern int med2mshNodeIndex(med_geometrie_element med,
int k);
572 std::vector<std::string> medGetFieldNames(
const std::string &fileName)
574 std::vector<std::string> fieldNames;
576 #if(MED_MAJOR_NUM >= 3)
577 med_idt fid = MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY);
579 med_idt fid = MEDouvrir((
char *)fileName.c_str(), MED_LECTURE);
582 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
586 #if(MED_MAJOR_NUM >= 3)
587 med_int numFields = MEDnField(fid);
589 med_int numFields = MEDnChamp(fid, 0);
592 for(
int index = 0; index < numFields; index++) {
593 med_int numComp = MEDnChamp(fid, index + 1);
595 Msg::Error(
"Could not get number of components for MED field");
599 char name[MED_TAILLE_NOM + 1], meshName[MED_TAILLE_NOM + 1];
600 char dtUnit[MED_TAILLE_PNOM + 1];
601 std::vector<char> compName(numComp * MED_TAILLE_PNOM + 1);
602 std::vector<char> compUnit(numComp * MED_TAILLE_PNOM + 1);
603 med_int numSteps = 0;
605 #if(MED_MAJOR_NUM >= 3)
607 if(MEDfieldInfo(fid, index + 1, name, meshName, &localMesh, &type,
608 &compName[0], &compUnit[0], dtUnit, &numSteps) < 0) {
610 if(MEDchampInfo(fid, index + 1, name, &type, &compName[0], &compUnit[0],
616 fieldNames.push_back(name);
619 #if(MED_MAJOR_NUM >= 3)
620 if(MEDfileClose(fid) < 0) {
622 if(MEDfermer(fid) < 0) {
624 Msg::Error(
"Unable to close file '%s'", fileName.c_str());
631 med_idt fid = MEDouvrir((
char *)fileName.c_str(), MED_LECTURE);
633 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
637 med_int numComp = MEDnChamp(fid, fileIndex + 1);
639 Msg::Error(
"Could not get number of components for MED field");
643 char name[MED_TAILLE_NOM + 1], meshName[MED_TAILLE_NOM + 1];
644 char dtUnit[MED_TAILLE_PNOM + 1];
645 std::vector<char> compName(numComp * MED_TAILLE_PNOM + 1);
646 std::vector<char> compUnit(numComp * MED_TAILLE_PNOM + 1);
647 med_int numSteps = 0;
649 #if(MED_MAJOR_NUM >= 3)
651 if(MEDfieldInfo(fid, fileIndex + 1, name, meshName, &localMesh, &type,
652 &compName[0], &compUnit[0], dtUnit, &numSteps) < 0) {
654 if(MEDchampInfo(fid, fileIndex + 1, name, &type, &compName[0], &compUnit[0],
661 Msg::Info(
"Reading %d-component field '%s'", numComp, name);
666 int numCompMsh = (numComp <= 1) ? 1 :
673 "More than 9 components in field: you will probably want to force "
674 "the field type to scalar, vector or tensor in the options");
680 const med_entite_maillage entType[] = {MED_NOEUD, MED_MAILLE,
682 #if(MED_MAJOR_NUM >= 3)
683 const med_geometrie_element eleType[] = {
684 MED_NONE, MED_SEG2, MED_TRIA3, MED_QUAD4, MED_TETRA4, MED_HEXA8,
685 MED_PENTA6, MED_PYRA5, MED_SEG3, MED_TRIA6, MED_QUAD9, MED_TETRA10,
686 MED_HEXA27, MED_POINT1, MED_QUAD8, MED_HEXA20, MED_PENTA15, MED_PYRA13};
687 const int nodesPerEle[] = {0, 2, 3, 4, 4, 8, 6, 5, 3,
688 6, 9, 10, 27, 1, 8, 20, 15, 13};
690 const med_geometrie_element eleType[] = {
691 MED_NONE, MED_SEG2, MED_TRIA3, MED_QUAD4, MED_TETRA4, MED_HEXA8,
692 MED_PENTA6, MED_PYRA5, MED_SEG3, MED_TRIA6, MED_TETRA10, MED_POINT1,
693 MED_QUAD8, MED_HEXA20, MED_PENTA15, MED_PYRA13};
694 const int nodesPerEle[] = {0, 2, 3, 4, 4, 8, 6, 5,
695 3, 6, 10, 1, 8, 20, 15, 13};
698 std::vector<std::pair<int, int> > pairs;
699 for(std::size_t i = 0; i <
sizeof(entType) /
sizeof(entType[0]); i++) {
700 for(std::size_t j = 0; j <
sizeof(eleType) /
sizeof(eleType[0]); j++) {
701 if((!i && !j) || j) {
702 #if(MED_MAJOR_NUM >= 3)
703 med_int n = numSteps;
705 med_int n = MEDnPasdetemps(fid, name, entType[i], eleType[j]);
708 pairs.push_back(std::make_pair(i, j));
709 numSteps = std::max(numSteps, n);
716 if(numSteps < 1 || pairs.empty()) {
717 Msg::Error(
"Nothing to import from MED file");
721 for(
int step = 0; step < numSteps; step++) {
728 for(std::size_t pair = 0; pair < pairs.size(); pair++) {
730 med_entite_maillage ent = entType[pairs[pair].first];
731 med_geometrie_element ele = eleType[pairs[pair].second];
732 med_int numdt, numit, ngauss;
734 #if(MED_MAJOR_NUM >= 3)
735 if(MEDfieldComputingStepInfo(fid, name, step + 1, &numdt, &numit, &dt) <
738 char dtunit[MED_TAILLE_PNOM + 1];
741 if(MEDpasdetempsInfo(fid, name, ent, ele, step + 1, &ngauss, &numdt,
742 &numit, dtunit, &dt, meshName, &local,
752 Msg::Error(
"Could not find mesh '%s'", meshName);
755 while(step >= (
int)
_steps.size())
757 _steps[step]->fillEntities();
758 _steps[step]->computeBoundingBox();
759 _steps[step]->setFileName(fileName);
760 _steps[step]->setFileIndex(fileIndex);
761 _steps[step]->setTime(dt);
764 char locName[MED_TAILLE_NOM + 1], profileName[MED_TAILLE_NOM + 1];
769 #if(MED_MAJOR_NUM >= 3)
771 med_int numVal = MEDfieldnValueWithProfile(
772 fid, name, numdt, numit, ent, ele, 1, MED_COMPACT_STMODE, profileName,
773 &profileSize, locName, &ngauss);
777 MEDnVal(fid, name, ent, ele, numdt, numit, meshName, MED_COMPACT);
779 if(numVal <= 0)
continue;
785 if(ent == MED_NOEUD_MAILLE) {
mult = nodesPerEle[pairs[pair].second]; }
786 else if(ngauss != 1) {
793 std::vector<double> val(numVal * numComp);
794 #if(MED_MAJOR_NUM >= 3)
795 if(MEDfieldValueWithProfileRd(fid, name, numdt, numit, ent, ele,
796 MED_COMPACT_STMODE, profileName,
797 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
798 (
unsigned char *)&val[0]) < 0) {
800 if(MEDchampLire(fid, meshName, name, (
unsigned char *)&val[0],
801 MED_FULL_INTERLACE, MED_ALL, locName, profileName,
802 MED_COMPACT, ent, ele, numdt, numit) < 0) {
809 "MED: eletyp=%d entity=%d (0:cell, 3:node, 4:elenode) ngauss=%d "
810 "localizationName=%s profileName=%s -- stepDataType=%d",
811 ele, ent, ngauss, locName, profileName,
_type);
815 std::vector<double> &p(
816 _steps[step]->getGaussPoints(med2mshElementType(ele)));
817 if(std::string(locName) == MED_GAUSS_ELNO) {
821 p.resize(ngauss * 3, 1.e22);
825 std::vector<med_float> refcoo((ele % 100) * dim);
826 std::vector<med_float> gscoo(ngauss * dim);
827 std::vector<med_float> wg(ngauss);
828 #if(MED_MAJOR_NUM >= 3)
829 if(MEDlocalizationRd(fid, locName, MED_FULL_INTERLACE, &refcoo[0],
830 &gscoo[0], &wg[0]) < 0) {
832 if(MEDgaussLire(fid, &refcoo[0], &gscoo[0], &wg[0],
833 MED_FULL_INTERLACE, locName) < 0) {
840 for(
int i = 0; i < (int)gscoo.size(); i++) {
841 p.push_back(gscoo[i]);
842 if(i % dim == dim - 1)
843 for(
int j = 0; j < 3 - dim; j++) p.push_back(0.);
849 std::vector<med_int> profile;
850 if(std::string(profileName) != MED_NOPFL) {
851 med_int n = MEDnValProfil(fid, profileName);
855 #if(MED_MAJOR_NUM >= 3)
856 if(MEDprofileRd(fid, profileName, &profile[0]) < 0) {
858 if(MEDprofilLire(fid, &profile[0], profileName) < 0) {
865 if(profile.empty()) {
866 Msg::Debug(
"MED profile is empty -- using continuous sequence");
867 profile.resize(numVal /
mult);
868 for(std::size_t i = 0; i < profile.size(); i++) profile[i] = i + 1;
872 bool nodal = (ent == MED_NOEUD);
873 #if(MED_MAJOR_NUM >= 3)
874 med_bool changeOfCoord;
875 med_bool geoTransform;
876 med_int numEnt = MEDmeshnEntity(
877 fid, meshName, MED_NO_DT, MED_NO_IT, nodal ? MED_NODE : MED_CELL,
878 nodal ? MED_NO_GEOTYPE : ele, nodal ? MED_COORDINATE : MED_CONNECTIVITY,
879 nodal ? MED_NO_CMODE : MED_NODAL, &changeOfCoord, &geoTransform);
882 MEDnEntMaa(fid, meshName, nodal ? MED_COOR : MED_CONN,
883 nodal ? MED_NOEUD : MED_MAILLE, nodal ? MED_NONE : ele,
884 nodal ? (med_connectivite)0 : MED_NOD);
886 std::vector<med_int>
tags(numEnt);
887 #if(MED_MAJOR_NUM >= 3)
888 if(MEDmeshEntityNumberRd(fid, meshName, MED_NO_DT, MED_NO_IT,
889 nodal ? MED_NODE : MED_CELL,
890 nodal ? MED_NO_GEOTYPE : ele, &
tags[0]) < 0)
892 if(MEDnumLire(fid, meshName, &
tags[0], numEnt,
893 nodal ? MED_NOEUD : MED_MAILLE, nodal ? MED_NONE : ele) < 0)
899 std::size_t startIndex = 0;
901 std::size_t maxv, maxe;
902 _steps[step]->getModel()->getCheckPointedMaxNumbers(maxv, maxe);
903 if(nodal) { startIndex += maxv; }
905 for(
int i = 1; i < pairs[pair].second; i++) {
906 #if(MED_MAJOR_NUM >= 3)
907 med_int n = MEDmeshnEntity(
908 fid, meshName, MED_NO_DT, MED_NO_IT, MED_CELL, eleType[i],
909 MED_CONNECTIVITY, MED_NODAL, &changeOfCoord, &geoTransform);
911 med_int n = MEDnEntMaa(fid, meshName, MED_CONN, MED_MAILLE,
912 eleType[i], MED_NOD);
914 if(n > 0) startIndex += n;
918 Msg::Debug(
"MED has no tags -- assuming starting index %lu",
923 for(std::size_t i = 0; i < profile.size(); i++) {
925 if(
tags.empty()) { num = startIndex + profile[i]; }
927 if(profile[i] == 0 || profile[i] > (
int)
tags.size()) {
931 num =
tags[profile[i] - 1];
934 double *d =
_steps[step]->getData(num,
true,
mult);
935 for(
int j = 0; j <
mult; j++) {
937 int j2 = (ent == MED_NOEUD_MAILLE) ? med2mshNodeIndex(ele, j) : j;
938 for(
int k = 0; k < numComp; k++)
939 d[numCompMsh * j + k] = val[numComp *
mult * i + numComp * j2 + k];
947 if(MEDfermer(fid) < 0) {
948 Msg::Error(
"Unable to close file '%s'", (
char *)fileName.c_str());
956 if(
_steps.empty())
return true;
959 Msg::Error(
"Export not done for multi-mesh views");
964 Msg::Error(
"Can only export node-based datasets for now");
971 if(!model->
writeMED(fileName,
true))
return false;
973 std::string meshName(model->
getName());
974 std::string fieldName(
getName());
976 #if (MED_MAJOR_NUM >= 4) || ((MED_MAJOR_NUM >= 3) && (MED_MINOR_NUM >= 3))
978 med_int major = MED_MAJOR_NUM, minor = MED_MINOR_NUM,
979 release = MED_RELEASE_NUM;
982 Msg::Info(
"Forcing MED file version to %d.%d", major, minor);
984 med_idt fid = MEDfileVersionOpen((
char *)fileName.c_str(), MED_ACC_RDEXT,
985 major, minor, release);
987 med_idt fid = MEDouvrir((
char *)fileName.c_str(), MED_LECTURE_AJOUT);
991 Msg::Error(
"Unable to open file '%s'", fileName.c_str());
996 char *profileName = (
char *)
"nodeProfile";
997 std::vector<med_int> profile, indices;
998 for(std::size_t i = 0; i <
_steps[0]->getNumData(); i++) {
999 if(
_steps[0]->getData(i)) {
1006 indices.push_back(i);
1010 if(profile.empty()) {
1015 #if(MED_MAJOR_NUM >= 3)
1016 if(MEDprofileWr(fid, profileName, (med_int)profile.size(), &profile[0]) < 0) {
1018 if(MEDprofilEcr(fid, &profile[0], (med_int)profile.size(), profileName) < 0) {
1024 int numComp =
_steps[0]->getNumComponents();
1025 #if(MED_MAJOR_NUM >= 3)
1026 if(MEDfieldCr(fid, (
char *)fieldName.c_str(), MED_FLOAT64, (med_int)numComp,
1027 "unknown",
"unknown",
"unknown",
1028 (
char *)meshName.c_str()) < 0) {
1030 if(MEDchampCr(fid, (
char *)fieldName.c_str(), MED_FLOAT64, (
char *)
"unknown",
1031 (
char *)
"unknown", (med_int)numComp) < 0) {
1037 #if(MED_MAJOR_NUM >= 3)
1038 med_bool changeOfCoord, geoTransform;
1040 MEDmeshnEntity(fid, (
char *)meshName.c_str(), MED_NO_DT, MED_NO_IT,
1041 MED_NODE, MED_NO_GEOTYPE, MED_COORDINATE, MED_NO_CMODE,
1042 &changeOfCoord, &geoTransform);
1044 med_int numNodes = MEDnEntMaa(fid, (
char *)meshName.c_str(), MED_COOR,
1045 MED_NOEUD, MED_NONE, (med_connectivite)0);
1048 Msg::Error(
"Could not get valid number of nodes in mesh");
1051 for(std::size_t step = 0; step <
_steps.size(); step++) {
1053 for(std::size_t i = 0; i <
_steps[step]->getNumData(); i++)
1054 if(
_steps[step]->getData(i)) n++;
1055 if(n != profile.size() || numComp !=
_steps[step]->getNumComponents()) {
1059 double time =
_steps[step]->getTime();
1060 std::vector<double> val(profile.size() * numComp);
1061 for(std::size_t i = 0; i < profile.size(); i++)
1062 for(
int k = 0; k < numComp; k++)
1063 val[i * numComp + k] =
_steps[step]->getData(indices[i])[k];
1064 #if(MED_MAJOR_NUM >= 3)
1065 if(MEDfieldValueWithProfileWr(
1066 fid, (
char *)fieldName.c_str(), (med_int)(step + 1), MED_NO_IT, time,
1067 MED_NODE, MED_NO_GEOTYPE, MED_COMPACT_STMODE, profileName,
"",
1068 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, numNodes,
1069 (
unsigned char *)&val[0]) < 0) {
1071 if(MEDchampEcr(fid, (
char *)meshName.c_str(), (
char *)fieldName.c_str(),
1072 (
unsigned char *)&val[0], MED_FULL_INTERLACE, numNodes,
1073 (
char *)MED_NOGAUSS, MED_ALL, profileName, MED_COMPACT,
1074 MED_NOEUD, MED_NONE, (med_int)step, (
char *)
"unknown", time,
1082 if(MEDfermer(fid) < 0) {
1083 Msg::Error(
"Unable to close file '%s'", (
char *)fileName.c_str());
1093 Msg::Error(
"Gmsh must be compiled with MED support to read '%s'",
1100 Msg::Error(
"Gmsh must be compiled with MED support to write '%s'",
1109 Msg::Info(
"Placeholder for reading punch file '%s'", fileName.c_str());
1111 std::map<int, std::vector<double> > data;
1112 for(
int i = 1; i < 200; i++) data[i].push_back(1.234);
1120 if(
_steps.empty())
return;
1123 Msg::Error(
"sendToServer currently only implemented for nodal datasets");
1127 int numEnt = 0, numComp = 0;
1128 for(std::size_t step = 0; step <
_steps.size(); step++) {
1129 int nc =
_steps[step]->getNumComponents();
1131 for(std::size_t i = 0; i <
_steps[step]->getNumData(); i++)
1132 if(
_steps[step]->getData(i)) ne++;
1138 if(ne != numEnt || nc != numComp) {
1139 Msg::Error(
"Can not send heterogeneous view to server");
1145 std::vector<double> exp;
1146 exp.push_back(numEnt);
1148 for(std::size_t i = 0; i <
_steps[0]->getNumData(); i++) {
1149 if(
_steps[0]->getData(i)) {
1157 for(std::size_t step = 0; step <
_steps.size(); step++) {
1158 for(
int k = 0; k < numComp; k++) {
1159 double data =
_steps[step]->getData(i)[k];
1160 exp.push_back(data);