|
| 1 | +#include <QGridLayout> |
| 2 | +#include <QGroupBox> |
| 3 | +#include <QLabel> |
| 4 | +#include <QVBoxLayout> |
| 5 | + |
| 6 | +#include "particle_setup_widget.h" |
| 7 | +#include "value_line_edit.h" |
| 8 | + |
| 9 | +ParticleSetupWidget::ParticleSetupWidget(const RParticleSetup &particleSetup, QWidget *parent) |
| 10 | + : QWidget(parent) |
| 11 | + , particleSetup(particleSetup) |
| 12 | +{ |
| 13 | + QVBoxLayout *mainLayout = new QVBoxLayout; |
| 14 | + this->setLayout(mainLayout); |
| 15 | + |
| 16 | + QGroupBox *groupBox = new QGroupBox(tr("Contaminant dispersion setup")); |
| 17 | + mainLayout->addWidget(groupBox); |
| 18 | + |
| 19 | + QGridLayout *groupLayout = new QGridLayout; |
| 20 | + groupBox->setLayout(groupLayout); |
| 21 | + |
| 22 | + int groupLayoutRow = 0; |
| 23 | + |
| 24 | + // Maximum saturation |
| 25 | + QLabel *labelMaximumSaturation = new QLabel(tr("Maximum saturation") + " [kg/m^3]"); |
| 26 | + groupLayout->addWidget(labelMaximumSaturation,groupLayoutRow,0); |
| 27 | + |
| 28 | + ValueLineEdit *lineMaximumSaturation = new ValueLineEdit(R_PARTICLE_MAXIMUM_SATURATION_MIN_VALUE,R_PARTICLE_MAXIMUM_SATURATION_MAX_VALUE); |
| 29 | + lineMaximumSaturation->setValue(this->particleSetup.getMaximumSaturation()); |
| 30 | + lineMaximumSaturation->setToolTip(tr("Maximum possible concentration of the contaminant. " |
| 31 | + "Particle rate decreases as the concentration approaches this value and stops at saturation. " |
| 32 | + "Relative saturation is computed when set. " |
| 33 | + "Zero means unlimited.")); |
| 34 | + groupLayout->addWidget(lineMaximumSaturation,groupLayoutRow++,1); |
| 35 | + |
| 36 | + QObject::connect(lineMaximumSaturation,&ValueLineEdit::valueChanged,this,&ParticleSetupWidget::onMaximumSaturationChanged); |
| 37 | + |
| 38 | + // Diffusion coefficient |
| 39 | + QLabel *labelDiffusionCoefficient = new QLabel(tr("Diffusion coefficient") + " [m^2/s]"); |
| 40 | + groupLayout->addWidget(labelDiffusionCoefficient,groupLayoutRow,0); |
| 41 | + |
| 42 | + ValueLineEdit *lineDiffusionCoefficient = new ValueLineEdit(R_PARTICLE_DIFFUSION_COEFFICIENT_MIN_VALUE,R_PARTICLE_DIFFUSION_COEFFICIENT_MAX_VALUE); |
| 43 | + lineDiffusionCoefficient->setValue(this->particleSetup.getDiffusionCoefficient()); |
| 44 | + lineDiffusionCoefficient->setToolTip(tr("Effective diffusion coefficient of the contaminant in the fluid. " |
| 45 | + "Molecular diffusion (about 1e-5 m^2/s in gases, 1e-9 m^2/s in liquids) is negligible in most flows; " |
| 46 | + "mixing is dominated by turbulence, which can be estimated as turbulent viscosity divided by 0.7. " |
| 47 | + "When diffusion dominates, use backward difference time march approximation to avoid oscillations. " |
| 48 | + "Zero means no diffusion.")); |
| 49 | + groupLayout->addWidget(lineDiffusionCoefficient,groupLayoutRow++,1); |
| 50 | + |
| 51 | + QObject::connect(lineDiffusionCoefficient,&ValueLineEdit::valueChanged,this,&ParticleSetupWidget::onDiffusionCoefficientChanged); |
| 52 | +} |
| 53 | + |
| 54 | +void ParticleSetupWidget::onMaximumSaturationChanged(double maximumSaturation) |
| 55 | +{ |
| 56 | + this->particleSetup.setMaximumSaturation(maximumSaturation); |
| 57 | + emit this->changed(this->particleSetup); |
| 58 | +} |
| 59 | + |
| 60 | +void ParticleSetupWidget::onDiffusionCoefficientChanged(double diffusionCoefficient) |
| 61 | +{ |
| 62 | + this->particleSetup.setDiffusionCoefficient(diffusionCoefficient); |
| 63 | + emit this->changed(this->particleSetup); |
| 64 | +} |
0 commit comments