714{
715 std::string extTasksFile = _tasksFile;
716 std::string extMechanicsFile = _mechanicsFile;
717 std::string extDefaultsFile = _defaultsFile;
718 std::string extSwitchersFile = _switchersFile;
719
720 if (
724 )
725 {
726 std::stringstream tasksFile(
Preprocessor(extTasksFile).resultString);
727 std::stringstream defaultsFile(
Preprocessor(extDefaultsFile).resultString);
728 std::stringstream switchersFile(
Preprocessor(extSwitchersFile).resultString);
729 std::vector<std::string> taskFolder;
730
731 std::unique_ptr<StreamParser> parserTaskList;
732 parserTaskList.reset(
new StreamParser(
info,
"parser", tasksFile,
'(',
')'));
733
734 std::vector<std::string> alltasks;
735 parserTaskList->get("problems", alltasks);
736
737 std::ptrdiff_t nTasks = std::count_if(alltasks.begin(), alltasks.end(), [](const std::string& a) {return (a.length() > 0);});
739 info(
'i') <<
"Number of problems to be solved: " << nTasks << std::endl;
740
741 for (size_t i = 0; i < alltasks.size(); ++i)
742 {
743 if (alltasks[i].length() > 0)
744 {
745
747
748 std::string dir = taskLine.first;
749
751 info(
'i') <<
"-------- Loading problem #" << i <<
" (" << dir <<
") --------" << std::endl;
752
753
755
756
758 std::unique_ptr<StreamParser> parserTask;
759
760 parserTask.reset(
new StreamParser(
info,
"problem parameters", tskStream, defaultsFile, {
"pspfile",
"np",
"copyPath"}));
761
762 std::string pspFile;
763 int np;
764
765
768
769 if (np > 1)
770 {
772 info(
'e') <<
"Internal MPI-parallelization is not supported longer!" << std::endl;
773 exit(-1);
774 }
775
776 std::string copyPath;
778 if (copyPath.length() > 0)
779 {
780
782 {
783 std::string initDir(copyPath.begin(), copyPath.end());
784 std::string command;
785
786#if defined(_WIN32)
787 std::replace(dir.begin(), dir.end(), '/', '\\');
788 std::replace(initDir.begin(), initDir.end(), '/', '\\');
789#endif
790
792
793#if defined(_WIN32)
794 command = "copy \"" + initDir + "\\*.*\" "+ dir + "\\";
795#else
796 command = "cp ./" + initDir + "/* " + dir + "/";
797#endif
798
799 std::cout << "Copying files from folder \"" << initDir << "\" to \"" << dir << "\"" << std::endl;
800
801 int systemRet = system(command.c_str());
802 if(systemRet == -1)
803 {
804
805 info(
'e') <<
"problem #" << i <<
" (" << dir << \
806 ") copying passport system method failed" << std::endl;
807 exit(-1);
808 }
809 std::cout << "Copying OK " << std::endl << std::endl;
810
811
812 }
813 }
814
815#ifdef USE_MPI
816 MPI_Barrier(MPI_COMM_WORLD);
817#endif
818
819 std::unique_ptr<PassportGen> ptrPsp;
820
821#ifdef CODE2D
822 ptrPsp.reset(
new VM2D::Passport(
info, dir, i,
"./" + dir +
"/" + pspFile, extMechanicsFile, extDefaultsFile, extSwitchersFile, vecTaskLineSecond, {
""}));
823#endif
824
825#ifdef CODE3D
826 ptrPsp.reset(
new VM3D::Passport(
info, dir, i, pspFile, extMechanicsFile, extDefaultsFile, extSwitchersFile, vecTaskLineSecond));
827#endif
828
829 AddTask(np, std::move(ptrPsp));
830
831 info(
'i') <<
"-------- Problem #" << i <<
" (" << dir <<
") is loaded --------" << std::endl << std::endl;
832 }
833 }
834
835
836 tasksFile.clear();
837
838
839 defaultsFile.clear();
840
841
842 switchersFile.clear();
843
844 }
845 else
846 {
847 exit(1);
848 }
849
850}
Класс, опеделяющий паспорт двумерной задачи
void endl()
Вывод в поток логов пустой строки
Класс, позволяющий выполнять предварительную обработку файлов
void AddTask(int _nProc, std::unique_ptr< PassportGen > _passport)
Добавление задачи в список
Класс, позволяющий выполнять разбор файлов и строк с настройками и параметрами
static std::vector< std::string > StringToVector(std::string line, char openBracket='(', char closeBracket=')')
Pазбор строки, содержащей запятые, на отдельные строки
static std::pair< std::string, std::string > SplitString(LogStream &info, std::string line, bool upcase=true)
Разбор строки на пару ключ-значение
static std::string VectorStringToString(const std::vector< std::string > &_vecString)
Объединение вектора (списка) из строк в одну строку
void CreateUserDirectory(const std::string &dir, const std::string &name)
Создание каталога
bool fileExistTest(std::string &fileName, LogStream &info, bool exitKey=false, const std::list< std::string > &extList={})
Проверка существования файла
const int defaultNp
Необходимое число процессоров для решения задачи
const std::string defaultCopyPath
Путь к каталогу с задачей для копирования в новые каталоги
const std::string defaultPspFile
Имя файла с паспортом задачи