1 /*****************************************************************************
2  *                                                                           *
3  *  Elmer, A Finite Element Software for Multiphysical Problems              *
4  *                                                                           *
5  *  Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland    *
6  *                                                                           *
7  *  This program is free software; you can redistribute it and/or            *
8  *  modify it under the terms of the GNU General Public License              *
9  *  as published by the Free Software Foundation; either version 2           *
10  *  of the License, or (at your option) any later version.                   *
11  *                                                                           *
12  *  This program is distributed in the hope that it will be useful,          *
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
15  *  GNU General Public License for more details.                             *
16  *                                                                           *
17  *  You should have received a copy of the GNU General Public License        *
18  *  along with this program (in file fem/GPL-2); if not, write to the        *
19  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,         *
20  *  Boston, MA 02110-1301, USA.                                              *
21  *                                                                           *
22  *****************************************************************************/
23 
24 /*****************************************************************************
25  *                                                                           *
26  *  ElmerGUI parallel control                                                *
27  *                                                                           *
28  *****************************************************************************
29  *                                                                           *
30  *  Authors: Mikko Lyly, Juha Ruokolainen and Peter R�back                   *
31  *  Email:   Juha.Ruokolainen@csc.fi                                         *
32  *  Web:     http://www.csc.fi/elmer                                         *
33  *  Address: CSC - IT Center for Science Ltd.                                 *
34  *           Keilaranta 14                                                   *
35  *           02101 Espoo, Finland                                            *
36  *                                                                           *
37  *  Original Date: 15 Mar 2008                                               *
38  *                                                                           *
39  *****************************************************************************/
40 
41 #include <QtGui>
42 #include <iostream>
43 #include "parallel.h"
44 
45 #if WITH_QT5
46 #include <QtWidgets>
47 #endif
48 
49 using namespace std;
50 
Parallel(QWidget * parent)51 Parallel::Parallel(QWidget *parent)
52   : QDialog(parent)
53 {
54   ui.setupUi(this);
55 
56   connect(ui.browseButton, SIGNAL(clicked()),
57 	  this, SLOT(browseButtonClicked()));
58 
59   connect(ui.defaultsButton, SIGNAL(clicked()),
60 	  this, SLOT(defaultsButtonClicked()));
61 
62   connect(ui.okButton, SIGNAL(clicked()),
63 	  this, SLOT(okButtonClicked()));
64 
65   defaultsButtonClicked();
66 
67   setWindowIcon(QIcon(":/icons/Mesh3D.png"));
68 }
69 
~Parallel()70 Parallel::~Parallel()
71 {
72 }
73 
browseButtonClicked()74 void Parallel::browseButtonClicked()
75 {
76   QString fileName = QFileDialog::getOpenFileName(this);
77 
78   if(fileName.isEmpty())
79     return;
80 
81   ui.parallelExecLineEdit->setText(fileName);
82 }
83 
defaultsButtonClicked()84 void Parallel::defaultsButtonClicked()
85 {
86   ui.parallelActiveCheckBox->setChecked(false);
87   ui.skipPartitioningCheckBox->setChecked(false);
88   ui.nofProcessorsSpinBox->setValue(2);
89 
90 #ifdef WIN32
91   ui.parallelExecLineEdit->setText("C:/Program Files/MPICH2/bin/mpiexec.exe");
92   ui.parallelArgsLineEdit->setText("-localonly %n -genvlist PATH,ELMER_HOME ElmerSolver_mpi.exe");
93 #else
94   ui.parallelExecLineEdit->setText("mpirun");
95   ui.parallelArgsLineEdit->setText("-np %n ElmerSolver_mpi");
96 #endif
97 
98   ui.divideLineEdit->setText("ElmerGrid 2 2 %msh -metis %n");
99   ui.mergeLineEdit->setText("ElmerGrid 15 3 %ep -partjoin %n");
100 }
101 
okButtonClicked()102 void Parallel::okButtonClicked()
103 {
104   this->close();
105 }
106 
appendToProject(QDomDocument * projectDoc,QDomElement * item)107 void Parallel::appendToProject(QDomDocument *projectDoc, QDomElement *item)
108 {
109   projectIO.parentWidget = this;
110   projectIO.appendToProject(projectDoc, item);
111 }
112 
readFromProject(QDomDocument * projectDoc,QDomElement * item)113 void Parallel::readFromProject(QDomDocument *projectDoc, QDomElement *item)
114 {
115   projectIO.parentWidget = this;
116   projectIO.readFromProject(projectDoc, item);
117 }
118