diff --git a/.gitignore b/.gitignore index 0e90e0b..3757d6b 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a04da5..4c3a0e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 66842d8..03d3806 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/duct/grid.cpp b/src/duct/grid.cpp new file mode 100644 index 0000000..1ff7a5d --- /dev/null +++ b/src/duct/grid.cpp @@ -0,0 +1,50 @@ +#include "grid.h" +#include "tasmet_tracer.h" +#include "tasmet_exception.h" +#include "tasmet_constants.h" +#include + +LinearGrid::LinearGrid(us ngp,d L): + ngp(ngp), + L(L) +{ + std::stringstream error; + if(ngpconstants::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)); + + +} diff --git a/src/duct/grid.h b/src/duct/grid.h new file mode 100644 index 0000000..ce2369e --- /dev/null +++ b/src/duct/grid.h @@ -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_ */ + diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt new file mode 100644 index 0000000..af70fe2 --- /dev/null +++ b/src/gui/CMakeLists.txt @@ -0,0 +1,9 @@ +#================ +# The TaSMET GUI +#================ +add_library(tasmet_gui + mainwindow.cpp + add_duct_dialog.cpp + ) + +target_link_libraries(tasmet_gui qcustomplot) diff --git a/src/gui/add_duct_dialog.cpp b/src/gui/add_duct_dialog.cpp new file mode 100644 index 0000000..54005a4 --- /dev/null +++ b/src/gui/add_duct_dialog.cpp @@ -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 +#include +#include +#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 +#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;ihadError()) { + _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(),QVector()); + + std::unique_ptr grid; + + switch (_duct.gridtype()) { + case pb::Linear: + try { + grid = std::unique_ptr(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(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 qx = from_arma(x); + QVector 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(); + +} + +////////////////////////////////////////////////////////////////////// diff --git a/src/gui/add_duct_dialog.h b/src/gui/add_duct_dialog.h new file mode 100644 index 0000000..676ad0c --- /dev/null +++ b/src/gui/add_duct_dialog.h @@ -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 +#include +#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 +////////////////////////////////////////////////////////////////////// diff --git a/src/gui/add_duct_dialog.ui b/src/gui/add_duct_dialog.ui new file mode 100644 index 0000000..ce4e8d7 --- /dev/null +++ b/src/gui/add_duct_dialog.ui @@ -0,0 +1,396 @@ + + + add_duct_dialog + + + + 0 + 0 + 841 + 876 + + + + Add/edit duct + + + + + + + + + + + + Geometry + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Length (L): + + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + [-] + + + + + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Cross-sectional area function: + + + + + + + [m] + + + + + + + Cross sectional shape + + + + + + + Porosity function: + + + + + + + [m^2] + + + + + + + Solid type + + + + + + + + + + Hydraulic radius: + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + [m] + + + + + + + + + + + + Preview options + + + + + + + + + Show: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + Model + + + + + + Drag model + + + + + + + Heat transfer model + + + + + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Solid temperature function + + + + + + + + + + [K] + + + + + + + Solid temperature model + + + + + + + + + + + + + Grid + + + + + + + + + Number of gridpoints + + + + + + + Grid type: + + + + + + + + + + Mid-tube grid spacing + + + + + + + + + + + + + Boundary grid spacing + + + + + + + [-] + + + + + + + [m] + + + + + + + [m] + + + + + + + + + + + + + + + + + 0 + 0 + + + + Preview + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + QCustomPlot + QWidget +
qcustomplot.h
+ 1 +
+
+ + + + buttonBox + accepted() + add_duct_dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + add_duct_dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp new file mode 100644 index 0000000..fb934a1 --- /dev/null +++ b/src/gui/mainwindow.cpp @@ -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 +#include +#include +#include +#include +#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(); + +} +////////////////////////////////////////////////////////////////////// diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h new file mode 100644 index 0000000..f7fe063 --- /dev/null +++ b/src/gui/mainwindow.h @@ -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 + +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 +////////////////////////////////////////////////////////////////////// + + + + + diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui new file mode 100644 index 0000000..49e11a5 --- /dev/null +++ b/src/gui/mainwindow.ui @@ -0,0 +1,439 @@ + + + MainWindow + + + + 0 + 0 + 1124 + 835 + + + + MainWindow + + + + + + + + 0 + 0 + + + + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + Global configuration + + + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + [Hz] + + + + + + + Number of harmonics: + + + + + + + 100 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Reference temperature + + + + + + + Gas type: + + + + + + + 1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + [-] + + + + + + + Fundamental frequency: + + + + + + + + + + System type: + + + + + + + [K] + + + + + + + Reference pressure + + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + [Pa] + + + + + + + + + + + + Add/edit segment + + + + + + + + Segment type + + + + + + + + + + Segment ID + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Add/edit segment... + + + + + + + Segment name + + + + + + + Unnamed segment + + + + + + + + + + + + Remove segment + + + + + + + + Segment ID + + + + + + + + + + Remove segment... + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Backlog + + + + + + Type your info here... + + + + + + + + + + Segment overview + + + + + + false + + + + + + + + + + Output + + + + + + false + + + + + + + + + + + + + + + + Solve + + + + + + Solve... + + + + + + + Reinitialize solution + + + + + + + Postprocess... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + 1124 + 21 + + + + + Fi&le + + + + + + + + + + + + + + &New + + + + + &Open + + + + + &Save + + + + + &Exit + + + + + + diff --git a/src/gui/solver.ui b/src/gui/solver.ui new file mode 100644 index 0000000..7017a49 --- /dev/null +++ b/src/gui/solver.ui @@ -0,0 +1,86 @@ + + + Dialog + + + + 0 + 0 + 747 + 336 + + + + Dialog + + + + + 10 + 40 + 306 + 168 + + + + Solver Settings + + + + + + Maximum iterations: + + + + + + + Solver type + + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Solution tolerance: + + + + + + + Residual tolerance: + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + diff --git a/src/gui/solver_dialog.h b/src/gui/solver_dialog.h new file mode 100644 index 0000000..0d5e522 --- /dev/null +++ b/src/gui/solver_dialog.h @@ -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 +////////////////////////////////////////////////////////////////////// diff --git a/src/gui/solver_dialog.ui b/src/gui/solver_dialog.ui new file mode 100644 index 0000000..7017a49 --- /dev/null +++ b/src/gui/solver_dialog.ui @@ -0,0 +1,86 @@ + + + Dialog + + + + 0 + 0 + 747 + 336 + + + + Dialog + + + + + 10 + 40 + 306 + 168 + + + + Solver Settings + + + + + + Maximum iterations: + + + + + + + Solver type + + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Solution tolerance: + + + + + + + Residual tolerance: + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..504857c --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,91 @@ +// main.cpp +// +// last-edit-by: J.A. de Jong +// +// Description: +// Main program to run +////////////////////////////////////////////////////////////////////// +#include +#include +#include + +// For using python from within Qt +#include + + +#include "tasmet_config.h" +#include "tasmet_tracer.h" +#include "gui/mainwindow.h" + +#include +#include + +void catchUnixSignals(const std::vector& quitSignals, + const std::vector& ignoreSignals = std::vector()) { + + 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(); +} +////////////////////////////////////////////////////////////////////// diff --git a/src/material/air.h b/src/material/air.h index 55aca10..cc91eca 100644 --- a/src/material/air.h +++ b/src/material/air.h @@ -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());} }; diff --git a/src/material/gas.cpp b/src/material/gas.cpp index 943d860..3d5e409 100644 --- a/src/material/gas.cpp +++ b/src/material/gas.cpp @@ -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 diff --git a/src/material/gas.h b/src/material/gas.h index ecb1d14..51ae97f 100644 --- a/src/material/gas.h +++ b/src/material/gas.h @@ -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;} diff --git a/src/material/helium.h b/src/material/helium.h index e6352d8..9fe58e5 100644 --- a/src/material/helium.h +++ b/src/material/helium.h @@ -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(){} }; diff --git a/src/material/nitrogen.h b/src/material/nitrogen.h index fb7c9be..92f7b64 100644 --- a/src/material/nitrogen.h +++ b/src/material/nitrogen.h @@ -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; diff --git a/src/material/solid.h b/src/material/solid.h index aece917..5066854 100644 --- a/src/material/solid.h +++ b/src/material/solid.h @@ -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); diff --git a/src/protobuf/CMakeLists.txt b/src/protobuf/CMakeLists.txt new file mode 100644 index 0000000..cf82f41 --- /dev/null +++ b/src/protobuf/CMakeLists.txt @@ -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}) diff --git a/src/protobuf/duct.proto b/src/protobuf/duct.proto new file mode 100644 index 0000000..fb1befd --- /dev/null +++ b/src/protobuf/duct.proto @@ -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]; + +} diff --git a/src/protobuf/system.proto b/src/protobuf/system.proto new file mode 100644 index 0000000..f7ac81f --- /dev/null +++ b/src/protobuf/system.proto @@ -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; + +} diff --git a/src/solver/broyden.h b/src/solver/broyden.h new file mode 100644 index 0000000..030a8cc --- /dev/null +++ b/src/solver/broyden.h @@ -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 >{ + +public: + +}; + + +#endif // BROYDEN_H +////////////////////////////////////////////////////////////////////// diff --git a/src/sys/globalconf.cpp b/src/sys/globalconf.cpp index fd33764..7adad26 100644 --- a/src/sys/globalconf.cpp +++ b/src/sys/globalconf.cpp @@ -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){ } +////////////////////////////////////////////////////////////////////// diff --git a/src/sys/tasystem.cpp b/src/sys/tasystem.cpp index 421d1a4..b6d9ef2 100644 --- a/src/sys/tasystem.cpp +++ b/src/sys/tasystem.cpp @@ -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"); diff --git a/src/sys/tasystem.h b/src/sys/tasystem.h index 6ce8bc1..bc75875 100644 --- a/src/sys/tasystem.h +++ b/src/sys/tasystem.h @@ -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 diff --git a/src/tasmet_assert.h b/src/tasmet_assert.h index e9f4a0e..dacad0f 100644 --- a/src/tasmet_assert.h +++ b/src/tasmet_assert.h @@ -29,12 +29,13 @@ struct is_same : 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) diff --git a/src/tasmet_config.h b/src/tasmet_config.h new file mode 100644 index 0000000..1d69eb2 --- /dev/null +++ b/src/tasmet_config.h @@ -0,0 +1,30 @@ +// tasmet_config.h +// +// Author: J.A. de Jong +// +// Description: +// +////////////////////////////////////////////////////////////////////// +#pragma once +#ifndef TASMET_CONFIG_H +#define TASMET_CONFIG_H +#include +#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 +////////////////////////////////////////////////////////////////////// + diff --git a/src/tasmet_consolecolors.h b/src/tasmet_consolecolors.h index 2a7c4c7..2ecbf24 100644 --- a/src/tasmet_consolecolors.h +++ b/src/tasmet_consolecolors.h @@ -10,12 +10,9 @@ #define CONSOLECOLORS_H #include -#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(){ diff --git a/src/tasmet_constants.h b/src/tasmet_constants.h index 403dd12..8773289 100644 --- a/src/tasmet_constants.h +++ b/src/tasmet_constants.h @@ -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 -T max(T t1,T t2) { return t1>t2?t1:t2;} +T max(T& t1,T& t2) { return t1>t2?t1:t2;} template -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 diff --git a/src/tasmet_enum.h b/src/tasmet_enum.h index ac8825d..c27970d 100644 --- a/src/tasmet_enum.h +++ b/src/tasmet_enum.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); } \ diff --git a/src/tasmet_qt.h b/src/tasmet_qt.h new file mode 100644 index 0000000..a251283 --- /dev/null +++ b/src/tasmet_qt.h @@ -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 +inline QVector from_arma(const arma::Col& arma_vec){ + + QVector qvec(arma_vec.size()); + for(us i=0;i +std::atomic tasmet_tracer_level = {MAXTRACELEVEL}; ////////////////////////////////////////////////////////////////////// + diff --git a/src/tasmet_tracer.h b/src/tasmet_tracer.h index ed16978..e32f03e 100644 --- a/src/tasmet_tracer.h +++ b/src/tasmet_tracer.h @@ -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 +extern std::atomic 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 diff --git a/testing/solver/brent_test.cpp b/testing/solver/brent_test.cpp index 06ab724..121ffe2 100644 --- a/testing/solver/brent_test.cpp +++ b/testing/solver/brent_test.cpp @@ -51,17 +51,17 @@ int main(){ INITTRACE(5); - TestFunction t(100); - Brent solver(t); + // TestFunction t(100); + // Brent solver(t); - std::function p = solver_callback; - solver.start(&p); + // std::function 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);