Whole lotta further
This commit is contained in:
parent
34e7c645e4
commit
e8421df13e
6
.gitignore
vendored
6
.gitignore
vendored
@ -6,6 +6,12 @@ nonlinPYTHON_wrap.cxx
|
||||
*.a
|
||||
*.dll
|
||||
*.pyd
|
||||
*.moc
|
||||
*.moc_parameters
|
||||
ui_*.h
|
||||
moc_*.cpp
|
||||
*.pb.*
|
||||
*_automoc.cpp
|
||||
__pycache__
|
||||
cmake_install.cmake
|
||||
doc/html
|
||||
|
@ -1,5 +1,5 @@
|
||||
# CMakeList.txt for TaSMET
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
cmake_minimum_required (VERSION 3.6)
|
||||
project(TaSMET)
|
||||
set(PACKAGE_VERSION 0.1)
|
||||
message("Running Cmake for TaSMET version ${PACKAGE_VERSION}")
|
||||
@ -19,12 +19,24 @@ add_definitions(-DTASMET_DEBUG=1)
|
||||
#====================================================
|
||||
|
||||
# Always required make flags in case of both compilers
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pipe -fPIC -Wfatal-errors -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable ")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pipe -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable ")
|
||||
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wfatal-errors -pipe -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable ")
|
||||
#========Qt5 Stuff ==================================
|
||||
find_package(Qt5Widgets)
|
||||
find_package(Qt5Core)
|
||||
find_package(Protobuf REQUIRED)
|
||||
# Add the include directories for the Qt 5 Widgets module to
|
||||
# the compile lines.
|
||||
include_directories(${Qt5Widgets_INCLUDE_DIRS})
|
||||
|
||||
# Use the compile definitions defined in the Qt 5 Widgets module
|
||||
add_definitions(${Qt5Widgets_DEFINITIONS})
|
||||
|
||||
# Stop letting Numpy complain about its API
|
||||
add_definitions(-DNPY_NO_DEPRECATED_API=NPY_1_4_API_VERSION)
|
||||
|
||||
# Add compiler flags for building executables (-fPIE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
#==================================================
|
||||
# Optimized code flags *******************************************
|
||||
#==================================================
|
||||
@ -75,6 +87,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake_tools)
|
||||
# Python #####################
|
||||
# ##########################
|
||||
|
||||
include_directories(/usr/include/PythonQt)
|
||||
|
||||
|
||||
if(TaSMET_PY_VERSION)
|
||||
# Find major version from version string
|
||||
set(PYTHON_LIBRARY "/usr/lib/libpython${TaSMET_PY_VERSION}.so")
|
||||
@ -111,3 +126,7 @@ include_directories(
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(testing)
|
||||
|
||||
# add_executable(tasmet src/main.cpp src/main.moc)
|
||||
add_executable(tasmet src/main.cpp)
|
||||
target_link_libraries(tasmet tasmet_gui tasmet_src messages PythonQt Qt5::Widgets)
|
||||
|
||||
|
@ -6,6 +6,7 @@ include_directories(
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${ARMADILLO_INCLUDE_DIRS}
|
||||
.
|
||||
protobuf
|
||||
# duct
|
||||
# duct/cell
|
||||
# duct/connectors
|
||||
@ -29,6 +30,8 @@ add_library(tasmet_src
|
||||
tasmet_exception.cpp
|
||||
tasmet_assert.cpp
|
||||
|
||||
duct/grid.cpp
|
||||
|
||||
funcs/bessel.cpp
|
||||
funcs/cbessj.cpp
|
||||
funcs/rottfuncs.cpp
|
||||
@ -56,29 +59,6 @@ add_library(tasmet_src
|
||||
sys/tasystem.cpp
|
||||
sys/triplets.cpp
|
||||
)
|
||||
|
||||
# set_source_files_properties(swig/nonlin.i
|
||||
# PROPERTIES CPLUSPLUS ON)
|
||||
# swig_add_module(TaSMET python swig/nonlin.i)
|
||||
|
||||
# set(SWIG_MODULE_TaSMET_FILE_nonlin_EXTRA_DEPS
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/common/swig_files/arma_numpy.i
|
||||
# )
|
||||
# swig_link_libraries(TaSMET tasmet_src common ${PYTHON_LIBRARIES}
|
||||
# ${ARMADILLO_LIBRARIES})
|
||||
|
||||
# set_source_files_properties( ${swig_generated_file_fullname}
|
||||
# PROPERTIES COMPILE_FLAGS "${SWIG_COMMON_COMPILE_FLAGS} ")
|
||||
|
||||
# Install swig files to the right place
|
||||
# install(TARGETS _TaSMET
|
||||
# DESTINATION ${PYTHON_SITE_PACKAGES}/${PROJECT_NAME})
|
||||
# install(FILES ${CMAKE_BINARY_DIR}/src/TaSMET.py
|
||||
# DESTINATION ${PYTHON_SITE_PACKAGES}/${PROJECT_NAME})
|
||||
# install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/python/__init__.py
|
||||
# DESTINATION ${PYTHON_SITE_PACKAGES}/${PROJECT_NAME})
|
||||
# install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/post
|
||||
# DESTINATION ${PYTHON_SITE_PACKAGES}/${PROJECT_NAME})
|
||||
# install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/gui
|
||||
# DESTINATION ${PYTHON_SITE_PACKAGES}/${PROJECT_NAME})
|
||||
|
||||
add_subdirectory(gui)
|
||||
add_subdirectory(protobuf)
|
||||
|
50
src/duct/grid.cpp
Normal file
50
src/duct/grid.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "grid.h"
|
||||
#include "tasmet_tracer.h"
|
||||
#include "tasmet_exception.h"
|
||||
#include "tasmet_constants.h"
|
||||
#include <sstream>
|
||||
|
||||
LinearGrid::LinearGrid(us ngp,d L):
|
||||
ngp(ngp),
|
||||
L(L)
|
||||
{
|
||||
std::stringstream error;
|
||||
if(ngp<constants::min_ngp) {
|
||||
error << "Number of gridpoints is lower than minimum. Minimum is: ";
|
||||
error << constants::min_ngp;
|
||||
throw TaSMETError(error);
|
||||
}
|
||||
else if(ngp>constants::max_ngp) {
|
||||
error << "Maximum number of gridpoints exceeded. Maximum is: ";
|
||||
error << constants::max_ngp;
|
||||
throw TaSMETError(error);
|
||||
}
|
||||
if(L<=0){
|
||||
throw TaSMETError("Illegal length chosen.");
|
||||
}
|
||||
}
|
||||
BlGrid::BlGrid(d L,d dxb,d dxmid):
|
||||
L(L),dxb(dxb),dxmid(dxmid)
|
||||
{
|
||||
TRACE(15,"BlGrid::BlGrid()");
|
||||
if(L<=0 || dxb<=0 || dxmid < dxb){
|
||||
throw TaSMETError("Illegal length chosen.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vd BlGrid::getx() const {
|
||||
TRACE(15,"BlGrid::getx()");
|
||||
|
||||
d delta=2*acosh(sqrt(dxmid/dxb));
|
||||
|
||||
d dxdxi0=0.5*L*(delta/tanh(delta/2))*(1-tanh(delta/2));
|
||||
d dxi=dxb/dxdxi0;
|
||||
us N=ceil(1/dxi);
|
||||
|
||||
vd xi=linspace(0,1,N);
|
||||
|
||||
return L*0.5*(1+tanh(delta*(xi-0.5))/tanh(delta/2));
|
||||
|
||||
|
||||
}
|
40
src/duct/grid.h
Normal file
40
src/duct/grid.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#ifndef _GRID_H_
|
||||
#define _GRID_H_
|
||||
#include "tasmet_enum.h"
|
||||
#include "tasmet_types.h"
|
||||
|
||||
|
||||
class Grid{
|
||||
public:
|
||||
Grid& operator=(const Grid& g)=delete;
|
||||
virtual vd getx() const=0;
|
||||
virtual ~Grid(){}
|
||||
};
|
||||
|
||||
class LinearGrid: public Grid{
|
||||
us ngp;
|
||||
d L; // Length of the Duct
|
||||
public:
|
||||
LinearGrid(us ngp,d L);
|
||||
LinearGrid(const LinearGrid& g):LinearGrid(g.ngp,g.L){}
|
||||
vd getx() const {return linspace(0,L,ngp);}
|
||||
};
|
||||
|
||||
// Boundary layer grid.
|
||||
// L: length of grid
|
||||
// dxb: boundary layer grid spacing (minimal grid spacing)
|
||||
// xb: boundary layer tickness
|
||||
// dxmid: spacing in the middle part
|
||||
|
||||
|
||||
class BlGrid:public Grid{
|
||||
d L,dxb,dxmid;
|
||||
public:
|
||||
BlGrid(d L,d dxb,d dxmid);
|
||||
vd getx() const;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _GRID_H_ */
|
||||
|
9
src/gui/CMakeLists.txt
Normal file
9
src/gui/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
#================
|
||||
# The TaSMET GUI
|
||||
#================
|
||||
add_library(tasmet_gui
|
||||
mainwindow.cpp
|
||||
add_duct_dialog.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(tasmet_gui qcustomplot)
|
323
src/gui/add_duct_dialog.cpp
Normal file
323
src/gui/add_duct_dialog.cpp
Normal file
@ -0,0 +1,323 @@
|
||||
// add_duct_dialog.cpp
|
||||
//
|
||||
// last-edit-by: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "ui_add_duct_dialog.h"
|
||||
#include "add_duct_dialog.h"
|
||||
#include <PythonQt.h>
|
||||
#include <QSignalBlocker>
|
||||
#include <qcustomplot.h>
|
||||
#include "tasmet_constants.h"
|
||||
#include "tasmet_enum.h"
|
||||
#include "tasmet_tracer.h"
|
||||
#include "tasmet_assert.h"
|
||||
#include "tasmet_exception.h"
|
||||
#include "duct/grid.h"
|
||||
#include <QVector>
|
||||
#include "tasmet_qt.h"
|
||||
|
||||
DECLARE_ENUM(PreviewShow,CSArea,Porosity,HydraulicRadius,SolidTemperatureFunction)
|
||||
|
||||
|
||||
|
||||
AddDuctDialog::AddDuctDialog(const us id,const std::string& name,QWidget* parent):
|
||||
QDialog(parent),
|
||||
_dialog(new Ui::add_duct_dialog),
|
||||
_duct(pb::Duct::default_instance())
|
||||
{
|
||||
TRACE(15,"AddDuctDialog");
|
||||
_blocked = true;
|
||||
_dialog->setupUi(this);
|
||||
|
||||
_duct.set_id(id);
|
||||
_duct.set_name(name);
|
||||
|
||||
QString title = "Add/edit duct segment '";
|
||||
title += QString::fromStdString(name);
|
||||
title +="'";
|
||||
this->setWindowTitle(title);
|
||||
|
||||
|
||||
_plot = _dialog->plot;
|
||||
|
||||
// Put validators on pure numeric fields
|
||||
_dialog->L->setValidator(new QDoubleValidator(constants::min_L,
|
||||
constants::max_L,
|
||||
constants::field_decimals));
|
||||
_dialog->ngp->setValidator(new QIntValidator(constants::min_ngp,
|
||||
constants::max_ngp
|
||||
));
|
||||
_dialog->dxb->setValidator(new QDoubleValidator(1e-16,
|
||||
1e6,
|
||||
constants::field_decimals));
|
||||
|
||||
_dialog->dxmid->setValidator(new QDoubleValidator(1e-16,
|
||||
1e6,
|
||||
constants::field_decimals));
|
||||
|
||||
|
||||
for(const PreviewShow& t: PreviewShow_vec){
|
||||
_dialog->previewshow->addItem(PreviewShowToString(t));
|
||||
}
|
||||
|
||||
for(int cshape = pb::Cshape_MIN;cshape<=pb::Cshape_MAX;cshape++){
|
||||
_dialog->cshape->addItem(QString::fromStdString(Cshape_Name((pb::Cshape) cshape)));
|
||||
}
|
||||
_dialog->cshape->setCurrentIndex(0);
|
||||
|
||||
for(int SolidType = pb::SolidType_MIN;SolidType<=pb::SolidType_MAX;SolidType++){
|
||||
_dialog->solidtype->addItem(QString::fromStdString(SolidType_Name((pb::SolidType) SolidType)));
|
||||
}
|
||||
_dialog->solidtype->setCurrentIndex(0);
|
||||
|
||||
for(int HeatTransferModel = pb::HeatTransferModel_MIN;HeatTransferModel<=pb::HeatTransferModel_MAX;HeatTransferModel++){
|
||||
_dialog->htmodel->addItem(QString::fromStdString(HeatTransferModel_Name((pb::HeatTransferModel) HeatTransferModel)));
|
||||
}
|
||||
_dialog->htmodel->setCurrentIndex(0);
|
||||
|
||||
for(int DragModel = pb::DragModel_MIN;DragModel<=pb::DragModel_MAX;DragModel++){
|
||||
_dialog->dragmodel->addItem(QString::fromStdString(DragModel_Name((pb::DragModel) DragModel)));
|
||||
}
|
||||
_dialog->dragmodel->setCurrentIndex(0);
|
||||
|
||||
for(int SolidTemperatureModel = pb::SolidTemperatureModel_MIN;SolidTemperatureModel<=pb::SolidTemperatureModel_MAX;SolidTemperatureModel++){
|
||||
_dialog->stempmodel->addItem(QString::fromStdString(SolidTemperatureModel_Name((pb::SolidTemperatureModel) SolidTemperatureModel)));
|
||||
}
|
||||
_dialog->stempmodel->setCurrentIndex(0);
|
||||
for(int gridtype = pb::GridType_MIN;gridtype<=pb::GridType_MAX;gridtype++){
|
||||
_dialog->gridtype->addItem(QString::fromStdString(GridType_Name((pb::GridType) gridtype)));
|
||||
}
|
||||
_dialog->gridtype->setCurrentIndex(0);
|
||||
|
||||
// create a single graph in the QCP
|
||||
_plot->addGraph();
|
||||
|
||||
|
||||
_duct.set_length(constants::default_L);
|
||||
_duct.set_name("Unnamed");
|
||||
_duct.set_dxb(0.01);
|
||||
_duct.set_dxmid(0.1);
|
||||
_duct.set_gridtype(pb::Linear);
|
||||
_duct.set_ngp(constants::default_ngp);
|
||||
_duct.set_area("1.0+0*x/L");
|
||||
_duct.set_phi("1.0+0*x/L");
|
||||
_duct.set_rh("sqrt(1/pi)");
|
||||
_duct.set_cshape(pb::Cshape_MIN);
|
||||
_duct.set_solidtype(pb::SolidType_MIN);
|
||||
_duct.set_htmodel(pb::HeatTransferModel_MIN);
|
||||
_duct.set_dragmodel(pb::DragModel_MIN);
|
||||
_duct.set_stempfunc("293.15+0*x/L");
|
||||
_duct.set_stempmodel(pb::SolidTemperatureModel_MIN);
|
||||
|
||||
set(_duct);
|
||||
|
||||
TRACE(15,"end AddDuctDialog");
|
||||
_blocked = false;
|
||||
changed();
|
||||
}
|
||||
AddDuctDialog::~AddDuctDialog(){
|
||||
delete _dialog;
|
||||
}
|
||||
void AddDuctDialog::accept(){
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
void AddDuctDialog::reject(){
|
||||
QDialog::reject();
|
||||
}
|
||||
void AddDuctDialog::set(const pb::Duct& duct) {
|
||||
TRACE(15,"AddDuctDialog::set()");
|
||||
_duct = duct;
|
||||
_dialog->L->setText(QString::number(duct.length()));
|
||||
_dialog->ngp->setText(QString::number(duct.ngp()));
|
||||
_dialog->dxb->setText(QString::number(duct.dxb()));
|
||||
_dialog->dxmid->setText(QString::number(duct.dxmid()));
|
||||
_dialog->S->setText(QString::fromStdString(duct.area()));
|
||||
_dialog->phi->setText(QString::fromStdString(duct.phi()));
|
||||
_dialog->rh->setText(QString::fromStdString(duct.rh()));
|
||||
_dialog->cshape->setCurrentIndex((int) duct.cshape());
|
||||
_dialog->solidtype->setCurrentIndex((int) duct.solidtype());
|
||||
_dialog->gridtype->setCurrentIndex((int) duct.gridtype());
|
||||
_dialog->htmodel->setCurrentIndex((int) duct.htmodel());
|
||||
_dialog->dragmodel->setCurrentIndex((int) duct.dragmodel());
|
||||
_dialog->stempmodel->setCurrentIndex((int) duct.stempmodel());
|
||||
_dialog->stempfunc->setText(QString::fromStdString(duct.stempfunc()));
|
||||
}
|
||||
|
||||
class PyEvaluate {
|
||||
PythonQtObjectPtr _context;
|
||||
PythonQt* _pyqt;
|
||||
public:
|
||||
PyEvaluate(const std::string& fun_return) {
|
||||
|
||||
_pyqt = PythonQt::self();
|
||||
if(_pyqt->hadError()) {
|
||||
TRACE(15,"Previous error in script");
|
||||
_pyqt->handleError();
|
||||
_pyqt->clearError();
|
||||
}
|
||||
|
||||
_context = _pyqt->getMainModule();
|
||||
|
||||
|
||||
std::stringstream script;
|
||||
// script << "print(\"hoi\")\n";
|
||||
script << "def myfun(x,L):\n return ";
|
||||
script << fun_return << "\n";
|
||||
|
||||
_context.evalScript(QString::fromStdString(script.str()));
|
||||
|
||||
if(_pyqt->hadError()) {
|
||||
_pyqt->clearError();
|
||||
throw TaSMETError("Script error");
|
||||
}
|
||||
|
||||
}
|
||||
vd operator()(const d L,const vd& x) {
|
||||
|
||||
vd y(x.size());
|
||||
|
||||
QVariant res;
|
||||
|
||||
for(us i=0;i<x.size();i++) {
|
||||
|
||||
QVariantList args;
|
||||
args << x(i) << L;
|
||||
|
||||
res = _context.call("myfun",args);
|
||||
y(i) = res.toDouble();
|
||||
|
||||
if(_pyqt->hadError()) {
|
||||
_pyqt->clearError();
|
||||
throw TaSMETError("Script error");
|
||||
}
|
||||
}
|
||||
return y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
void AddDuctDialog::changed(){
|
||||
TRACE(15,"AddDuctDialog::changed()");
|
||||
|
||||
// Early return when constructor is still running
|
||||
if(_blocked) return;
|
||||
|
||||
_duct.set_length(_dialog->L->text().toFloat());
|
||||
_duct.set_ngp(_dialog->ngp->text().toInt());
|
||||
_duct.set_dxb(_dialog->dxb->text().toFloat());
|
||||
_duct.set_dxmid(_dialog->dxmid->text().toFloat());
|
||||
_duct.set_area(_dialog->S->text().toStdString());
|
||||
_duct.set_phi(_dialog->phi->text().toStdString());
|
||||
_duct.set_rh(_dialog->rh->text().toStdString());
|
||||
_duct.set_cshape((pb::Cshape) _dialog->cshape->currentIndex());
|
||||
_duct.set_solidtype((pb::SolidType) _dialog->solidtype->currentIndex());
|
||||
_duct.set_gridtype((pb::GridType) _dialog->gridtype->currentIndex());
|
||||
_duct.set_htmodel((pb::HeatTransferModel) _dialog->htmodel->currentIndex());
|
||||
_duct.set_dragmodel((pb::DragModel) _dialog->dragmodel->currentIndex());
|
||||
_duct.set_stempmodel((pb::SolidTemperatureModel) _dialog->stempmodel->currentIndex());
|
||||
_duct.set_stempfunc(_dialog->stempfunc->text().toStdString());
|
||||
|
||||
// Empty the graph
|
||||
_plot->graph(0)->setData(QVector<d>(),QVector<d>());
|
||||
|
||||
std::unique_ptr<Grid> grid;
|
||||
|
||||
switch (_duct.gridtype()) {
|
||||
case pb::Linear:
|
||||
try {
|
||||
grid = std::unique_ptr<Grid>(new LinearGrid(_duct.ngp(),_duct.length()));
|
||||
}
|
||||
catch(...) {
|
||||
return;
|
||||
}
|
||||
_dialog->ngp->setEnabled(true);
|
||||
_dialog->dxb->setEnabled(false);
|
||||
_dialog->dxmid->setEnabled(false);
|
||||
break;
|
||||
case pb::BlGrid:
|
||||
|
||||
try {
|
||||
grid = std::unique_ptr<Grid>(new BlGrid(_duct.length(),
|
||||
_duct.dxb(),
|
||||
_duct.dxmid()));
|
||||
}
|
||||
catch(...) {
|
||||
return;
|
||||
}
|
||||
_duct.clear_ngp();
|
||||
_dialog->ngp->setEnabled(false);
|
||||
_dialog->dxb->setEnabled(true);
|
||||
_dialog->dxmid->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
vd x = grid->getx();
|
||||
vd y;
|
||||
|
||||
PreviewShow pshow = (PreviewShow) _dialog->previewshow->currentIndex();
|
||||
|
||||
std::string pyeval_return_type;
|
||||
|
||||
switch (pshow) {
|
||||
case CSArea:
|
||||
pyeval_return_type = _duct.area();
|
||||
_plot->yAxis->setLabel("S [m^2]");
|
||||
break;
|
||||
case Porosity:
|
||||
pyeval_return_type = _duct.phi();
|
||||
_plot->yAxis->setLabel("phi [-]");
|
||||
break;
|
||||
case HydraulicRadius:
|
||||
pyeval_return_type = _duct.rh();
|
||||
_plot->yAxis->setLabel("rh [m]");
|
||||
break;
|
||||
case SolidTemperatureFunction:
|
||||
pyeval_return_type = _duct.stempfunc();
|
||||
_plot->yAxis->setLabel("Ts [K]");
|
||||
break;
|
||||
default:
|
||||
tasmet_assert(false,"Unhandled PreviewShow case");
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
PyEvaluate pyeval(pyeval_return_type);
|
||||
y = pyeval(_duct.length(),x);
|
||||
|
||||
}
|
||||
catch(TaSMETError& e) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<d> qx = from_arma(x);
|
||||
QVector<d> qy = from_arma(y);
|
||||
|
||||
// Assumes graph 0 exists
|
||||
_plot->graph(0)->setData(qx, qy);
|
||||
// give the axes some labels:
|
||||
_plot->xAxis->setLabel("x [m]");
|
||||
|
||||
// set axes ranges, so we see all data:
|
||||
_plot->xAxis->setRange(0, _duct.length());
|
||||
|
||||
d max = arma::max(y);
|
||||
d min = arma::min(y);
|
||||
|
||||
_plot->yAxis->setRange(0,max+max/10);
|
||||
VARTRACE(15,min);
|
||||
VARTRACE(15,max);
|
||||
// _plot->yAxis->setRange(0, 1);
|
||||
_plot->replot();
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
64
src/gui/add_duct_dialog.h
Normal file
64
src/gui/add_duct_dialog.h
Normal file
@ -0,0 +1,64 @@
|
||||
// add_duct_dialog.h
|
||||
//
|
||||
// Author: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#ifndef ADD_DUCT_DIALOG_H
|
||||
#define ADD_DUCT_DIALOG_H
|
||||
#include <QDialog>
|
||||
#include <memory>
|
||||
#include "duct.pb.h"
|
||||
#include "tasmet_types.h"
|
||||
|
||||
namespace Ui{
|
||||
class add_duct_dialog;
|
||||
}
|
||||
class QCustomPlot;
|
||||
class Grid;
|
||||
|
||||
class AddDuctDialog: public QDialog {
|
||||
|
||||
Q_OBJECT
|
||||
Ui::add_duct_dialog *_dialog;
|
||||
QCustomPlot* _plot;
|
||||
pb::Duct _duct;
|
||||
bool _blocked = false;
|
||||
public:
|
||||
AddDuctDialog(const us id,const std::string& name,QWidget* parent = nullptr);
|
||||
~AddDuctDialog();
|
||||
private slots:
|
||||
void accept();
|
||||
void reject();
|
||||
|
||||
void on_L_textEdited() {changed();}
|
||||
void on_S_textEdited() {changed();}
|
||||
void on_phi_textEdited() {changed();}
|
||||
void on_rh_textEdited() {changed();}
|
||||
void on_cshape_currentIndexChanged(int) {changed();}
|
||||
void on_solidtype_currentIndexChanged(int) {changed();}
|
||||
|
||||
void on_gridtype_currentIndexChanged(int) {changed();}
|
||||
void on_ngp_textEdited() {changed();}
|
||||
void on_dxb_textEdited() {changed();}
|
||||
void on_dxmid_textEdited() {changed();}
|
||||
|
||||
void on_htmodel_currentIndexChanged(int) {changed();}
|
||||
void on_stempfunc_textEdited() {changed();}
|
||||
void on_stempmodel_currentIndexChanged(int) {changed();}
|
||||
|
||||
void on_previewshow_currentIndexChanged(int) {changed();}
|
||||
private:
|
||||
// Called whenever the user changes a field
|
||||
void changed();
|
||||
void set(const pb::Duct&);
|
||||
const pb::Duct& get() const {return _duct; }
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // ADD_DUCT_DIALOG_H
|
||||
//////////////////////////////////////////////////////////////////////
|
396
src/gui/add_duct_dialog.ui
Normal file
396
src/gui/add_duct_dialog.ui
Normal file
@ -0,0 +1,396 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>add_duct_dialog</class>
|
||||
<widget class="QDialog" name="add_duct_dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>841</width>
|
||||
<height>876</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Add/edit duct</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="geometry_groupbox">
|
||||
<property name="title">
|
||||
<string>Geometry</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="L">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Length (L): </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="S">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>[-]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="cshape"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="phi">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>Cross-sectional area function:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>[m]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="text">
|
||||
<string>Cross sectional shape</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="text">
|
||||
<string>Porosity function:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="text">
|
||||
<string>[m^2]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="text">
|
||||
<string>Solid type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="solidtype"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Hydraulic radius: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="rh">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>[m]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Preview options</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="previewshow"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_37">
|
||||
<property name="text">
|
||||
<string>Show: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Model</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="text">
|
||||
<string>Drag model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_25">
|
||||
<property name="text">
|
||||
<string>Heat transfer model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="htmodel"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="stempfunc">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_28">
|
||||
<property name="text">
|
||||
<string>Solid temperature function</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="dragmodel"/>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="text">
|
||||
<string>[K]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_30">
|
||||
<property name="text">
|
||||
<string>Solid temperature model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="stempmodel"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="dxmid"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_31">
|
||||
<property name="text">
|
||||
<string>Number of gridpoints</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_27">
|
||||
<property name="text">
|
||||
<string>Grid type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="ngp"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_32">
|
||||
<property name="text">
|
||||
<string>Mid-tube grid spacing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="gridtype"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="dxb"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="text">
|
||||
<string>Boundary grid spacing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_34">
|
||||
<property name="text">
|
||||
<string>[-]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_35">
|
||||
<property name="text">
|
||||
<string>[m]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="text">
|
||||
<string>[m]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="preview_groupbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCustomPlot" name="plot" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QCustomPlot</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qcustomplot.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>add_duct_dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>add_duct_dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
76
src/gui/mainwindow.cpp
Normal file
76
src/gui/mainwindow.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
// mainwindow.cpp
|
||||
//
|
||||
// last-edit-by: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "tasmet_config.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QString>
|
||||
#include <QSettings>
|
||||
#include <QWidget>
|
||||
#include <QDoubleValidator>
|
||||
#include <QIntValidator>
|
||||
#include "gas.h"
|
||||
#include "tasmet_tracer.h"
|
||||
#include "add_duct_dialog.h"
|
||||
|
||||
TaSMETMainWindow::TaSMETMainWindow():
|
||||
window(new Ui::MainWindow())
|
||||
{
|
||||
|
||||
window->setupUi(this);
|
||||
|
||||
// Restore settings
|
||||
QSettings settings(company,appname);
|
||||
restoreGeometry(settings.value("geometry").toByteArray());
|
||||
restoreState(settings.value("windowState").toByteArray());
|
||||
|
||||
for(const SystemType& t: SystemType_vec){
|
||||
window->systemtype->addItem(SystemTypeToString(t));
|
||||
}
|
||||
for(const GasType& t: GasType_vec){
|
||||
window->gastype->addItem(GasTypeToString(t));
|
||||
}
|
||||
for(const SegmentType& t: SegmentType_vec){
|
||||
window->segmenttype->addItem(SegmentTypeToString(t));
|
||||
}
|
||||
|
||||
window->T0->setText(QString::number(constants::default_T0));
|
||||
window->T0->setValidator(new QDoubleValidator(constants::min_T0,
|
||||
constants::max_T0,
|
||||
constants::field_decimals));
|
||||
|
||||
window->p0->setText(QString::number(constants::default_p0));
|
||||
window->p0->setValidator(new QDoubleValidator(constants::min_p0,
|
||||
constants::max_p0,
|
||||
constants::field_decimals));
|
||||
|
||||
|
||||
|
||||
}
|
||||
TaSMETMainWindow::~TaSMETMainWindow(){
|
||||
delete window;
|
||||
}
|
||||
void TaSMETMainWindow::closeEvent(QCloseEvent *event) {
|
||||
|
||||
// Save window configuration to settings
|
||||
QSettings settings(company,appname);
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
settings.setValue("windowState", saveState());
|
||||
|
||||
// Forward close event to parent
|
||||
QMainWindow::closeEvent(event);
|
||||
|
||||
}
|
||||
void TaSMETMainWindow::on_addsegment_clicked() {
|
||||
|
||||
AddDuctDialog dialog(0,"hola",this);
|
||||
|
||||
int rv = dialog.exec();
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
37
src/gui/mainwindow.h
Normal file
37
src/gui/mainwindow.h
Normal file
@ -0,0 +1,37 @@
|
||||
// mainwindow.h
|
||||
//
|
||||
// Author: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
#include "tasmet_config.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class TaSMETMainWindow: public QMainWindow {
|
||||
Q_OBJECT
|
||||
Ui::MainWindow *window;
|
||||
public:
|
||||
TaSMETMainWindow();
|
||||
~TaSMETMainWindow();
|
||||
private slots:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void on_addsegment_clicked();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
439
src/gui/mainwindow.ui
Normal file
439
src/gui/mainwindow.ui
Normal file
@ -0,0 +1,439 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1124</width>
|
||||
<height>835</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="globalconf">
|
||||
<property name="title">
|
||||
<string>Global configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="T0">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>[Hz]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Number of harmonics: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="f">
|
||||
<property name="text">
|
||||
<string>100</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Reference temperature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Gas type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="Nf">
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="gastype"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>[-]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Fundamental frequency: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="systemtype"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>System type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>[K]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Reference pressure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="p0">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>[Pa]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="addseg">
|
||||
<property name="title">
|
||||
<string>Add/edit segment</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Segment type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="segmenttype"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Segment ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="segmentid_add">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="addsegment">
|
||||
<property name="text">
|
||||
<string>Add/edit segment...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Segment name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="name">
|
||||
<property name="text">
|
||||
<string>Unnamed segment</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="remseg">
|
||||
<property name="title">
|
||||
<string>Remove segment</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Segment ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="segmentid_remove"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="removesegment">
|
||||
<property name="text">
|
||||
<string>Remove segment...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Backlog</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_3">
|
||||
<property name="plainText">
|
||||
<string>Type your info here...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Segment overview</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="output">
|
||||
<property name="title">
|
||||
<string>Output</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Solve</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QPushButton" name="solve">
|
||||
<property name="text">
|
||||
<string>Solve...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="text">
|
||||
<string>Reinitialize solution</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>Postprocess...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1124</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>Fi&le</string>
|
||||
</property>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionNew">
|
||||
<property name="text">
|
||||
<string>&New</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="text">
|
||||
<string>&Open</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="text">
|
||||
<string>&Save</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>&Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
86
src/gui/solver.ui
Normal file
86
src/gui/solver.ui
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>747</width>
|
||||
<height>336</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="solversettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>306</width>
|
||||
<height>168</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Solver Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Maximum iterations:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Solver type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="solvertype"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="reltol">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Solution tolerance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Residual tolerance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="funtol">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="maxiter">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
33
src/gui/solver_dialog.h
Normal file
33
src/gui/solver_dialog.h
Normal file
@ -0,0 +1,33 @@
|
||||
// solver_dialog.h
|
||||
//
|
||||
// Author: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#ifndef SOLVER_DIALOG_H
|
||||
#define SOLVER_DIALOG_H
|
||||
|
||||
|
||||
// Put here, temporarily
|
||||
window->funtol->setText(QString::number(constants::default_funtol));
|
||||
window->funtol->setValidator(new QDoubleValidator(constants::min_funtol,
|
||||
constants::max_funtol,
|
||||
constants::field_decimals));
|
||||
window->reltol->setText(QString::number(constants::default_funtol));
|
||||
window->reltol->setValidator(new QDoubleValidator(constants::min_funtol,
|
||||
constants::max_funtol,
|
||||
constants::field_decimals));
|
||||
|
||||
window->maxiter->setText(QString::number(constants::default_maxiter));
|
||||
window->maxiter->setValidator(new QIntValidator(constants::min_maxiter,
|
||||
constants::max_maxiter));
|
||||
|
||||
for(const SolverType& t: SolverType_vec){
|
||||
window->solvertype->addItem(SolverTypeToString(t));
|
||||
}
|
||||
|
||||
|
||||
#endif // SOLVER_DIALOG_H
|
||||
//////////////////////////////////////////////////////////////////////
|
86
src/gui/solver_dialog.ui
Normal file
86
src/gui/solver_dialog.ui
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>747</width>
|
||||
<height>336</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="solversettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>306</width>
|
||||
<height>168</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Solver Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Maximum iterations:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Solver type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="solvertype"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="reltol">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Solution tolerance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Residual tolerance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="funtol">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="maxiter">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
91
src/main.cpp
Normal file
91
src/main.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
// main.cpp
|
||||
//
|
||||
// last-edit-by: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
// Main program to run
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
|
||||
// For using python from within Qt
|
||||
#include <PythonQt.h>
|
||||
|
||||
|
||||
#include "tasmet_config.h"
|
||||
#include "tasmet_tracer.h"
|
||||
#include "gui/mainwindow.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void catchUnixSignals(const std::vector<int>& quitSignals,
|
||||
const std::vector<int>& ignoreSignals = std::vector<int>()) {
|
||||
|
||||
auto handler = [](int sig) ->void {
|
||||
printf("\nquit the application (user request signal = %d).\n", sig);
|
||||
QCoreApplication::quit();
|
||||
};
|
||||
|
||||
// all these signals will be ignored.
|
||||
for ( int sig : ignoreSignals )
|
||||
signal(sig, SIG_IGN);
|
||||
|
||||
// each of these signals calls the handler (quits the QCoreApplication).
|
||||
for ( int sig : quitSignals )
|
||||
signal(sig, handler);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// This can be used to store files in the application. Very useful
|
||||
// when our application grows bigger
|
||||
// Q_INIT_RESOURCE(application);
|
||||
INITTRACE(15);
|
||||
|
||||
std::cout << "hoid" << std::endl;
|
||||
// Initialize PythonQt
|
||||
// PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
|
||||
PythonQt::init();
|
||||
std::cout << "hoid" << std::endl;
|
||||
PythonQt* pyqt = PythonQt::self();
|
||||
PythonQtObjectPtr context = pyqt->getMainModule();
|
||||
std::cout << "hoid" << std::endl;
|
||||
QVariant rv = context.evalScript("from math import *\n");
|
||||
if(pyqt->hadError()) {
|
||||
return -1;
|
||||
}
|
||||
std::cout << "hoid" << std::endl;
|
||||
// std::cout << rv.typeName() << std::endl;
|
||||
std::cout << (rv.isNull()?"true": "false") << std::endl;
|
||||
std::cout << "hoid" << std::endl;
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
catchUnixSignals({SIGQUIT, SIGINT, SIGTERM, SIGHUP});
|
||||
|
||||
// QCoreApplication::setOrganizationName("QtProject");
|
||||
QCoreApplication::setApplicationName(appname);
|
||||
QCoreApplication::setApplicationVersion(appversion);
|
||||
// QCommandLineParser parser;
|
||||
// parser.setApplicationDescription(QCoreApplication::applicationName());
|
||||
// parser.addHelpOption();
|
||||
// parser.addVersionOption();
|
||||
// parser.addPositionalArgument("file", "The file to open.");
|
||||
// parser.process(app);
|
||||
|
||||
// if (!parser.positionalArguments().isEmpty())
|
||||
// mainWin.loadFile(parser.positionalArguments().first());
|
||||
|
||||
|
||||
|
||||
TaSMETMainWindow win;
|
||||
|
||||
win.setWindowTitle("TaSMET UI");
|
||||
win.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
@ -31,6 +31,8 @@ public:
|
||||
d mu(d T,d p) const;
|
||||
d kappa(d T,d p) const;
|
||||
~Air(){}
|
||||
|
||||
Air* copy() const { return new Air(T0(),p0());}
|
||||
};
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
Gas* Gas::newGas(const GasType gastype,d T0,d p0) {
|
||||
|
||||
if(T0>constants::maxT || T0< constants::minT)
|
||||
if(T0>constants::max_T0 || T0< constants::min_T0)
|
||||
throw TaSMETError("Illegal reference temperature given");
|
||||
if(p0>constants::maxp || p0< constants::minp)
|
||||
if(p0>constants::max_p0 || p0< constants::min_p0)
|
||||
throw TaSMETError("Illegal reference pressure given");
|
||||
// End sanity checks
|
||||
|
||||
|
@ -20,9 +20,11 @@
|
||||
varname_ = varname(T(i),p(i));\
|
||||
return varname_
|
||||
|
||||
DECLARE_ENUM(GasType,air,helium,nitrogen);
|
||||
|
||||
class Gas{
|
||||
public:
|
||||
DECLARE_ENUM(GasType,air,helium,nitrogen);
|
||||
|
||||
private:
|
||||
GasType _gastype;
|
||||
protected:
|
||||
@ -35,10 +37,9 @@ public:
|
||||
virtual ~Gas(){}
|
||||
|
||||
// Static method to generate a Gas
|
||||
virtual Gas* copy() const = 0;
|
||||
|
||||
|
||||
static Gas* newGas(const GasType gastype,d T0=constants::T0,
|
||||
d p0=constants::p0);
|
||||
static Gas* newGas(const GasType gastype,d T0, d p0);
|
||||
|
||||
operator GasType() { return _gastype;}
|
||||
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
d mu(d T,d p) const;
|
||||
|
||||
d kappa(d T,d p) const;
|
||||
Helium* copy() const { return new Helium(T0(),p0());}
|
||||
|
||||
virtual ~Helium(){}
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ protected:
|
||||
d Rs() const {return 297;}
|
||||
public:
|
||||
Nitrogen(d T0,d p0):PerfectGas(nitrogen,T0,p0){}
|
||||
|
||||
Nitrogen* copy() const { return new Nitrogen(T0(),p0());}
|
||||
const vd& cpc() const { return _cpc; }
|
||||
d mu(d T,d p) const;
|
||||
d kappa(d T,d p) const;
|
||||
|
@ -6,10 +6,9 @@
|
||||
#include "tasmet_enum.h"
|
||||
|
||||
|
||||
DECLARE_ENUM(SolidType,stainless,stainless_hopkins,copper,kapton);
|
||||
|
||||
class Solid{
|
||||
public:
|
||||
DECLARE_ENUM(SolidType,stainless,stainless_hopkins,copper,kapton);
|
||||
private:
|
||||
SolidType _solidtype;
|
||||
protected:
|
||||
Solid(const SolidType);
|
||||
|
4
src/protobuf/CMakeLists.txt
Normal file
4
src/protobuf/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
file(GLOB ProtoFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.proto")
|
||||
PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
|
||||
add_library(messages STATIC ${ProtoSources} ${ProtoHeaders})
|
||||
target_link_libraries(messages ${PROTOBUF_LIBRARY})
|
50
src/protobuf/duct.proto
Normal file
50
src/protobuf/duct.proto
Normal file
@ -0,0 +1,50 @@
|
||||
syntax = "proto2";
|
||||
package pb;
|
||||
|
||||
enum SolidType {
|
||||
Stainless = 0;
|
||||
Copper = 1;
|
||||
}
|
||||
enum GridType {
|
||||
Linear = 0;
|
||||
BlGrid = 1;
|
||||
}
|
||||
enum HeatTransferModel {
|
||||
Isentropic = 0;
|
||||
LaminarHeatTransfer = 1;
|
||||
}
|
||||
enum DragModel {
|
||||
Inviscid = 0;
|
||||
LaminarDrag = 1;
|
||||
}
|
||||
enum Cshape {
|
||||
Blapprox = 0;
|
||||
Circ = 1;
|
||||
VertPlates = 2;
|
||||
}
|
||||
message Geom {
|
||||
}
|
||||
enum SolidTemperatureModel {
|
||||
Prescribed = 0;
|
||||
HeatBalance = 1;
|
||||
}
|
||||
|
||||
message Duct {
|
||||
required uint32 id = 1;
|
||||
required string name = 2;
|
||||
required double length = 3 [default = 1];
|
||||
optional uint32 ngp = 4 [default = 100];
|
||||
optional double dxb = 5 [default = 0.1];
|
||||
optional double dxmid = 6 [default = 0.01];
|
||||
required GridType gridtype = 8 [default = Linear];
|
||||
required string area = 9 [default="1+0*x/L"];
|
||||
required string phi = 10 [default = "1+0*x/L"];
|
||||
optional string rh = 11 [default = ""];
|
||||
required Cshape cshape = 12;
|
||||
required SolidType solidtype = 13;
|
||||
required HeatTransferModel htmodel = 14;
|
||||
required DragModel dragmodel = 15 [default = Inviscid];
|
||||
required string stempfunc = 16 [default = "293.15+x*x/L"];
|
||||
required SolidTemperatureModel stempmodel = 17 [default = Prescribed];
|
||||
|
||||
}
|
24
src/protobuf/system.proto
Normal file
24
src/protobuf/system.proto
Normal file
@ -0,0 +1,24 @@
|
||||
syntax = "proto2";
|
||||
package pb;
|
||||
|
||||
import duct;
|
||||
|
||||
enum SystemType {
|
||||
TaSystem = 0;
|
||||
}
|
||||
enum GasType {
|
||||
air = 0;
|
||||
helium = 1;
|
||||
nitrogen = 2;
|
||||
}
|
||||
message System {
|
||||
required SystemType systemtype = 1;
|
||||
required uint32 Nf = 2;
|
||||
required double freq = 3;
|
||||
required GasType gastype = 4;
|
||||
required double p0 = 5;
|
||||
required double T0 = 6;
|
||||
|
||||
repeated Duct ducts = 7;
|
||||
|
||||
}
|
23
src/solver/broyden.h
Normal file
23
src/solver/broyden.h
Normal file
@ -0,0 +1,23 @@
|
||||
// broyden.h
|
||||
//
|
||||
// Author: J.A. de Jong
|
||||
//
|
||||
// Description: Implementation of the Broyden solver, a gradient-free
|
||||
// nonlinear system solver
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#ifndef BROYDEN_H
|
||||
#define BROYDEN_H
|
||||
#include "solver.h"
|
||||
|
||||
|
||||
|
||||
class Broyden: public Solver<NoGradientNonlinearSystem<vd> >{
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // BROYDEN_H
|
||||
//////////////////////////////////////////////////////////////////////
|
@ -1,3 +1,10 @@
|
||||
// globalconf.cpp
|
||||
//
|
||||
// last-edit-by: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "globalconf.h"
|
||||
#include "tasmet_constants.h"
|
||||
#include "tasmet_exception.h"
|
||||
@ -65,4 +72,5 @@ void GlobalConf::setomg(d omg){
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -13,15 +13,15 @@
|
||||
#include "tasmet_exception.h"
|
||||
#include "tasmet_constants.h"
|
||||
|
||||
TaSystem::TaSystem(const GlobalConf& gc,Gas::GasType gastype):
|
||||
TaSystem::TaSystem(const GlobalConf& gc,const Gas& g):
|
||||
_gc(new GlobalConf(gc)),
|
||||
_gas(Gas::newGas(gastype))
|
||||
_gas(g.copy())
|
||||
{
|
||||
TRACE(14,"TaSystem::TaSystem(gc,gastype)");
|
||||
}
|
||||
TaSystem::TaSystem(const TaSystem& o):
|
||||
_gc(o._gc), // Share a ptr to the Global conf
|
||||
_gas(Gas::newGas(Gas::GasType(*o._gas)))
|
||||
_gas(o._gas->copy())
|
||||
{
|
||||
TRACE(25,"TaSystem::TaSystem(TaSystem&) copy");
|
||||
|
||||
|
@ -30,12 +30,12 @@ protected:
|
||||
TaSystem& operator=(const TaSystem& other)=delete;
|
||||
TaSystem(const TaSystem& o);
|
||||
public:
|
||||
TaSystem(const GlobalConf& g,Gas::GasType gastype);
|
||||
TaSystem(const GlobalConf& gc,const Gas& g);
|
||||
|
||||
// Set globalconf configuration. Applies updateNf as well.
|
||||
void setGc(const GlobalConf& gc);
|
||||
const Gas& getGas() const {return *_gas;}
|
||||
void setGas(Gas::GasType gastype);
|
||||
void setGas(const Gas& g);
|
||||
|
||||
// Set and get the mass in the system. If the mass is not set
|
||||
// before initializing, the mass is computed from the segment's
|
||||
|
@ -29,12 +29,13 @@ struct is_same<T, T> : std::true_type {};
|
||||
|
||||
void tasmet_assertfailed(const char* filename,size_t linenr,const char* statement);
|
||||
|
||||
#define tasmet_assert(assertion,txt) \
|
||||
if (!(assertion)) \
|
||||
{ \
|
||||
#define tasmet_assert(assertion,txt) \
|
||||
{ \
|
||||
if (!(assertion)) \
|
||||
{ \
|
||||
tasmet_assertfailed(__FILE__, __LINE__, txt ); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#else
|
||||
#define tasmet_assert(assertion,txt)
|
||||
|
30
src/tasmet_config.h
Normal file
30
src/tasmet_config.h
Normal file
@ -0,0 +1,30 @@
|
||||
// tasmet_config.h
|
||||
//
|
||||
// Author: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#ifndef TASMET_CONFIG_H
|
||||
#define TASMET_CONFIG_H
|
||||
#include <QString>
|
||||
#include "tasmet_enum.h"
|
||||
|
||||
const QString appname = "TaSMET Ui";
|
||||
const QString appversion = "1.0";
|
||||
const QString company = "None";
|
||||
|
||||
// DECLARE_ENUM(SYSTEM_TYPE,DrivenSystem,EngineSystem)
|
||||
DECLARE_ENUM(SystemType,Driven)
|
||||
|
||||
DECLARE_ENUM(SegmentType,Duct)
|
||||
|
||||
DECLARE_ENUM(SolverType,NewtonRaphson)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // TASMET_CONFIG_H
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -10,12 +10,9 @@
|
||||
#define CONSOLECOLORS_H
|
||||
#include <iostream>
|
||||
|
||||
#ifndef SWIG
|
||||
#define red "\e[31m"
|
||||
#define green "\e[32m"
|
||||
#define def " \e[39m"
|
||||
|
||||
#endif // SWIG
|
||||
#define RED_COLOR "\e[31m"
|
||||
#define GREEN_COLOR "\e[32m"
|
||||
#define DEFAULT_COLOR " \e[39m"
|
||||
|
||||
// Command to clear the content of a console
|
||||
inline void clearConsole(){
|
||||
|
@ -1,20 +1,19 @@
|
||||
// constants.h
|
||||
// tasmet_constants.h
|
||||
//
|
||||
// Author: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
// Definition of important constants
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Definition of code constants
|
||||
#pragma once
|
||||
#ifndef CONSTANTS_H
|
||||
#define CONSTANTS_H
|
||||
#ifndef TASMET_CONSTANTS_H
|
||||
#define TASMET_CONSTANTS_H
|
||||
#include "tasmet_enum.h"
|
||||
#include "tasmet_types.h"
|
||||
|
||||
template<typename T>
|
||||
T max(T t1,T t2) { return t1>t2?t1:t2;}
|
||||
T max(T& t1,T& t2) { return t1>t2?t1:t2;}
|
||||
template<typename T>
|
||||
T min(T t1,T t2) { return t1>t2?t2:t1;}
|
||||
T min(T& t1,T& t2) { return t1>t2?t2:t1;}
|
||||
|
||||
// Variables and their names
|
||||
// Unfortunately to let the code compile with Swig v 2.0, strongly
|
||||
@ -40,7 +39,7 @@ DECLARE_ENUM(Varnr,
|
||||
mEkin // Kinetic energy flow (Watts)
|
||||
);
|
||||
|
||||
DECLARE_ENUM(Pos,left=0,right=1);
|
||||
DECLARE_ENUM(Pos,posleft,posright);
|
||||
|
||||
DECLARE_ENUM(EqType,
|
||||
Con, // Continuity
|
||||
@ -63,9 +62,10 @@ namespace constants {
|
||||
|
||||
typedef unsigned us;
|
||||
|
||||
const us mingp=4; // Minimum number of gridpoints
|
||||
const us maxgp=3000; // Maximum number of gridpoints
|
||||
|
||||
const us min_ngp=4; // Minimum number of gridpoints
|
||||
const us max_ngp=3000; // Maximum number of gridpoints
|
||||
const us default_ngp = 100;
|
||||
|
||||
const us maxNf=100; // Maximum number of frequencies
|
||||
const d minomg=1e-3; // Minimal oscillation frequency
|
||||
const d maxomg=1e5;
|
||||
@ -73,13 +73,31 @@ namespace constants {
|
||||
const int maxsegs=30; // Maximum number of segments in a TaSystem
|
||||
const int maxndofs=600000; // Maximum number of DOFS
|
||||
|
||||
const d minp=1e0;
|
||||
const d maxp=1e7;
|
||||
const d minT=2; // Minimal temperature
|
||||
const d maxT=2000; // Maximal temperature
|
||||
|
||||
const d p0=101325; // Reference pressure [Pa]
|
||||
const d T0=293.15; // Reference temperature [K]
|
||||
const d min_p0=1e0;
|
||||
const d max_p0=1e7;
|
||||
const d default_p0=101325; // Reference pressure [Pa]
|
||||
|
||||
const d min_T0 = 2; // Minimal temperature
|
||||
const d max_T0 = 2000; // Maximal temperature
|
||||
const d default_T0=293.15; // Reference temperature [K]
|
||||
|
||||
|
||||
|
||||
const d min_funtol = 1e-16;
|
||||
const d default_funtol = 1e-6;
|
||||
const d max_funtol = 1e-1;
|
||||
const us funtol_decimals = 10;
|
||||
|
||||
const us default_maxiter = 1000;
|
||||
const us min_maxiter = 1;
|
||||
const us max_maxiter = 100000000;
|
||||
|
||||
const us field_decimals = 10;
|
||||
|
||||
const d default_L = 1.0;
|
||||
const d min_L = 1e-9;
|
||||
const d max_L = 1e6;
|
||||
|
||||
// These variable numbers are important, as they determine the
|
||||
// position of these variables in the array in cell.h
|
||||
@ -94,4 +112,4 @@ namespace constants {
|
||||
|
||||
} // namespace constants
|
||||
|
||||
#endif // CONSTANTS_H
|
||||
#endif // TASMET_CONSTANTS_H
|
||||
|
@ -46,6 +46,8 @@ inline void SplitEnumArgs(const char* szArgs, std::string Array[], int nMax)
|
||||
};
|
||||
#define DECLARE_ENUM(ename, ...) \
|
||||
enum ename { __VA_ARGS__, MAX_NUMBER_OF_##ename }; \
|
||||
const ename ename##_vec[] = { __VA_ARGS__ };\
|
||||
\
|
||||
static std::string ename##Strings[MAX_NUMBER_OF_##ename]; \
|
||||
inline const char* ename##ToString(ename e) { \
|
||||
if (ename##Strings[0].empty()) { SplitEnumArgs(#__VA_ARGS__, ename##Strings, MAX_NUMBER_OF_##ename); } \
|
||||
|
25
src/tasmet_qt.h
Normal file
25
src/tasmet_qt.h
Normal file
@ -0,0 +1,25 @@
|
||||
// tasmet_qt.h
|
||||
//
|
||||
// Author: J.A. de Jong
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#ifndef TASMET_QT_H
|
||||
#define TASMET_QT_H
|
||||
#include "tasmet_types.h"
|
||||
|
||||
template<typename T>
|
||||
inline QVector<T> from_arma(const arma::Col<T>& arma_vec){
|
||||
|
||||
QVector<T> qvec(arma_vec.size());
|
||||
for(us i=0;i<arma_vec.size();i++){
|
||||
qvec[i] = arma_vec(i);
|
||||
}
|
||||
return qvec;
|
||||
}
|
||||
|
||||
|
||||
#endif // TASMET_QT_H
|
||||
//////////////////////////////////////////////////////////////////////
|
@ -7,7 +7,8 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tasmet_tracer.h"
|
||||
|
||||
int tasmet_tracer_level = MAXTRACELEVEL;
|
||||
#include <atomic>
|
||||
std::atomic<int> tasmet_tracer_level = {MAXTRACELEVEL};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -29,7 +29,7 @@ static_assert(false,"TRACER macro not defined");
|
||||
#define POS FILEWITHOUTPATH << ":" << __LINE__ << ": "
|
||||
// End not so interesting part
|
||||
|
||||
#define RAWWARNING(a) std::cout << red << a << def << "\n";
|
||||
#define RAWWARNING(a) std::cout << RED_COLOR << a << DEFAULT_COLOR << "\n";
|
||||
#define WARN(a) RAWWARNING(POS << "WARNING: " << a)
|
||||
|
||||
// SHOULD NOT BE USED IN A LIBRARY!!
|
||||
@ -58,7 +58,8 @@ static_assert(false,"TRACER macro not defined");
|
||||
#define BUILDINTRACELEVEL (-10)
|
||||
#endif
|
||||
|
||||
extern int tasmet_tracer_level;
|
||||
#include <atomic>
|
||||
extern std::atomic<int> tasmet_tracer_level;
|
||||
// Use this preprocessor command to introduce one tasmet_tracer_level integer per unit
|
||||
/* Introduce one static logger */
|
||||
// We trust that the compiler will eliminate 'dead code', which means
|
||||
|
@ -51,17 +51,17 @@ int main(){
|
||||
|
||||
INITTRACE(5);
|
||||
|
||||
TestFunction t(100);
|
||||
Brent solver(t);
|
||||
// TestFunction t(100);
|
||||
// Brent solver(t);
|
||||
|
||||
std::function<SolverAction(SolverProgress)> p = solver_callback;
|
||||
solver.start(&p);
|
||||
// std::function<SolverAction(SolverProgress)> p = solver_callback;
|
||||
// solver.start(&p);
|
||||
|
||||
d res = solver.getSolution();
|
||||
// d res = solver.getSolution();
|
||||
|
||||
cout << "Final solution: x = " << res << endl;
|
||||
// cout << "Final solution: x = " << res << endl;
|
||||
|
||||
Nitrogen nit(293.15,101325);
|
||||
// Nitrogen nit(293.15,101325);
|
||||
Air air(293.15,101325);
|
||||
Helium helium(293.15,101325);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user