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 sifgenerator                                                    *
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 #ifndef SIFGENERATOR_H
42 #define SIFGENERATOR_H
43 
44 #include <QTextEdit>
45 #include <QHash>
46 #include <QMap>
47 #include <QScriptEngine>
48 
49 #include "meshtype.h"
50 #include "maxlimits.h"
51 #include "generalsetup.h"
52 #include "boundarypropertyeditor.h"
53 #include "bodypropertyeditor.h"
54 #include "solverparameters.h"
55 #include "meshcontrol.h"
56 #include "dynamiceditor.h"
57 
58 enum EquationTypes {
59   HEAT_EQUATION,
60   LINEAR_ELASTICITY,
61   NAVIER_STOKES,
62   ADVECTION_DIFFUSION,
63   HELMHOLTZ_EQUATION
64 };
65 
66 class SifGenerator  {
67  public:
68   SifGenerator();
69   ~SifGenerator();
70 
71   void setMesh(mesh_t *mesh);
72   void setTextEdit(QTextEdit *textEdit);
73   void setDim(int dim);
74   void setCdim(int cdim);
75   void setElmerDefs(QDomDocument *doc);
76   void setGeneralSetup(GeneralSetup *setup);
77   void setEquationEditor(const QVector<DynamicEditor*> &d);
78   void setMaterialEditor(const QVector<DynamicEditor*> &d);
79   void setBodyForceEditor(const QVector<DynamicEditor*> &d);
80   void setInitialConditionEditor(const QVector<DynamicEditor*> &d);
81   void setBoundaryConditionEditor(const QVector<DynamicEditor*> &d);
82   void setSolverParameterEditor(const QVector<SolverParameterEditor*> &d);
83   void setBoundaryPropertyEditor(const QVector<BoundaryPropertyEditor*> &d);
84   void setBodyPropertyEditor(const QVector<BodyPropertyEditor*> &d);
85   void setMeshControl(MeshControl *meshControl);
86   void setLimit(Limit *limit);
87 
88   void makeHeaderBlock();
89   void makeSimulationBlock();
90   void makeConstantsBlock();
91   void makeBodyBlocks();
92   void makeEquationBlocks();
93   void makeSolverBlocks(const QString &name);
94   void makeMaterialBlocks();
95   void makeBodyForceBlocks();
96   void makeInitialConditionBlocks();
97   void makeBoundaryBlocks();
98 
99   QMap<int, int> bodyMap;// QHash<int, int> bodyMap;
100   QMap<int, int> boundaryMap;// QHash<int, int> boundaryMap;
101 
102  private:
103   mesh_t* mesh;
104   QTextEdit* te;
105   int dim, cdim;
106   QDomDocument* elmerDefs;
107   GeneralSetup* generalSetup;
108   QVector<DynamicEditor*> equationEditor;
109   QVector<DynamicEditor*> materialEditor;
110   QVector<DynamicEditor*> bodyForceEditor;
111   QVector<DynamicEditor*> initialConditionEditor;
112   QVector<DynamicEditor*> boundaryConditionEditor;
113   QVector<SolverParameterEditor*> solverParameterEditor;
114   QVector<BoundaryPropertyEditor*> boundaryPropertyEditor;
115   QVector<BodyPropertyEditor*> bodyPropertyEditor;
116   MeshControl *meshControl;
117   Limit *limit;
118 
119   int  findHashValue(DynamicEditor*, const QString&, const QString&);
120   bool parseSolverSpecificTab(DynamicEditor *, const QString&);
121   void parseExecSolverTab(Ui::solverParameterEditor);
122   void parseNumericalTechniquesTab(Ui::solverParameterEditor);
123   void parseSteadyStateTab(Ui::solverParameterEditor);
124   void parseNonlinearSystemTab(Ui::solverParameterEditor);
125   void parseLinearSystemTab(Ui::solverParameterEditor);
126   void parseParallelTab(Ui::solverParameterEditor);
127   void addSifLine(const QString&, const QString&);
128   void addSifLineBool(const QString&, bool);
129   void handleBCLineEdit(const QDomElement&, QWidget*, const QMap<int, int>&);
130   void handleLineEdit(const QDomElement&, QWidget*);
131   void handleComboBox(const QDomElement&, QWidget*);
132   void handleCheckBox(const QDomElement&, QWidget*);
133   void handleTextEdit(const QDomElement&, QWidget*);
134 };
135 
136 #endif // SIFGENERATOR_H
137