+std::vector<std::string> MgAdapt::getListFieldsNames(std::string fileIn)
+{
+ MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileIn);
+ std::vector<std::string> listFieldsNames(mfd->getFields()->getFieldsNames());
+ return listFieldsNames ;
+}
+
+void MgAdapt::checkDimensionOptionAdaptation()
+{
+ // Quand le maillage est 3D, tout est possible
+ // Quand le maillage est 2D, il faut 'surface' sauf si carte de fonds 3D
+ MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(medFileIn);
+ int meshdim = mfd->getMeshes()->getMeshAtPos(0)->getMeshDimension() ;
+// std::cout << "meshdim = " << meshdim << std::endl;
+
+ if ( meshdim == 2 )
+ {
+ std::string optionName = "adaptation";
+ std::string optionValue = getOptionValue(optionName);
+// std::cout << "optionValue = '" << optionValue <<"'"<< std::endl;
+ bool a_tester = false ;
+ // carte locale ou constante : impératif d'avoir "surface"
+ if ( useLocalMap || useConstantValue) a_tester = true ;
+ // carte de fond : impératif d'avoir "surface" si le fonds est aussi 2D
+ else
+ {
+ MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfdbg = MEDCoupling::MEDFileData::New(sizeMapFile);
+ int meshdimbg = mfdbg->getMeshes()->getMeshAtPos(0)->getMeshDimension() ;
+// std::cout << "meshdimbg = " << meshdimbg << std::endl;
+ if ( meshdimbg == 2 ) a_tester = true ;
+ }
+ if ( a_tester )
+ {
+ if ( optionValue == "" ) setOptionValue (optionName, "surface");
+ else
+ {
+ if ( optionValue != "surface" )
+ {
+ THROW_SALOME_EXCEPTION("Mesh dimension is 2; the option should be 'surface'"
+ " instead of '" << optionValue << "'.");
+ }
+ }
+ }
+ }
+}
+
+void MgAdapt::checkFieldName(std::string fileIn)
+{
+ bool ret = false ;
+ std::vector<std::string> listFieldsNames = getListFieldsNames(fileIn);
+ std::size_t jaux(listFieldsNames.size());
+ for(std::size_t j=0;j<jaux;j++)
+ {
+ if ( fieldName == listFieldsNames[j] )
+ {
+ ret = true ;
+ break ;
+ }
+ }
+ if ( ! ret )
+ {
+ std::cout << "Available field names:" << std::endl;
+ for(std::size_t j=0;j<jaux;j++)
+ { std::cout << listFieldsNames[j] << std::endl;}
+ THROW_SALOME_EXCEPTION( "Field " << fieldName << " is not found.");
+ }
+}
+
+void MgAdapt::checkTimeStepRank(std::string fileIn)
+{
+ bool ret = false ;
+ MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileIn);
+ MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts( mfd->getFields()->getFieldWithName(fieldName) );
+ std::vector<double> timevalue;
+ std::vector< std::pair<int,int> > timesteprank = fts->getTimeSteps(timevalue);
+ std::size_t jaux(timesteprank.size());
+ for(std::size_t j=0;j<jaux;j++)
+ {
+ if ( ( timeStep == timesteprank[j].first ) & ( rank == timesteprank[j].second ) )
+ {
+ ret = true ;
+ break ;
+ }
+ }
+ if ( ! ret )
+ {
+ std::cout << "Available (Time step, Rank):" << std::endl;
+ for(std::size_t j=0;j<jaux;j++)
+ { std::cout << "(Time step = " << timesteprank[j].first << ", Rank = " << timesteprank[j].second << ")" << std::endl;}
+ THROW_SALOME_EXCEPTION("(Time step = " << timeStep << ", Rank = " << rank << ") is not found.");
+ }
+}