diff --git a/Applications/DataExplorer/Base/ImportFileTypes.h b/Applications/DataExplorer/Base/ImportFileTypes.h index 86369b9a60bc36b57e42a4f8a6b278a540f945d4..e46268163fd23d34e66e6c39600c024a1079fd55 100644 --- a/Applications/DataExplorer/Base/ImportFileTypes.h +++ b/Applications/DataExplorer/Base/ImportFileTypes.h @@ -42,51 +42,66 @@ public: static std::string convertImportFileTypeToString(ImportFileType::type t) { - if (t==ImportFileType::FEFLOW) return "FEFLOW"; - else if (t==ImportFileType::GMS) return "GMS"; - else if (t==ImportFileType::GMSH) return "GMSH"; - else if (t==ImportFileType::NETCDF) return "NetCDF"; - else if (t==ImportFileType::OGS) return "OGS"; - else if (t==ImportFileType::OGS_GEO) return "OGS geometry"; - else if (t==ImportFileType::OGS_STN) return "OGS station list"; - else if (t==ImportFileType::OGS_MSH) return "OGS mesh"; - else if (t==ImportFileType::PETREL) return "Petrel"; - else if((t==ImportFileType::RASTER) || (t==ImportFileType::POLYRASTER)) return "Raster"; - else if (t==ImportFileType::SHAPE) return "Shape"; - else if (t==ImportFileType::TETGEN) return "TetGen node"; - else if (t==ImportFileType::VTK) return "VTK"; - else return ""; + if (t == ImportFileType::FEFLOW) + return "FEFLOW"; + if (t == ImportFileType::GMS) + return "GMS"; + if (t == ImportFileType::GMSH) + return "GMSH"; + if (t == ImportFileType::NETCDF) + return "NetCDF"; + if (t == ImportFileType::OGS) + return "OGS"; + if (t == ImportFileType::OGS_GEO) + return "OGS geometry"; + if (t == ImportFileType::OGS_STN) + return "OGS station list"; + if (t == ImportFileType::OGS_MSH) + return "OGS mesh"; + if (t == ImportFileType::PETREL) + return "Petrel"; + if ((t == ImportFileType::RASTER) || (t == ImportFileType::POLYRASTER)) + return "Raster"; + if (t == ImportFileType::SHAPE) + return "Shape"; + else if (t == ImportFileType::TETGEN) + return "TetGen node"; + else if (t == ImportFileType::VTK) + return "VTK"; + else + return ""; } static std::string getFileSuffixString(ImportFileType::type t) { - if (t==ImportFileType::FEFLOW) + if (t == ImportFileType::FEFLOW) return "FEFLOW files (*.fem)"; - else if (t==ImportFileType::GMS) + if (t == ImportFileType::GMS) return "GMS files (*.txt *.3dm)"; - else if (t==ImportFileType::GMSH) + if (t == ImportFileType::GMSH) return "GMSH mesh files (*.msh)"; - else if (t==ImportFileType::NETCDF) + if (t == ImportFileType::NETCDF) return "NetCDF files (*.nc)"; - else if (t==ImportFileType::OGS) - return "OpenGeosys files (*.gsp *.gml *.vtu *.stn);;GeoSys legacy files (*.gli *.msh);;All files (* *.*)"; - else if (t==ImportFileType::OGS_GEO) + if (t == ImportFileType::OGS) + return "OpenGeosys files (*.gsp *.gml *.vtu *.stn);;GeoSys legacy " + "files (*.gli *.msh);;All files (* *.*)"; + if (t == ImportFileType::OGS_GEO) return "OpenGeosys files (*.gml *.gli)"; - else if (t==ImportFileType::OGS_STN) + if (t == ImportFileType::OGS_STN) return "OpenGeosys files (*.stn)"; - else if (t==ImportFileType::OGS_MSH) + if (t == ImportFileType::OGS_MSH) return "OpenGeosys files (*.vtu *.msh)"; - else if (t==ImportFileType::PETREL) + if (t == ImportFileType::PETREL) return "Petrel files (*)"; - else if (t==ImportFileType::RASTER) + if (t == ImportFileType::RASTER) return "Raster files (*.asc *.grd *.bmp *.jpg *.png *.tif)"; - else if (t==ImportFileType::SHAPE) + if (t == ImportFileType::SHAPE) return "ESRI Shape files (*.shp)"; - else if (t==ImportFileType::TETGEN) + else if (t == ImportFileType::TETGEN) return "TetGen node files (*.node *.poly *.smesh)"; - else if (t==ImportFileType::VTK) + else if (t == ImportFileType::VTK) return "VTK files (*.vtk *.vti *.vtr *.vts *.vtp *.vtu)"; - else return "All files (*.*)"; -} - + else + return "All files (*.*)"; + } }; diff --git a/Applications/DataExplorer/Base/TreeItem.cpp b/Applications/DataExplorer/Base/TreeItem.cpp index 67960c2f927ee0019260421ce9efae1b97ae39d7..9ef71373e0abc987ed09d89421ee0293fa42e1c8 100644 --- a/Applications/DataExplorer/Base/TreeItem.cpp +++ b/Applications/DataExplorer/Base/TreeItem.cpp @@ -53,8 +53,8 @@ TreeItem* TreeItem::child(int row) const { if (_childItems.count() > row) return _childItems.value(row); - else - return nullptr; + + return nullptr; } /** diff --git a/Applications/DataExplorer/Base/TreeModel.cpp b/Applications/DataExplorer/Base/TreeModel.cpp index 1017e9c21dffdda2b857c521942a43269811c68a..f20559810bfc7390b7a247581780cb53c12518bd 100644 --- a/Applications/DataExplorer/Base/TreeModel.cpp +++ b/Applications/DataExplorer/Base/TreeModel.cpp @@ -63,8 +63,8 @@ QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) con TreeItem* childItem = parentItem->child(row); if (childItem) return createIndex(row, column, childItem); - else - return QModelIndex(); + + return QModelIndex(); } /** @@ -109,8 +109,8 @@ int TreeModel::columnCount(const QModelIndex &parent) const { if (parent.isValid()) return static_cast<TreeItem*>(parent.internalPointer())->columnCount(); - else - return _rootItem->columnCount(); + + return _rootItem->columnCount(); } void TreeModel::updateData() diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp index 7372ffc74ad8fc551368898035861f312dadb4ee..9ed8e20e912ad49ee2ebd76e47707689349f4a5c 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp @@ -73,7 +73,7 @@ float DiagramList::calcMaxYValue() bool DiagramList::getPath(QPainterPath &path, float scaleX, float scaleY) { QPointF p; - if (getPoint(p,0)) + if (getPoint(p, 0)) { QPainterPath pp(QPointF(p.x() * scaleX, p.y() * scaleY)); path = pp; @@ -81,13 +81,13 @@ bool DiagramList::getPath(QPainterPath &path, float scaleX, float scaleY) std::size_t nCoords = _coords.size(); for (std::size_t i = 1; i < nCoords; i++) { - getPoint(p,i); + getPoint(p, i); path.lineTo(QPointF(p.x() * scaleX, p.y() * scaleY)); } return true; } - else - return false; + + return false; } bool DiagramList::getPoint(QPointF &p, std::size_t i) @@ -98,8 +98,8 @@ bool DiagramList::getPoint(QPointF &p, std::size_t i) p.setY(_coords[i].second); return true; } - else - return false; + + return false; } /* @@ -320,8 +320,8 @@ std::size_t DiagramList::size() { if (!(_coords.empty())) return _coords.size(); - else - return 0; + + return 0; } void DiagramList::update() @@ -336,6 +336,6 @@ QDateTime DiagramList::getDateTime(QString stringDate) { if (stringDate.length() <= 10) return QDateTime::fromString(stringDate, "dd.MM.yyyy"); - else - return QDateTime::fromString(stringDate, "dd.MM.yyyy.HH.mm.ss"); + + return QDateTime::fromString(stringDate, "dd.MM.yyyy.HH.mm.ss"); } diff --git a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp index d89d9ab9d7d4b003dd21529985424f141bbf95f6..be01d0cf215f34761a33973cf63b273daef2641e 100644 --- a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp @@ -196,14 +196,12 @@ MeshLib::Mesh* MeshLayerEditDialog::createPrismMesh() } return nullptr; } - else - { - std::vector<float> layer_thickness; - for (unsigned i=0; i<nLayers; ++i) - layer_thickness.push_back(this->_edits[i]->text().toFloat()); - INFO("Mesh construction time: %d ms.", myTimer0.elapsed()); - return mapper.createStaticLayers(*_msh, layer_thickness); - } + + std::vector<float> layer_thickness; + for (unsigned i = 0; i < nLayers; ++i) + layer_thickness.push_back(this->_edits[i]->text().toFloat()); + INFO("Mesh construction time: %d ms.", myTimer0.elapsed()); + return mapper.createStaticLayers(*_msh, layer_thickness); } MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() diff --git a/Applications/DataExplorer/DataView/MshModel.cpp b/Applications/DataExplorer/DataView/MshModel.cpp index 3626e926f243147372025e691a1f82885c89cbc9..d237abafd17c8546cdb78fdf2a5decfd2ed4719e 100644 --- a/Applications/DataExplorer/DataView/MshModel.cpp +++ b/Applications/DataExplorer/DataView/MshModel.cpp @@ -95,8 +95,8 @@ const MeshLib::Mesh* MshModel::getMesh(const QModelIndex &idx) const auto* item = dynamic_cast<MshItem*>(this->getItem(idx)); if (item) return item->getMesh(); - else - return nullptr; + + return nullptr; } WARN("MshModel::getMesh(): Specified index does not exist."); return nullptr; diff --git a/Applications/DataExplorer/DataView/NetCdfConfigureDialog.cpp b/Applications/DataExplorer/DataView/NetCdfConfigureDialog.cpp index 50d962384db39d77b4e1fe3546a34a67095ecddf..32bdb622e8d7ba560f1920a3ffabf2a9fb1dc3d2 100644 --- a/Applications/DataExplorer/DataView/NetCdfConfigureDialog.cpp +++ b/Applications/DataExplorer/DataView/NetCdfConfigureDialog.cpp @@ -288,25 +288,21 @@ double NetCdfConfigureDialog::getResolution() { if (comboBoxDim1->currentIndex() > -1) { - NcVar *latVar = _currentFile->get_var(comboBoxDim1->currentIndex()); - double firstValue=0, lastValue=0; - unsigned size=0; - getDimEdges(latVar->id(),size,firstValue,lastValue); + NcVar* latVar = _currentFile->get_var(comboBoxDim1->currentIndex()); + double firstValue = 0, lastValue = 0; + unsigned size = 0; + getDimEdges(latVar->id(), size, firstValue, lastValue); if (size < 2) { return 1; } - else - { - double interval = fabs(lastValue-firstValue); - double resolution = (double)interval/(size-1); - return resolution; - } - } - else - { - return 0; + + double interval = fabs(lastValue - firstValue); + double resolution = (double)interval / (size - 1); + return resolution; } + + return 0; } void NetCdfConfigureDialog::createDataObject() diff --git a/Applications/DataExplorer/DataView/SHPImportDialog.cpp b/Applications/DataExplorer/DataView/SHPImportDialog.cpp index d0efc5ea1b3b8bd0089fcc22f92cc1acc198f520..f1fd135b2d927d6ac3c573928c05897cb63689e0 100644 --- a/Applications/DataExplorer/DataView/SHPImportDialog.cpp +++ b/Applications/DataExplorer/DataView/SHPImportDialog.cpp @@ -136,26 +136,25 @@ void SHPImportDialog::accept() OGSError::box("Please insert a name for the data in this file."); return; } - else - { - if (_fileType == 1 && _choice1->isChecked()) - _shpInterface->readSHPFile(_filename, - FileIO::SHPInterface::OGSType::POINT, - list_name.toStdString()); - if (_fileType == 1 && _choice2->isChecked()) - _shpInterface->readSHPFile(_filename, - FileIO::SHPInterface::OGSType::STATION, - list_name.toStdString()); - if (_fileType == 2 && _choice1->isChecked()) - _shpInterface->readSHPFile(_filename, - FileIO::SHPInterface::OGSType::POLYLINE, - list_name.toStdString()); - if (_fileType == 2 && _choice2->isChecked()) - _shpInterface->readSHPFile(_filename, - FileIO::SHPInterface::OGSType::POLYGON, - list_name.toStdString()); - emit shpLoaded(list_name); - } + + if (_fileType == 1 && _choice1->isChecked()) + _shpInterface->readSHPFile(_filename, + FileIO::SHPInterface::OGSType::POINT, + list_name.toStdString()); + if (_fileType == 1 && _choice2->isChecked()) + _shpInterface->readSHPFile(_filename, + FileIO::SHPInterface::OGSType::STATION, + list_name.toStdString()); + if (_fileType == 2 && _choice1->isChecked()) + _shpInterface->readSHPFile(_filename, + FileIO::SHPInterface::OGSType::POLYLINE, + list_name.toStdString()); + if (_fileType == 2 && _choice2->isChecked()) + _shpInterface->readSHPFile(_filename, + FileIO::SHPInterface::OGSType::POLYGON, + list_name.toStdString()); + emit shpLoaded(list_name); + this->done(QDialog::Accepted); } diff --git a/Applications/DataExplorer/DataView/StationTreeModel.cpp b/Applications/DataExplorer/DataView/StationTreeModel.cpp index c80ac9421853bccecdcc3836b719eca20df504d6..e43755455dbfda87b5818acbcda977f34e9abe90 100644 --- a/Applications/DataExplorer/DataView/StationTreeModel.cpp +++ b/Applications/DataExplorer/DataView/StationTreeModel.cpp @@ -62,12 +62,12 @@ QModelIndex StationTreeModel::index( int row, int column, QModelIndex newIndex = createIndex(row, column, childItem); // assign ModelIndex to BaseItem so it can communicate with the model BaseItem* item = childItem->getItem(); - if ( item != nullptr ) + if (item != nullptr) item->setModelIndex(newIndex); return newIndex; } - else - return QModelIndex(); + + return QModelIndex(); } /** @@ -86,8 +86,8 @@ GeoLib::Station* StationTreeModel::stationFromIndex( const QModelIndex& index, listName = parentItem->data(0).toString(); return treeItem->getStation(); } - else - return nullptr; + + return nullptr; } vtkPolyDataAlgorithm* StationTreeModel::vtkSource(const std::string &name) const diff --git a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp index 9d4b1536f444e99fd626f1a6e3d931fbc646104a..d06af5490d096fc886732edf978d66fbe4c3410d 100644 --- a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp +++ b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp @@ -49,8 +49,8 @@ void MeshFromRasterDialog::accept() OGSError::box("Please specify a name for the data vector."); return; } - else - _array_name = this->arrayNameEdit->text().toStdString(); + + _array_name = this->arrayNameEdit->text().toStdString(); } _element_selection = MeshLib::MeshElemType::TRIANGLE; if (this->quadButton->isChecked()) _element_selection = MeshLib::MeshElemType::QUAD; diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp index 2891723f45194e5f6186ab5d0327e084637fb578..63b7af969ea5f72ca2426d5402b2c1b192d0381a 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp @@ -52,8 +52,8 @@ vtkLookupTable* VtkAlgorithmProperties::GetLookupTable(const QString& array_name auto it = _lut.find(array_name); if (it != _lut.end()) return it->second; - else - return nullptr; + + return nullptr; } void VtkAlgorithmProperties::RemoveLookupTable(const QString& array_name) @@ -101,22 +101,18 @@ QVariant VtkAlgorithmProperties::GetUserProperty(QString name) const { if (this->_algorithmUserProperties->contains(name)) return this->_algorithmUserProperties->value(name); - else - { - ERR("Not a valid property: %s", name.toStdString().c_str()); - return QVariant(); - } + + ERR("Not a valid property: %s", name.toStdString().c_str()); + return QVariant(); } QList<QVariant> VtkAlgorithmProperties::GetUserVectorProperty(QString name) const { if (this->_algorithmUserVectorProperties->contains(name)) return this->_algorithmUserVectorProperties->value(name); - else - { - ERR("Not a valid property: %s", name.toStdString().c_str()); - return QList<QVariant>(); - } + + ERR("Not a valid property: %s", name.toStdString().c_str()); + return QList<QVariant>(); } void VtkAlgorithmProperties::SetActiveAttribute(QString name) diff --git a/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp b/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp index 22690d918757eb1d5d840c1f2777ec1c34d2f602..b5b7e1e86c8cdabb0771189a693b9a50c471b34e 100644 --- a/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp +++ b/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp @@ -111,29 +111,28 @@ VtkCompositeFilter* VtkFilterFactory::CreateCompositeFilter( QString type, { if (type.compare(QString("VtkCompositeImageToCylindersFilter")) == 0) return new VtkCompositeImageToCylindersFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositePointToGlyphFilter")) == 0) + if (type.compare(QString("VtkCompositePointToGlyphFilter")) == 0) return new VtkCompositePointToGlyphFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeLineToTubeFilter")) == 0) + if (type.compare(QString("VtkCompositeLineToTubeFilter")) == 0) return new VtkCompositeLineToTubeFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeColormapToImageFilter")) == 0) + if (type.compare(QString("VtkCompositeColormapToImageFilter")) == 0) return new VtkCompositeColormapToImageFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeTextureOnSurfaceFilter")) == 0) + if (type.compare(QString("VtkCompositeTextureOnSurfaceFilter")) == 0) return new VtkCompositeTextureOnSurfaceFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeThresholdFilter")) == 0) + if (type.compare(QString("VtkCompositeThresholdFilter")) == 0) return new VtkCompositeThresholdFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeColorByHeightFilter")) == 0) + if (type.compare(QString("VtkCompositeColorByHeightFilter")) == 0) return new VtkCompositeColorByHeightFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeElementSelectionFilter")) == 0) + if (type.compare(QString("VtkCompositeElementSelectionFilter")) == 0) return new VtkCompositeElementSelectionFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeNodeSelectionFilter")) == 0) + if (type.compare(QString("VtkCompositeNodeSelectionFilter")) == 0) return new VtkCompositeNodeSelectionFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeContourFilter")) == 0) + if (type.compare(QString("VtkCompositeContourFilter")) == 0) return new VtkCompositeContourFilter(inputAlgorithm); - else if (type.compare(QString("VtkCompositeGeoObjectFilter")) == 0) + if (type.compare(QString("VtkCompositeGeoObjectFilter")) == 0) return new VtkCompositeGeoObjectFilter(inputAlgorithm); - else - return nullptr; + return nullptr; } vtkAlgorithm* VtkFilterFactory::CreateSimpleFilter( QString type ) diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.cpp b/Applications/DataExplorer/VtkVis/VtkRaster.cpp index 9ce56065c3de0fbdbc28f90fce24c59ec32a803a..97b84e97fbb9f64e55c97b754bd818d7cc18a3a2 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.cpp +++ b/Applications/DataExplorer/VtkVis/VtkRaster.cpp @@ -52,7 +52,8 @@ vtkImageAlgorithm* VtkRaster::loadImage(const std::string &fileName, raster.reset(FileIO::AsciiRasterInterface::getRasterFromSurferFile(fileName)); if (raster) return VtkRaster::loadImageFromArray(raster->begin(), raster->getHeader()); - else if ((fileInfo.suffix().toLower() == "tif") || (fileInfo.suffix().toLower() == "tiff")) + if ((fileInfo.suffix().toLower() == "tif") || + (fileInfo.suffix().toLower() == "tiff")) { #ifdef GEOTIFF_FOUND return loadImageFromTIFF(fileName, x0, y0, delta); @@ -61,8 +62,8 @@ vtkImageAlgorithm* VtkRaster::loadImage(const std::string &fileName, return nullptr; #endif } - else - return loadImageFromFile(fileName); + + return loadImageFromFile(fileName); } vtkImageImport* VtkRaster::loadImageFromArray(double const*const data_array, GeoLib::RasterHeader header) { diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp index 787d9eef6b7299eca0b05967ede3589693e4be45..f50dfc2c120362a320fc640ad6d33a894b16e0c6 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp @@ -84,16 +84,16 @@ VtkVisPipelineItem* VtkVisPipelineItem::child( int row ) const TreeItem* treeItem = TreeItem::child(row); if (treeItem) return dynamic_cast<VtkVisPipelineItem*>(treeItem); - else - return nullptr; + + return nullptr; } QVariant VtkVisPipelineItem::data( int column ) const { if (column == 1) return isVisible(); - else - return TreeItem::data(column); + + return TreeItem::data(column); } bool VtkVisPipelineItem::setData( int column, const QVariant &value ) @@ -103,8 +103,8 @@ bool VtkVisPipelineItem::setData( int column, const QVariant &value ) setVisible(value.toBool()); return true; } - else - return TreeItem::setData(column, value); + + return TreeItem::setData(column, value); } bool VtkVisPipelineItem::isVisible() const { diff --git a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp index 7235847531202acfcb848d09aa0af5b766893e6e..e70410ac82e9ade5c7292d1492b50c7fd45c79a9 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp @@ -333,14 +333,14 @@ bool VtkVisPointSetItem::activeAttributeExists(vtkDataSetAttributes* data, std:: if(arrayName.compare(name) == 0) arrayFound = true; } - if(arrayFound) + if (arrayFound) { // TODO Necessary? Currently this function is not called data->SetActiveAttribute(name.c_str(), vtkDataSetAttributes::SCALARS); return true; } - else - return false; + + return false; } void VtkVisPointSetItem::setScale(double x, double y, double z) const diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index fe3af8a93f5cc0b140a0a7d2eaccd0639f936af4..2ae650beb0f28841ecd8f79a590d2695902beea9 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -1287,6 +1287,6 @@ QString MainWindow::getLastUsedDir() QStringList files = settings.value("recentFileList").toStringList(); if (!files.empty()) return QFileInfo(files[0]).absolutePath(); - else - return QDir::homePath(); + + return QDir::homePath(); } diff --git a/Applications/FileIO/AsciiRasterInterface.cpp b/Applications/FileIO/AsciiRasterInterface.cpp index e62c67114823419066700e45fc2010be6eddadfe..27c813e23189298fe2b3b706a8a8e6699c60ba90 100644 --- a/Applications/FileIO/AsciiRasterInterface.cpp +++ b/Applications/FileIO/AsciiRasterInterface.cpp @@ -62,10 +62,10 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromASCFile(std::string const& fn GeoLib::Raster *raster(new GeoLib::Raster(header, values, values+header.n_cols*header.n_rows)); delete [] values; return raster; - } else { - WARN("Raster::getRasterFromASCFile(): Could not read header of file %s", fname.c_str()); - return nullptr; } + WARN("Raster::getRasterFromASCFile(): Could not read header of file %s", + fname.c_str()); + return nullptr; } bool AsciiRasterInterface::readASCHeader(std::ifstream &in, GeoLib::RasterHeader &header) @@ -150,10 +150,10 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromSurferFile(std::string const& GeoLib::Raster *raster(new GeoLib::Raster(header, values, values+header.n_cols*header.n_rows)); delete [] values; return raster; - } else { - ERR("Raster::getRasterFromASCFile() - could not read header of file %s", fname.c_str()); - return nullptr; } + ERR("Raster::getRasterFromASCFile() - could not read header of file %s", + fname.c_str()); + return nullptr; } bool AsciiRasterInterface::readSurferHeader( @@ -168,27 +168,26 @@ bool AsciiRasterInterface::readSurferHeader( ERR("Error in readSurferHeader() - No Surfer file."); return false; } + + in >> header.n_cols >> header.n_rows; + in >> min >> max; + header.origin[0] = min; + header.cell_size = (max - min) / static_cast<double>(header.n_cols); + + in >> min >> max; + header.origin[1] = min; + header.origin[2] = 0; + + if (ceil((max - min) / static_cast<double>(header.n_rows)) == + ceil(header.cell_size)) + header.cell_size = ceil(header.cell_size); else { - in >> header.n_cols >> header.n_rows; - in >> min >> max; - header.origin[0] = min; - header.cell_size = (max-min)/static_cast<double>(header.n_cols); - - in >> min >> max; - header.origin[1] = min; - header.origin[2] = 0; - - if (ceil((max-min)/static_cast<double>(header.n_rows)) == ceil(header.cell_size)) - header.cell_size = ceil(header.cell_size); - else - { - ERR("Error in readSurferHeader() - Anisotropic cellsize detected."); - return false; - } - header.no_data = min-1; - in >> min >> max; + ERR("Error in readSurferHeader() - Anisotropic cellsize detected."); + return false; } + header.no_data = min - 1; + in >> min >> max; return true; } diff --git a/Applications/FileIO/CsvInterface.cpp b/Applications/FileIO/CsvInterface.cpp index d1f462ec568df9e76862186ce86818aff256c1be..02399ff394ada2353b2b2a818392506b9faf8b42 100644 --- a/Applications/FileIO/CsvInterface.cpp +++ b/Applications/FileIO/CsvInterface.cpp @@ -179,8 +179,8 @@ std::size_t CsvInterface::findColumn(std::string const& line, char delim, std::s { if (field.compare(column_name) == 0) break; - else - count++; + + count++; } if (count == fields.size()) @@ -232,9 +232,9 @@ std::size_t CsvInterface::getVectorSize(std::size_t idx) const { if (_data[idx].type() == typeid(std::vector<std::string>)) return boost::any_cast<std::vector<std::string>>(_data[idx]).size(); - else if (_data[idx].type() == typeid(std::vector<double>)) + if (_data[idx].type() == typeid(std::vector<double>)) return boost::any_cast<std::vector<double>>(_data[idx]).size(); - else if (_data[idx].type() == typeid(std::vector<int>)) + if (_data[idx].type() == typeid(std::vector<int>)) return boost::any_cast<std::vector<int>>(_data[idx]).size(); return 0; } diff --git a/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp b/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp index 05c626ed2850d8f164831463b9f5325cf7cad1d4..4d04fe2184ad72e2970603e7f7b4ff378bb74d99 100644 --- a/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp +++ b/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp @@ -417,7 +417,7 @@ void FEFLOWMeshInterface::readElevation(std::ifstream& in, { break; } - else if (mode == 1) + if (mode == 1) { // slice number l++; @@ -609,7 +609,7 @@ void FEFLOWMeshInterface::readELEMENTALSETS( { break; } - else if (mode == 1) + if (mode == 1) { // starting a new set std::string set_name; diff --git a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp index 337250085eb05ce77fb5ce3a8a6efe0fdf1acec1..7580985583475e1bf931f843fb44a535c938fdb0 100644 --- a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp +++ b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp @@ -82,9 +82,8 @@ bool GMSHPolygonTree::insertStation(GeoLib::Point const* station) // station did not fit into child nodes -> insert the station into this node _stations.push_back (station); return true; - } else { - return false; } + return false; } void GMSHPolygonTree::insertPolyline(GeoLib::PolylineWithSegmentMarker * ply) diff --git a/Applications/Utils/MeshEdit/editMaterialID.cpp b/Applications/Utils/MeshEdit/editMaterialID.cpp index ee0316c47bcafb0c85bfd7f8f8d77f298fe86661..35e560122aa6db451c8b79d6c9286e71d7e0b5a1 100644 --- a/Applications/Utils/MeshEdit/editMaterialID.cpp +++ b/Applications/Utils/MeshEdit/editMaterialID.cpp @@ -56,7 +56,9 @@ int main (int argc, char* argv[]) if (!replaceArg.isSet() && !condenseArg.isSet() && !specifyArg.isSet()) { INFO("Please select editing mode: -r or -c or -s"); return 0; - } else if (replaceArg.isSet() && condenseArg.isSet()) { + } + if (replaceArg.isSet() && condenseArg.isSet()) + { INFO("Please select only one editing mode: -r or -c or -s"); return 0; } else if (replaceArg.isSet()) { diff --git a/Applications/Utils/OGSFileConverter/FileListDialog.cpp b/Applications/Utils/OGSFileConverter/FileListDialog.cpp index 2b4cee0d2511f890bdbad261fc49ef415931ba49..bf96e5b2424330f62ae213dffbe3b1d4c895bae6 100644 --- a/Applications/Utils/OGSFileConverter/FileListDialog.cpp +++ b/Applications/Utils/OGSFileConverter/FileListDialog.cpp @@ -96,10 +96,13 @@ void FileListDialog::reject() const QString FileListDialog::getFileTypeString(FileType file_type) const { if (file_type==FileType::GML) return "OpenGeoSys geometry files (*.gml)"; - else if (file_type==FileType::VTU) return "OpenGeoSys mesh files (*.vtu)"; - else if (file_type==FileType::GLI) return "GeoSys geometry files (*.gli)"; - else if (file_type==FileType::MSH) return "GeoSys mesh files (*.msh)"; - else return "All files (*.*)"; + if (file_type == FileType::VTU) + return "OpenGeoSys mesh files (*.vtu)"; + if (file_type == FileType::GLI) + return "GeoSys geometry files (*.gli)"; + if (file_type == FileType::MSH) + return "GeoSys mesh files (*.msh)"; + return "All files (*.*)"; } void FileListDialog::displayWarningLabel() const diff --git a/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp b/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp index 7d26ec3c325644bb65ac284c17bb79e76dfd9197..4409bfb1e0cf6fccf98ad5070b5d276c3791adc6 100644 --- a/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp +++ b/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp @@ -157,12 +157,15 @@ int main (int argc, char* argv[]) if (!isLengthSet) { ERR("Missing input: Length information is not provided at all."); return EXIT_FAILURE; - } else { - for (unsigned i=0; i<3; i++) { - if (dim_used[i] && !vec_lengthArg[i]->isSet()) { - ERR("Missing input: Length for dimension [%d] is required but missing.", i); - return EXIT_FAILURE; - } + } + for (unsigned i = 0; i < 3; i++) + { + if (dim_used[i] && !vec_lengthArg[i]->isSet()) + { + ERR("Missing input: Length for dimension [%d] is required but " + "missing.", + i); + return EXIT_FAILURE; } } diff --git a/BaseLib/ConfigTree-impl.h b/BaseLib/ConfigTree-impl.h index 79cdcf73e7e37aefac85d2f0cc85c6fd61e061f0..0fb7848c1303c8ff8b0d28d175af31d9012249c3 100644 --- a/BaseLib/ConfigTree-impl.h +++ b/BaseLib/ConfigTree-impl.h @@ -165,10 +165,9 @@ getValue() const if (auto v = _tree->get_value_optional<T>()) { return *v; - } else { - error("Value `" + shortString(_tree->data()) - + "' is not convertible to the desired type."); } + error("Value `" + shortString(_tree->data()) + + "' is not convertible to the desired type."); } template<typename T> @@ -195,11 +194,10 @@ getConfigAttributeOptional(std::string const& attr) const ++ct.count; // count only if attribute has been found if (auto v = a->get_value_optional<T>()) { return v; - } else { - error("Value for XML attribute \"" + attr + "\" `" - + shortString(a->data()) - + "' not convertible to the desired type."); } + error("Value for XML attribute \"" + attr + "\" `" + + shortString(a->data()) + + "' not convertible to the desired type."); } } diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp index e287b015142fef1e82f4f7547f06ec17ed95694f..5c1fb2e095430a272ff1ed590ace6babc5b15c08 100644 --- a/BaseLib/ConfigTree.cpp +++ b/BaseLib/ConfigTree.cpp @@ -146,9 +146,8 @@ getConfigSubtree(std::string const& root) const { if (auto t = getConfigSubtreeOptional(root)) { return std::move(*t); - } else { - error("Key <" + root + "> has not been found."); } + error("Key <" + root + "> has not been found."); } boost::optional<ConfigTree> @@ -160,10 +159,9 @@ getConfigSubtreeOptional(std::string const& root) const if (auto subtree = _tree->get_child_optional(root)) { markVisited(root, Attr::TAG, false); return ConfigTree(*subtree, *this, root); - } else { - markVisited(root, Attr::TAG, true); - return boost::none; } + markVisited(root, Attr::TAG, true); + return boost::none; } Range<ConfigTree::SubtreeIterator> diff --git a/BaseLib/ConfigTreeUtil.cpp b/BaseLib/ConfigTreeUtil.cpp index 9a7c9a999f7ee6f4d784b2cbb102d7eaf7962d38..c41c8b3c0bd27ac6ec6ecab64e6252284169e98d 100644 --- a/BaseLib/ConfigTreeUtil.cpp +++ b/BaseLib/ConfigTreeUtil.cpp @@ -67,10 +67,9 @@ makeConfigTree(const std::string& filepath, const bool be_ruthless, if (auto child = ptree.get_child_optional(toplevel_tag)) { return ConfigTreeTopLevel(filepath, be_ruthless, std::move(*child)); - } else { - OGS_FATAL("Tag <%s> has not been found in file `%s'.", - toplevel_tag.c_str(), filepath.c_str()); } + OGS_FATAL("Tag <%s> has not been found in file `%s'.", toplevel_tag.c_str(), + filepath.c_str()); } } diff --git a/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp index 6e0f6cec8095d79116ca9742c4f1a76ce28d3839..bf244e38ae47e416ed28ea4a0be0a02b287e90e6 100644 --- a/BaseLib/DateTools.cpp +++ b/BaseLib/DateTools.cpp @@ -124,8 +124,7 @@ std::string formatDate( if (std::strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S%z", std::localtime(&time_t))) { return time_str; - } else { - return "FAILED FORMATTING THE GIVEN TIME POINT."; } + return "FAILED FORMATTING THE GIVEN TIME POINT."; } } // end namespace BaseLib diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index 08779b7263f35f8b4b60978d0f7709b2634a37b6..3c27558ad4314d2094b712879315bf3725db55b7 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -171,9 +171,8 @@ std::string joinPaths(std::string const& pathA, std::string const& pathB) if (pathB.front() == pathSeparator) { auto const tmpB = pathB.substr(1); return appendPathSeparator(pathA) + tmpB; - } else { - return appendPathSeparator(pathA) + pathB; } + return appendPathSeparator(pathA) + pathB; } } // end namespace BaseLib diff --git a/BaseLib/IO/Writer.cpp b/BaseLib/IO/Writer.cpp index 9807d3918fd31db04b6d55846609e545d9b69f18..cc5c55d336963d5ea60021f4343ff33a3f712604 100644 --- a/BaseLib/IO/Writer.cpp +++ b/BaseLib/IO/Writer.cpp @@ -37,8 +37,8 @@ std::string Writer::writeToString() if (this->write()) return _out.str(); - else - return std::string(""); + + return std::string(""); } int Writer::writeToFile(std::string const& filename) diff --git a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp index 4fa8ed79033e5dfe46e9e827702584a9a3adf1e1..208f2f279b764e6639107a01e7c14ee2ec7eced1 100644 --- a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp +++ b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp @@ -62,11 +62,11 @@ int XMLQtInterface::isValid() const QXmlSchemaValidator validator( schema ); if ( validator.validate( _fileData ) ) return 1; - else - { - INFO("XMLQtInterface::isValid(): XML file %s is invalid (in reference to schema %s).", - _fileName.toStdString().c_str(), _schemaName.c_str()); - } + + INFO( + "XMLQtInterface::isValid(): XML file %s is invalid (in reference " + "to schema %s).", + _fileName.toStdString().c_str(), _schemaName.c_str()); } else { @@ -75,11 +75,11 @@ int XMLQtInterface::isValid() const QXmlSchemaValidator validator; if ( validator.validate( _fileData ) ) return 1; - else - { - INFO("XMLQtInterface::isValid(): XML file %s is invalid (in reference to its schema).", - _fileName.toStdString().c_str()); - } + + INFO( + "XMLQtInterface::isValid(): XML file %s is invalid (in reference " + "to its schema).", + _fileName.toStdString().c_str()); } return 0; } diff --git a/GeoLib/AABB.h b/GeoLib/AABB.h index 6842b06d96828d1ead161235ba81bfdd26f05bee..12efac0d59c79e5ed9567978ed9315a00038b4c5 100644 --- a/GeoLib/AABB.h +++ b/GeoLib/AABB.h @@ -123,10 +123,8 @@ public: if (updated.second.any()) { enlarge(updated.second); return true; - } else if (updated.first) { - return true; } - return false; + return updated.first; } /** diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index e80312454522c8e8dde99e85ec6293e980f64796..5c3d96996f1a6be46da2ad2db5010bfa6a70a61f 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -474,12 +474,12 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d( double const t = (c[0] - a[0]) / (b[0] - a[0]); return 0.0 <= t && t <= 1.0; } - else if (b[1] - a[1] != 0) + if (b[1] - a[1] != 0) { double const t = (c[1] - a[1]) / (b[1] - a[1]); return 0.0 <= t && t <= 1.0; } - else if (b[2] - a[2] != 0) + if (b[2] - a[2] != 0) { double const t = (c[2] - a[2]) / (b[2] - a[2]); return 0.0 <= t && t <= 1.0; @@ -523,9 +523,9 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d( return { MathLib::Point3d{std::array<double,3>{{ c[0]+rhs[1]*(d[0]-c[0]), c[1]+rhs[1]*(d[1]-c[1]), c[2]+rhs[1]*(d[2]-c[2])}} } }; - } else { - return std::vector<MathLib::Point3d>(); // parameter s not in the valid range } + return std::vector<MathLib::Point3d>(); // parameter s not in the valid + // range } void sortSegments( diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index cdbd199dc56c675eeea0232e058db7d7fc2d05d5..8ef4f3b4cd7cb55ba59e2e118486b48884bc9dfd 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -163,8 +163,8 @@ bool GEOObjects::appendPolylineVec(const std::vector<Polyline*>& polylines, _callbacks->appendPolylineVec(name); return true; } - else - return false; + + return false; } const std::vector<Polyline*>* GEOObjects::getPolylineVec(const std::string &name) const @@ -235,16 +235,14 @@ bool GEOObjects::appendSurfaceVec(const std::vector<Surface*>& surfaces, _callbacks->appendSurfaceVec(name); return true; } - else - { - // the copy is needed because addSurfaceVec is passing it to SurfaceVec - // ctor, which needs write access to the surface vector. - auto sfc = std::make_unique<std::vector<GeoLib::Surface*>>(); - for (auto surface : surfaces) - sfc->push_back(surface); - addSurfaceVec(std::move(sfc), name); - return false; - } + + // the copy is needed because addSurfaceVec is passing it to SurfaceVec + // ctor, which needs write access to the surface vector. + auto sfc = std::make_unique<std::vector<GeoLib::Surface*>>(); + for (auto surface : surfaces) + sfc->push_back(surface); + addSurfaceVec(std::move(sfc), name); + return false; } const std::vector<Surface*>* GEOObjects::getSurfaceVec(const std::string &name) const diff --git a/GeoLib/IO/Legacy/OGSIOVer4.cpp b/GeoLib/IO/Legacy/OGSIOVer4.cpp index 03df58a8a76928b317cc449ae2f816e13170ef91..4ce311cf2e12916d13c659dbe35d4eca431590fd 100644 --- a/GeoLib/IO/Legacy/OGSIOVer4.cpp +++ b/GeoLib/IO/Legacy/OGSIOVer4.cpp @@ -521,8 +521,8 @@ bool readGLIFileV4(const std::string& fname, if (errors.empty()) return true; - else - return false; + + return false; } std::size_t writeTINSurfaces(std::ofstream &os, GeoLib::SurfaceVec const* sfcs_vec, std::size_t sfc_count, std::string const& path) diff --git a/GeoLib/OctTree-impl.h b/GeoLib/OctTree-impl.h index 5ba847807c8473fa546844b9ad7a3b35d004432f..3f8eee0256f9d9c1f1771e50f423cce9094e6caf 100644 --- a/GeoLib/OctTree-impl.h +++ b/GeoLib/OctTree-impl.h @@ -90,10 +90,9 @@ bool OctTree<POINT, MAX_POINTS>::addPoint(POINT * pnt, POINT *& ret_pnt) for (auto c : _children) { if (c->addPoint_(pnt, ret_pnt)) { return true; - } else { - if (ret_pnt != nullptr) - return false; } + if (ret_pnt != nullptr) + return false; } } @@ -154,10 +153,9 @@ bool OctTree<POINT, MAX_POINTS>::addPoint_(POINT * pnt, POINT *& ret_pnt) for (auto c : _children) { if (c->addPoint_(pnt, ret_pnt)) { return true; - } else { - if (ret_pnt != nullptr) - return false; } + if (ret_pnt != nullptr) + return false; } } diff --git a/GeoLib/PointVec.cpp b/GeoLib/PointVec.cpp index 4f52e98006feff0208e8ebca6132dc4cb372c872..584dc6ab293682c2623bdabfd4c430f69cdbcaf4 100644 --- a/GeoLib/PointVec.cpp +++ b/GeoLib/PointVec.cpp @@ -188,11 +188,9 @@ std::size_t PointVec::uniqueInsert(Point* pnt) _data_vec->push_back(pnt); return _data_vec->size() - 1; } - else - { - delete pnt; - return ret_pnt->getID(); - } + + delete pnt; + return ret_pnt->getID(); } void PointVec::correctNameIDMapping() diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index daa2a28aa491939dc91d3663c53a5460763819c5..52b3d770bcff0ed3020f1983e625915a616afdd3 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -59,10 +59,9 @@ bool Polygon::initialise () if (this->isClosed()) { ensureCWOrientation(); return true; - } else { - WARN("Polygon::initialise(): base polyline is not closed."); - return false; } + WARN("Polygon::initialise(): base polyline is not closed."); + return false; } bool Polygon::isPntInPolygon (GeoLib::Point const & pnt) const @@ -271,16 +270,16 @@ EdgeType Polygon::getEdgeType (std::size_t k, GeoLib::Point const & pnt) const const GeoLib::Point & w (*(getPoint(k + 1))); if (v[1] < pnt[1] && pnt[1] <= w[1]) return EdgeType::CROSSING; - else - return EdgeType::INESSENTIAL; + + return EdgeType::INESSENTIAL; } case Location::RIGHT: { const GeoLib::Point & v (*(getPoint(k))); const GeoLib::Point & w (*(getPoint(k + 1))); if (w[1] < pnt[1] && pnt[1] <= v[1]) return EdgeType::CROSSING; - else - return EdgeType::INESSENTIAL; + + return EdgeType::INESSENTIAL; } case Location::BETWEEN: case Location::SOURCE: @@ -524,31 +523,38 @@ bool operator==(Polygon const& lhs, Polygon const& rhs) } } return true; - } else { - // opposite direction with start point of first polygon at arbitrary position - // *** ATTENTION - WARN("operator==(Polygon const& lhs, Polygon const& rhs) - not tested case (implementation is probably buggy) - please contact thomas.fischer@ufz.de mentioning the problem."); - // in second polygon - if (lhs.getPointID(1) == rhs.getPointID(k-1)) { - std::size_t j(k-2); - for (; j>0; j--) { - if (lhs.getPointID(k-2-j) != rhs.getPointID(j)) { - return false; - } + } + // opposite direction with start point of first polygon at arbitrary + // position + // *** ATTENTION + WARN( + "operator==(Polygon const& lhs, Polygon const& rhs) - not tested case " + "(implementation is probably buggy) - please contact " + "thomas.fischer@ufz.de mentioning the problem."); + // in second polygon + if (lhs.getPointID(1) == rhs.getPointID(k - 1)) + { + std::size_t j(k - 2); + for (; j > 0; j--) + { + if (lhs.getPointID(k - 2 - j) != rhs.getPointID(j)) + { + return false; } - // new start point at second polygon - the point n-1 of a polygon is equal to the - // first point of the polygon (for this reason: n-2) - j=n-2; - for (; j>k-1; j--) { - if (lhs.getPointID(n-2+j+k-2) != rhs.getPointID(j)) { - return false; - } + } + // new start point at second polygon - the point n-1 of a polygon is + // equal to the first point of the polygon (for this reason: n-2) + j = n - 2; + for (; j > k - 1; j--) + { + if (lhs.getPointID(n - 2 + j + k - 2) != rhs.getPointID(j)) + { + return false; } - return true; - } else { - return false; } + return true; } + return false; } } // end namespace GeoLib diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index 90a863039a4c6d3deb24e00fbc8e9724ab6ac812..0b0beb9e476b80929d0f6c4c0f61571d47e06c89 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -78,17 +78,18 @@ bool Polyline::insertPoint(std::size_t pos, std::size_t pnt_id) // check if inserting pnt_id would result in two identical IDs for adjacent points if (pos == 0 && pnt_id == _ply_pnt_ids[0]) { return false; - } else { - if (pos != 0) { - if (pos == (_ply_pnt_ids.size() - 1) && pnt_id == _ply_pnt_ids[pos]) { - return false; - } else { - if (pnt_id == _ply_pnt_ids[pos - 1] || pnt_id == _ply_pnt_ids[pos]) { - return false; - } - } - } } + if (pos != 0) + { + if (pos == (_ply_pnt_ids.size() - 1) && pnt_id == _ply_pnt_ids[pos]) + { + return false; + } + if (pnt_id == _ply_pnt_ids[pos - 1] || pnt_id == _ply_pnt_ids[pos]) + { + return false; + } + } auto const pos_dt( static_cast<std::vector<std::size_t>::difference_type>(pos)); @@ -193,8 +194,8 @@ bool Polyline::isClosed() const if (_ply_pnt_ids.front() == _ply_pnt_ids.back()) return true; - else - return false; + + return false; } bool Polyline::isCoplanar() const diff --git a/GeoLib/QuadTree.h b/GeoLib/QuadTree.h index 4a40d60ccf88d2bef2c33255df9e9672a84c872a..ef96e22086d69e2665992615977568eccc41beae 100644 --- a/GeoLib/QuadTree.h +++ b/GeoLib/QuadTree.h @@ -294,8 +294,8 @@ private: if (this->_father->isChild (this, Quadrant::NW)) return north_neighbor->getChild (Quadrant::SW); - else - return north_neighbor->getChild (Quadrant::SE); + + return north_neighbor->getChild(Quadrant::SE); } QuadTree<POINT>* getSouthNeighbor () const @@ -316,8 +316,8 @@ private: if (this->_father->isChild (this, Quadrant::SW)) return south_neighbor->getChild (Quadrant::NW); - else - return south_neighbor->getChild (Quadrant::NE); + + return south_neighbor->getChild(Quadrant::NE); } QuadTree<POINT>* getEastNeighbor () const @@ -338,8 +338,8 @@ private: if (this->_father->isChild (this, Quadrant::SE)) return east_neighbor->getChild (Quadrant::SW); - else - return east_neighbor->getChild (Quadrant::NW); + + return east_neighbor->getChild(Quadrant::NW); } QuadTree<POINT>* getWestNeighbor () const @@ -360,8 +360,8 @@ private: if (this->_father->isChild (this, Quadrant::SW)) return west_neighbor->getChild (Quadrant::SE); - else - return west_neighbor->getChild (Quadrant::NE); + + return west_neighbor->getChild(Quadrant::NE); } /** diff --git a/GeoLib/SensorData.cpp b/GeoLib/SensorData.cpp index dcf368718105a0122fa9113b258b4fb9b710a900..697ce47bf9c30eda14e842e7a7226caaab1226b5 100644 --- a/GeoLib/SensorData.cpp +++ b/GeoLib/SensorData.cpp @@ -158,17 +158,21 @@ int SensorData::readDataFromFile(const std::string &file_name) std::string SensorData::convertSensorDataType2String(SensorDataType t) { if (SensorDataType::EVAPORATION == t) return "Evaporation"; - else if (SensorDataType::PRECIPITATION == t) return "Precipitation"; - else if (SensorDataType::TEMPERATURE == t) return "Temperature"; + if (SensorDataType::PRECIPITATION == t) + return "Precipitation"; + if (SensorDataType::TEMPERATURE == t) + return "Temperature"; // pls leave this as last choice - else return "Unknown"; + return "Unknown"; } SensorDataType SensorData::convertString2SensorDataType(const std::string &s) { if ((s.compare("Evaporation")==0) || (s.compare("EVAPORATION")==0)) return SensorDataType::EVAPORATION; - else if ((s.compare("Precipitation")==0) || (s.compare("PRECIPITATION")==0)) return SensorDataType::PRECIPITATION; - else if ((s.compare("Temperature")==0) || (s.compare("TEMPERATURE")==0)) return SensorDataType::TEMPERATURE; - else return SensorDataType::OTHER; + if ((s.compare("Precipitation") == 0) || (s.compare("PRECIPITATION") == 0)) + return SensorDataType::PRECIPITATION; + if ((s.compare("Temperature") == 0) || (s.compare("TEMPERATURE") == 0)) + return SensorDataType::TEMPERATURE; + return SensorDataType::OTHER; } diff --git a/GeoLib/TemplateVec.h b/GeoLib/TemplateVec.h index faf220172e11fe32180f572dceb55d201a592cef..83603034b5518c3a072b9a41decdf8ed5d569c7b 100644 --- a/GeoLib/TemplateVec.h +++ b/GeoLib/TemplateVec.h @@ -121,7 +121,7 @@ public: id = it->second; return true; } - else return false; + return false; } /// Returns an element with the given name. @@ -131,8 +131,8 @@ public: bool ret (getElementIDByName (name, id)); if (ret) return (*_data_vec)[id]; - else - return nullptr; + + return nullptr; } /** diff --git a/MaterialLib/Adsorption/Adsorption.cpp b/MaterialLib/Adsorption/Adsorption.cpp index 17b332c1e36721fce7bc4a3624568488c80f35df..d5e0451ffb13d69844332536b29a1e26a604062f 100644 --- a/MaterialLib/Adsorption/Adsorption.cpp +++ b/MaterialLib/Adsorption/Adsorption.cpp @@ -52,16 +52,19 @@ double AdsorptionReaction::getEvaporationEnthalpy(double T_Ads) // in kJ/kg for (size_t i=0; i< sizeof(c)/sizeof(c[0]);i++) hv += c[i] * pow(T_Ads,i); return hv; - } else if (T_Ads <= 300.){ + } + if (T_Ads <= 300.) + { const double c[] = {2.50043e3,-2.35209,1.91685e-4,-1.94824e-5,2.89539e-7,-3.51199e-9,2.06926e-11,-6.4067e-14,8.518e-17,1.558e-20,-1.122e-22}; double hv = 0.; for (size_t i=0; i< sizeof(c)/sizeof(c[0]);i++) hv += c[i] * pow(T_Ads,i); return hv; - } else { - const double c[] = {2.99866e3,-3.1837e-3,-1.566964e1,-2.514e-6,2.045933e-2,1.0389e-8}; - return ((c[0] + c[2]*T_Ads + c[4]*pow(T_Ads,2))/(1. + c[1]*T_Ads + c[3]*pow(T_Ads,2) + c[5]*pow(T_Ads,3))); } + const double c[] = {2.99866e3, -3.1837e-3, -1.566964e1, + -2.514e-6, 2.045933e-2, 1.0389e-8}; + return ((c[0] + c[2] * T_Ads + c[4] * pow(T_Ads, 2)) / + (1. + c[1] * T_Ads + c[3] * pow(T_Ads, 2) + c[5] * pow(T_Ads, 3))); } diff --git a/MaterialLib/Adsorption/DensityCook.h b/MaterialLib/Adsorption/DensityCook.h index b9215f8dc1ceb05027ffebf6d80cf77696370462..e56c060f3a3b85150178b5432fddb89d215498d8 100644 --- a/MaterialLib/Adsorption/DensityCook.h +++ b/MaterialLib/Adsorption/DensityCook.h @@ -30,11 +30,12 @@ inline double rhoWaterDean(const double T_Ads) if (Tcel <= 100.) { return b[0] + Tcel * (b[1] + Tcel * (b[2] + Tcel * (b[3] + Tcel * b[4]) ) ); } - else { - const double rho_100 = b[0] + b[1]*1.e2 + b[2]*1.e4 + b[3]*1.e6 + b[4]*1.e8; - const double aT_100 = -1./rho_100 * (b[1] + 2.*b[2]*1.e2 + 3.*b[3]*1.e4 + 4.*b[4]*1.e6); - return rho_100 * (1. - aT_100*(Tcel-100.)); - } + + const double rho_100 = + b[0] + b[1] * 1.e2 + b[2] * 1.e4 + b[3] * 1.e6 + b[4] * 1.e8; + const double aT_100 = -1. / rho_100 * (b[1] + 2. * b[2] * 1.e2 + + 3. * b[3] * 1.e4 + 4. * b[4] * 1.e6); + return rho_100 * (1. - aT_100 * (Tcel - 100.)); } inline double alphaTWaterDean(const double T_Ads) @@ -45,11 +46,12 @@ inline double alphaTWaterDean(const double T_Ads) const double r = b[0] + Tcel * (b[1] + Tcel * (b[2] + Tcel * (b[3] + Tcel * b[4]) ) ); return -1.0/r * ( b[1] + Tcel * (2.0*b[2] + Tcel * (3.0*b[3] + Tcel * 4.0*b[4]) ) ); } - else { - const double rho_100 = b[0] + b[1]*1.e2 + b[2]*1.e4 + b[3]*1.e6 + b[4]*1.e8; - const double aT_100 = -1./rho_100 * (b[1] + 2.*b[2]*1.e2 + 3.*b[3]*1.e4 + 4.*b[4]*1.e6); - return aT_100 / (1. - aT_100*(Tcel-100.)); - } + + const double rho_100 = + b[0] + b[1] * 1.e2 + b[2] * 1.e4 + b[3] * 1.e6 + b[4] * 1.e8; + const double aT_100 = -1. / rho_100 * (b[1] + 2. * b[2] * 1.e2 + + 3. * b[3] * 1.e4 + 4. * b[4] * 1.e6); + return aT_100 / (1. - aT_100 * (Tcel - 100.)); } } diff --git a/MaterialLib/Adsorption/DensityDubinin.cpp b/MaterialLib/Adsorption/DensityDubinin.cpp index bb663e658ca038b84d3f6dc3bc4dc0725f8471c1..9e6f920c90391d7a8ceaba78eba545f3f37ed54e 100644 --- a/MaterialLib/Adsorption/DensityDubinin.cpp +++ b/MaterialLib/Adsorption/DensityDubinin.cpp @@ -38,19 +38,18 @@ double DensityDubinin::getAdsorbateDensity(const double T_Ads) const if (T_Ads < Tb) { return rhoWaterDean(T_Ads); - } else { - const double Tc = 647.3; // K - const double pc = 221.2e5; // Pa - // boiling point density - const double rhob = rhoWaterDean(Tb); - // state values - const double R = MaterialLib::PhysicalConstant::IdealGasConstant; - const double M = MaterialLib::PhysicalConstant::MolarMass::Water; - const double b = R * Tc/(8. * pc); // m^3/mol - const double rhom = M/b; // kg/m^3 - const double rho = rhob - (rhob-rhom)/(Tc-Tb)*(T_Ads-Tb); - return rho; } + const double Tc = 647.3; // K + const double pc = 221.2e5; // Pa + // boiling point density + const double rhob = rhoWaterDean(Tb); + // state values + const double R = MaterialLib::PhysicalConstant::IdealGasConstant; + const double M = MaterialLib::PhysicalConstant::MolarMass::Water; + const double b = R * Tc / (8. * pc); // m^3/mol + const double rhom = M / b; // kg/m^3 + const double rho = rhob - (rhob - rhom) / (Tc - Tb) * (T_Ads - Tb); + return rho; } //Thermal expansivity model for water found in the works of Hauer @@ -59,21 +58,20 @@ double DensityDubinin::getAlphaT(const double T_Ads) const const double Tb = 373.1; if (T_Ads <= Tb) { return alphaTWaterDean(T_Ads); - } else { - // critical T and p - const double Tc = 647.3; // K - // const double rhoc = 322.; // kg/m^3 - const double pc = 221.2e5; // Pa - // boiling point density - const double rhob = rhoWaterDean(Tb); - // state values - const double R = MaterialLib::PhysicalConstant::IdealGasConstant; - const double M = MaterialLib::PhysicalConstant::MolarMass::Water; - const double b = R * Tc/(8. * pc); // m^3/mol - const double rhom = M/(b); // kg/m^3 - const double rho = rhob - (rhob-rhom)/(Tc-Tb)*(T_Ads-Tb); - return ((rhob-rhom)/(Tc-Tb)*1./rho); } + // critical T and p + const double Tc = 647.3; // K + // const double rhoc = 322.; // kg/m^3 + const double pc = 221.2e5; // Pa + // boiling point density + const double rhob = rhoWaterDean(Tb); + // state values + const double R = MaterialLib::PhysicalConstant::IdealGasConstant; + const double M = MaterialLib::PhysicalConstant::MolarMass::Water; + const double b = R * Tc / (8. * pc); // m^3/mol + const double rhom = M / (b); // kg/m^3 + const double rho = rhob - (rhob - rhom) / (Tc - Tb) * (T_Ads - Tb); + return ((rhob - rhom) / (Tc - Tb) * 1. / rho); } // Characteristic curve. Return W (A) diff --git a/MaterialLib/Adsorption/Reaction.cpp b/MaterialLib/Adsorption/Reaction.cpp index e6336669565366119f6cca56497db704a60e9ecb..d7357f14360979e1fa10ff4c740a8729424be6e8 100644 --- a/MaterialLib/Adsorption/Reaction.cpp +++ b/MaterialLib/Adsorption/Reaction.cpp @@ -39,11 +39,11 @@ newInstance(BaseLib::ConfigTree const& conf) if (type == "Z13XBF") return std::make_unique<DensityLegacy>(); - else if (type == "Z13XBF_100MPa") + if (type == "Z13XBF_100MPa") return std::make_unique<Density100MPa>(); - else if (type == "Z13XBF_Const") + if (type == "Z13XBF_Const") return std::make_unique<DensityConst>(); - else if (type == "Z13XBF_Cook") + if (type == "Z13XBF_Cook") return std::make_unique<DensityCook>(); else if (type == "Z13XBF_Dubinin") return std::make_unique<DensityDubinin>(); diff --git a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp index a356b380d24a4056dc710f43d238c70c90a1ab57..7940e0c919ad86712621341d46dbdef93b2a8659 100644 --- a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp +++ b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp @@ -106,11 +106,11 @@ std::unique_ptr<FluidProperty> createFluidDensityModel( //! \ogs_file_param{material__fluid__density__Constant__value} config.getConfigParameter<double>("value")); } - else if (type == "LiquidDensity") + if (type == "LiquidDensity") return createLiquidDensity(config); - else if (type == "TemperatureDependent") + if (type == "TemperatureDependent") return createLinearTemperatureDependentDensity(config); - else if (type == "ConcentrationDependent") + if (type == "ConcentrationDependent") return createLinearConcentrationDependentDensity(config); else if (type == "IdealGasLaw") { diff --git a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp index 81cf322b4349bca11a63fc06c5ec190099c5a0c0..d0ba45cfde78e9b62f718429aab326a9d707a3f6 100644 --- a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp +++ b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp @@ -82,11 +82,11 @@ std::unique_ptr<FluidProperties> createFluidProperties( std::move(specific_heat_capacity), std::move(thermal_conductivity), is_mu_density_dependent, is_cp_density_dependent, is_KT_density_dependent); - else - return std::make_unique< - MaterialLib::Fluid::PrimaryVariableDependentFluidProperties>( - std::move(liquid_density), std::move(viscosity), - std::move(specific_heat_capacity), std::move(thermal_conductivity)); + + return std::make_unique< + MaterialLib::Fluid::PrimaryVariableDependentFluidProperties>( + std::move(liquid_density), std::move(viscosity), + std::move(specific_heat_capacity), std::move(thermal_conductivity)); } } // end namespace diff --git a/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.cpp b/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.cpp index c664c3c12355e60afb1e56c06ea33f34b4f3feb9..f677560e4a470b511fcad5434b7747daf1bf5226 100644 --- a/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.cpp +++ b/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.cpp @@ -66,7 +66,7 @@ double FluidPropertiesWithDensityDependentModels::getdValue( { return compute_df_drho_drho_dT(property_type, variable_values); } - else if (variable_type == PropertyVariableType::p) + if (variable_type == PropertyVariableType::p) { return compute_df_drho_drho_dp(property_type, variable_values); } diff --git a/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp b/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp index 55b73280567b2b45680d9a88efcd00c5f0e1b2b2..aa7d3438b63367fa4821261e5da992d42f8314a3 100644 --- a/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp +++ b/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp @@ -34,13 +34,11 @@ std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel( //! \ogs_file_param{material__fluid__specific_heat_capacity__Constant__value} config.getConfigParameter<double>("value")); // TODO: add more models - else - { - OGS_FATAL( - "The viscosity type %s is unavailable.\n" - "The available type is \n\tConstant\n", - type.data()); - } + + OGS_FATAL( + "The viscosity type %s is unavailable.\n" + "The available type is \n\tConstant\n", + type.data()); } } // end namespace diff --git a/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp b/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp index 32fadfafc842c64673722c5a5dc48079176115c2..fdd949517d11f2a331c599daad0385eb9b7dd8a2 100644 --- a/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp +++ b/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp @@ -34,13 +34,11 @@ std::unique_ptr<FluidProperty> createFluidThermalConductivityModel( //! \ogs_file_param{material__fluid__thermal_conductivity__Constant__value} config.getConfigParameter<double>("value")); // TODO: add more models - else - { - OGS_FATAL( - "The viscosity type %s is unavailable.\n" - "The available type is \n\tConstant\n", - type.data()); - } + + OGS_FATAL( + "The viscosity type %s is unavailable.\n" + "The available type is \n\tConstant\n", + type.data()); } } // end namespace diff --git a/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp b/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp index 008bc9ee4cebe8691343c7e93fed251be2486cdf..887b3bac1aa5507010835dc3c5b7c6ea24999097 100644 --- a/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp +++ b/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp @@ -31,11 +31,9 @@ std::unique_ptr<Porosity> createPorosityModel(BaseLib::ConfigTree const& config) return std::make_unique<ConstantPorosity>( //! \ogs_file_param{material__porous_medium__porosity__Constant__value} config.getConfigParameter<double>("value")); - else - { - OGS_FATAL("The porosity type %s is unavailable.\n", - "The available type is \n\tConstant.", type.data()); - } + + OGS_FATAL("The porosity type %s is unavailable.\n", + "The available type is \n\tConstant.", type.data()); } } // end namespace diff --git a/MaterialLib/PorousMedium/Storage/createStorageModel.cpp b/MaterialLib/PorousMedium/Storage/createStorageModel.cpp index 5b2a0db2c5c37e774266cc8661cdf3d0cce9969e..a0c825edaf5a4eca1ad20a6312e94fbed07c2c4a 100644 --- a/MaterialLib/PorousMedium/Storage/createStorageModel.cpp +++ b/MaterialLib/PorousMedium/Storage/createStorageModel.cpp @@ -31,11 +31,9 @@ std::unique_ptr<Storage> createStorageModel(BaseLib::ConfigTree const& config) return std::make_unique<ConstantStorage>( //! \ogs_file_param{material__porous_medium__storage__Constant__value} config.getConfigParameter<double>("value")); - else - { - OGS_FATAL("The storage type %s is unavailable.\n", type.data(), - "The available type is Constant."); - } + + OGS_FATAL("The storage type %s is unavailable.\n", type.data(), + "The available type is Constant."); } } // end namespace diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp index 8ef24f347563f8354017d2280d1c01d6e3845542..6f62cfc59005d491013b2d4cc0bdd734f3328adb 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp @@ -137,11 +137,11 @@ std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel( { return createBrooksCorey(config); } - else if (type == "vanGenuchten") + if (type == "vanGenuchten") { return createVanGenuchten(config); } - else if (type == "Curve") + if (type == "Curve") { //! \ogs_file_param{material__porous_medium__capillary_pressure__type} config.checkConfigParameter("type", "Curve"); @@ -155,14 +155,12 @@ std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel( return std::make_unique<CapillaryPressureSaturationCurve>( std::move(curve)); } - else - { - OGS_FATAL( - "The capillary pressure saturation models %s are unavailable.\n" - "The available types are: \n\tBrooksCorey, \n\tvanGenuchten,", - "\n\tCurve.\n", - type.data()); - } + + OGS_FATAL( + "The capillary pressure saturation models %s are unavailable.\n" + "The available types are: \n\tBrooksCorey, \n\tvanGenuchten,", + "\n\tCurve.\n", + type.data()); } } // end namespace diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.cpp index 5e7e028a7cad49575ab4fb189252062fe20ed97a..937cd3095ca393f1dfd1f302134244441284c092 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.cpp @@ -30,17 +30,15 @@ double VanGenuchtenCapillaryPressureSaturation::getCapillaryPressure( { return getPcBarvGSg(Sg); } - else if (Sg < _saturation_nonwet_r) + if (Sg < _saturation_nonwet_r) { return getPcBarvGSg(_saturation_nonwet_r) + getdPcdSvGBar(_saturation_nonwet_r) * (Sg - _saturation_nonwet_r); } - else - { - return getPcBarvGSg(1 - _saturation_r) + - getdPcdSvGBar(1 - _saturation_r) * (Sg - 1 + _saturation_r); - } + + return getPcBarvGSg(1 - _saturation_r) + + getdPcdSvGBar(1 - _saturation_r) * (Sg - 1 + _saturation_r); } const double S = MathLib::limitValueInInterval(saturation, _saturation_r + _minor_offset, @@ -72,14 +70,12 @@ double VanGenuchtenCapillaryPressureSaturation::getdPcdS( { return -getdPcdSvGBar(Sg); } - else if (Sg < _saturation_nonwet_r) + if (Sg < _saturation_nonwet_r) { return -getdPcdSvGBar(_saturation_nonwet_r); } - else - { - return -getdPcdSvGBar(1 - _saturation_r); - } + + return -getdPcdSvGBar(1 - _saturation_r); } const double S = MathLib::limitValueInInterval(saturation, _saturation_r + _minor_offset, diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp index b81606e226959e0dd9c0a0f60c4d8369656c5497..b6456f5b3ff39683ee2bbc7f41e1afa06f4fac7b 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp @@ -173,15 +173,15 @@ std::unique_ptr<RelativePermeability> createRelativePermeabilityModel( { return createWettingPhaseVanGenuchten(config); } - else if (type == "NonWettingPhaseVanGenuchten") + if (type == "NonWettingPhaseVanGenuchten") { return createNonWettingPhaseVanGenuchten(config); } - else if (type == "WettingPhaseBrooksCoreyOilGas") + if (type == "WettingPhaseBrooksCoreyOilGas") { return createWettingPhaseBrooksCoreyOilGas(config); } - else if (type == "NonWettingPhaseBrooksCoreyOilGas") + if (type == "NonWettingPhaseBrooksCoreyOilGas") { return createNonWettingPhaseBrooksCoreyOilGas(config); } diff --git a/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp b/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp index 27acf820a22216585bfd80b067d17144fe18cea9..16487e0c6b4f3e44c457db0f2a96785f285c2c73 100644 --- a/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp +++ b/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp @@ -166,7 +166,7 @@ double TwoPhaseFlowWithPPMaterialProperties::getNonwetRelativePermeability( { if (saturation < 0.) return 1.0; - else if (saturation > 1) + if (saturation > 1) return 0.0; return boost::math::pow<3>(1 - saturation); } @@ -177,7 +177,7 @@ double TwoPhaseFlowWithPPMaterialProperties::getWetRelativePermeability( { if (saturation < 0) return 0.0; - else if (saturation > 1) + if (saturation > 1) return 1.0; return boost::math::pow<3>(saturation); } diff --git a/MathLib/Curve/PiecewiseLinearMonotonicCurve.cpp b/MathLib/Curve/PiecewiseLinearMonotonicCurve.cpp index 79b38459d90adbb8b83c76d625182bb0151ff3b0..444f435868e06b91bdc837d94a2c45f568cbbc04 100644 --- a/MathLib/Curve/PiecewiseLinearMonotonicCurve.cpp +++ b/MathLib/Curve/PiecewiseLinearMonotonicCurve.cpp @@ -36,13 +36,11 @@ bool PiecewiseLinearMonotonicCurve::isStrongMonotonic() const if (std::fabs(gradient0) < std::numeric_limits<double>::min()) return false; - else - { - return std::none_of(_supp_pnts.begin(), _supp_pnts.end(), - [&](const double p) { - return this->getDerivative(p) * gradient0 <= 0.; - }); - } + + return std::none_of(_supp_pnts.begin(), _supp_pnts.end(), + [&](const double p) { + return this->getDerivative(p) * gradient0 <= 0.; + }); } double PiecewiseLinearMonotonicCurve::getInversVariable(const double y) const @@ -54,17 +52,15 @@ double PiecewiseLinearMonotonicCurve::getInversVariable(const double y) const { return _supp_pnts[0]; } - else if (y >= _values_at_supp_pnts.back()) + if (y >= _values_at_supp_pnts.back()) { return _supp_pnts[_supp_pnts.size() - 1]; } - else - { - // search interval that has the point inside - auto const& it(std::lower_bound(_values_at_supp_pnts.begin(), - _values_at_supp_pnts.end(), y)); - interval_idx = std::distance(_values_at_supp_pnts.begin(), it) - 1; - } + + // search interval that has the point inside + auto const& it(std::lower_bound(_values_at_supp_pnts.begin(), + _values_at_supp_pnts.end(), y)); + interval_idx = std::distance(_values_at_supp_pnts.begin(), it) - 1; } else { @@ -72,19 +68,16 @@ double PiecewiseLinearMonotonicCurve::getInversVariable(const double y) const { return _supp_pnts[0]; } - else if (y <= _values_at_supp_pnts.back()) + if (y <= _values_at_supp_pnts.back()) { return _supp_pnts[_supp_pnts.size() - 1]; } - else - { - // search interval in the reverse direction for the point inside - auto const& it(std::lower_bound(_values_at_supp_pnts.rbegin(), - _values_at_supp_pnts.rend(), y)); - interval_idx = _values_at_supp_pnts.size() - - (std::distance(_values_at_supp_pnts.rbegin(), it)) - - 1; - } + + // search interval in the reverse direction for the point inside + auto const& it(std::lower_bound(_values_at_supp_pnts.rbegin(), + _values_at_supp_pnts.rend(), y)); + interval_idx = _values_at_supp_pnts.size() - + (std::distance(_values_at_supp_pnts.rbegin(), it)) - 1; } const double xi_1 = _supp_pnts[interval_idx + 1]; diff --git a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp index df5ac0e9b9a69419ce52f501ed5366496215e580..723cabe7ee45f347797a152d2c636298194c1f51 100644 --- a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp +++ b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp @@ -40,9 +40,10 @@ PiecewiseLinearInterpolation::PiecewiseLinearInterpolation( if (it != _supp_pnts.end()) { const std::size_t i = std::distance(_supp_pnts.begin(), it); - OGS_FATAL("Variable %d and variable %d are the same. " - "Piecewise linear interpolation is not possible\n", - i, i+1); + OGS_FATAL( + "Variable %d and variable %d are the same. " + "Piecewise linear interpolation is not possible\n", + i, i + 1); } } @@ -114,12 +115,10 @@ double PiecewiseLinearInterpolation::getDerivative( double const w = (pnt_to_interpolate - x) / (x_l - x); return (1. - w) * tangent_right + w * tangent_left; } - else - { - return (_values_at_supp_pnts[interval_idx] - - _values_at_supp_pnts[interval_idx - 1]) / - (_supp_pnts[interval_idx] - _supp_pnts[interval_idx - 1]); - } + + return (_values_at_supp_pnts[interval_idx] - + _values_at_supp_pnts[interval_idx - 1]) / + (_supp_pnts[interval_idx] - _supp_pnts[interval_idx - 1]); } double PiecewiseLinearInterpolation::getSupportMax() const diff --git a/MathLib/LinAlg/PETSc/PETScMatrix.h b/MathLib/LinAlg/PETSc/PETScMatrix.h index 50b623fa3d18ff8fffda6c0f98c9ed7054521ff1..90fc96ac00c967d276a0a061aba22e6e976695dd 100644 --- a/MathLib/LinAlg/PETSc/PETScMatrix.h +++ b/MathLib/LinAlg/PETSc/PETScMatrix.h @@ -112,10 +112,7 @@ class PETScMatrix } /// Get matrix reference. - PETSc_Mat &getRawMatrix() - { - return _A; - } + Mat& getRawMatrix() { return _A; } /*! Get a matrix reference. * @@ -123,10 +120,7 @@ class PETScMatrix * This method is dangerous insofar as you can do arbitrary things also * with a const PETSc matrix. */ - PETSc_Mat const& getRawMatrix() const - { - return _A; - } + Mat const& getRawMatrix() const { return _A; } /// Set all entries to zero. void setZero() @@ -227,7 +221,7 @@ class PETScMatrix void destroy() { if (_A) MatDestroy(&_A); _A = nullptr; } /// PETSc matrix - PETSc_Mat _A = nullptr; + Mat _A = nullptr; /// Number of the global rows PetscInt _nrows; diff --git a/MathLib/Nonlinear/Root1D.h b/MathLib/Nonlinear/Root1D.h index 7b60212e87527eb5accf5e92b5b061598401334e..426c1f5ca0bb165254aea9aca80b90941c9ceb67 100644 --- a/MathLib/Nonlinear/Root1D.h +++ b/MathLib/Nonlinear/Root1D.h @@ -81,7 +81,9 @@ public: if (detail::almost_zero(fc)) { _a = _b = c; return; - } else if (!detail::same_sign(fc, _fb)) { + } + if (!detail::same_sign(fc, _fb)) + { _a = _b; _fa = _fb; _b = c; _fb = fc; } else { diff --git a/MathLib/TemplatePoint.h b/MathLib/TemplatePoint.h index 293df0eceb512da3dc66e05b6a17ad39926880a5..8edae75ba9b41962f9b96b64a0ce860c53f9867f 100644 --- a/MathLib/TemplatePoint.h +++ b/MathLib/TemplatePoint.h @@ -123,11 +123,12 @@ bool operator< (TemplatePoint<T,DIM> const& a, TemplatePoint<T,DIM> const& b) { if (a[i] > b[i]) { return false; - } else { - if (a[i] < b[i]) { - return true; - } } + if (a[i] < b[i]) + { + return true; + } + // continue with next dimension, because a[0] == b[0] } @@ -161,10 +162,7 @@ bool lessEq(TemplatePoint<T, DIM> const& a, TemplatePoint<T, DIM> const& b, // test a relative and an absolute criterion if (coordinateIsLargerEps(a[i], b[i])) { - if (a[i] <= b[i]) - return true; - else - return false; + return static_cast<bool>(a[i] <= b[i]); } // a[i] ~= b[i] up to an epsilon. Compare next dimension. } diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index 98bd173a24c68a98863e0309131dec449e295162..9026e911836278ebe95a6d9cd76dddba91838495 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -242,11 +242,11 @@ static MeshLib::Element const* findElementContainingPointXY( delete elem_2d->getNode(k); } return elem; - } else { - // clean up the copied nodes - for (std::size_t k(0); k<elem_2d->getNumberOfNodes(); ++k) { - delete elem_2d->getNode(k); - } + } + // clean up the copied nodes + for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k) + { + delete elem_2d->getNode(k); } } return nullptr; diff --git a/MeshLib/CoordinateSystem.h b/MeshLib/CoordinateSystem.h index f8ed88db0b490f8f1d9c53be9e45bebef1259046..2a918a2e9f502fd987ddc750e9dd12d32f5de0bb 100644 --- a/MeshLib/CoordinateSystem.h +++ b/MeshLib/CoordinateSystem.h @@ -55,10 +55,10 @@ public: unsigned getDimension() const { if (hasZ()) return 3; - else if (hasY()) + if (hasY()) return 2; - else - return 1; + + return 1; } /// has X dimension diff --git a/MeshLib/ElementStatus.cpp b/MeshLib/ElementStatus.cpp index 3beef299edc1d78a7c40aa881ef6f1fb98768729..fa26ffce4200996c8430e82abb10abcbf3269b17 100644 --- a/MeshLib/ElementStatus.cpp +++ b/MeshLib/ElementStatus.cpp @@ -71,16 +71,16 @@ std::vector<MeshLib::Element*> const& ElementStatus::getActiveElements() const { if (_hasAnyInactive) return _vec_active_eles; - else - return _mesh->getElements(); + + return _mesh->getElements(); } std::vector<MeshLib::Node*> const& ElementStatus::getActiveNodes() const { if (_hasAnyInactive) return _vec_active_nodes; - else - return _mesh->getNodes(); + + return _mesh->getNodes(); } std::vector<MeshLib::Element*> ElementStatus::getActiveElementsAtNode(std::size_t node_id) const diff --git a/MeshLib/Elements/Element.cpp b/MeshLib/Elements/Element.cpp index aa76fb7d795f2cb4513ccce932ba8090c6917528..7f2e8237932b5d82d0ad934b1ba466896622d73c 100644 --- a/MeshLib/Elements/Element.cpp +++ b/MeshLib/Elements/Element.cpp @@ -224,7 +224,7 @@ bool isPointInElementXY(MathLib::Point3d const& p, Element const& e) return MathLib::isPointInTriangleXY(p, n0, n1, n2); } - else if (e.getGeomType() == MeshElemType::QUAD) + if (e.getGeomType() == MeshElemType::QUAD) { MathLib::Point3d const& n0(*e.getNode(0)); MathLib::Point3d const& n1(*e.getNode(1)); @@ -234,12 +234,9 @@ bool isPointInElementXY(MathLib::Point3d const& p, Element const& e) return MathLib::isPointInTriangleXY(p, n0, n1, n2) || MathLib::isPointInTriangleXY(p, n0, n2, n3); } - else - { - WARN("isPointInElementXY: element type \"%s\" is not supported.", - MeshLib::MeshElemType2String(e.getGeomType()).c_str()); - return false; - } -} + WARN("isPointInElementXY: element type \"%s\" is not supported.", + MeshLib::MeshElemType2String(e.getGeomType()).c_str()); + return false; +} } diff --git a/MeshLib/Elements/ElementErrorCode.h b/MeshLib/Elements/ElementErrorCode.h index ac284ae897b9a0bd11289ff6b45778b2b2043b2b..74bf8624e6ee36d8dd85facb827943c1fbba98b3 100644 --- a/MeshLib/Elements/ElementErrorCode.h +++ b/MeshLib/Elements/ElementErrorCode.h @@ -48,11 +48,11 @@ public: { if (e == ElementErrorFlag::ZeroVolume) return "zero volume"; - else if (e == ElementErrorFlag::NonCoplanar) + if (e == ElementErrorFlag::NonCoplanar) return "non coplanar nodes"; - else if (e == ElementErrorFlag::NonConvex) + if (e == ElementErrorFlag::NonConvex) return "non-convex geometry"; - else if (e == ElementErrorFlag::NodeOrder) + if (e == ElementErrorFlag::NodeOrder) return "wrong node order"; return "nonspecified error"; } diff --git a/MeshLib/Elements/PrismRule15.cpp b/MeshLib/Elements/PrismRule15.cpp index edc1ac1eb18e9a0c0b09a47569f5cce58b2c5626..ee2ac06ffbaa340360779e7a27947f70d5894a11 100644 --- a/MeshLib/Elements/PrismRule15.cpp +++ b/MeshLib/Elements/PrismRule15.cpp @@ -50,10 +50,10 @@ const Element* PrismRule15::getFace(const Element* e, unsigned i) for (unsigned j=0; j<nFaceNodes; j++) nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); - if (i==0 || i==4) + if (i == 0 || i == 4) return new Tri6(nodes); - else - return new Quad8(nodes); + + return new Quad8(nodes); } ERR("Error in MeshLib::Element::getFace() - Index %d does not exist.", i); return nullptr; diff --git a/MeshLib/Elements/PrismRule6.cpp b/MeshLib/Elements/PrismRule6.cpp index 3c4327add346a6c546459a1da35ddbbbb45c785d..5919fdb90defeec071a455e924fd26710a5ec779 100644 --- a/MeshLib/Elements/PrismRule6.cpp +++ b/MeshLib/Elements/PrismRule6.cpp @@ -52,10 +52,10 @@ const Element* PrismRule6::getFace(const Element* e, unsigned i) for (unsigned j=0; j<nFaceNodes; j++) nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); - if (i==0 || i==4) + if (i == 0 || i == 4) return new Tri(nodes); - else - return new Quad(nodes); + + return new Quad(nodes); } ERR("Error in MeshLib::Element::getFace() - Index %d does not exist.", i); return nullptr; diff --git a/MeshLib/Elements/PyramidRule13.cpp b/MeshLib/Elements/PyramidRule13.cpp index 1960f12ad756dc119bad0fdecc866af14a06d4f8..6ab723e77c8b80c1f505aeaaf81149894dd8ae18 100644 --- a/MeshLib/Elements/PyramidRule13.cpp +++ b/MeshLib/Elements/PyramidRule13.cpp @@ -49,10 +49,10 @@ const Element* PyramidRule13::getFace(const Element* e, unsigned i) for (unsigned j=0; j<nFaceNodes; j++) nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); - if (i<4) + if (i < 4) return new Tri6(nodes); - else - return new Quad8(nodes); + + return new Quad8(nodes); } ERR("Error in MeshLib::Element::getFace() - Index %d does not exist.", i); return nullptr; diff --git a/MeshLib/Elements/PyramidRule5.cpp b/MeshLib/Elements/PyramidRule5.cpp index cb2616461bc264fe2a4d18ee9a6024b248b2b966..78bd225bd8f0886d54e4d88ea2baad18443b374d 100644 --- a/MeshLib/Elements/PyramidRule5.cpp +++ b/MeshLib/Elements/PyramidRule5.cpp @@ -51,10 +51,10 @@ const Element* PyramidRule5::getFace(const Element* e, unsigned i) for (unsigned j=0; j<nFaceNodes; j++) nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); - if (i<4) + if (i < 4) return new Tri(nodes); - else - return new Quad(nodes); + + return new Quad(nodes); } ERR("Error in MeshLib::Element::getFace() - Index %d does not exist.", i); return nullptr; diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h index 413f25cbe2fcc9108802064a9e46da9dd7e27f5c..791409b86238dc7eed536f108798d3f110a3ff97 100644 --- a/MeshLib/Elements/TemplateElement.h +++ b/MeshLib/Elements/TemplateElement.h @@ -144,10 +144,11 @@ public: /// Return a specific edge node. inline Node* getEdgeNode(unsigned edge_id, unsigned node_id) const override { - if (getNumberOfEdges()>0) - return const_cast<Node*>(this->_nodes[ELEMENT_RULE::edge_nodes[edge_id][node_id]]); - else - return nullptr; + if (getNumberOfEdges() > 0) + return const_cast<Node*>( + this->_nodes[ELEMENT_RULE::edge_nodes[edge_id][node_id]]); + + return nullptr; } /** diff --git a/MeshLib/IO/Legacy/MeshIO.cpp b/MeshLib/IO/Legacy/MeshIO.cpp index 426c032864ed1d3bfd5ded2deb259e2de861e59a..45158e259492764881ca330584701b38151446eb 100644 --- a/MeshLib/IO/Legacy/MeshIO.cpp +++ b/MeshLib/IO/Legacy/MeshIO.cpp @@ -70,7 +70,7 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) // check keywords if (line_string.find("#STOP") != std::string::npos) break; - else if (line_string.find("$NODES") != std::string::npos) + if (line_string.find("$NODES") != std::string::npos) { double x, y, z, double_dummy; unsigned idx; @@ -147,11 +147,9 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) in.close(); return mesh; } - else - { - in.close(); - return nullptr; - } + + in.close(); + return nullptr; } std::size_t MeshIO::readMaterialID(std::istream & in) const diff --git a/MeshLib/IO/writeMeshToFile.cpp b/MeshLib/IO/writeMeshToFile.cpp index 3580a4326ea9fc6e2b3b9a7f4e0168c6de382c57..2472bd9b7937cd59dfb6367df0d3354631a8812e 100644 --- a/MeshLib/IO/writeMeshToFile.cpp +++ b/MeshLib/IO/writeMeshToFile.cpp @@ -30,7 +30,9 @@ int writeMeshToFile(const MeshLib::Mesh &mesh, const std::string &file_name) meshIO.setMesh(&mesh); meshIO.writeToFile(file_name); return 0; - } else if (BaseLib::hasFileExtension("vtu", file_name)) { + } + if (BaseLib::hasFileExtension("vtu", file_name)) + { MeshLib::IO::VtuInterface writer(&mesh); writer.writeToFile(file_name); return 0; diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h index 6f26b61c0de67fb66186eb037cbee927637d3a52..bb307ed8acb8c66ffc2d07a1b7abaa73e411ccef 100644 --- a/MeshLib/Mesh.h +++ b/MeshLib/Mesh.h @@ -276,14 +276,12 @@ PropertyVector<T>* getOrCreateMeshProperty(Mesh& mesh, assert(result->size() == numberOfMeshItems() * number_of_components); return result; } - else - { - auto result = mesh.getProperties().template createNewPropertyVector<T>( - property_name, item_type, number_of_components); - assert(result); - result->resize(numberOfMeshItems() * number_of_components); - return result; - } + + auto result = mesh.getProperties().template createNewPropertyVector<T>( + property_name, item_type, number_of_components); + assert(result); + result->resize(numberOfMeshItems() * number_of_components); + return result; } } /* namespace */ diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp index ade3934074bba7b4228026ea02c7bee96a668e0b..1cadf0e4e64cb70d40dc7cb94fa90b92082061b4 100644 --- a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp +++ b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp @@ -44,11 +44,11 @@ MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::v { if (element->getGeomType() == MeshElemType::LINE) return copyElement<MeshLib::Line>(element, nodes); - else if (element->getGeomType() == MeshElemType::TRIANGLE) + if (element->getGeomType() == MeshElemType::TRIANGLE) return copyElement<MeshLib::Tri>(element, nodes); - else if (element->getGeomType() == MeshElemType::QUAD) + if (element->getGeomType() == MeshElemType::QUAD) return copyElement<MeshLib::Quad>(element, nodes); - else if (element->getGeomType() == MeshElemType::TETRAHEDRON) + if (element->getGeomType() == MeshElemType::TETRAHEDRON) return copyElement<MeshLib::Tet>(element, nodes); else if (element->getGeomType() == MeshElemType::HEXAHEDRON) return copyElement<MeshLib::Hex>(element, nodes); diff --git a/MeshLib/MeshEditing/FlipElements.cpp b/MeshLib/MeshEditing/FlipElements.cpp index cef1426e36ca181b18114b85d0159a81185dd33b..37da7231a714437bf6d99ba97987bc7d540d9bbe 100644 --- a/MeshLib/MeshEditing/FlipElements.cpp +++ b/MeshLib/MeshEditing/FlipElements.cpp @@ -33,10 +33,10 @@ std::unique_ptr<MeshLib::Element> createFlippedElement( if (elem.getGeomType() == MeshElemType::LINE) return std::make_unique<MeshLib::Line>(elem_nodes.release(), elem.getID()); - else if (elem.getGeomType() == MeshElemType::TRIANGLE) + if (elem.getGeomType() == MeshElemType::TRIANGLE) return std::make_unique<MeshLib::Tri>(elem_nodes.release(), elem.getID()); - else if (elem.getGeomType() == MeshElemType::QUAD) + if (elem.getGeomType() == MeshElemType::QUAD) { std::swap(elem_nodes[2], elem_nodes[3]); return std::make_unique<MeshLib::Quad>(elem_nodes.release(), diff --git a/MeshLib/MeshEditing/MeshRevision.cpp b/MeshLib/MeshEditing/MeshRevision.cpp index c7a9877cadd81b37025df6d21c7445cad30a72b3..af879086bdccf961d5c6206024a81b280be02205 100644 --- a/MeshLib/MeshEditing/MeshRevision.cpp +++ b/MeshLib/MeshEditing/MeshRevision.cpp @@ -279,11 +279,11 @@ std::size_t MeshRevision::subdivideElement( { if (element->getGeomType() == MeshElemType::QUAD) return this->subdivideQuad(element, nodes, elements); - else if (element->getGeomType() == MeshElemType::HEXAHEDRON) + if (element->getGeomType() == MeshElemType::HEXAHEDRON) return this->subdivideHex(element, nodes, elements); - else if (element->getGeomType() == MeshElemType::PYRAMID) + if (element->getGeomType() == MeshElemType::PYRAMID) return this->subdividePyramid(element, nodes, elements); - else if (element->getGeomType() == MeshElemType::PRISM) + if (element->getGeomType() == MeshElemType::PRISM) return this->subdividePrism(element, nodes, elements); return 0; } @@ -301,9 +301,9 @@ std::size_t MeshRevision::reduceElement(MeshLib::Element const*const element, { elements.push_back (this->constructLine(element, nodes)); return 1; - } else - if ((element->getGeomType() == MeshElemType::QUAD) || - (element->getGeomType() == MeshElemType::TETRAHEDRON)) + } + if ((element->getGeomType() == MeshElemType::QUAD) || + (element->getGeomType() == MeshElemType::TETRAHEDRON)) { if (n_unique_nodes == 3 && min_elem_dim < 3) elements.push_back (this->constructTri(element, nodes)); @@ -311,9 +311,12 @@ std::size_t MeshRevision::reduceElement(MeshLib::Element const*const element, elements.push_back (this->constructLine(element, nodes)); return 1; } - else if (element->getGeomType() == MeshElemType::HEXAHEDRON) { + if (element->getGeomType() == MeshElemType::HEXAHEDRON) + { return reduceHex(element, n_unique_nodes, nodes, elements, min_elem_dim); - } else if (element->getGeomType() == MeshElemType::PYRAMID) { + } + if (element->getGeomType() == MeshElemType::PYRAMID) + { this->reducePyramid(element, n_unique_nodes, nodes, elements, min_elem_dim); return 1; } else if (element->getGeomType() == MeshElemType::PRISM) { @@ -759,20 +762,18 @@ MeshLib::Element* MeshRevision::constructFourNodeElement( { if (elem->validate().none()) return elem; - else - { - // change node order if not convex - MeshLib::Node* tmp = new_nodes[i+1]; - new_nodes[i+1] = new_nodes[i]; - new_nodes[i] = tmp; - } + + // change node order if not convex + MeshLib::Node* tmp = new_nodes[i + 1]; + new_nodes[i + 1] = new_nodes[i]; + new_nodes[i] = tmp; } return elem; } - else if (!isQuad) + if (!isQuad) return new MeshLib::Tet(new_nodes); - else // is quad but min elem dim == 3 - return nullptr; + // is quad but min elem dim == 3 + return nullptr; } unsigned MeshRevision::findPyramidTopNode(MeshLib::Element const& element, @@ -847,13 +848,19 @@ const std::pair<unsigned, unsigned> MeshRevision::lutHexBackNodes( unsigned MeshRevision::lutPrismThirdNode(unsigned id1, unsigned id2) const { - if ((id1==0 && id2==1) || (id1==1 && id2==2)) return 2; - else if ((id1==1 && id2==2) || (id1==2 && id2==1)) return 0; - else if ((id1==0 && id2==2) || (id1==2 && id2==0)) return 1; - else if ((id1==3 && id2==4) || (id1==4 && id2==3)) return 5; - else if ((id1==4 && id2==5) || (id1==5 && id2==4)) return 3; - else if ((id1==3 && id2==5) || (id1==5 && id2==3)) return 4; - else return std::numeric_limits<unsigned>::max(); + if ((id1 == 0 && id2 == 1) || (id1 == 1 && id2 == 2)) + return 2; + if ((id1 == 1 && id2 == 2) || (id1 == 2 && id2 == 1)) + return 0; + if ((id1 == 0 && id2 == 2) || (id1 == 2 && id2 == 0)) + return 1; + if ((id1 == 3 && id2 == 4) || (id1 == 4 && id2 == 3)) + return 5; + if ((id1 == 4 && id2 == 5) || (id1 == 5 && id2 == 4)) + return 3; + if ((id1 == 3 && id2 == 5) || (id1 == 5 && id2 == 3)) + return 4; + return std::numeric_limits<unsigned>::max(); } void MeshRevision::cleanUp(std::vector<MeshLib::Node*> &new_nodes, std::vector<MeshLib::Element*> &new_elements) const diff --git a/MeshLib/MeshEditing/RemoveMeshComponents.cpp b/MeshLib/MeshEditing/RemoveMeshComponents.cpp index c1aa910c0862b369d32e550782ad504870c760d0..cdba5ab05077eb56178b6aadec0792fbe6599692 100644 --- a/MeshLib/MeshEditing/RemoveMeshComponents.cpp +++ b/MeshLib/MeshEditing/RemoveMeshComponents.cpp @@ -80,11 +80,9 @@ MeshLib::Mesh* removeElements(const MeshLib::Mesh& mesh, const std::vector<std:: removed_element_ids, removed_node_ids)); return new_mesh; } - else - { - INFO("Current selection removes all elements."); - return nullptr; - } + + INFO("Current selection removes all elements."); + return nullptr; } MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::size_t> &del_nodes_idx, const std::string &new_mesh_name) @@ -131,10 +129,8 @@ MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::siz removed_element_ids, del_nodes_idx)); return new_mesh; } - else - { - return nullptr; - } + + return nullptr; } } // end namespace MeshLib diff --git a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp index a22b63ea61df281612820cf0690b6db11e90fecf..10c8aa8694769f8baab1d7ed12e3d6d84cc688c7 100644 --- a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp +++ b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp @@ -92,11 +92,12 @@ MeshLib::Node* LayeredMeshGenerator::getNewLayerNode(MeshLib::Node const& dem_no { double const elevation = std::min(raster.interpolateValueAtPoint(dem_node), dem_node[2]); - if ((std::abs(elevation - raster.getHeader().no_data) < std::numeric_limits<double>::epsilon()) || + if ((std::abs(elevation - raster.getHeader().no_data) < + std::numeric_limits<double>::epsilon()) || (elevation - last_layer_node[2] < _minimum_thickness)) return new MeshLib::Node(last_layer_node); - else - return new MeshLib::Node(dem_node[0], dem_node[1], elevation, new_node_id); + + return new MeshLib::Node(dem_node[0], dem_node[1], elevation, new_node_id); } void LayeredMeshGenerator::cleanUpOnError() diff --git a/MeshLib/MeshQuality/EdgeRatioMetric.cpp b/MeshLib/MeshQuality/EdgeRatioMetric.cpp index 5da30958f3cc07f217130d760efb0fd1a808100a..5a6206abe480774a5fcebf4d60bfecf02dd92c4f 100644 --- a/MeshLib/MeshQuality/EdgeRatioMetric.cpp +++ b/MeshLib/MeshQuality/EdgeRatioMetric.cpp @@ -81,34 +81,30 @@ double EdgeRatioMetric::checkTriangle (MathLib::Point3d const& a, MathLib::Point3d const& b, MathLib::Point3d const& c) const { - double len0 (sqrt(MathLib::sqrDist (b,a))); - double len1 (sqrt(MathLib::sqrDist (b,c))); - double len2 (sqrt(MathLib::sqrDist (a,c))); + double len0(sqrt(MathLib::sqrDist(b, a))); + double len1(sqrt(MathLib::sqrDist(b, c))); + double len2(sqrt(MathLib::sqrDist(a, c))); if (len0 < len1 && len0 < len2) { if (len1 < len2) return len0 / len2; - else - return len0 / len1; + + return len0 / len1; } - else + + if (len1 < len2) { - if (len1 < len2) - { - if (len0 < len2) - return len1 / len2; - else - return len1 / len0; - } - else - { - if (len0 < len1) - return len2 / len1; - else - return len2 / len0; - } + if (len0 < len2) + return len1 / len2; + + return len1 / len0; } + + if (len0 < len1) + return len2 / len1; + + return len2 / len0; } double EdgeRatioMetric::checkQuad (MathLib::Point3d const& a, diff --git a/MeshLib/MeshSearch/MeshElementGrid.cpp b/MeshLib/MeshSearch/MeshElementGrid.cpp index 9622b90c08aa14eb4f263fe77171cbdc329ecde2..bce212bfa9e9b07ba1215ea5e67862ebe49f9017 100644 --- a/MeshLib/MeshSearch/MeshElementGrid.cpp +++ b/MeshLib/MeshSearch/MeshElementGrid.cpp @@ -139,13 +139,13 @@ bool MeshElementGrid::sortElementInGridCells(MeshLib::Element const& element) c = getGridCellCoordinates(*(static_cast<MathLib::Point3d const*>(element.getNode(k)))); if (!c.first) return false; - else { - for (std::size_t j(0); j<3; ++j) { - if (min[j] > c.second[j]) - min[j] = c.second[j]; - if (max[j] < c.second[j]) - max[j] = c.second[j]; - } + + for (std::size_t j(0); j < 3; ++j) + { + if (min[j] > c.second[j]) + min[j] = c.second[j]; + if (max[j] < c.second[j]) + max[j] = c.second[j]; } } diff --git a/MeshLib/MeshSurfaceExtraction.cpp b/MeshLib/MeshSurfaceExtraction.cpp index b478f489b725dd2f4c612f3bc0b73038a6aa8b03..166ccaecc749abc8eb61d9bf7cc983afc0d03a7b 100644 --- a/MeshLib/MeshSurfaceExtraction.cpp +++ b/MeshLib/MeshSurfaceExtraction.cpp @@ -182,11 +182,11 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshBoundary(const MeshLib::Mesh &mesh) MeshLib::NodeSearch ns(*result); if (ns.searchUnused() == 0) { return result; - } else { - auto removed = MeshLib::removeNodes(*result, ns.getSearchedNodeIDs(), result->getName()); - delete result; - return removed; } + auto removed = MeshLib::removeNodes(*result, ns.getSearchedNodeIDs(), + result->getName()); + delete result; + return removed; } void MeshSurfaceExtraction::get2DSurfaceElements( diff --git a/NumLib/ODESolver/ConvergenceCriterion.cpp b/NumLib/ODESolver/ConvergenceCriterion.cpp index 0ddb813292d2e1279f06abb9aa5b7dd0171245c5..5d0d3d110b2f048abb91523cad8c5daf43247d0b 100644 --- a/NumLib/ODESolver/ConvergenceCriterion.cpp +++ b/NumLib/ODESolver/ConvergenceCriterion.cpp @@ -26,11 +26,17 @@ std::unique_ptr<ConvergenceCriterion> createConvergenceCriterion( if (type == "DeltaX") { return createConvergenceCriterionDeltaX(config); - } else if (type == "Residual") { + } + if (type == "Residual") + { return createConvergenceCriterionResidual(config); - } else if (type == "PerComponentDeltaX") { + } + if (type == "PerComponentDeltaX") + { return createConvergenceCriterionPerComponentDeltaX(config); - } else if (type == "PerComponentResidual") { + } + if (type == "PerComponentResidual") + { return createConvergenceCriterionPerComponentResidual(config); } diff --git a/NumLib/ODESolver/MatrixTranslator.h b/NumLib/ODESolver/MatrixTranslator.h index 7565730d762354841c340e2d49c3b4a216a2b6a1..589e47afc07249af90a4088e297055abcffda526 100644 --- a/NumLib/ODESolver/MatrixTranslator.h +++ b/NumLib/ODESolver/MatrixTranslator.h @@ -297,17 +297,14 @@ std::unique_ptr<MatrixTranslator<ODETag>> createMatrixTranslator( return std::unique_ptr<MatrixTranslator<ODETag>>( new MatrixTranslatorForwardEuler<ODETag>(*fwd_euler)); } - else if (auto* crank = - dynamic_cast<CrankNicolson const*>(&timeDisc)) + if (auto* crank = dynamic_cast<CrankNicolson const*>(&timeDisc)) { return std::unique_ptr<MatrixTranslator<ODETag>>( new MatrixTranslatorCrankNicolson<ODETag>(*crank)); } - else - { - return std::unique_ptr<MatrixTranslator<ODETag>>( - new MatrixTranslatorGeneral<ODETag>(timeDisc)); - } + + return std::unique_ptr<MatrixTranslator<ODETag>>( + new MatrixTranslatorGeneral<ODETag>(timeDisc)); } //! @} diff --git a/NumLib/ODESolver/NonlinearSolver.cpp b/NumLib/ODESolver/NonlinearSolver.cpp index 84c3d52da10729bef6a8823e3fe95e63c7d62077..c8a36c347e193e5669b32095b1e6da5ce8ac662b 100644 --- a/NumLib/ODESolver/NonlinearSolver.cpp +++ b/NumLib/ODESolver/NonlinearSolver.cpp @@ -319,7 +319,9 @@ createNonlinearSolver(GlobalLinearSolver& linear_solver, using ConcreteNLS = NonlinearSolver<tag>; return std::make_pair( std::make_unique<ConcreteNLS>(linear_solver, max_iter), tag); - } else if (type == "Newton") { + } + if (type == "Newton") + { auto const tag = NonlinearSolverTag::Newton; using ConcreteNLS = NonlinearSolver<tag>; return std::make_pair( diff --git a/NumLib/ODESolver/TimeDiscretizationBuilder.cpp b/NumLib/ODESolver/TimeDiscretizationBuilder.cpp index 40d891911563467dc1eadbbe83c91b91f4921161..d434ac16cee863bb6f70744a253bf80602e73b72 100644 --- a/NumLib/ODESolver/TimeDiscretizationBuilder.cpp +++ b/NumLib/ODESolver/TimeDiscretizationBuilder.cpp @@ -25,19 +25,19 @@ std::unique_ptr<TimeDiscretization> createTimeDiscretization( return std::make_unique<BackwardEuler>(); } //! \ogs_file_param_special{prj__time_loop__processes__process__time_discretization__ForwardEuler} - else if (type == "ForwardEuler") + if (type == "ForwardEuler") { return std::make_unique<ForwardEuler>(); } //! \ogs_file_param_special{prj__time_loop__processes__process__time_discretization__CrankNicolson} - else if (type == "CrankNicolson") + if (type == "CrankNicolson") { //! \ogs_file_param{prj__time_loop__processes__process__time_discretization__CrankNicolson__theta} auto const theta = config.getConfigParameter<double>("theta"); return std::make_unique<CrankNicolson>(theta); } //! \ogs_file_param_special{prj__time_loop__processes__process__time_discretization__BackwardDifferentiationFormula} - else if (type == "BackwardDifferentiationFormula") + if (type == "BackwardDifferentiationFormula") { //! \ogs_file_param{prj__time_loop__processes__process__time_discretization__BackwardDifferentiationFormula__order} auto const order = config.getConfigParameter<unsigned>("order"); diff --git a/ProcessLib/BoundaryCondition/BoundaryCondition.cpp b/ProcessLib/BoundaryCondition/BoundaryCondition.cpp index 98a44215c09a9ca969256ff4d01dbf6d52a2daaf..8df5b5e7bf7354726d678fb06b8969f5e76ebe87 100644 --- a/ProcessLib/BoundaryCondition/BoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/BoundaryCondition.cpp @@ -36,22 +36,20 @@ BoundaryConditionBuilder::createBoundaryCondition( config, dof_table, mesh, variable_id, integration_order, shapefunction_order, parameters); } - else if (type == "Neumann") + if (type == "Neumann") { return createNeumannBoundaryCondition( config, dof_table, mesh, variable_id, integration_order, shapefunction_order, parameters); } - else if (type == "Robin") + if (type == "Robin") { return createRobinBoundaryCondition( config, dof_table, mesh, variable_id, integration_order, shapefunction_order, parameters); } - else - { - OGS_FATAL("Unknown boundary condition type: `%s'.", type.c_str()); - } + + OGS_FATAL("Unknown boundary condition type: `%s'.", type.c_str()); } std::unique_ptr<BoundaryCondition> diff --git a/ProcessLib/CreateJacobianAssembler.cpp b/ProcessLib/CreateJacobianAssembler.cpp index d40f0344bd6de289b1b5f6b4108b590c522e8bbc..1fee3e3eb988e34ff5821689bc38df1731982905 100644 --- a/ProcessLib/CreateJacobianAssembler.cpp +++ b/ProcessLib/CreateJacobianAssembler.cpp @@ -27,7 +27,9 @@ std::unique_ptr<AbstractJacobianAssembler> createJacobianAssembler( if (type == "Analytical") { config->ignoreConfigParameter("type"); return std::make_unique<AnalyticalJacobianAssembler>(); - } else if (type == "CentralDifferences") { + } + if (type == "CentralDifferences") + { return createCentralDifferencesJacobianAssembler(*config); } diff --git a/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h b/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h index cca32a96d4dae3e7bb521b210754bcdd5d1a1c3c..3827ae943edd399c4d0d31767bec949fbe73dae7 100644 --- a/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h +++ b/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h @@ -322,13 +322,11 @@ private: e, n_variables, local_matrix_size, dofIndex_to_localIndex, std::forward<ConstructorArgs>(args)... }}; - } else { - return LADataIntfPtr{ - new LADataMatrixNearFracture<ShapeFunctionDisplacement, ShapeFunctionPressure>{ - e, n_variables, local_matrix_size, dofIndex_to_localIndex, - std::forward<ConstructorArgs>(args)... - }}; } + return LADataIntfPtr{new LADataMatrixNearFracture< + ShapeFunctionDisplacement, ShapeFunctionPressure>{ + e, n_variables, local_matrix_size, dofIndex_to_localIndex, + std::forward<ConstructorArgs>(args)...}}; } return LADataIntfPtr{ new LAFractureData<ShapeFunctionDisplacement, ShapeFunctionPressure>{ diff --git a/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h b/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h index 0f0985e677b2c7f2131bc89795e1f38bded8c148..da915ef43088cdaff14146bd20be23caa34f408d 100644 --- a/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h +++ b/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h @@ -380,14 +380,12 @@ private: e, local_matrix_size, std::forward<ConstructorArgs>(args)...}}; } - else - { - return LADataIntfPtr{ - new LADataMatrixNearFracture<ShapeFunction>{ - e, n_variables, local_matrix_size, - dofIndex_to_localIndex, - std::forward<ConstructorArgs>(args)...}}; - } + + return LADataIntfPtr{ + new LADataMatrixNearFracture<ShapeFunction>{ + e, n_variables, local_matrix_size, + dofIndex_to_localIndex, + std::forward<ConstructorArgs>(args)...}}; } return LADataIntfPtr{new LAFractureData<ShapeFunction>{ e, local_matrix_size, dofIndex_to_localIndex, diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp b/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp index bf57232732b39e452bb84c299c6b07ae12fc0c5e..8fb0f1397bc76eab02b28cf3b92e38d910a0d942 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp @@ -115,16 +115,13 @@ createLiquidFlowMaterialProperties( has_material_ids, material_ids, solid_thermal_expansion, biot_constant); } - else - { - ConstantParameter<double> void_parameter("void_solid_thermal_expansion", - 0.); - return std::make_unique<LiquidFlowMaterialProperties>( - std::move(fluid_properties), - std::move(intrinsic_permeability_models), - std::move(porosity_models), std::move(storage_models), - has_material_ids, material_ids, void_parameter, void_parameter); - } + + ConstantParameter<double> void_parameter("void_solid_thermal_expansion", + 0.); + return std::make_unique<LiquidFlowMaterialProperties>( + std::move(fluid_properties), std::move(intrinsic_permeability_models), + std::move(porosity_models), std::move(storage_models), has_material_ids, + material_ids, void_parameter, void_parameter); } } // end of namespace diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp index 577261fc04c6ffb5ca3e00cb6431ad989d41b257..01c570cbe7c8f4413596a046608965a7fe9136ea 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp @@ -90,28 +90,26 @@ std::unique_ptr<Process> createLiquidFlowProcess( std::move(named_function_caller), *mat_ids, has_material_ids, gravity_axis_id, g, reference_temperature, mat_config}}; } - else - { - INFO("The liquid flow is in homogeneous porous media."); - - MeshLib::Properties dummy_property; - // For a reference argument of LiquidFlowProcess(...). - auto const& dummy_property_vector = - dummy_property.createNewPropertyVector<int>( - "MaterialIDs", MeshLib::MeshItemType::Cell, 1); - // Since dummy_property_vector is only visible in this function, - // the following constant, has_material_ids, is employed to indicate - // that material_ids does not exist. - const bool has_material_ids = false; - - return std::unique_ptr<Process>{new LiquidFlowProcess{ - mesh, std::move(jacobian_assembler), parameters, integration_order, - std::move(process_variables), std::move(secondary_variables), - std::move(named_function_caller), *dummy_property_vector, - has_material_ids, gravity_axis_id, g, reference_temperature, - mat_config}}; - } + INFO("The liquid flow is in homogeneous porous media."); + + MeshLib::Properties dummy_property; + // For a reference argument of LiquidFlowProcess(...). + auto const& dummy_property_vector = + dummy_property.createNewPropertyVector<int>( + "MaterialIDs", MeshLib::MeshItemType::Cell, 1); + + // Since dummy_property_vector is only visible in this function, + // the following constant, has_material_ids, is employed to indicate + // that material_ids does not exist. + const bool has_material_ids = false; + + return std::unique_ptr<Process>{new LiquidFlowProcess{ + mesh, std::move(jacobian_assembler), parameters, integration_order, + std::move(process_variables), std::move(secondary_variables), + std::move(named_function_caller), *dummy_property_vector, + has_material_ids, gravity_axis_id, g, reference_temperature, + mat_config}}; } } // end of namespace diff --git a/ProcessLib/Parameter/GroupBasedParameter.cpp b/ProcessLib/Parameter/GroupBasedParameter.cpp index 246a38e75ca10f9fc74a833427ab0071784fdcaf..d59ab1b95a4df3c59291159b81fecb063a891b14 100644 --- a/ProcessLib/Parameter/GroupBasedParameter.cpp +++ b/ProcessLib/Parameter/GroupBasedParameter.cpp @@ -87,8 +87,7 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( return std::make_unique< GroupBasedParameter<double, MeshLib::MeshItemType::Node>>( name, *group_id_property, vec_values); - else if (group_id_property->getMeshItemType() == - MeshLib::MeshItemType::Cell) + if (group_id_property->getMeshItemType() == MeshLib::MeshItemType::Cell) return std::make_unique< GroupBasedParameter<double, MeshLib::MeshItemType::Cell>>( name, *group_id_property, vec_values); diff --git a/ProcessLib/Parameter/Parameter.cpp b/ProcessLib/Parameter/Parameter.cpp index d1dba1bc7ad5e436cbbabfcd4246f528d78f1a27..3f9295f223a66f17121363a7cd9ecc7951550fae 100644 --- a/ProcessLib/Parameter/Parameter.cpp +++ b/ProcessLib/Parameter/Parameter.cpp @@ -39,19 +39,19 @@ std::unique_ptr<ParameterBase> createParameter( auto param = createConstantParameter(name, config); return param; } - else if (type == "CurveScaled") + if (type == "CurveScaled") { INFO("CurveScaledParameter: %s", name.c_str()); auto param = createCurveScaledParameter(name, config, curves); return param; } - else if (type == "Group") + if (type == "Group") { INFO("GroupBasedParameter: %s", name.c_str()); auto param = createGroupBasedParameter(name, config, *meshes.front()); return param; } - else if (type == "MeshElement") + if (type == "MeshElement") { INFO("MeshElementParameter: %s", name.c_str()); auto param = createMeshElementParameter(name, config, *meshes.front()); diff --git a/ProcessLib/TES/TESOGS5MaterialModels.h b/ProcessLib/TES/TESOGS5MaterialModels.h index 9b2ccd3920b6fde709189f1fcb6f3c9306361cd6..ca4b35acdb753e1c70104940fb5ea4832e0120fd 100644 --- a/ProcessLib/TES/TESOGS5MaterialModels.h +++ b/ProcessLib/TES/TESOGS5MaterialModels.h @@ -36,11 +36,9 @@ double mypow(const double x) { return 1.0 / mypow<-i>(x); } - else - { - const double p = mypow<(i >> 1)>(x); - return (i & 1) ? p * p * x : p * p; - } + + const double p = mypow<(i >> 1)>(x); + return (i & 1) ? p * p * x : p * p; } template <> diff --git a/ProcessLib/TES/TESReactionAdaptor.cpp b/ProcessLib/TES/TESReactionAdaptor.cpp index 599b79d0bd9e4266c8d2dc33a6fb42deed0afabc..c65e96ace24675a5357b4c6f5830e5cca1a1a652 100644 --- a/ProcessLib/TES/TESReactionAdaptor.cpp +++ b/ProcessLib/TES/TESReactionAdaptor.cpp @@ -33,16 +33,15 @@ std::unique_ptr<TESFEMReactionAdaptor> TESFEMReactionAdaptor::newInstance( { return std::make_unique<TESFEMReactionAdaptorAdsorption>(data); } - else if (dynamic_cast<Adsorption::ReactionInert const*>(ads) != nullptr) + if (dynamic_cast<Adsorption::ReactionInert const*>(ads) != nullptr) { return std::make_unique<TESFEMReactionAdaptorInert>(data); } - else if (dynamic_cast<Adsorption::ReactionSinusoidal const*>(ads) != - nullptr) + if (dynamic_cast<Adsorption::ReactionSinusoidal const*>(ads) != nullptr) { return std::make_unique<TESFEMReactionAdaptorSinusoidal>(data); } - else if (dynamic_cast<Adsorption::ReactionCaOH2 const*>(ads) != nullptr) + if (dynamic_cast<Adsorption::ReactionCaOH2 const*>(ads) != nullptr) { return std::make_unique<TESFEMReactionAdaptorCaOH2>(data); } @@ -299,7 +298,7 @@ ReactionRate TESFEMReactionAdaptorSinusoidal::initReaction( TESFEMReactionAdaptorCaOH2::TESFEMReactionAdaptorCaOH2( TESLocalAssemblerData const& data) : _d(data), - _react(dynamic_cast<Adsorption::ReactionCaOH2&>(*data.ap.react_sys.get())) + _react(dynamic_cast<Adsorption::ReactionCaOH2&>(*data.ap.react_sys)) { _ode_solver = MathLib::ODE::createODESolver<1>(_react.getOdeSolverConfig()); // TODO invalidate config diff --git a/ProcessLib/UncoupledProcessesTimeLoop.cpp b/ProcessLib/UncoupledProcessesTimeLoop.cpp index f5e1ab759dd484b8aa18c6ceff99aff5a1b6f96f..f31970e6894ce354fe4bdacf8ee519e8e72746aa 100644 --- a/ProcessLib/UncoupledProcessesTimeLoop.cpp +++ b/ProcessLib/UncoupledProcessesTimeLoop.cpp @@ -261,19 +261,17 @@ std::unique_ptr<SingleProcessData> makeSingleProcessData( std::move(time_disc), process, std::move(coupled_processes), std::move(process_output)); } - else if (auto* nonlinear_solver_newton = - dynamic_cast<NumLib::NonlinearSolver<Tag::Newton>*>( - &nonlinear_solver)) + if (auto* nonlinear_solver_newton = + dynamic_cast<NumLib::NonlinearSolver<Tag::Newton>*>( + &nonlinear_solver)) { return std::make_unique<SingleProcessData>( *nonlinear_solver_newton, std::move(conv_crit), std::move(time_disc), process, std::move(coupled_processes), std::move(process_output)); } - else - { - OGS_FATAL("Encountered unknown nonlinear solver type. Aborting"); - } + + OGS_FATAL("Encountered unknown nonlinear solver type. Aborting"); } std::vector<std::unique_ptr<SingleProcessData>> createPerProcessData( @@ -687,10 +685,8 @@ bool UncoupledProcessesTimeLoop::solveUncoupledEquationSystems( return false; } - else - { - _output->doOutput(pcs, spd->process_output, timestep_id, t, x); - } + + _output->doOutput(pcs, spd->process_output, timestep_id, t, x); ++pcs_idx; } // end of for (auto& spd : _per_process_data) diff --git a/Tests/GeoLib/TestLineSegmentIntersect2d.cpp b/Tests/GeoLib/TestLineSegmentIntersect2d.cpp index 925be966f63d6d6d83bdf36bbbfdb008d646a46c..285a476f394fc0268ca1e9bdedb5a206a5bc79b3 100644 --- a/Tests/GeoLib/TestLineSegmentIntersect2d.cpp +++ b/Tests/GeoLib/TestLineSegmentIntersect2d.cpp @@ -74,8 +74,8 @@ TEST_F(LineSegmentIntersect2dTest, RandomSegmentOrientationIntersecting) const double sqr_dist(MathLib::sqrDist(ipnts[0], center)); if (sqr_dist < std::numeric_limits<double>::epsilon()) return true; - else - return false; + + return false; } return ipnts.size() == 2; };