From b917388237cd7abd84ee6d532ca3fe83dd866bb5 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Thu, 18 May 2017 20:36:42 +0200 Subject: [PATCH] Use std::make_unique(). --- Applications/ApplicationsLib/LogogSetup.h | 5 +- Applications/ApplicationsLib/ProjectData.cpp | 3 +- .../DataExplorer/DataView/GEOModels.cpp | 2 +- .../DataExplorer/DataView/MshView.cpp | 2 +- Applications/DataExplorer/main.cpp | 2 +- Applications/DataExplorer/mainwindow.cpp | 17 +++--- .../FileIO/FEFLOW/FEFLOWMeshInterface.cpp | 4 +- Applications/FileIO/Gmsh/GMSHInterface.cpp | 3 +- Applications/FileIO/Gmsh/GMSHPolygonTree.cpp | 6 +- Applications/FileIO/SHPInterface.cpp | 15 ++--- Applications/FileIO/SWMM/SWMMInterface.cpp | 11 ++-- Applications/FileIO/TetGenInterface.cpp | 6 +- .../Utils/FileConverter/ConvertSHPToGLI.cpp | 2 +- Applications/Utils/FileConverter/TIN2VTK.cpp | 3 +- .../Utils/GeoTools/TriangulatePolyline.cpp | 3 +- ...CreateBoundaryConditionsAlongPolylines.cpp | 16 ++---- .../generateStructuredMesh.cpp | 2 +- GeoLib/AnalyticalGeometry.cpp | 7 +-- GeoLib/DuplicateGeometry.cpp | 10 ++-- GeoLib/GEOObjects.cpp | 20 +++---- GeoLib/Grid.h | 7 +-- GeoLib/IO/Legacy/OGSIOVer4.cpp | 15 ++--- .../IO/XmlIO/Boost/BoostXmlGmlInterface.cpp | 15 ++--- GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp | 15 ++--- GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp | 6 +- GeoLib/Surface.cpp | 4 +- GeoLib/TemplateVec.h | 2 +- MaterialLib/Adsorption/Reaction.cpp | 22 +++---- .../Fluid/Density/CreateFluidDensityModel.cpp | 26 ++++----- .../FluidProperties/CreateFluidProperties.cpp | 21 ++++--- .../CreateSpecificFluidHeatCapacityModel.cpp | 4 +- .../CreateFluidThermalConductivityModel.cpp | 4 +- .../Fluid/Viscosity/CreateViscosityModel.cpp | 30 +++++----- .../CreateLinearElasticIsotropic.cpp | 3 +- .../FractureModels/CreateMohrCoulomb.cpp | 3 +- .../Porosity/createPorosityModel.cpp | 4 +- .../Storage/createStorageModel.cpp | 4 +- .../CreateCapillaryPressureModel.cpp | 14 ++--- .../CreateRelativePermeabilityModel.cpp | 17 +++--- MaterialLib/SolidModels/CreateEhlers.h | 4 +- .../CreateLinearElasticIsotropic.h | 3 +- .../CreateTwoPhaseFlowMaterialProperties.cpp | 15 +++-- .../Curve/CreatePiecewiseLinearCurve-impl.h | 3 +- MathLib/LinAlg/Eigen/EigenLinearSolver.cpp | 8 ++- MathLib/LinAlg/MatrixVectorTraits.cpp | 33 +++++------ MathLib/ODE/ConcreteODESolver.h | 3 +- MeshGeoToolsLib/AppendLinesAlongPolyline.cpp | 4 +- MeshGeoToolsLib/MeshNodeSearcher.cpp | 5 +- MeshLib/MeshEditing/AddLayerToMesh.cpp | 5 +- MeshLib/MeshEditing/ConvertToLinearMesh.cpp | 10 ++-- MeshLib/MeshEditing/FlipElements.cpp | 19 +++---- MeshLib/MeshGenerators/LayeredVolume.cpp | 2 +- MeshLib/MeshSearch/MeshElementGrid.cpp | 13 ++--- MeshLib/convertMeshToGeo.cpp | 5 +- .../ODESolver/ConvergenceCriterionDeltaX.cpp | 5 +- ...ConvergenceCriterionPerComponentDeltaX.cpp | 5 +- ...nvergenceCriterionPerComponentResidual.cpp | 5 +- .../ConvergenceCriterionResidual.cpp | 5 +- NumLib/ODESolver/NonlinearSolver.cpp | 10 +--- .../Algorithms/FixedTimeStepping.cpp | 2 +- .../DirichletBoundaryCondition.cpp | 7 +-- .../NeumannBoundaryCondition.cpp | 7 +-- .../RobinBoundaryCondition.cpp | 8 +-- .../CalculateSurfaceFlux.cpp | 9 ++- .../CentralDifferencesJacobianAssembler.cpp | 4 +- .../CreateComponentTransportProcess.cpp | 4 +- ProcessLib/CreateJacobianAssembler.cpp | 6 +- .../CreateGroundwaterFlowProcess.cpp | 4 +- ProcessLib/HT/CreateHTProcess.cpp | 4 +- .../CreateHeatConductionProcess.cpp | 4 +- .../CreateHydroMechanicsProcess.cpp | 9 ++- .../HydroMechanics/HydroMechanicsProcess.h | 21 +++---- .../BoundaryConditionBuilder.cpp | 4 +- .../NeumannBoundaryCondition.cpp | 9 ++- ProcessLib/LIE/Common/PostUtils.cpp | 3 +- .../CreateHydroMechanicsProcess.cpp | 11 ++-- .../HydroMechanics/HydroMechanicsProcess.cpp | 38 +++++++------ .../CreateSmallDeformationProcess.cpp | 9 ++- .../SmallDeformationProcess.cpp | 27 ++++----- .../CreateLiquidFlowMaterialProperties.cpp | 25 ++++---- ProcessLib/Parameter/ConstantParameter.cpp | 6 +- ProcessLib/Parameter/CurveScaledParameter.cpp | 4 +- ProcessLib/Parameter/GroupBasedParameter.cpp | 12 ++-- ProcessLib/Parameter/MeshElementParameter.cpp | 3 +- ProcessLib/Parameter/MeshNodeParameter.cpp | 3 +- ProcessLib/Process.cpp | 12 ++-- ProcessLib/ProcessVariable.cpp | 2 +- .../CreateRichardsFlowProcess.cpp | 4 +- .../CreateSmallDeformationProcess.cpp | 9 ++- .../SmallDeformationProcess.h | 6 +- ProcessLib/TES/CreateTESProcess.cpp | 4 +- ProcessLib/TES/TESProcess.cpp | 9 ++- ProcessLib/TES/TESReactionAdaptor.cpp | 14 ++--- ...alTwoPhaseFlowWithPPMaterialProperties.cpp | 22 ++++--- ...CreateThermalTwoPhaseFlowWithPPProcess.cpp | 4 +- ...teTwoPhaseFlowWithPPMaterialProperties.cpp | 14 ++--- .../CreateTwoPhaseFlowWithPPProcess.cpp | 4 +- ...eateTwoPhaseFlowPrhoMaterialProperties.cpp | 13 ++--- .../CreateTwoPhaseFlowWithPrhoProcess.cpp | 4 +- ProcessLib/UncoupledProcessesTimeLoop.cpp | 31 +++++----- Tests/FileIO/TestGmlInterface.h | 15 ++--- Tests/GeoLib/AutoCheckGenerators.cpp | 4 +- ...tComputeAndInsertAllIntersectionPoints.cpp | 3 +- Tests/GeoLib/TestDuplicateGeometry.cpp | 6 +- Tests/GeoLib/TestGEOObjectsMerge.cpp | 30 ++++------ Tests/GeoLib/TestPointVec.cpp | 14 ++--- Tests/MeshGeoToolsLib/TestGeoMapper.cpp | 3 +- Tests/MeshLib/TestBoundaryElementSearch.cpp | 6 +- Tests/MeshLib/TestCoordinatesMappingLocal.cpp | 4 +- Tests/MeshLib/TestMeshNodeSearch.cpp | 17 +++--- Tests/MeshLib/TestProjectMeshOnPlane.cpp | 2 +- Tests/NumLib/LocalToGlobalIndexMap.cpp | 57 ++++++++++--------- .../LocalToGlobalIndexMapMultiComponent.cpp | 20 +++---- Tests/NumLib/TestDistribution.cpp | 24 +++----- Tests/NumLib/TestExtrapolation.cpp | 7 ++- Tests/NumLib/TestODEInt.cpp | 15 ++--- Tests/NumLib/TestSparsityPattern.cpp | 20 +++---- Tests/ProcessLib/TestLIE.cpp | 10 ++-- Tests/testrunner.cpp | 8 +-- 119 files changed, 528 insertions(+), 649 deletions(-) diff --git a/Applications/ApplicationsLib/LogogSetup.h b/Applications/ApplicationsLib/LogogSetup.h index 9862f4a290b..d7cc24fa4ad 100644 --- a/Applications/ApplicationsLib/LogogSetup.h +++ b/Applications/ApplicationsLib/LogogSetup.h @@ -28,9 +28,8 @@ public: LogogSetup() { LOGOG_INITIALIZE(); - logog_cout = std::unique_ptr<logog::Cout>(new logog::Cout); - setFormatter(std::unique_ptr<BaseLib::LogogSimpleFormatter> - (new BaseLib::LogogSimpleFormatter)); + logog_cout = std::make_unique<logog::Cout>(); + setFormatter(std::make_unique<BaseLib::LogogSimpleFormatter>()); } ~LogogSetup() diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index d9103b63295..aa6e935372e 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -507,8 +507,7 @@ void ProjectData::parseLinearSolvers(BaseLib::ConfigTree const& config) BaseLib::insertIfKeyUniqueElseError( _linear_solvers, name, - std::unique_ptr<GlobalLinearSolver>( - new GlobalLinearSolver("", &conf)), + std::make_unique<GlobalLinearSolver>("", &conf), "The linear solver name is not unique"); } } diff --git a/Applications/DataExplorer/DataView/GEOModels.cpp b/Applications/DataExplorer/DataView/GEOModels.cpp index 96a5c30d1f7..5b1e901ec7d 100644 --- a/Applications/DataExplorer/DataView/GEOModels.cpp +++ b/Applications/DataExplorer/DataView/GEOModels.cpp @@ -27,7 +27,7 @@ GEOModels::GEOModels(GeoLib::GEOObjects& geo_objects, QObject* parent /*= 0*/) : QObject(parent), _geo_objects(geo_objects) { - _geo_objects._callbacks.reset(new GEOModelsCallbacks{*this}); + _geo_objects._callbacks = std::make_unique<GEOModelsCallbacks>(*this); _geoModel = new GeoTreeModel(); _stationModel = new StationTreeModel(); diff --git a/Applications/DataExplorer/DataView/MshView.cpp b/Applications/DataExplorer/DataView/MshView.cpp index 4eb6417c486..728513f6ffe 100644 --- a/Applications/DataExplorer/DataView/MshView.cpp +++ b/Applications/DataExplorer/DataView/MshView.cpp @@ -159,7 +159,7 @@ void MshView::openMap2dMeshDialog() if (dlg.exec() != QDialog::Accepted) return; - std::unique_ptr<MeshLib::Mesh> result(new MeshLib::Mesh(*mesh)); + auto result = std::make_unique<MeshLib::Mesh>(*mesh); result->setName(dlg.getNewMeshName()); if (dlg.useRasterMapping()) { diff --git a/Applications/DataExplorer/main.cpp b/Applications/DataExplorer/main.cpp index 0e7bc1a9815..2de9c234f62 100644 --- a/Applications/DataExplorer/main.cpp +++ b/Applications/DataExplorer/main.cpp @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) QApplication::setOrganizationDomain("opengeosys.org"); setlocale(LC_NUMERIC,"C"); QLocale::setDefault(QLocale::German); - std::unique_ptr<MainWindow> w (new MainWindow()); + auto w = std::make_unique<MainWindow>(); w->setWindowTitle( w->windowTitle() + " - " + QString::fromStdString(BaseLib::BuildInfo::git_describe)); if (QCoreApplication::arguments().size()>1) { diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index 905df83a4af..fe3af8a93f5 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -108,11 +108,11 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) setupUi(this); // Setup various models - _meshModel.reset(new MshModel(_project)); - _elementModel.reset(new ElementTreeModel()); - _processModel.reset(new TreeModel()); + _meshModel = std::make_unique<MshModel>(_project); + _elementModel = std::make_unique<ElementTreeModel>(); + _processModel = std::make_unique<TreeModel>(); - _geo_model.reset(new GEOModels{_project.getGEOObjects()}); + _geo_model = std::make_unique<GEOModels>(_project.getGEOObjects()); geoTabWidget->treeView->setModel(_geo_model->getGeoModel()); stationTabWidget->treeView->setModel(_geo_model->getStationModel()); mshTabWidget->treeView->setModel(_meshModel.get()); @@ -120,7 +120,8 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) modellingTabWidget->treeView->setModel(_processModel.get()); // vtk visualization pipeline - _vtkVisPipeline.reset(new VtkVisPipeline(visualizationWidget->renderer())); + _vtkVisPipeline = + std::make_unique<VtkVisPipeline>(visualizationWidget->renderer()); // station model connects connect(stationTabWidget->treeView, SIGNAL(openStationListFile(int)), @@ -327,7 +328,8 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) SLOT(createPresentationMenu())); menuWindows->insertMenu(showVisDockAction, presentationMenu); - _visPrefsDialog.reset(new VisPrefsDialog(*_vtkVisPipeline, *visualizationWidget)); + _visPrefsDialog = std::make_unique<VisPrefsDialog>(*_vtkVisPipeline, + *visualizationWidget); } void MainWindow::closeEvent(QCloseEvent* event) @@ -540,8 +542,7 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) { if (fi.suffix().toLower() == "txt") // GMS borehole files { - auto boreholes = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>()); + auto boreholes = std::make_unique<std::vector<GeoLib::Point*>>(); std::string name = fi.baseName().toStdString(); if (GMSInterface::readBoreholesFromGMS(boreholes.get(), fileName.toStdString())) diff --git a/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp b/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp index 1a85ecedf56..05c626ed285 100644 --- a/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp +++ b/Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp @@ -211,8 +211,8 @@ MeshLib::Mesh* FEFLOWMeshInterface::readFEFLOWFile(const std::string& filename) INFO("Create mesh"); std::string project_name( BaseLib::extractBaseNameWithoutExtension(filename)); - auto mesh(std::unique_ptr<MeshLib::Mesh>( - new MeshLib::Mesh(project_name, vec_nodes, vec_elements))); + auto mesh( + std::make_unique<MeshLib::Mesh>(project_name, vec_nodes, vec_elements)); INFO("Set values for material property."); auto opt_material_ids(mesh->getProperties().createNewPropertyVector<int>( "MaterialIDs", MeshLib::MeshItemType::Cell, 1)); diff --git a/Applications/FileIO/Gmsh/GMSHInterface.cpp b/Applications/FileIO/Gmsh/GMSHInterface.cpp index 43e497936b7..5f02a6f17a2 100644 --- a/Applications/FileIO/Gmsh/GMSHInterface.cpp +++ b/Applications/FileIO/Gmsh/GMSHInterface.cpp @@ -157,8 +157,7 @@ int GMSHInterface::writeGMSHInputFile(std::ostream& out) // *** insert stations and polylines (except polygons) in the appropriate object of // class GMSHPolygonTree // *** insert stations - auto gmsh_stations = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto gmsh_stations = std::make_unique<std::vector<GeoLib::Point*>>(); for (auto const& geometry_name : _selected_geometries) { auto const* stations(_geo_objs.getStationVec(geometry_name)); if (stations) { diff --git a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp index f89729114b4..337250085eb 100644 --- a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp +++ b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp @@ -387,10 +387,8 @@ void GMSHPolygonTree::writeAdditionalPointData(std::size_t & pnt_id_offset, std: #ifndef NDEBUG if (dynamic_cast<GMSHAdaptiveMeshDensity*>(_mesh_density_strategy)) { - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); - auto plys = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); + auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>(); dynamic_cast<GMSHAdaptiveMeshDensity*>(_mesh_density_strategy)->getQuadTreeGeometry(*pnts, *plys); std::string quad_tree_geo("QuadTree"); _geo_objs.addPointVec(std::move(pnts), quad_tree_geo); diff --git a/Applications/FileIO/SHPInterface.cpp b/Applications/FileIO/SHPInterface.cpp index 5e3969bd7d7..81424262032 100644 --- a/Applications/FileIO/SHPInterface.cpp +++ b/Applications/FileIO/SHPInterface.cpp @@ -72,8 +72,7 @@ void SHPInterface::readSHPFile(const std::string &filename, OGSType choice, cons void SHPInterface::readPoints(const SHPHandle &hSHP, int numberOfElements, std::string listName) { if (numberOfElements > 0) { - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(); SHPObject* hSHPObject; for (int i = 0; i < numberOfElements; i++) { @@ -93,8 +92,7 @@ void SHPInterface::readPoints(const SHPHandle &hSHP, int numberOfElements, std:: void SHPInterface::readStations(const SHPHandle &hSHP, int numberOfElements, std::string listName) { if (numberOfElements > 0) { - auto stations = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto stations = std::make_unique<std::vector<GeoLib::Point*>>(); stations->reserve(numberOfElements); SHPObject* hSHPObject; @@ -116,10 +114,8 @@ void SHPInterface::readPolylines(const SHPHandle &hSHP, int numberOfElements, st { if (numberOfElements <= 0) return; - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); - auto lines = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); + auto lines = std::make_unique<std::vector<GeoLib::Polyline*>>(); std::size_t pnt_id(0); // for each polyline @@ -178,8 +174,7 @@ void SHPInterface::readPolygons(const SHPHandle &hSHP, int numberOfElements, con readPolylines(hSHP, numberOfElements, listName); auto const polylines = _geoObjects.getPolylineVec(listName); - auto sfc_vec = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); + auto sfc_vec = std::make_unique<std::vector<GeoLib::Surface*>>(); for (auto const* polyline : *polylines) { GeoLib::Surface* sfc(GeoLib::Surface::createSurface(*polyline)); diff --git a/Applications/FileIO/SWMM/SWMMInterface.cpp b/Applications/FileIO/SWMM/SWMMInterface.cpp index 53f89222c0c..fa5b333edf9 100644 --- a/Applications/FileIO/SWMM/SWMMInterface.cpp +++ b/Applications/FileIO/SWMM/SWMMInterface.cpp @@ -374,8 +374,8 @@ bool SwmmInterface::convertSwmmInputToGeometry(std::string const& inp_file_name, return false; } - std::unique_ptr<std::vector<GeoLib::Point*>> points (new std::vector<GeoLib::Point*>); - std::unique_ptr<std::vector<GeoLib::Polyline*>> lines (new std::vector<GeoLib::Polyline*>); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(); + auto lines = std::make_unique<std::vector<GeoLib::Polyline*>>(); std::vector<std::string> pnt_names; std::vector<std::string> line_names; @@ -416,8 +416,7 @@ bool SwmmInterface::convertSwmmInputToGeometry(std::string const& inp_file_name, return geometryCleanup(*points, *lines); } - std::unique_ptr<std::map<std::string, std::size_t>> name_id_map{ - new std::map<std::string, std::size_t>}; + auto name_id_map = std::make_unique<std::map<std::string, std::size_t>>(); std::size_t const n_names (pnt_names.size()); for (std::size_t i=0; i<n_names; ++i) { @@ -468,8 +467,8 @@ bool SwmmInterface::convertSwmmInputToGeometry(std::string const& inp_file_name, delete ply; return false; } - std::unique_ptr<std::map<std::string, std::size_t>> line_id_map{ - new std::map<std::string, std::size_t>}; + auto line_id_map = + std::make_unique<std::map<std::string, std::size_t>>(); std::size_t const n_names (line_names.size()); for (std::size_t i=0; i<n_names; ++i) line_id_map->insert(std::make_pair(line_names[i], i)); diff --git a/Applications/FileIO/TetGenInterface.cpp b/Applications/FileIO/TetGenInterface.cpp index c19ad9e9062..8faa618d2aa 100644 --- a/Applications/FileIO/TetGenInterface.cpp +++ b/Applications/FileIO/TetGenInterface.cpp @@ -64,8 +64,7 @@ bool TetGenInterface::readTetGenGeometry (std::string const& geo_fname, return false; } const std::size_t nNodes (nodes.size()); - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(); points->reserve(nNodes); for (std::size_t k(0); k<nNodes; ++k) { @@ -76,8 +75,7 @@ bool TetGenInterface::readTetGenGeometry (std::string const& geo_fname, geo_objects.addPointVec(std::move(points), geo_name); const std::vector<std::size_t> &id_map (geo_objects.getPointVecObj(geo_name)->getIDMap()); - auto surfaces = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); + auto surfaces = std::make_unique<std::vector<GeoLib::Surface*>>(); if (!parseSmeshFacets(poly_stream, *surfaces, *geo_objects.getPointVec(geo_name), id_map)) { // remove surfaces read until now but keep the points diff --git a/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp b/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp index 8537bcd040b..78fdfbfc6e4 100644 --- a/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp +++ b/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp @@ -41,7 +41,7 @@ void convertPoints (DBFHandle dbf_handle, int n_records (DBFGetRecordCount (dbf_handle)); INFO("Reading %d records.", n_records); - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>(new std::vector<GeoLib::Point*>); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(); points->reserve (n_records); std::string name; diff --git a/Applications/Utils/FileConverter/TIN2VTK.cpp b/Applications/Utils/FileConverter/TIN2VTK.cpp index 13475fb2be1..e1cc1319219 100644 --- a/Applications/Utils/FileConverter/TIN2VTK.cpp +++ b/Applications/Utils/FileConverter/TIN2VTK.cpp @@ -49,8 +49,7 @@ int main (int argc, char* argv[]) INFO("reading the TIN file..."); const std::string tinFileName(inArg.getValue()); - auto pnt_vec = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto pnt_vec = std::make_unique<std::vector<GeoLib::Point*>>(); GeoLib::PointVec point_vec("SurfacePoints", std::move(pnt_vec)); std::unique_ptr<GeoLib::Surface> sfc( GeoLib::IO::TINInterface::readTIN(tinFileName, point_vec)); diff --git a/Applications/Utils/GeoTools/TriangulatePolyline.cpp b/Applications/Utils/GeoTools/TriangulatePolyline.cpp index 65ad2681bd5..acd65f60e9b 100644 --- a/Applications/Utils/GeoTools/TriangulatePolyline.cpp +++ b/Applications/Utils/GeoTools/TriangulatePolyline.cpp @@ -97,8 +97,7 @@ int main(int argc, char *argv[]) // create surface INFO ("Triangulating surface..."); - auto new_sfc = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); + auto new_sfc = std::make_unique<std::vector<GeoLib::Surface*>>(); new_sfc->push_back(GeoLib::Surface::createSurface(*line)); GeoLib::SurfaceVec* sfc_vec (geo_objects.getSurfaceVecObj(geo_names[0])); diff --git a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp index 09551a33782..7dfe2bdead3 100644 --- a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp +++ b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp @@ -40,10 +40,8 @@ void convertMeshNodesToGeometry(std::vector<MeshLib::Node*> const& nodes, GeoLib::GEOObjects & geometry_sets) { // copy data - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); - std::unique_ptr<std::map<std::string, std::size_t>> pnt_names{ - new std::map<std::string, std::size_t>}; + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); + auto pnt_names = std::make_unique<std::map<std::string, std::size_t>>(); std::size_t cnt(0); for (std::size_t id: node_ids) { pnts->push_back(new GeoLib::Point(*(nodes[id]), cnt)); @@ -197,8 +195,8 @@ int main (int argc, char* argv[]) return EXIT_FAILURE; } - std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_strategy{ - new MeshGeoToolsLib::SearchLength}; + auto search_length_strategy = + std::make_unique<MeshGeoToolsLib::SearchLength>(); if (search_length_arg.isSet()) { search_length_strategy.reset( new MeshGeoToolsLib::SearchLength(search_length_arg.getValue())); @@ -245,10 +243,8 @@ int main (int argc, char* argv[]) ); double const eps (std::numeric_limits<double>::epsilon()); - auto surface_pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); - std::unique_ptr<std::map<std::string, std::size_t>> name_id_map{ - new std::map<std::string, std::size_t>}; + auto surface_pnts = std::make_unique<std::vector<GeoLib::Point*>>(); + auto name_id_map = std::make_unique<std::map<std::string, std::size_t>>(); // insert first point surface_pnts->push_back( diff --git a/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp b/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp index a06820166c6..cdc7ce9fbd9 100644 --- a/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp +++ b/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp @@ -71,7 +71,7 @@ int main (int argc, char* argv[]) ' ', BaseLib::BuildInfo::git_describe); - std::unique_ptr<BaseLib::TCLAPCustomOutput> tclapOutput(new BaseLib::TCLAPCustomOutput()); + auto tclapOutput = std::make_unique<BaseLib::TCLAPCustomOutput>(); cmd.setOutput(tclapOutput.get()); std::vector<std::string> allowed_ele_types; diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index d78b3d6ad37..e8031245452 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -310,10 +310,9 @@ std::unique_ptr<GeoLib::Point> triangleLineIntersection( u*=denom; v*=denom; w*=denom; - return std::unique_ptr<GeoLib::Point>{ - new GeoLib::Point(u * a[0] + v * b[0] + w * c[0], - u * a[1] + v * b[1] + w * c[1], - u * a[2] + v * b[2] + w * c[2])}; + return std::make_unique<GeoLib::Point>(u * a[0] + v * b[0] + w * c[0], + u * a[1] + v * b[1] + w * c[1], + u * a[2] + v * b[2] + w * c[2]); } void computeAndInsertAllIntersectionPoints(GeoLib::PointVec &pnt_vec, diff --git a/GeoLib/DuplicateGeometry.cpp b/GeoLib/DuplicateGeometry.cpp index 8ea38744140..b4489ceeb91 100644 --- a/GeoLib/DuplicateGeometry.cpp +++ b/GeoLib/DuplicateGeometry.cpp @@ -38,7 +38,7 @@ void DuplicateGeometry::duplicate(std::string const& input_name) return; } - std::unique_ptr< std::vector<GeoLib::Point*> > new_pnts (new std::vector<GeoLib::Point*>); + auto new_pnts = std::make_unique<std::vector<GeoLib::Point*>>(); new_pnts->reserve(pnts->size()); std::transform(pnts->cbegin(), pnts->cend(), std::back_inserter(*new_pnts), [](GeoLib::Point* point) { return new GeoLib::Point(*point); }); @@ -63,8 +63,8 @@ std::unique_ptr<std::vector<GeoLib::Polyline*>> DuplicateGeometry::copyPolylines std::vector<GeoLib::Polyline*> const& polylines) const { std::size_t const n_plys = polylines.size(); - std::unique_ptr<std::vector<GeoLib::Polyline*>> new_lines - (new std::vector<Polyline*>(n_plys, nullptr)); + auto new_lines = + std::make_unique<std::vector<GeoLib::Polyline*>>(n_plys, nullptr); for (std::size_t i=0; i<n_plys; ++i) { @@ -82,8 +82,8 @@ std::unique_ptr<std::vector<Surface*>> DuplicateGeometry::copySurfacesVector( std::vector<Surface*> const& surfaces) const { std::size_t const n_sfc = surfaces.size(); - std::unique_ptr<std::vector<GeoLib::Surface*>> new_surfaces - (new std::vector<Surface*>(n_sfc, nullptr)); + auto new_surfaces = + std::make_unique<std::vector<GeoLib::Surface*>>(n_sfc, nullptr); for (std::size_t i=0; i<n_sfc; ++i) { diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 6626cd9316f..cdbd199dc56 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -239,8 +239,7 @@ bool GEOObjects::appendSurfaceVec(const std::vector<Surface*>& surfaces, { // the copy is needed because addSurfaceVec is passing it to SurfaceVec // ctor, which needs write access to the surface vector. - auto sfc = std::unique_ptr<std::vector<GeoLib::Surface*>>{ - new std::vector<GeoLib::Surface*>}; + auto sfc = std::make_unique<std::vector<GeoLib::Surface*>>(); for (auto surface : surfaces) sfc->push_back(surface); addSurfaceVec(std::move(sfc), name); @@ -390,10 +389,9 @@ bool GEOObjects::mergePoints(std::vector<std::string> const & geo_names, { const std::size_t n_geo_names(geo_names.size()); - auto merged_points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); - std::unique_ptr<std::map<std::string, std::size_t>> merged_pnt_names{ - new std::map<std::string, std::size_t>}; + auto merged_points = std::make_unique<std::vector<GeoLib::Point*>>(); + auto merged_pnt_names = + std::make_unique<std::map<std::string, std::size_t>>(); for (std::size_t j(0); j < n_geo_names; ++j) { GeoLib::PointVec const*const pnt_vec(this->getPointVecObj(geo_names[j])); @@ -435,10 +433,9 @@ void GEOObjects::mergePolylines(std::vector<std::string> const & geo_names, const std::size_t n_geo_names(geo_names.size()); std::vector<std::size_t> ply_offsets(n_geo_names, 0); - auto merged_polylines = std::unique_ptr<std::vector<GeoLib::Polyline*>>{ - new std::vector<GeoLib::Polyline*>}; - std::unique_ptr<std::map<std::string, std::size_t>> merged_ply_names{ - new std::map<std::string, std::size_t>}; + auto merged_polylines = std::make_unique<std::vector<GeoLib::Polyline*>>(); + auto merged_ply_names = + std::make_unique<std::map<std::string, std::size_t>>(); std::vector<GeoLib::Point*> const* merged_points(this->getPointVecObj(merged_geo_name)->getVector()); std::vector<std::size_t> const& id_map (this->getPointVecObj(merged_geo_name)->getIDMap ()); @@ -481,8 +478,7 @@ void GEOObjects::mergeSurfaces(std::vector<std::string> const & geo_names, const std::size_t n_geo_names(geo_names.size()); std::vector<std::size_t> sfc_offsets(n_geo_names, 0); - auto merged_sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); + auto merged_sfcs = std::make_unique<std::vector<GeoLib::Surface*>>(); std::unique_ptr<std::map<std::string, std::size_t>> merged_sfc_names; for (std::size_t j(0); j < n_geo_names; j++) { const std::vector<GeoLib::Surface*>* sfcs (this->getSurfaceVec(geo_names[j])); diff --git a/GeoLib/Grid.h b/GeoLib/Grid.h index 050f489a5c7..1a71fa88d83 100644 --- a/GeoLib/Grid.h +++ b/GeoLib/Grid.h @@ -312,8 +312,8 @@ void Grid<POINT>::createGridGeometry(GeoLib::GEOObjects* geo_obj) const grid_names.push_back(name); { - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto points = + std::make_unique<std::vector<GeoLib::Point*>>(); points->push_back(new GeoLib::Point(llf[0]+i*dx, llf[1]+j*dy, llf[2]+k*dz)); points->push_back(new GeoLib::Point(llf[0]+i*dx, llf[1]+(j+1)*dy, llf[2]+k*dz)); points->push_back(new GeoLib::Point(llf[0]+(i+1)*dx, llf[1]+(j+1)*dy, llf[2]+k*dz)); @@ -326,8 +326,7 @@ void Grid<POINT>::createGridGeometry(GeoLib::GEOObjects* geo_obj) const nullptr); } - auto plys = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>(); auto const& points = *geo_obj->getPointVec(grid_names.back()); auto* ply0(new GeoLib::Polyline(points)); diff --git a/GeoLib/IO/Legacy/OGSIOVer4.cpp b/GeoLib/IO/Legacy/OGSIOVer4.cpp index a78e6c5ba9a..03df58a8a76 100644 --- a/GeoLib/IO/Legacy/OGSIOVer4.cpp +++ b/GeoLib/IO/Legacy/OGSIOVer4.cpp @@ -458,8 +458,7 @@ bool readGLIFileV4(const std::string& fname, std::unique_ptr<std::map<std::string, std::size_t>>{}; bool zero_based_idx(true); - auto pnt_vec = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto pnt_vec = std::make_unique<std::vector<GeoLib::Point*>>(); INFO("GeoLib::readGLIFile(): read points from stream."); tag = readPoints(in, pnt_vec.get(), zero_based_idx, pnt_id_names_map.get()); INFO("GeoLib::readGLIFile(): \t ok, %d points read.", pnt_vec->size()); @@ -473,10 +472,8 @@ bool readGLIFileV4(const std::string& fname, const std::string path = BaseLib::extractPath(fname); // read names of plys into temporary string-vec - auto ply_names = std::unique_ptr<std::map<std::string, std::size_t>>{ - new std::map<std::string, std::size_t>}; - auto ply_vec = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto ply_names = std::make_unique<std::map<std::string, std::size_t>>(); + auto ply_vec = std::make_unique<std::vector<GeoLib::Polyline*>>(); GeoLib::PointVec & point_vec( *const_cast<GeoLib::PointVec*>(geo.getPointVecObj(unique_name))); auto* geo_pnt_vec( @@ -492,10 +489,8 @@ bool readGLIFileV4(const std::string& fname, else INFO("GeoLib::readGLIFile(): tag #POLYLINE not found."); - auto sfc_vec = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); - auto sfc_names = std::unique_ptr<std::map<std::string, std::size_t>>{ - new std::map<std::string, std::size_t>}; + auto sfc_vec = std::make_unique<std::vector<GeoLib::Surface*>>(); + auto sfc_names = std::make_unique<std::map<std::string, std::size_t>>(); if (tag.find("#SURFACE") != std::string::npos && in) { INFO("GeoLib::readGLIFile(): read surfaces from stream."); diff --git a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp index a102e337a28..0582a108a1f 100644 --- a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp +++ b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp @@ -45,17 +45,14 @@ bool BoostXmlGmlInterface::readFile(const std::string &fname) doc->ignoreConfigAttribute("xsi:noNamespaceSchemaLocation"); doc->ignoreConfigAttribute("xmlns:ogs"); - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); - auto polylines = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); - auto surfaces = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(); + auto polylines = std::make_unique<std::vector<GeoLib::Polyline*>>(); + auto surfaces = std::make_unique<std::vector<GeoLib::Surface*>>(); using MapNameId = std::map<std::string, std::size_t>; - std::unique_ptr<MapNameId> pnt_names{new MapNameId}; - std::unique_ptr<MapNameId> ply_names{new MapNameId}; - std::unique_ptr<MapNameId> sfc_names{new MapNameId}; + auto pnt_names = std::make_unique<MapNameId>(); + auto ply_names = std::make_unique<MapNameId>(); + auto sfc_names = std::make_unique<MapNameId>(); //! \ogs_file_param{gml__name} auto geo_name = doc->getConfigParameter<std::string>("name"); diff --git a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp index ab5bca51b0e..47924775ef0 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp @@ -75,17 +75,14 @@ int XmlGmlInterface::readFile(const QString &fileName) std::string gliName("[NN]"); - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); - auto polylines = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); - auto surfaces = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(); + auto polylines = std::make_unique<std::vector<GeoLib::Polyline*>>(); + auto surfaces = std::make_unique<std::vector<GeoLib::Surface*>>(); using MapNameId = std::map<std::string, std::size_t>; - std::unique_ptr<MapNameId> pnt_names{new MapNameId}; - std::unique_ptr<MapNameId> ply_names{new MapNameId}; - std::unique_ptr<MapNameId> sfc_names{new MapNameId}; + auto pnt_names = std::make_unique<MapNameId>(); + auto ply_names = std::make_unique<MapNameId>(); + auto sfc_names = std::make_unique<MapNameId>(); QDomNodeList geoTypes = docElement.childNodes(); for (int i = 0; i < geoTypes.count(); i++) diff --git a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp index 3e645faffa3..cd13fc16f70 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp @@ -57,8 +57,7 @@ int XmlStnInterface::readFile(const QString &fileName) { // read all the station lists QDomNodeList stationList = lists.at(i).childNodes(); - auto stations = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto stations = std::make_unique<std::vector<GeoLib::Point*>>(); std::string stnName("[NN]"); for (int j = 0; j < stationList.count(); j++) @@ -351,8 +350,7 @@ int XmlStnInterface::rapidReadFile(const std::string &fileName) for (rapidxml::xml_node<>* station_list = doc.first_node()->first_node(); station_list; station_list = station_list->next_sibling()) { - auto stations = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto stations = std::make_unique<std::vector<GeoLib::Point*>>(); std::string stnName("[NN]"); stnName = station_list->first_node("name")->value(); diff --git a/GeoLib/Surface.cpp b/GeoLib/Surface.cpp index e3d8b72f799..2790f123fc9 100644 --- a/GeoLib/Surface.cpp +++ b/GeoLib/Surface.cpp @@ -74,7 +74,7 @@ void Surface::addTriangle(std::size_t pnt_a, ids[0] = pnt_a; ids[1] = pnt_b; ids[2] = pnt_c; - _bounding_volume.reset(new AABB(_sfc_pnts, ids)); + _bounding_volume = std::make_unique<GeoLib::AABB>(_sfc_pnts, ids); } else { @@ -155,7 +155,7 @@ bool Surface::isPntInSfc(MathLib::Point3d const& pnt, double eps) const // Mutable _surface_grid is constructed if method is called the first time. if (_surface_grid == nullptr) { - _surface_grid.reset(new SurfaceGrid(this)); + _surface_grid = std::make_unique<GeoLib::SurfaceGrid>(this); } return _surface_grid->isPointInSurface(pnt, eps); } diff --git a/GeoLib/TemplateVec.h b/GeoLib/TemplateVec.h index b2fc3cfada6..faf220172e1 100644 --- a/GeoLib/TemplateVec.h +++ b/GeoLib/TemplateVec.h @@ -69,7 +69,7 @@ public: } if (!_name_id_map) - _name_id_map.reset(new NameIdMap); + _name_id_map = std::make_unique<NameIdMap>(); } /** diff --git a/MaterialLib/Adsorption/Reaction.cpp b/MaterialLib/Adsorption/Reaction.cpp index c6466e79ef9..e6336669565 100644 --- a/MaterialLib/Adsorption/Reaction.cpp +++ b/MaterialLib/Adsorption/Reaction.cpp @@ -38,27 +38,27 @@ newInstance(BaseLib::ConfigTree const& conf) auto const type = conf.getConfigParameter<std::string>("type"); if (type == "Z13XBF") - return std::unique_ptr<Reaction>(new DensityLegacy); + return std::make_unique<DensityLegacy>(); else if (type == "Z13XBF_100MPa") - return std::unique_ptr<Reaction>(new Density100MPa); + return std::make_unique<Density100MPa>(); else if (type == "Z13XBF_Const") - return std::unique_ptr<Reaction>(new DensityConst); + return std::make_unique<DensityConst>(); else if (type == "Z13XBF_Cook") - return std::unique_ptr<Reaction>(new DensityCook); + return std::make_unique<DensityCook>(); else if (type == "Z13XBF_Dubinin") - return std::unique_ptr<Reaction>(new DensityDubinin); + return std::make_unique<DensityDubinin>(); else if (type == "Z13XBF_Hauer") - return std::unique_ptr<Reaction>(new DensityHauer); + return std::make_unique<DensityHauer>(); else if (type == "Z13XBF_Mette") - return std::unique_ptr<Reaction>(new DensityMette); + return std::make_unique<DensityMette>(); else if (type == "Z13XBF_Nunez") - return std::unique_ptr<Reaction>(new DensityNunez); + return std::make_unique<DensityNunez>(); else if (type == "Inert") - return std::unique_ptr<Reaction>(new ReactionInert); + return std::make_unique<ReactionInert>(); else if (type == "Sinusoidal") - return std::unique_ptr<Reaction>(new ReactionSinusoidal(conf)); + return std::make_unique<ReactionSinusoidal>(conf); else if (type == "CaOH2") - return std::unique_ptr<Reaction>(new ReactionCaOH2(conf)); + return std::make_unique<ReactionCaOH2>(conf); OGS_FATAL("Unknown reactive system: %s.", type.c_str()); diff --git a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp index 629444347b7..a356b380d24 100644 --- a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp +++ b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp @@ -48,8 +48,7 @@ static std::unique_ptr<FluidProperty> createLiquidDensity( const auto p0 = config.getConfigParameter<double>("p0"); //! \ogs_file_param{material__fluid__density__LiquidDensity__bulk_modulus} const auto E = config.getConfigParameter<double>("bulk_modulus"); - return std::unique_ptr<FluidProperty>( - new LiquidDensity(beta, rho0, T0, p0, E)); + return std::make_unique<LiquidDensity>(beta, rho0, T0, p0, E); } /** @@ -69,8 +68,7 @@ static std::unique_ptr<FluidProperty> createLinearTemperatureDependentDensity( const auto T0 = config.getConfigParameter<double>("temperature0"); //! \ogs_file_param{material__fluid__density__TemperatureDependent__beta} const auto beta = config.getConfigParameter<double>("beta"); - return std::unique_ptr<FluidProperty>( - new LinearTemperatureDependentDensity(rho0, T0, beta)); + return std::make_unique<LinearTemperatureDependentDensity>(rho0, T0, beta); } static std::unique_ptr<FluidProperty> createLinearConcentrationDependentDensity( @@ -88,11 +86,10 @@ static std::unique_ptr<FluidProperty> createLinearConcentrationDependentDensity( const double fluid_density_difference_ratio = //! \ogs_file_param{material__fluid__density__ConcentrationDependent__fluid_density_difference_ratio} config.getConfigParameter<double>("fluid_density_difference_ratio"); - return std::unique_ptr<FluidProperty>( - new LinearConcentrationDependentDensity( - reference_density, - reference_concentration, - fluid_density_difference_ratio)); + return std::make_unique<LinearConcentrationDependentDensity>( + reference_density, + reference_concentration, + fluid_density_difference_ratio); } std::unique_ptr<FluidProperty> createFluidDensityModel( @@ -105,9 +102,9 @@ std::unique_ptr<FluidProperty> createFluidDensityModel( { //! \ogs_file_param{material__fluid__density__type} config.checkConfigParameter("type", "Constant"); - return std::unique_ptr<FluidProperty>(new ConstantFluidProperty( + return std::make_unique<ConstantFluidProperty>( //! \ogs_file_param{material__fluid__density__Constant__value} - config.getConfigParameter<double>("value"))); + config.getConfigParameter<double>("value")); } else if (type == "LiquidDensity") return createLiquidDensity(config); @@ -119,14 +116,13 @@ std::unique_ptr<FluidProperty> createFluidDensityModel( { //! \ogs_file_param{material__fluid__density__type} config.checkConfigParameter("type", "IdealGasLaw"); - return std::unique_ptr<FluidProperty>( + return std::make_unique<IdealGasLaw>( //! \ogs_file_param{material__fluid__density__IdealGasLaw__molar_mass} - new IdealGasLaw(config.getConfigParameter<double>("molar_mass"))); + config.getConfigParameter<double>("molar_mass")); } else if (type == "WaterDensityIAPWSIF97Region1") { - return std::unique_ptr<FluidProperty>( - new WaterDensityIAPWSIF97Region1()); + return std::make_unique<WaterDensityIAPWSIF97Region1>(); } else { diff --git a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp index b05e7cbdb4b..81cf322b434 100644 --- a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp +++ b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp @@ -76,18 +76,17 @@ std::unique_ptr<FluidProperties> createFluidProperties( if (is_mu_density_dependent || is_cp_density_dependent || is_KT_density_dependent) - return std::unique_ptr<MaterialLib::Fluid::FluidProperties>( - new MaterialLib::Fluid::FluidPropertiesWithDensityDependentModels( - std::move(liquid_density), std::move(viscosity), - std::move(specific_heat_capacity), - std::move(thermal_conductivity), is_mu_density_dependent, - is_cp_density_dependent, is_KT_density_dependent)); + return std::make_unique< + MaterialLib::Fluid::FluidPropertiesWithDensityDependentModels>( + std::move(liquid_density), std::move(viscosity), + std::move(specific_heat_capacity), std::move(thermal_conductivity), + is_mu_density_dependent, is_cp_density_dependent, + is_KT_density_dependent); else - return std::unique_ptr<MaterialLib::Fluid::FluidProperties>( - new 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/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp b/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp index 62422e00ab3..55b73280567 100644 --- a/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp +++ b/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp @@ -30,9 +30,9 @@ std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel( auto const type = config.getConfigParameter<std::string>("type"); if (type == "Constant") - return std::unique_ptr<FluidProperty>(new ConstantFluidProperty( + return std::make_unique<ConstantFluidProperty>( //! \ogs_file_param{material__fluid__specific_heat_capacity__Constant__value} - config.getConfigParameter<double>("value"))); + config.getConfigParameter<double>("value")); // TODO: add more models else { diff --git a/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp b/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp index a860e76e28f..32fadfafc84 100644 --- a/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp +++ b/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp @@ -30,9 +30,9 @@ std::unique_ptr<FluidProperty> createFluidThermalConductivityModel( auto const type = config.getConfigParameter<std::string>("type"); if (type == "Constant") - return std::unique_ptr<FluidProperty>(new ConstantFluidProperty( + return std::make_unique<ConstantFluidProperty>( //! \ogs_file_param{material__fluid__thermal_conductivity__Constant__value} - config.getConfigParameter<double>("value"))); + config.getConfigParameter<double>("value")); // TODO: add more models else { diff --git a/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp b/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp index c50768bf4bb..14966deeea1 100644 --- a/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp +++ b/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp @@ -45,8 +45,7 @@ static std::unique_ptr<FluidProperty> createLinearPressureDependentViscosity( //! \ogs_file_param{material__fluid__viscosity__LinearPressure__gamma} const auto gamma = config.getConfigParameter<double>("gamma"); - return std::unique_ptr<FluidProperty>( - new LinearPressureDependentViscosity(mu0, p0, gamma)); + return std::make_unique<LinearPressureDependentViscosity>(mu0, p0, gamma); } /** @@ -69,8 +68,7 @@ static std::unique_ptr<FluidProperty> createTemperatureDependentViscosity( //! \ogs_file_param{material__fluid__viscosity__TemperatureDependent__tv} const auto Tv = config.getConfigParameter<double>("tv"); - return std::unique_ptr<FluidProperty>( - new TemperatureDependentViscosity(mu0, Tc, Tv)); + return std::make_unique<TemperatureDependentViscosity>(mu0, Tc, Tv); } std::unique_ptr<FluidProperty> createViscosityModel( @@ -83,9 +81,9 @@ std::unique_ptr<FluidProperty> createViscosityModel( { //! \ogs_file_param{material__fluid__viscosity__type} config.checkConfigParameter("type", "Constant"); - return std::unique_ptr<FluidProperty>(new ConstantFluidProperty( + return std::make_unique<ConstantFluidProperty>( //! \ogs_file_param{material__fluid__viscosity__Constant__value} - config.getConfigParameter<double>("value"))); + config.getConfigParameter<double>("value")); } if (type == "LinearPressure") return createLinearPressureDependentViscosity(config); @@ -106,27 +104,27 @@ std::unique_ptr<FluidProperty> createViscosityModel( config.checkConfigParameter("liquid_type", "Water"); const VogelsViscosityConstantsWater constants; - return std::unique_ptr<FluidProperty>( - new VogelsLiquidDynamicViscosity<VogelsViscosityConstantsWater>( - constants)); + return std::make_unique< + VogelsLiquidDynamicViscosity<VogelsViscosityConstantsWater>>( + constants); } if (fluid_type == "CO2") { //! \ogs_file_param{material__fluid__viscosity__Vogels__liquid_type} config.checkConfigParameter("liquid_type", "CO2"); const VogelsViscosityConstantsCO2 constants; - return std::unique_ptr<FluidProperty>( - new VogelsLiquidDynamicViscosity<VogelsViscosityConstantsCO2>( - constants)); + return std::make_unique< + VogelsLiquidDynamicViscosity<VogelsViscosityConstantsCO2>>( + constants); } if (fluid_type == "CH4") { //! \ogs_file_param{material__fluid__viscosity__Vogels__liquid_type} config.checkConfigParameter("liquid_type", "CH4"); const VogelsViscosityConstantsCH4 constants; - return std::unique_ptr<FluidProperty>( - new VogelsLiquidDynamicViscosity<VogelsViscosityConstantsCH4>( - constants)); + return std::make_unique< + VogelsLiquidDynamicViscosity<VogelsViscosityConstantsCH4>>( + constants); } OGS_FATAL( @@ -138,7 +136,7 @@ std::unique_ptr<FluidProperty> createViscosityModel( { //! \ogs_file_param{material__fluid__viscosity__type} config.checkConfigParameter("type", "WaterViscosityIAPWS"); - return std::unique_ptr<FluidProperty>(new WaterViscosityIAPWS()); + return std::make_unique<WaterViscosityIAPWS>(); } OGS_FATAL( diff --git a/MaterialLib/FractureModels/CreateLinearElasticIsotropic.cpp b/MaterialLib/FractureModels/CreateLinearElasticIsotropic.cpp index 2ccec0bde6d..5d7db1850cf 100644 --- a/MaterialLib/FractureModels/CreateLinearElasticIsotropic.cpp +++ b/MaterialLib/FractureModels/CreateLinearElasticIsotropic.cpp @@ -38,8 +38,7 @@ createLinearElasticIsotropic( typename LinearElasticIsotropic<DisplacementDim>::MaterialProperties mp{ Kn, Ks}; - return std::unique_ptr<LinearElasticIsotropic<DisplacementDim>>{ - new LinearElasticIsotropic<DisplacementDim>{mp}}; + return std::make_unique<LinearElasticIsotropic<DisplacementDim>>(mp); } diff --git a/MaterialLib/FractureModels/CreateMohrCoulomb.cpp b/MaterialLib/FractureModels/CreateMohrCoulomb.cpp index 180f1e49d01..9d4ef82be37 100644 --- a/MaterialLib/FractureModels/CreateMohrCoulomb.cpp +++ b/MaterialLib/FractureModels/CreateMohrCoulomb.cpp @@ -51,8 +51,7 @@ createMohrCoulomb( typename MohrCoulomb<DisplacementDim>::MaterialProperties mp{ Kn, Ks, friction_angle, dilatancy_angle, cohesion}; - return std::unique_ptr<MohrCoulomb<DisplacementDim>>{ - new MohrCoulomb<DisplacementDim>{mp}}; + return std::make_unique<MohrCoulomb<DisplacementDim>>(mp); } diff --git a/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp b/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp index b8c1e1efbd3..008bc9ee4ce 100644 --- a/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp +++ b/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp @@ -28,9 +28,9 @@ std::unique_ptr<Porosity> createPorosityModel(BaseLib::ConfigTree const& config) auto const type = config.getConfigParameter<std::string>("type"); if (type == "Constant") - return std::unique_ptr<Porosity>( + return std::make_unique<ConstantPorosity>( //! \ogs_file_param{material__porous_medium__porosity__Constant__value} - new ConstantPorosity(config.getConfigParameter<double>("value"))); + config.getConfigParameter<double>("value")); else { OGS_FATAL("The porosity type %s is unavailable.\n", diff --git a/MaterialLib/PorousMedium/Storage/createStorageModel.cpp b/MaterialLib/PorousMedium/Storage/createStorageModel.cpp index e41adfc46bd..5b2a0db2c5c 100644 --- a/MaterialLib/PorousMedium/Storage/createStorageModel.cpp +++ b/MaterialLib/PorousMedium/Storage/createStorageModel.cpp @@ -28,9 +28,9 @@ std::unique_ptr<Storage> createStorageModel(BaseLib::ConfigTree const& config) auto const type = config.getConfigParameter<std::string>("type"); if (type == "Constant") - return std::unique_ptr<Storage>( + return std::make_unique<ConstantStorage>( //! \ogs_file_param{material__porous_medium__storage__Constant__value} - new ConstantStorage(config.getConfigParameter<double>("value"))); + config.getConfigParameter<double>("value")); else { OGS_FATAL("The storage type %s is unavailable.\n", type.data(), diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp index 0e4c98d1962..8ef24f34756 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp @@ -68,9 +68,8 @@ static std::unique_ptr<CapillaryPressureSaturation> createBrooksCorey( //! \ogs_file_param{material__porous_medium__capillary_pressure__BrooksCorey__pc_max} const auto Pc_max = config.getConfigParameter<double>("pc_max"); - return std::unique_ptr<CapillaryPressureSaturation>( - new BrooksCoreyCapillaryPressureSaturation( - pd, Sr, Sg_r, Smax, m, Pc_max)); + return std::make_unique<BrooksCoreyCapillaryPressureSaturation>( + pd, Sr, Sg_r, Smax, m, Pc_max); } /** @@ -124,9 +123,8 @@ static std::unique_ptr<CapillaryPressureSaturation> createVanGenuchten( (*has_regularized_conf) ? "true" : "false"); has_regularized = *has_regularized_conf; } - return std::unique_ptr<CapillaryPressureSaturation>( - new VanGenuchtenCapillaryPressureSaturation( - pd, Sr, Sg_r, Smax, m, Pc_max, has_regularized)); + return std::make_unique<VanGenuchtenCapillaryPressureSaturation>( + pd, Sr, Sg_r, Smax, m, Pc_max, has_regularized); } std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel( @@ -154,8 +152,8 @@ std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel( auto curve = MathLib::createPiecewiseLinearCurve< MathLib::PiecewiseLinearMonotonicCurve>(curve_config); - return std::unique_ptr<CapillaryPressureSaturation>( - new CapillaryPressureSaturationCurve(std::move(curve))); + return std::make_unique<CapillaryPressureSaturationCurve>( + std::move(curve)); } else { diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp index ffe7b4ed666..b81606e2269 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp @@ -62,8 +62,7 @@ std::unique_ptr<RelativePermeability> createWettingPhaseVanGenuchten( //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseVanGenuchten__krel_min} const auto krel_min = config.getConfigParameter<double>("krel_min"); - return std::unique_ptr<RelativePermeability>( - new WettingPhaseVanGenuchten(Sr, Smax, m, krel_min)); + return std::make_unique<WettingPhaseVanGenuchten>(Sr, Smax, m, krel_min); } /** @@ -95,8 +94,7 @@ std::unique_ptr<RelativePermeability> createNonWettingPhaseVanGenuchten( //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseVanGenuchten__krel_min} const auto krel_min = config.getConfigParameter<double>("krel_min"); - return std::unique_ptr<RelativePermeability>( - new NonWettingPhaseVanGenuchten(Sr, Smax, m, krel_min)); + return std::make_unique<NonWettingPhaseVanGenuchten>(Sr, Smax, m, krel_min); } /** @@ -128,8 +126,8 @@ std::unique_ptr<RelativePermeability> createWettingPhaseBrooksCoreyOilGas( //! \ogs_file_param{material__porous_medium__relative_permeability__WettingPhaseBrooksCoreyOilGas__krel_min} const auto krel_min = config.getConfigParameter<double>("krel_min"); - return std::unique_ptr<RelativePermeability>( - new WettingPhaseBrooksCoreyOilGas(Sr, Smax, m, krel_min)); + return std::make_unique<WettingPhaseBrooksCoreyOilGas>( + Sr, Smax, m, krel_min); } /** @@ -161,8 +159,8 @@ std::unique_ptr<RelativePermeability> createNonWettingPhaseBrooksCoreyOilGas( //! \ogs_file_param{material__porous_medium__relative_permeability__NonWettingPhaseBrooksCoreyOilGas__krel_min} const auto krel_min = config.getConfigParameter<double>("krel_min"); - return std::unique_ptr<RelativePermeability>( - new NonWettingPhaseBrooksCoreyOilGas(Sr, Smax, m, krel_min)); + return std::make_unique<NonWettingPhaseBrooksCoreyOilGas>( + Sr, Smax, m, krel_min); } std::unique_ptr<RelativePermeability> createRelativePermeabilityModel( @@ -197,8 +195,7 @@ std::unique_ptr<RelativePermeability> createRelativePermeabilityModel( auto curve = MathLib::createPiecewiseLinearCurve<MathLib ::PiecewiseLinearInterpolation>(curve_config); - return std::unique_ptr<RelativePermeability>( - new RelativePermeabilityCurve(std::move(curve))); + return std::make_unique<RelativePermeabilityCurve>(std::move(curve)); } else { diff --git a/MaterialLib/SolidModels/CreateEhlers.h b/MaterialLib/SolidModels/CreateEhlers.h index bba68d8c13c..0d0df1392e4 100644 --- a/MaterialLib/SolidModels/CreateEhlers.h +++ b/MaterialLib/SolidModels/CreateEhlers.h @@ -62,8 +62,8 @@ inline std::unique_ptr<EhlersDamageProperties> createDamageProperties( DBUG("Use \'%s\' as h_d.", h_d.name.c_str()); - return std::unique_ptr<EhlersDamageProperties>{ - new EhlersDamageProperties{alpha_d, beta_d, h_d}}; + return std::make_unique<EhlersDamageProperties>( + EhlersDamageProperties{alpha_d, beta_d, h_d}); } template <int DisplacementDim> diff --git a/MaterialLib/SolidModels/CreateLinearElasticIsotropic.h b/MaterialLib/SolidModels/CreateLinearElasticIsotropic.h index 29110bfa9fa..000484a9e67 100644 --- a/MaterialLib/SolidModels/CreateLinearElasticIsotropic.h +++ b/MaterialLib/SolidModels/CreateLinearElasticIsotropic.h @@ -44,8 +44,7 @@ createLinearElasticIsotropic( typename LinearElasticIsotropic<DisplacementDim>::MaterialProperties mp{ youngs_modulus, poissons_ratio}; - return std::unique_ptr<LinearElasticIsotropic<DisplacementDim>>{ - new LinearElasticIsotropic<DisplacementDim>{mp}}; + return std::make_unique<LinearElasticIsotropic<DisplacementDim>>(mp); } } // namespace Solids diff --git a/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp b/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp index 459c233b5c2..03cc750ca53 100644 --- a/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp +++ b/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp @@ -127,14 +127,13 @@ createTwoPhaseFlowMaterialProperties( BaseLib::reorderVector(storage_models, mat_ids); return std::forward_as_tuple( - std::unique_ptr<TwoPhaseFlowWithPPMaterialProperties>{ - new TwoPhaseFlowWithPPMaterialProperties{ - material_ids, std::move(liquid_density), - std::move(liquid_viscosity), std::move(gas_density), - std::move(gas_viscosity), std::move(intrinsic_permeability_models), - std::move(porosity_models), std::move(storage_models), - std::move(capillary_pressure_models), - std::move(relative_permeability_models)}}, + std::make_unique<TwoPhaseFlowWithPPMaterialProperties>( + material_ids, std::move(liquid_density), + std::move(liquid_viscosity), std::move(gas_density), + std::move(gas_viscosity), std::move(intrinsic_permeability_models), + std::move(porosity_models), std::move(storage_models), + std::move(capillary_pressure_models), + std::move(relative_permeability_models)), std::move(fluid_config)); } diff --git a/MathLib/Curve/CreatePiecewiseLinearCurve-impl.h b/MathLib/Curve/CreatePiecewiseLinearCurve-impl.h index 206fc3d4709..e9f596d8d33 100644 --- a/MathLib/Curve/CreatePiecewiseLinearCurve-impl.h +++ b/MathLib/Curve/CreatePiecewiseLinearCurve-impl.h @@ -38,7 +38,6 @@ std::unique_ptr<CurveType> createPiecewiseLinearCurve( "The given coordinates and values vector sizes are " "different."); } - return std::unique_ptr<CurveType>( - new CurveType(std::move(x), std::move(y))); + return std::make_unique<CurveType>(std::move(x), std::move(y)); } } diff --git a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp index 8001aa63bff..6d6f9231a65 100644 --- a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp +++ b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp @@ -120,7 +120,7 @@ std::unique_ptr<EigenLinearSolverBase> createIterativeSolver() { using Slv = EigenIterativeLinearSolver< Solver<EigenMatrix::RawMatrixType, Precon>>; - return std::unique_ptr<Slv>(new Slv); + return std::make_unique<Slv>(); } template <template <typename, typename> class Solver> @@ -188,7 +188,8 @@ EigenLinearSolver::EigenLinearSolver( case EigenOption::SolverType::SparseLU: { using SolverType = Eigen::SparseLU<Matrix, Eigen::COLAMDOrdering<int>>; - _solver.reset(new details::EigenDirectLinearSolver<SolverType>); + _solver = std::make_unique< + details::EigenDirectLinearSolver<SolverType>>(); return; } case EigenOption::SolverType::BiCGSTAB: @@ -266,7 +267,8 @@ bool EigenLinearSolver::solve(EigenMatrix &A, EigenVector& b, EigenVector &x) if (_option.scaling) { INFO("-> scale"); - scal.reset(new Eigen::IterScaling<EigenMatrix::RawMatrixType>()); + scal = + std::make_unique<Eigen::IterScaling<EigenMatrix::RawMatrixType>>(); scal->computeRef(A.getRawMatrix()); b.getRawVector() = scal->LeftScaling().cwiseProduct(b.getRawVector()); } diff --git a/MathLib/LinAlg/MatrixVectorTraits.cpp b/MathLib/LinAlg/MatrixVectorTraits.cpp index b47d4668408..602aa4558c0 100644 --- a/MathLib/LinAlg/MatrixVectorTraits.cpp +++ b/MathLib/LinAlg/MatrixVectorTraits.cpp @@ -19,14 +19,14 @@ std::unique_ptr<PETScMatrix> MatrixVectorTraits<PETScMatrix>:: newInstance() { - return std::unique_ptr<PETScMatrix>(new PETScMatrix); + return std::make_unique<PETScMatrix>(); } std::unique_ptr<PETScMatrix> MatrixVectorTraits<PETScMatrix>:: newInstance(PETScMatrix const& A) { - return std::unique_ptr<PETScMatrix>(new PETScMatrix(A)); + return std::make_unique<PETScMatrix>(A); } std::unique_ptr<PETScMatrix> @@ -47,26 +47,24 @@ newInstance(MatrixSpecifications const& spec) mat_opt.d_nz = max_nonzeroes; mat_opt.o_nz = max_nonzeroes; mat_opt.is_global_size = false; - return std::unique_ptr<PETScMatrix>( - new PETScMatrix(nrows, ncols, mat_opt)); + return std::make_unique<PETScMatrix>(nrows, ncols, mat_opt); } else - return std::unique_ptr<PETScMatrix>( - new PETScMatrix(nrows, ncols)); + return std::make_unique<PETScMatrix>(nrows, ncols); } std::unique_ptr<PETScVector> MatrixVectorTraits<PETScVector>:: newInstance() { - return std::unique_ptr<PETScVector>(new PETScVector); + return std::make_unique<PETScVector>(); } std::unique_ptr<PETScVector> MatrixVectorTraits<PETScVector>:: newInstance(PETScVector const& x) { - return std::unique_ptr<PETScVector>(new PETScVector(x)); + return std::make_unique<PETScVector>(x); } std::unique_ptr<PETScVector> @@ -76,11 +74,10 @@ newInstance(MatrixSpecifications const& spec) auto const is_global_size = false; if (spec.ghost_indices != nullptr) { - return std::unique_ptr<PETScVector>( - new PETScVector(spec.nrows, *spec.ghost_indices, is_global_size)); + return std::make_unique<PETScVector>(spec.nrows, *spec.ghost_indices, + is_global_size); } else { - return std::unique_ptr<PETScVector>( - new PETScVector(spec.nrows, is_global_size)); + return std::make_unique<PETScVector>(spec.nrows, is_global_size); } } @@ -96,21 +93,21 @@ std::unique_ptr<EigenMatrix> MatrixVectorTraits<EigenMatrix>:: newInstance() { - return std::unique_ptr<EigenMatrix>(new EigenMatrix(0, 0)); // TODO default constructor + return std::make_unique<EigenMatrix>(0, 0); // TODO default constructor } std::unique_ptr<EigenMatrix> MatrixVectorTraits<EigenMatrix>:: newInstance(EigenMatrix const& A) { - return std::unique_ptr<EigenMatrix>(new EigenMatrix(A)); + return std::make_unique<EigenMatrix>(A); } std::unique_ptr<EigenMatrix> MatrixVectorTraits<EigenMatrix>:: newInstance(MatrixSpecifications const& spec) { - auto A = std::unique_ptr<EigenMatrix>(new EigenMatrix(spec.nrows)); + auto A = std::make_unique<EigenMatrix>(spec.nrows); if (spec.sparsity_pattern) setMatrixSparsity(*A, *spec.sparsity_pattern); @@ -122,21 +119,21 @@ std::unique_ptr<EigenVector> MatrixVectorTraits<EigenVector>:: newInstance() { - return std::unique_ptr<EigenVector>(new EigenVector); + return std::make_unique<EigenVector>(); } std::unique_ptr<EigenVector> MatrixVectorTraits<EigenVector>:: newInstance(EigenVector const& x) { - return std::unique_ptr<EigenVector>(new EigenVector(x)); + return std::make_unique<EigenVector>(x); } std::unique_ptr<EigenVector> MatrixVectorTraits<EigenVector>:: newInstance(MatrixSpecifications const& spec) { - return std::unique_ptr<EigenVector>(new EigenVector(spec.nrows)); + return std::make_unique<EigenVector>(spec.nrows); } } // namespace MathLib diff --git a/MathLib/ODE/ConcreteODESolver.h b/MathLib/ODE/ConcreteODESolver.h index ae688d88b2e..fa73dd377be 100644 --- a/MathLib/ODE/ConcreteODESolver.h +++ b/MathLib/ODE/ConcreteODESolver.h @@ -59,8 +59,7 @@ public: JacobianFunction<NumEquations> df) override { Implementation::setFunction( - std::unique_ptr<detail::FunctionHandlesImpl<NumEquations>>{ - new detail::FunctionHandlesImpl<NumEquations>{f, df}}); + std::make_unique<detail::FunctionHandlesImpl<NumEquations>>(f, df)); } void setTolerance(const std::array<double, NumEquations>& abstol, diff --git a/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp b/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp index 500807475ab..0149e781962 100644 --- a/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp +++ b/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp @@ -77,8 +77,8 @@ std::unique_ptr<MeshLib::Mesh> appendLinesAlongPolylines( // generate a mesh const std::string name = mesh.getName() + "_with_lines"; - std::unique_ptr<MeshLib::Mesh> new_mesh( - new MeshLib::Mesh(name, vec_new_nodes, vec_new_eles)); + auto new_mesh = + std::make_unique<MeshLib::Mesh>(name, vec_new_nodes, vec_new_eles); auto opt_mat_pv = new_mesh->getProperties().createNewPropertyVector<int>( "MaterialIDs", MeshLib::MeshItemType::Cell); if (opt_mat_pv) { diff --git a/MeshGeoToolsLib/MeshNodeSearcher.cpp b/MeshGeoToolsLib/MeshNodeSearcher.cpp index 6b328cdbd6c..e123bd4a5f3 100644 --- a/MeshGeoToolsLib/MeshNodeSearcher.cpp +++ b/MeshGeoToolsLib/MeshNodeSearcher.cpp @@ -173,8 +173,9 @@ MeshNodeSearcher const& MeshNodeSearcher::getMeshNodeSearcher( } } - _mesh_node_searchers[mesh_id].reset(new MeshGeoToolsLib::MeshNodeSearcher( - mesh, std::move(search_length_algorithm), SearchAllNodes::Yes)); + _mesh_node_searchers[mesh_id] = + std::make_unique<MeshGeoToolsLib::MeshNodeSearcher>( + mesh, std::move(search_length_algorithm), SearchAllNodes::Yes); return *_mesh_node_searchers[mesh_id]; } diff --git a/MeshLib/MeshEditing/AddLayerToMesh.cpp b/MeshLib/MeshEditing/AddLayerToMesh.cpp index d518a7335e9..4bf30a70d37 100644 --- a/MeshLib/MeshEditing/AddLayerToMesh.cpp +++ b/MeshLib/MeshEditing/AddLayerToMesh.cpp @@ -106,8 +106,9 @@ MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh, double thickness, sfc_mesh.reset(MeshLib::MeshSurfaceExtraction::getMeshSurface( mesh, dir, angle, prop_name)); else { - sfc_mesh = (on_top) ? std::unique_ptr<MeshLib::Mesh>(new MeshLib::Mesh(mesh)) : - std::unique_ptr<MeshLib::Mesh>(MeshLib::createFlippedMesh(mesh)); + sfc_mesh = (on_top) ? std::make_unique<MeshLib::Mesh>(mesh) + : std::unique_ptr<MeshLib::Mesh>( + MeshLib::createFlippedMesh(mesh)); // add property storing node ids auto* const pv = sfc_mesh->getProperties().createNewPropertyVector<std::size_t>( diff --git a/MeshLib/MeshEditing/ConvertToLinearMesh.cpp b/MeshLib/MeshEditing/ConvertToLinearMesh.cpp index 9b6cf62fe74..0907d6069ea 100644 --- a/MeshLib/MeshEditing/ConvertToLinearMesh.cpp +++ b/MeshLib/MeshEditing/ConvertToLinearMesh.cpp @@ -70,11 +70,11 @@ std::unique_ptr<MeshLib::Mesh> convertToLinearMesh(MeshLib::Mesh const& org_mesh } } - std::unique_ptr<MeshLib::Mesh> new_mesh( - new MeshLib::Mesh(new_mesh_name, vec_new_nodes, vec_new_eles, - org_mesh.getProperties().excludeCopyProperties( - std::vector<MeshLib::MeshItemType>( - 1, MeshLib::MeshItemType::Node)))); + auto new_mesh = std::make_unique<MeshLib::Mesh>( + new_mesh_name, vec_new_nodes, vec_new_eles, + org_mesh.getProperties().excludeCopyProperties( + std::vector<MeshLib::MeshItemType>(1, + MeshLib::MeshItemType::Node))); // copy property vectors for nodes MeshLib::Properties const& src_properties = org_mesh.getProperties(); diff --git a/MeshLib/MeshEditing/FlipElements.cpp b/MeshLib/MeshEditing/FlipElements.cpp index 3a58eed0df3..cef1426e36c 100644 --- a/MeshLib/MeshEditing/FlipElements.cpp +++ b/MeshLib/MeshEditing/FlipElements.cpp @@ -25,23 +25,22 @@ std::unique_ptr<MeshLib::Element> createFlippedElement( return nullptr; unsigned const n_nodes(elem.getNumberOfNodes()); - auto elem_nodes = - std::unique_ptr<MeshLib::Node* []> { new MeshLib::Node*[n_nodes] }; + auto elem_nodes = std::make_unique<MeshLib::Node* []>(n_nodes); for (unsigned i = 0; i < n_nodes; ++i) elem_nodes[i] = nodes[elem.getNode(i)->getID()]; std::swap(elem_nodes[0], elem_nodes[1]); if (elem.getGeomType() == MeshElemType::LINE) - return std::unique_ptr<MeshLib::Line>( - new MeshLib::Line(elem_nodes.release(), elem.getID())); + return std::make_unique<MeshLib::Line>(elem_nodes.release(), + elem.getID()); else if (elem.getGeomType() == MeshElemType::TRIANGLE) - return std::unique_ptr<MeshLib::Tri>( - new MeshLib::Tri(elem_nodes.release(), elem.getID())); + return std::make_unique<MeshLib::Tri>(elem_nodes.release(), + elem.getID()); else if (elem.getGeomType() == MeshElemType::QUAD) { std::swap(elem_nodes[2], elem_nodes[3]); - return std::unique_ptr<MeshLib::Quad>( - new MeshLib::Quad(elem_nodes.release(), elem.getID())); + return std::make_unique<MeshLib::Quad>(elem_nodes.release(), + elem.getID()); } return nullptr; } @@ -60,8 +59,8 @@ std::unique_ptr<MeshLib::Mesh> createFlippedMesh(MeshLib::Mesh const& mesh) for (std::size_t i=0; i<n_elems; ++i) new_elems.push_back(createFlippedElement(*elems[i], new_nodes).release()); - return std::unique_ptr<MeshLib::Mesh>(new MeshLib::Mesh( - "FlippedElementMesh", new_nodes, new_elems, mesh.getProperties())); + return std::make_unique<MeshLib::Mesh>("FlippedElementMesh", new_nodes, + new_elems, mesh.getProperties()); } } // end namespace MeshLib diff --git a/MeshLib/MeshGenerators/LayeredVolume.cpp b/MeshLib/MeshGenerators/LayeredVolume.cpp index ee2dbe76687..08cb6378c7e 100644 --- a/MeshLib/MeshGenerators/LayeredVolume.cpp +++ b/MeshLib/MeshGenerators/LayeredVolume.cpp @@ -45,7 +45,7 @@ bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh, std::unique_ptr<MeshLib::Mesh> top( removeElements(mesh, ex.getSearchedElementIDs(), "MeshLayer")); if (top==nullptr) - top.reset(new MeshLib::Mesh(mesh)); + top = std::make_unique<MeshLib::Mesh>(mesh); if (!MeshLib::MeshLayerMapper::layerMapping( *top, *rasters.back(), noDataReplacementValue)) diff --git a/MeshLib/MeshSearch/MeshElementGrid.cpp b/MeshLib/MeshSearch/MeshElementGrid.cpp index f7e6c1f4304..9622b90c08a 100644 --- a/MeshLib/MeshSearch/MeshElementGrid.cpp +++ b/MeshLib/MeshSearch/MeshElementGrid.cpp @@ -199,12 +199,10 @@ void getGridGeometry(MeshElementGrid const& grid, { std::vector<std::string> cell_names; - auto addPoints = [&geometries](MathLib::Point3d const& p, - std::array<double,3> const& d, std::array<std::size_t,3> const& c, - std::string & name) - { - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto addPoints = [&geometries]( + MathLib::Point3d const& p, std::array<double, 3> const& d, + std::array<std::size_t, 3> const& c, std::string& name) { + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); pnts->push_back(new GeoLib::Point(p[0]+c[0]*d[0], p[1]+c[1]*d[1], p[2]+c[2]*d[2])); pnts->push_back(new GeoLib::Point(p[0]+c[0]*d[0], p[1]+(c[1]+1)*d[1], p[2]+c[2]*d[2])); pnts->push_back(new GeoLib::Point(p[0]+(c[0]+1)*d[0], p[1]+(c[1]+1)*d[1], p[2]+c[2]*d[2])); @@ -229,8 +227,7 @@ void getGridGeometry(MeshElementGrid const& grid, +std::to_string(j)+"-"+std::to_string(k)); addPoints(grid._aabb.getMinPoint(), grid._step_sizes, {{i, j, k}}, cell_names.back()); - auto plys = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>(); auto & points = *geometries.getPointVec(cell_names.back()); auto* ply_bottom(new GeoLib::Polyline(points)); diff --git a/MeshLib/convertMeshToGeo.cpp b/MeshLib/convertMeshToGeo.cpp index 23d880bae57..d6e27dcfa9f 100644 --- a/MeshLib/convertMeshToGeo.cpp +++ b/MeshLib/convertMeshToGeo.cpp @@ -39,8 +39,7 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects // nodes to points conversion std::string mesh_name(mesh.getName()); { - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(); points->reserve(mesh.getNumberOfNodes()); for (auto node_ptr : mesh.getNodes()) @@ -54,7 +53,7 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects std::string const mat_name ("MaterialIDs"); auto bounds (MeshInformation::getValueBounds<int>(mesh, mat_name)); const unsigned nMatGroups(bounds.second-bounds.first+1); - auto sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>(new std::vector<GeoLib::Surface*>); + auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>(); sfcs->reserve(nMatGroups); auto const& points = *geo_objects.getPointVec(mesh_name); for (unsigned i=0; i<nMatGroups; ++i) diff --git a/NumLib/ODESolver/ConvergenceCriterionDeltaX.cpp b/NumLib/ODESolver/ConvergenceCriterionDeltaX.cpp index 0f7791dd436..88de5643426 100644 --- a/NumLib/ODESolver/ConvergenceCriterionDeltaX.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionDeltaX.cpp @@ -69,9 +69,8 @@ std::unique_ptr<ConvergenceCriterionDeltaX> createConvergenceCriterionDeltaX( if (norm_type == MathLib::VecNormType::INVALID) OGS_FATAL("Unknown vector norm type `%s'.", norm_type_str.c_str()); - return std::unique_ptr<ConvergenceCriterionDeltaX>( - new ConvergenceCriterionDeltaX(std::move(abstol), std::move(reltol), - norm_type)); + return std::make_unique<ConvergenceCriterionDeltaX>( + std::move(abstol), std::move(reltol), norm_type); } } // NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp b/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp index 341fd5ffff4..b9faaeed41e 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp @@ -108,9 +108,8 @@ createConvergenceCriterionPerComponentDeltaX(const BaseLib::ConfigTree& config) if (norm_type == MathLib::VecNormType::INVALID) OGS_FATAL("Unknown vector norm type `%s'.", norm_type_str.c_str()); - return std::unique_ptr<ConvergenceCriterionPerComponentDeltaX>( - new ConvergenceCriterionPerComponentDeltaX( - std::move(*abstols), std::move(*reltols), norm_type)); + return std::make_unique<ConvergenceCriterionPerComponentDeltaX>( + std::move(*abstols), std::move(*reltols), norm_type); } } // NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp b/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp index 67b7e44cc9c..ab6de3302ca 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp @@ -142,9 +142,8 @@ createConvergenceCriterionPerComponentResidual( if (norm_type == MathLib::VecNormType::INVALID) OGS_FATAL("Unknown vector norm type `%s'.", norm_type_str.c_str()); - return std::unique_ptr<ConvergenceCriterionPerComponentResidual>( - new ConvergenceCriterionPerComponentResidual( - std::move(*abstols), std::move(*reltols), norm_type)); + return std::make_unique<ConvergenceCriterionPerComponentResidual>( + std::move(*abstols), std::move(*reltols), norm_type); } } // NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionResidual.cpp b/NumLib/ODESolver/ConvergenceCriterionResidual.cpp index e78d7c9a56e..dc437fc66fe 100644 --- a/NumLib/ODESolver/ConvergenceCriterionResidual.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionResidual.cpp @@ -83,9 +83,8 @@ createConvergenceCriterionResidual(const BaseLib::ConfigTree& config) if (norm_type == MathLib::VecNormType::INVALID) OGS_FATAL("Unknown vector norm type `%s'.", norm_type_str.c_str()); - return std::unique_ptr<ConvergenceCriterionResidual>( - new ConvergenceCriterionResidual(std::move(abstol), std::move(reltol), - norm_type)); + return std::make_unique<ConvergenceCriterionResidual>( + std::move(abstol), std::move(reltol), norm_type); } } // NumLib diff --git a/NumLib/ODESolver/NonlinearSolver.cpp b/NumLib/ODESolver/NonlinearSolver.cpp index 9da3ac3cc74..84c3d52da10 100644 --- a/NumLib/ODESolver/NonlinearSolver.cpp +++ b/NumLib/ODESolver/NonlinearSolver.cpp @@ -309,8 +309,6 @@ std::pair<std::unique_ptr<NonlinearSolverBase>, NonlinearSolverTag> createNonlinearSolver(GlobalLinearSolver& linear_solver, BaseLib::ConfigTree const& config) { - using AbstractNLS = NonlinearSolverBase; - //! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver__type} auto const type = config.getConfigParameter<std::string>("type"); //! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver__max_iter} @@ -320,16 +318,12 @@ createNonlinearSolver(GlobalLinearSolver& linear_solver, auto const tag = NonlinearSolverTag::Picard; using ConcreteNLS = NonlinearSolver<tag>; return std::make_pair( - std::unique_ptr<AbstractNLS>( - new ConcreteNLS{linear_solver, max_iter}), - tag); + std::make_unique<ConcreteNLS>(linear_solver, max_iter), tag); } else if (type == "Newton") { auto const tag = NonlinearSolverTag::Newton; using ConcreteNLS = NonlinearSolver<tag>; return std::make_pair( - std::unique_ptr<AbstractNLS>( - new ConcreteNLS{linear_solver, max_iter}), - tag); + std::make_unique<ConcreteNLS>(linear_solver, max_iter), tag); } OGS_FATAL("Unsupported nonlinear solver type"); } diff --git a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp index 91efcf3df2a..7ee39bc34fc 100644 --- a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp +++ b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp @@ -85,7 +85,7 @@ FixedTimeStepping::newInstance(BaseLib::ConfigTree const& config) timesteps.resize(timesteps.size() + repeat, delta_t); } - return std::unique_ptr<ITimeStepAlgorithm>(new FixedTimeStepping(t_initial, t_end, timesteps)); + return std::make_unique<FixedTimeStepping>(t_initial, t_end, timesteps); } const TimeStep FixedTimeStepping::getTimeStep() const diff --git a/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.cpp index 2126a2aea97..5b7f98728da 100644 --- a/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/DirichletBoundaryCondition.cpp @@ -77,10 +77,9 @@ std::unique_ptr<DirichletBoundaryCondition> createDirichletBoundaryCondition( auto& param = findParameter<double>(param_name, parameters, 1); - return std::unique_ptr<DirichletBoundaryCondition>( - new DirichletBoundaryCondition(param, std::move(mesh_node_ids), - dof_table, mesh_id, variable_id, - component_id)); + return std::make_unique<DirichletBoundaryCondition>( + param, std::move(mesh_node_ids), dof_table, mesh_id, variable_id, + component_id); } } // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.cpp index a5d81e69169..fbcbb411695 100644 --- a/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.cpp @@ -32,10 +32,9 @@ std::unique_ptr<NeumannBoundaryCondition> createNeumannBoundaryCondition( auto const& param = findParameter<double>(param_name, parameters, 1); - return std::unique_ptr<NeumannBoundaryCondition>( - new NeumannBoundaryCondition(is_axially_symmetric, integration_order, shapefunction_order, - dof_table, variable_id, component_id, - global_dim, std::move(elements), param)); + return std::make_unique<NeumannBoundaryCondition>( + is_axially_symmetric, integration_order, shapefunction_order, dof_table, + variable_id, component_id, global_dim, std::move(elements), param); } } // ProcessLib diff --git a/ProcessLib/BoundaryCondition/RobinBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/RobinBoundaryCondition.cpp index 568010349bc..fa1561a4865 100644 --- a/ProcessLib/BoundaryCondition/RobinBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/RobinBoundaryCondition.cpp @@ -34,10 +34,10 @@ std::unique_ptr<RobinBoundaryCondition> createRobinBoundaryCondition( auto const& alpha = findParameter<double>(alpha_name, parameters, 1); auto const& u_0 = findParameter<double>(u_0_name, parameters, 1); - return std::unique_ptr<RobinBoundaryCondition>(new RobinBoundaryCondition( - is_axially_symmetric, integration_order, shapefunction_order, dof_table, variable_id, - component_id, global_dim, std::move(elements), - RobinBoundaryConditionData{alpha, u_0})); + return std::make_unique<RobinBoundaryCondition>( + is_axially_symmetric, integration_order, shapefunction_order, dof_table, + variable_id, component_id, global_dim, std::move(elements), + RobinBoundaryConditionData{alpha, u_0}); } } // ProcessLib diff --git a/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp b/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp index 6dba93cf506..3b961d230e2 100644 --- a/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp +++ b/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFlux.cpp @@ -25,8 +25,8 @@ CalculateSurfaceFlux::CalculateSurfaceFlux( _local_assemblers.resize(boundary_mesh.getElements().size()); // needed to create dof table - std::unique_ptr<MeshLib::MeshSubset const> mesh_subset_all_nodes( - new MeshLib::MeshSubset(boundary_mesh, &boundary_mesh.getNodes())); + auto mesh_subset_all_nodes = std::make_unique<MeshLib::MeshSubset const>( + boundary_mesh, &boundary_mesh.getNodes()); // Collect the mesh subsets in a vector. std::vector<MeshLib::MeshSubsets> all_mesh_subsets; @@ -36,9 +36,8 @@ CalculateSurfaceFlux::CalculateSurfaceFlux( [&]() { return MeshLib::MeshSubsets{mesh_subset_all_nodes.get()}; }); // needed for creation of local assemblers - std::unique_ptr<NumLib::LocalToGlobalIndexMap const> dof_table( - new NumLib::LocalToGlobalIndexMap(std::move(all_mesh_subsets), - NumLib::ComponentOrder::BY_LOCATION)); + auto dof_table = std::make_unique<NumLib::LocalToGlobalIndexMap const>( + std::move(all_mesh_subsets), NumLib::ComponentOrder::BY_LOCATION); auto const bulk_element_ids = boundary_mesh.getProperties().template getPropertyVector<std::size_t>( diff --git a/ProcessLib/CentralDifferencesJacobianAssembler.cpp b/ProcessLib/CentralDifferencesJacobianAssembler.cpp index 938369eca7a..cfa31be7b9f 100644 --- a/ProcessLib/CentralDifferencesJacobianAssembler.cpp +++ b/ProcessLib/CentralDifferencesJacobianAssembler.cpp @@ -166,8 +166,8 @@ createCentralDifferencesJacobianAssembler(BaseLib::ConfigTree const& config) abs_eps.emplace_back(1e-8); } - return std::unique_ptr<CentralDifferencesJacobianAssembler>( - new CentralDifferencesJacobianAssembler(std::move(abs_eps))); + return std::make_unique<CentralDifferencesJacobianAssembler>( + std::move(abs_eps)); } } // ProcessLib diff --git a/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp b/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp index 79e53c0cd9d..03475f52a9f 100644 --- a/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp +++ b/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp @@ -143,10 +143,10 @@ std::unique_ptr<Process> createComponentTransportProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<Process>{new ComponentTransportProcess{ + return std::make_unique<ComponentTransportProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), - std::move(secondary_variables), std::move(named_function_caller)}}; + std::move(secondary_variables), std::move(named_function_caller)); } } // namespace ComponentTransport diff --git a/ProcessLib/CreateJacobianAssembler.cpp b/ProcessLib/CreateJacobianAssembler.cpp index abcce5bb2a6..d40f0344bd6 100644 --- a/ProcessLib/CreateJacobianAssembler.cpp +++ b/ProcessLib/CreateJacobianAssembler.cpp @@ -19,16 +19,14 @@ std::unique_ptr<AbstractJacobianAssembler> createJacobianAssembler( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) - return std::unique_ptr<AbstractJacobianAssembler>( - new AnalyticalJacobianAssembler); + return std::make_unique<AnalyticalJacobianAssembler>(); //! \ogs_file_param{prj__processes__process__jacobian_assembler__type} auto const type = config->peekConfigParameter<std::string>("type"); if (type == "Analytical") { config->ignoreConfigParameter("type"); - return std::unique_ptr<AbstractJacobianAssembler>( - new AnalyticalJacobianAssembler); + return std::make_unique<AnalyticalJacobianAssembler>(); } else if (type == "CentralDifferences") { return createCentralDifferencesJacobianAssembler(*config); } diff --git a/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp b/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp index 4f380330460..da6ab5ccd85 100644 --- a/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp +++ b/ProcessLib/GroundwaterFlow/CreateGroundwaterFlowProcess.cpp @@ -93,12 +93,12 @@ std::unique_ptr<Process> createGroundwaterFlowProcess( surface_mesh->setAxiallySymmetric(mesh.isAxiallySymmetric()); } - return std::unique_ptr<Process>{new GroundwaterFlowProcess{ + return std::make_unique<GroundwaterFlowProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), std::move(secondary_variables), std::move(named_function_caller), surface_mesh.release(), std::move(balance_pv_name), - std::move(balance_out_fname)}}; + std::move(balance_out_fname)); } } // namespace GroundwaterFlow diff --git a/ProcessLib/HT/CreateHTProcess.cpp b/ProcessLib/HT/CreateHTProcess.cpp index 987df379781..9caebb641d1 100644 --- a/ProcessLib/HT/CreateHTProcess.cpp +++ b/ProcessLib/HT/CreateHTProcess.cpp @@ -167,10 +167,10 @@ std::unique_ptr<Process> createHTProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<Process>{new HTProcess{ + return std::make_unique<HTProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), - std::move(secondary_variables), std::move(named_function_caller)}}; + std::move(secondary_variables), std::move(named_function_caller)); } } // namespace HT diff --git a/ProcessLib/HeatConduction/CreateHeatConductionProcess.cpp b/ProcessLib/HeatConduction/CreateHeatConductionProcess.cpp index 4b87721fb87..7488975e8c0 100644 --- a/ProcessLib/HeatConduction/CreateHeatConductionProcess.cpp +++ b/ProcessLib/HeatConduction/CreateHeatConductionProcess.cpp @@ -77,10 +77,10 @@ std::unique_ptr<Process> createHeatConductionProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<Process>{new HeatConductionProcess{ + return std::make_unique<HeatConductionProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), - std::move(secondary_variables), std::move(named_function_caller)}}; + std::move(secondary_variables), std::move(named_function_caller)); } } // namespace HeatConduction diff --git a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp index a4bede7634e..7ec961e1075 100644 --- a/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp +++ b/ProcessLib/HydroMechanics/CreateHydroMechanicsProcess.cpp @@ -192,11 +192,10 @@ std::unique_ptr<Process> createHydroMechanicsProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<HydroMechanicsProcess<DisplacementDim>>{ - new HydroMechanicsProcess<DisplacementDim>{ - mesh, std::move(jacobian_assembler), parameters, integration_order, - std::move(process_variables), std::move(process_data), - std::move(secondary_variables), std::move(named_function_caller)}}; + return std::make_unique<HydroMechanicsProcess<DisplacementDim>>( + mesh, std::move(jacobian_assembler), parameters, integration_order, + std::move(process_variables), std::move(process_data), + std::move(secondary_variables), std::move(named_function_caller)); } template std::unique_ptr<Process> createHydroMechanicsProcess<2>( diff --git a/ProcessLib/HydroMechanics/HydroMechanicsProcess.h b/ProcessLib/HydroMechanics/HydroMechanicsProcess.h index 4ca7953b5d4..e4ae10e2839 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsProcess.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsProcess.h @@ -61,12 +61,12 @@ private: void constructDofTable() override { // Create single component dof in every of the mesh's nodes. - _mesh_subset_all_nodes.reset( - new MeshLib::MeshSubset(_mesh, &_mesh.getNodes())); + _mesh_subset_all_nodes = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_mesh.getNodes()); // Create single component dof in the mesh's base nodes. _base_nodes = MeshLib::getBaseNodes(_mesh.getElements()); - _mesh_subset_base_nodes.reset( - new MeshLib::MeshSubset(_mesh, &_base_nodes)); + _mesh_subset_base_nodes = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_base_nodes); // Collect the mesh subsets in a vector. @@ -83,9 +83,10 @@ private: }); std::vector<unsigned> const vec_n_components{1, DisplacementDim}; - _local_to_global_index_map.reset(new NumLib::LocalToGlobalIndexMap( - std::move(all_mesh_subsets), vec_n_components, - NumLib::ComponentOrder::BY_LOCATION)); + _local_to_global_index_map = + std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(all_mesh_subsets), vec_n_components, + NumLib::ComponentOrder::BY_LOCATION); } void initializeConcreteProcess( @@ -106,11 +107,11 @@ private: std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component; all_mesh_subsets_single_component.emplace_back( _mesh_subset_all_nodes.get()); - _local_to_global_index_map_single_component.reset( - new NumLib::LocalToGlobalIndexMap( + _local_to_global_index_map_single_component = + std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(all_mesh_subsets_single_component), // by location order is needed for output - NumLib::ComponentOrder::BY_LOCATION)); + NumLib::ComponentOrder::BY_LOCATION); Base::_secondary_variables.addSecondaryVariable( "sigma_xx", 1, diff --git a/ProcessLib/LIE/BoundaryCondition/BoundaryConditionBuilder.cpp b/ProcessLib/LIE/BoundaryCondition/BoundaryConditionBuilder.cpp index 98027d69cb3..7a6d7605591 100644 --- a/ProcessLib/LIE/BoundaryCondition/BoundaryConditionBuilder.cpp +++ b/ProcessLib/LIE/BoundaryCondition/BoundaryConditionBuilder.cpp @@ -29,8 +29,8 @@ BoundaryConditionBuilder::createNeumannBoundaryCondition( const unsigned shapefunction_order, const std::vector<std::unique_ptr<ProcessLib::ParameterBase>>& parameters) { - std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_strategy{ - new MeshGeoToolsLib::SearchLength}; + auto search_length_strategy = + std::make_unique<MeshGeoToolsLib::SearchLength>(); MeshGeoToolsLib::MeshNodeSearcher const& mesh_node_searcher = MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeSearcher( mesh, std::move(search_length_strategy)); diff --git a/ProcessLib/LIE/BoundaryCondition/NeumannBoundaryCondition.cpp b/ProcessLib/LIE/BoundaryCondition/NeumannBoundaryCondition.cpp index 99d996de65f..959f1d300aa 100644 --- a/ProcessLib/LIE/BoundaryCondition/NeumannBoundaryCondition.cpp +++ b/ProcessLib/LIE/BoundaryCondition/NeumannBoundaryCondition.cpp @@ -42,11 +42,10 @@ std::unique_ptr<BoundaryCondition> createNeumannBoundaryCondition( auto const& param = findParameter<double>(param_name, parameters, 1); - return std::unique_ptr<BoundaryCondition>( - new NeumannBoundaryCondition( - is_axially_symmetric, integration_order, shapefunction_order, - dof_table, variable_id, component_id, - global_dim, std::move(elements), param, fracture_prop)); + return std::make_unique<NeumannBoundaryCondition>( + is_axially_symmetric, integration_order, shapefunction_order, dof_table, + variable_id, component_id, global_dim, std::move(elements), param, + fracture_prop); } } // LIE diff --git a/ProcessLib/LIE/Common/PostUtils.cpp b/ProcessLib/LIE/Common/PostUtils.cpp index 7e08cd88d57..8c59ab209c8 100644 --- a/ProcessLib/LIE/Common/PostUtils.cpp +++ b/ProcessLib/LIE/Common/PostUtils.cpp @@ -107,7 +107,8 @@ PostProcessTool::PostProcessTool( } // new mesh - _output_mesh.reset(new MeshLib::Mesh(org_mesh.getName(), new_nodes, new_eles)); + _output_mesh = std::make_unique<MeshLib::Mesh>(org_mesh.getName(), + new_nodes, new_eles); createProperties<int>(); createProperties<double>(); copyProperties<int>(); diff --git a/ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp b/ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp index f53e2a4201b..972eec043d4 100644 --- a/ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp +++ b/ProcessLib/LIE/HydroMechanics/CreateHydroMechanicsProcess.cpp @@ -234,7 +234,7 @@ std::unique_ptr<Process> createHydroMechanicsProcess( { auto& fracture_properties_config = *opt_fracture_properties_config; - frac_prop.reset(new FractureProperty()); + frac_prop = std::make_unique<ProcessLib::LIE::FractureProperty>(); frac_prop->mat_id = //! \ogs_file_param{prj__processes__process__HYDRO_MECHANICS_WITH_LIE__fracture_properties__material_id} fracture_properties_config.getConfigParameter<int>("material_id"); @@ -299,11 +299,10 @@ std::unique_ptr<Process> createHydroMechanicsProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<HydroMechanicsProcess<GlobalDim>>{ - new HydroMechanicsProcess<GlobalDim>{ - mesh, std::move(jacobian_assembler), parameters, integration_order, - std::move(process_variables), std::move(process_data), - std::move(secondary_variables), std::move(named_function_caller)}}; + return std::make_unique<HydroMechanicsProcess<GlobalDim>>( + mesh, std::move(jacobian_assembler), parameters, integration_order, + std::move(process_variables), std::move(process_data), + std::move(secondary_variables), std::move(named_function_caller)); } template std::unique_ptr<Process> createHydroMechanicsProcess<2>( diff --git a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp index d9ba570241f..7315253f1a9 100644 --- a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp +++ b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp @@ -91,14 +91,14 @@ HydroMechanicsProcess<GlobalDim>::HydroMechanicsProcess( if (pv.getName().find("displacement_jump") == std::string::npos) continue; pv.setBoundaryConditionBuilder( - std::unique_ptr<ProcessLib::BoundaryConditionBuilder>( - new BoundaryConditionBuilder( - *_process_data.fracture_property.get()))); + std::make_unique<BoundaryConditionBuilder>( + *_process_data.fracture_property.get())); } if (!_process_data.deactivate_matrix_in_flow) { - _process_data.p_element_status.reset(new MeshLib::ElementStatus(&mesh)); + _process_data.p_element_status = + std::make_unique<MeshLib::ElementStatus>(&mesh); } else { @@ -111,7 +111,9 @@ HydroMechanicsProcess<GlobalDim>::HydroMechanicsProcess( matID) == vec_fracture_mat_IDs.end()) vec_p_inactive_matIDs.push_back(matID); } - _process_data.p_element_status.reset(new MeshLib::ElementStatus(&mesh, vec_p_inactive_matIDs)); + _process_data.p_element_status = + std::make_unique<MeshLib::ElementStatus>(&mesh, + vec_p_inactive_matIDs); ProcessVariable const& pv_p = getProcessVariables()[0]; _process_data.p0 = &pv_p.getInitialCondition(); @@ -126,20 +128,21 @@ void HydroMechanicsProcess<GlobalDim>::constructDofTable() // prepare mesh subsets to define DoFs //------------------------------------------------------------ // for extrapolation - _mesh_subset_all_nodes.reset( - new MeshLib::MeshSubset(_mesh, &_mesh.getNodes())); + _mesh_subset_all_nodes = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_mesh.getNodes()); // pressure _mesh_nodes_p = MeshLib::getBaseNodes( _process_data.p_element_status->getActiveElements()); - _mesh_subset_nodes_p.reset(new MeshLib::MeshSubset(_mesh, &_mesh_nodes_p)); + _mesh_subset_nodes_p = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_mesh_nodes_p); // regular u - _mesh_subset_matrix_nodes.reset( - new MeshLib::MeshSubset(_mesh, &_mesh.getNodes())); + _mesh_subset_matrix_nodes = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_mesh.getNodes()); if (!_vec_fracture_nodes.empty()) { // u jump - _mesh_subset_fracture_nodes.reset( - new MeshLib::MeshSubset(_mesh, &_vec_fracture_nodes)); + _mesh_subset_fracture_nodes = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_vec_fracture_nodes); } // Collect the mesh subsets in a vector. @@ -176,11 +179,12 @@ void HydroMechanicsProcess<GlobalDim>::constructDofTable() } INFO("[LIE/HM] creating a DoF table"); - _local_to_global_index_map.reset(new NumLib::LocalToGlobalIndexMap( - std::move(all_mesh_subsets), - vec_n_components, - vec_var_elements, - NumLib::ComponentOrder::BY_COMPONENT)); + _local_to_global_index_map = + std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(all_mesh_subsets), + vec_n_components, + vec_var_elements, + NumLib::ComponentOrder::BY_COMPONENT); DBUG("created %d DoF", _local_to_global_index_map->size()); } diff --git a/ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.cpp b/ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.cpp index fadad80dd91..e5985935b03 100644 --- a/ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.cpp +++ b/ProcessLib/LIE/SmallDeformation/CreateSmallDeformationProcess.cpp @@ -177,11 +177,10 @@ createSmallDeformationProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<SmallDeformationProcess<DisplacementDim>>{ - new SmallDeformationProcess<DisplacementDim>{ - mesh, std::move(jacobian_assembler), parameters, integration_order, - std::move(process_variables), std::move(process_data), - std::move(secondary_variables), std::move(named_function_caller)}}; + return std::make_unique<SmallDeformationProcess<DisplacementDim>>( + mesh, std::move(jacobian_assembler), parameters, integration_order, + std::move(process_variables), std::move(process_data), + std::move(secondary_variables), std::move(named_function_caller)); } template diff --git a/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp b/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp index 9be631e3a50..a253ffea15f 100644 --- a/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp +++ b/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp @@ -98,9 +98,8 @@ SmallDeformationProcess<DisplacementDim>::SmallDeformationProcess( if (pv.getName().find("displacement_jump") == std::string::npos) continue; pv.setBoundaryConditionBuilder( - std::unique_ptr<ProcessLib::BoundaryConditionBuilder>( - new BoundaryConditionBuilder( - *_process_data._vec_fracture_property[pv_disp_jump_id].get()))); + std::make_unique<BoundaryConditionBuilder>( + *_process_data._vec_fracture_property[pv_disp_jump_id].get())); pv_disp_jump_id++; } @@ -117,15 +116,17 @@ void SmallDeformationProcess<DisplacementDim>::constructDofTable() // prepare mesh subsets to define DoFs //------------------------------------------------------------ // for extrapolation - _mesh_subset_all_nodes.reset(new MeshLib::MeshSubset(_mesh, &_mesh.getNodes())); + _mesh_subset_all_nodes = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_mesh.getNodes()); // regular u - _mesh_subset_matrix_nodes.reset(new MeshLib::MeshSubset(_mesh, &_mesh.getNodes())); + _mesh_subset_matrix_nodes = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_mesh.getNodes()); // u jump for (unsigned i=0; i<_vec_fracture_nodes.size(); i++) { _mesh_subset_fracture_nodes.push_back( - std::unique_ptr<MeshLib::MeshSubset const>( - new MeshLib::MeshSubset(_mesh, &_vec_fracture_nodes[i]))); + std::make_unique<MeshLib::MeshSubset const>( + _mesh, &_vec_fracture_nodes[i])); } // Collect the mesh subsets in a vector. @@ -149,12 +150,12 @@ void SmallDeformationProcess<DisplacementDim>::constructDofTable() for (unsigned i=0; i<_vec_fracture_matrix_elements.size(); i++) vec_var_elements.push_back(&_vec_fracture_matrix_elements[i]); - _local_to_global_index_map.reset( - new NumLib::LocalToGlobalIndexMap( + _local_to_global_index_map = + std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(all_mesh_subsets), vec_n_components, vec_var_elements, - NumLib::ComponentOrder::BY_COMPONENT)); + NumLib::ComponentOrder::BY_COMPONENT); } @@ -178,11 +179,11 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess( std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component; all_mesh_subsets_single_component.emplace_back( _mesh_subset_all_nodes.get()); - _local_to_global_index_map_single_component.reset( - new NumLib::LocalToGlobalIndexMap( + _local_to_global_index_map_single_component = + std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(all_mesh_subsets_single_component), // by location order is needed for output - NumLib::ComponentOrder::BY_LOCATION)); + NumLib::ComponentOrder::BY_LOCATION); Base::_secondary_variables.addSecondaryVariable( "sigma_xx", 1, diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp b/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp index 511cb590a5b..bf57232732b 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp @@ -108,25 +108,22 @@ createLiquidFlowMaterialProperties( auto& biot_constant = findParameter<double>( //! \ogs_file_param_special{prj__processes__process__LIQUID_FLOW__material_property__solid__biot_constant} *solid_config, "biot_constant", parameters, 1); - return std::unique_ptr<LiquidFlowMaterialProperties>( - new LiquidFlowMaterialProperties( - std::move(fluid_properties), - std::move(intrinsic_permeability_models), - std::move(porosity_models), std::move(storage_models), - has_material_ids, material_ids, solid_thermal_expansion, - biot_constant)); + 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, solid_thermal_expansion, + biot_constant); } else { ConstantParameter<double> void_parameter("void_solid_thermal_expansion", 0.); - return std::unique_ptr<LiquidFlowMaterialProperties>( - new 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)); + 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); } } diff --git a/ProcessLib/Parameter/ConstantParameter.cpp b/ProcessLib/Parameter/ConstantParameter.cpp index 4f28feecda7..33b79436b77 100644 --- a/ProcessLib/Parameter/ConstantParameter.cpp +++ b/ProcessLib/Parameter/ConstantParameter.cpp @@ -30,8 +30,7 @@ std::unique_ptr<ParameterBase> createConstantParameter( if (value) { DBUG("Using value %g for constant parameter.", *value); - return std::unique_ptr<ParameterBase>( - new ConstantParameter<double>(name, *value)); + return std::make_unique<ConstantParameter<double>>(name, *value); } } @@ -50,8 +49,7 @@ std::unique_ptr<ParameterBase> createConstantParameter( DBUG("\t%g", v); } - return std::unique_ptr<ParameterBase>( - new ConstantParameter<double>(name, values)); + return std::make_unique<ConstantParameter<double>>(name, values); } } // ProcessLib diff --git a/ProcessLib/Parameter/CurveScaledParameter.cpp b/ProcessLib/Parameter/CurveScaledParameter.cpp index f0666b5f414..5c13add31c1 100644 --- a/ProcessLib/Parameter/CurveScaledParameter.cpp +++ b/ProcessLib/Parameter/CurveScaledParameter.cpp @@ -36,8 +36,8 @@ std::unique_ptr<ParameterBase> createCurveScaledParameter( DBUG("Using parameter %s", referenced_parameter_name.c_str()); // TODO other data types than only double - return std::unique_ptr<ParameterBase>(new CurveScaledParameter<double>( - name, *curve_it->second, referenced_parameter_name)); + return std::make_unique<CurveScaledParameter<double>>( + name, *curve_it->second, referenced_parameter_name); } } // ProcessLib diff --git a/ProcessLib/Parameter/GroupBasedParameter.cpp b/ProcessLib/Parameter/GroupBasedParameter.cpp index df03fba721a..246a38e75ca 100644 --- a/ProcessLib/Parameter/GroupBasedParameter.cpp +++ b/ProcessLib/Parameter/GroupBasedParameter.cpp @@ -84,14 +84,14 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( vec_values[p.first] = p.second; if (group_id_property->getMeshItemType() == MeshLib::MeshItemType::Node) - return std::unique_ptr<ParameterBase>( - new GroupBasedParameter<double, MeshLib::MeshItemType::Node>( - name, *group_id_property, vec_values)); + return std::make_unique< + GroupBasedParameter<double, MeshLib::MeshItemType::Node>>( + name, *group_id_property, vec_values); else if (group_id_property->getMeshItemType() == MeshLib::MeshItemType::Cell) - return std::unique_ptr<ParameterBase>( - new GroupBasedParameter<double, MeshLib::MeshItemType::Cell>( - name, *group_id_property, vec_values)); + return std::make_unique< + GroupBasedParameter<double, MeshLib::MeshItemType::Cell>>( + name, *group_id_property, vec_values); OGS_FATAL("Mesh item type of the specified property is not supported."); } diff --git a/ProcessLib/Parameter/MeshElementParameter.cpp b/ProcessLib/Parameter/MeshElementParameter.cpp index 43f346b1839..f105a46cb1a 100644 --- a/ProcessLib/Parameter/MeshElementParameter.cpp +++ b/ProcessLib/Parameter/MeshElementParameter.cpp @@ -33,8 +33,7 @@ std::unique_ptr<ParameterBase> createMeshElementParameter( field_name.c_str()); } - return std::unique_ptr<ParameterBase>( - new MeshElementParameter<double>(name, *property)); + return std::make_unique<MeshElementParameter<double>>(name, *property); } } // ProcessLib diff --git a/ProcessLib/Parameter/MeshNodeParameter.cpp b/ProcessLib/Parameter/MeshNodeParameter.cpp index 1c50bdcc695..240dfe9a9e9 100644 --- a/ProcessLib/Parameter/MeshNodeParameter.cpp +++ b/ProcessLib/Parameter/MeshNodeParameter.cpp @@ -33,8 +33,7 @@ std::unique_ptr<ParameterBase> createMeshNodeParameter( field_name.c_str()); } - return std::unique_ptr<ParameterBase>( - new MeshNodeParameter<double>(name, *property)); + return std::make_unique<MeshNodeParameter<double>>(name, *property); } } // ProcessLib diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp index 4fc07febe18..5bf2b92329e 100644 --- a/ProcessLib/Process.cpp +++ b/ProcessLib/Process.cpp @@ -144,8 +144,8 @@ void Process::assembleWithJacobian(const double t, GlobalVector const& x, void Process::constructDofTable() { // Create single component dof in every of the mesh's nodes. - _mesh_subset_all_nodes.reset( - new MeshLib::MeshSubset(_mesh, &_mesh.getNodes())); + _mesh_subset_all_nodes = + std::make_unique<MeshLib::MeshSubset>(_mesh, &_mesh.getNodes()); // Collect the mesh subsets in a vector. std::vector<MeshLib::MeshSubsets> all_mesh_subsets; @@ -164,10 +164,10 @@ void Process::constructDofTable() for (ProcessVariable const& pv : _process_variables) vec_var_n_components.push_back(pv.getNumberOfComponents()); - _local_to_global_index_map.reset(new NumLib::LocalToGlobalIndexMap( - std::move(all_mesh_subsets), vec_var_n_components, - NumLib::ComponentOrder::BY_LOCATION)); - + _local_to_global_index_map = + std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(all_mesh_subsets), vec_var_n_components, + NumLib::ComponentOrder::BY_LOCATION); } void Process::initializeExtrapolator() diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index 76533636cb4..fc9f3e4a5e0 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -33,7 +33,7 @@ ProcessVariable::ProcessVariable( //! \ogs_file_param{prj__process_variables__process_variable__initial_condition} config.getConfigParameter<std::string>("initial_condition"), parameters, _n_components)), - _bc_builder(new BoundaryConditionBuilder()) + _bc_builder(std::make_unique<BoundaryConditionBuilder>()) { DBUG("Constructing process variable %s", _name.c_str()); diff --git a/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp b/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp index 08b2a7ed729..5355698ef95 100644 --- a/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp +++ b/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp @@ -122,10 +122,10 @@ std::unique_ptr<Process> createRichardsFlowProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<Process>{new RichardsFlowProcess{ + return std::make_unique<RichardsFlowProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), - std::move(secondary_variables), std::move(named_function_caller)}}; + std::move(secondary_variables), std::move(named_function_caller)); } } // namespace RichardsFlow diff --git a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp index 50d6de1f82e..b326950c169 100644 --- a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp +++ b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp @@ -113,11 +113,10 @@ createSmallDeformationProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<SmallDeformationProcess<DisplacementDim>>{ - new SmallDeformationProcess<DisplacementDim>{ - mesh, std::move(jacobian_assembler), parameters, integration_order, - std::move(process_variables), std::move(process_data), - std::move(secondary_variables), std::move(named_function_caller)}}; + return std::make_unique<SmallDeformationProcess<DisplacementDim>>( + mesh, std::move(jacobian_assembler), parameters, integration_order, + std::move(process_variables), std::move(process_data), + std::move(secondary_variables), std::move(named_function_caller)); } template std::unique_ptr<Process> createSmallDeformationProcess<2>( diff --git a/ProcessLib/SmallDeformation/SmallDeformationProcess.h b/ProcessLib/SmallDeformation/SmallDeformationProcess.h index 4930a9b8b69..f2d4c98cf74 100644 --- a/ProcessLib/SmallDeformation/SmallDeformationProcess.h +++ b/ProcessLib/SmallDeformation/SmallDeformationProcess.h @@ -74,11 +74,11 @@ private: std::vector<MeshLib::MeshSubsets> all_mesh_subsets_single_component; all_mesh_subsets_single_component.emplace_back( _mesh_subset_all_nodes.get()); - _local_to_global_index_map_single_component.reset( - new NumLib::LocalToGlobalIndexMap( + _local_to_global_index_map_single_component = + std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(all_mesh_subsets_single_component), // by location order is needed for output - NumLib::ComponentOrder::BY_LOCATION)); + NumLib::ComponentOrder::BY_LOCATION); _nodal_forces->resize(DisplacementDim * mesh.getNumberOfNodes()); Base::_secondary_variables.addSecondaryVariable( diff --git a/ProcessLib/TES/CreateTESProcess.cpp b/ProcessLib/TES/CreateTESProcess.cpp index 842696a8163..be8eeb4d976 100644 --- a/ProcessLib/TES/CreateTESProcess.cpp +++ b/ProcessLib/TES/CreateTESProcess.cpp @@ -50,10 +50,10 @@ std::unique_ptr<Process> createTESProcess( ProcessLib::parseSecondaryVariables(config, secondary_variables, named_function_caller); - return std::unique_ptr<Process>{new TESProcess{ + return std::make_unique<TESProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(secondary_variables), - std::move(named_function_caller), config}}; + std::move(named_function_caller), config); } } // namespace TES diff --git a/ProcessLib/TES/TESProcess.cpp b/ProcessLib/TES/TESProcess.cpp index 9ccb2d4f15f..55d9b8566ac 100644 --- a/ProcessLib/TES/TESProcess.cpp +++ b/ProcessLib/TES/TESProcess.cpp @@ -184,11 +184,10 @@ void TESProcess::initializeSecondaryVariables() // ///////////////////////////////////////////////////////////////////////// // named functions: solid density ////////////////////////////////////////// - std::unique_ptr<CachedSecondaryVariable> solid_density( - new CachedSecondaryVariable( - "TES_solid_density", getExtrapolator(), _local_assemblers, - &TESLocalAssemblerInterface::getIntPtSolidDensity, - _secondary_variable_context)); + auto solid_density = std::make_unique<CachedSecondaryVariable>( + "TES_solid_density", getExtrapolator(), _local_assemblers, + &TESLocalAssemblerInterface::getIntPtSolidDensity, + _secondary_variable_context); for (auto&& fct : solid_density->getNamedFunctions()) _named_function_caller.addNamedFunction(std::move(fct)); diff --git a/ProcessLib/TES/TESReactionAdaptor.cpp b/ProcessLib/TES/TESReactionAdaptor.cpp index 85bb8cdb16b..599b79d0bd9 100644 --- a/ProcessLib/TES/TESReactionAdaptor.cpp +++ b/ProcessLib/TES/TESReactionAdaptor.cpp @@ -31,28 +31,24 @@ std::unique_ptr<TESFEMReactionAdaptor> TESFEMReactionAdaptor::newInstance( auto const* ads = data.ap.react_sys.get(); if (dynamic_cast<Adsorption::AdsorptionReaction const*>(ads) != nullptr) { - return std::unique_ptr<TESFEMReactionAdaptor>( - new TESFEMReactionAdaptorAdsorption(data)); + return std::make_unique<TESFEMReactionAdaptorAdsorption>(data); } else if (dynamic_cast<Adsorption::ReactionInert const*>(ads) != nullptr) { - return std::unique_ptr<TESFEMReactionAdaptor>( - new TESFEMReactionAdaptorInert(data)); + return std::make_unique<TESFEMReactionAdaptorInert>(data); } else if (dynamic_cast<Adsorption::ReactionSinusoidal const*>(ads) != nullptr) { - return std::unique_ptr<TESFEMReactionAdaptor>( - new TESFEMReactionAdaptorSinusoidal(data)); + return std::make_unique<TESFEMReactionAdaptorSinusoidal>(data); } else if (dynamic_cast<Adsorption::ReactionCaOH2 const*>(ads) != nullptr) { - return std::unique_ptr<TESFEMReactionAdaptor>( - new TESFEMReactionAdaptorCaOH2(data)); + return std::make_unique<TESFEMReactionAdaptorCaOH2>(data); } OGS_FATAL("No suitable TESFEMReactionAdaptor found. Aborting."); - return std::unique_ptr<TESFEMReactionAdaptor>(nullptr); + return nullptr; } TESFEMReactionAdaptorAdsorption::TESFEMReactionAdaptorAdsorption( diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.cpp b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.cpp index e8cf73374a3..aed18492597 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.cpp +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.cpp @@ -89,19 +89,17 @@ createThermalTwoPhaseFlowWithPPMaterialProperties( thermal_conductivity_wet_solid_conf); std::unique_ptr<MaterialLib::Fluid::WaterVaporProperties> vapor_property = - std::unique_ptr<MaterialLib::Fluid::WaterVaporProperties>( - new MaterialLib::Fluid::WaterVaporProperties()); + std::make_unique<MaterialLib::Fluid::WaterVaporProperties>(); - return std::unique_ptr<ThermalTwoPhaseFlowWithPPMaterialProperties>{ - new ThermalTwoPhaseFlowWithPPMaterialProperties{ - std::move(two_phase_material_model), - std::move(specific_heat_capacity_solid), - std::move(specific_heat_capacity_water), - std::move(specific_heat_capacity_air), - std::move(specific_heat_capacity_vapor), - std::move(thermal_conductivity_dry_solid), - std::move(thermal_conductivity_wet_solid), - std::move(vapor_property)}}; + return std::make_unique<ThermalTwoPhaseFlowWithPPMaterialProperties>( + std::move(two_phase_material_model), + std::move(specific_heat_capacity_solid), + std::move(specific_heat_capacity_water), + std::move(specific_heat_capacity_air), + std::move(specific_heat_capacity_vapor), + std::move(thermal_conductivity_dry_solid), + std::move(thermal_conductivity_wet_solid), + std::move(vapor_property)); } } // end namespace diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp index 7d6ec15d78e..12e3471ac89 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp @@ -131,11 +131,11 @@ std::unique_ptr<Process> createThermalTwoPhaseFlowWithPPProcess( latent_heat_evaporation, std::move(material)}; - return std::unique_ptr<Process>{new ThermalTwoPhaseFlowWithPPProcess{ + return std::make_unique<ThermalTwoPhaseFlowWithPPProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), std::move(secondary_variables), std::move(named_function_caller), - mat_config, curves}}; + mat_config, curves); } } // end of namespace diff --git a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.cpp b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.cpp index 5c5f353d016..5332806a6b5 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.cpp +++ b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.cpp @@ -125,14 +125,12 @@ createTwoPhaseFlowWithPPMaterialProperties( BaseLib::reorderVector(porosity_models, mat_ids); BaseLib::reorderVector(storage_models, mat_ids); - return std::unique_ptr<TwoPhaseFlowWithPPMaterialProperties>{ - new TwoPhaseFlowWithPPMaterialProperties{ - material_ids, std::move(liquid_density), - std::move(liquid_viscosity), std::move(gas_density), - std::move(gas_viscosity), intrinsic_permeability_models, - std::move(porosity_models), std::move(storage_models), - std::move(capillary_pressure_models), - std::move(relative_permeability_models)}}; + return std::make_unique<TwoPhaseFlowWithPPMaterialProperties>( + material_ids, std::move(liquid_density), std::move(liquid_viscosity), + std::move(gas_density), std::move(gas_viscosity), + intrinsic_permeability_models, std::move(porosity_models), + std::move(storage_models), std::move(capillary_pressure_models), + std::move(relative_permeability_models)); } } // end namespace diff --git a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp index 8bd46d221fb..71be4b9be07 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp +++ b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp @@ -92,11 +92,11 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPPProcess( TwoPhaseFlowWithPPProcessData process_data{ specific_body_force, has_gravity, mass_lumping, temperature, std::move(material)}; - return std::unique_ptr<Process>{new TwoPhaseFlowWithPPProcess{ + return std::make_unique<TwoPhaseFlowWithPPProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), std::move(secondary_variables), std::move(named_function_caller), - mat_config, curves}}; + mat_config, curves); } } // end of namespace diff --git a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.cpp b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.cpp index cd5174a7e05..db054cb6b85 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.cpp +++ b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.cpp @@ -125,13 +125,12 @@ createTwoPhaseFlowPrhoMaterialProperties( BaseLib::reorderVector(_porosity_models, mat_ids); BaseLib::reorderVector(_storage_models, mat_ids); - return std::unique_ptr<TwoPhaseFlowWithPrhoMaterialProperties>{ - new TwoPhaseFlowWithPrhoMaterialProperties{ - material_ids, std::move(_liquid_density), std::move(_viscosity), - std::move(_gas_density), std::move(_gas_viscosity), - _intrinsic_permeability_models, std::move(_porosity_models), - std::move(_storage_models), std::move(_capillary_pressure_models), - std::move(_relative_permeability_models)}}; + return std::make_unique<TwoPhaseFlowWithPrhoMaterialProperties>( + material_ids, std::move(_liquid_density), std::move(_viscosity), + std::move(_gas_density), std::move(_gas_viscosity), + _intrinsic_permeability_models, std::move(_porosity_models), + std::move(_storage_models), std::move(_capillary_pressure_models), + std::move(_relative_permeability_models)); } } // end namespace diff --git a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp index 2e794cf91d4..3c3bb6a3016 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp +++ b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp @@ -103,11 +103,11 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPrhoProcess( specific_body_force, has_gravity, mass_lumping, diff_coeff_b, diff_coeff_a, temperature, std::move(material)}; - return std::unique_ptr<Process>{new TwoPhaseFlowWithPrhoProcess{ + return std::make_unique<TwoPhaseFlowWithPrhoProcess>( mesh, std::move(jacobian_assembler), parameters, integration_order, std::move(process_variables), std::move(process_data), std::move(secondary_variables), std::move(named_function_caller), - mat_config, curves}}; + mat_config, curves); } } // end of namespace diff --git a/ProcessLib/UncoupledProcessesTimeLoop.cpp b/ProcessLib/UncoupledProcessesTimeLoop.cpp index 7d17477193a..f5e1ab759dd 100644 --- a/ProcessLib/UncoupledProcessesTimeLoop.cpp +++ b/ProcessLib/UncoupledProcessesTimeLoop.cpp @@ -29,7 +29,8 @@ std::unique_ptr<NumLib::ITimeStepAlgorithm> createTimeStepper( { //! \ogs_file_param_special{prj__time_loop__time_stepping__SingleStep} config.ignoreConfigParameter("type"); - timestepper.reset(new NumLib::FixedTimeStepping(0.0, 1.0, 1.0)); + timestepper = + std::make_unique<NumLib::FixedTimeStepping>(0.0, 1.0, 1.0); } else if (type == "FixedTimeStepping") { @@ -205,9 +206,9 @@ void setTimeDiscretizedODESystem( // because the Newton ODESystem derives from the Picard ODESystem. // So no further checks are needed here. - spd.tdisc_ode_sys.reset( - new NumLib::TimeDiscretizedODESystem<ODETag, Tag::Picard>( - ode_sys, *spd.time_disc)); + spd.tdisc_ode_sys = std::make_unique< + NumLib::TimeDiscretizedODESystem<ODETag, Tag::Picard>>( + ode_sys, *spd.time_disc); } else if (dynamic_cast<NonlinearSolverNewton*>(&spd.nonlinear_solver)) { @@ -216,9 +217,9 @@ void setTimeDiscretizedODESystem( using ODENewton = NumLib::ODESystem<ODETag, Tag::Newton>; if (auto* ode_newton = dynamic_cast<ODENewton*>(&ode_sys)) { - spd.tdisc_ode_sys.reset( - new NumLib::TimeDiscretizedODESystem<ODETag, Tag::Newton>( - *ode_newton, *spd.time_disc)); + spd.tdisc_ode_sys = std::make_unique< + NumLib::TimeDiscretizedODESystem<ODETag, Tag::Newton>>( + *ode_newton, *spd.time_disc); } else { @@ -255,19 +256,19 @@ std::unique_ptr<SingleProcessData> makeSingleProcessData( dynamic_cast<NumLib::NonlinearSolver<Tag::Picard>*>( &nonlinear_solver)) { - return std::unique_ptr<SingleProcessData>{new SingleProcessData{ + return std::make_unique<SingleProcessData>( *nonlinear_solver_picard, std::move(conv_crit), std::move(time_disc), process, std::move(coupled_processes), - std::move(process_output)}}; + std::move(process_output)); } else if (auto* nonlinear_solver_newton = dynamic_cast<NumLib::NonlinearSolver<Tag::Newton>*>( &nonlinear_solver)) { - return std::unique_ptr<SingleProcessData>{new SingleProcessData{ + 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)}}; + std::move(process_output)); } else { @@ -383,11 +384,9 @@ std::unique_ptr<UncoupledProcessesTimeLoop> createUncoupledProcessesTimeLoop( //! \ogs_file_param{prj__time_loop__processes} config.getConfigSubtree("processes"), processes, nonlinear_solvers); - return std::unique_ptr<UncoupledProcessesTimeLoop>{ - new UncoupledProcessesTimeLoop{ - std::move(timestepper), std::move(output), - std::move(per_process_data), max_coupling_iterations, - std::move(coupling_conv_crit)}}; + return std::make_unique<UncoupledProcessesTimeLoop>( + std::move(timestepper), std::move(output), std::move(per_process_data), + max_coupling_iterations, std::move(coupling_conv_crit)); } std::vector<GlobalVector*> setInitialConditions( diff --git a/Tests/FileIO/TestGmlInterface.h b/Tests/FileIO/TestGmlInterface.h index 6dee87e12b0..20a22a35ff1 100644 --- a/Tests/FileIO/TestGmlInterface.h +++ b/Tests/FileIO/TestGmlInterface.h @@ -49,8 +49,7 @@ public: test_pnts.emplace_back(3,1,0,6); test_pnts.emplace_back(3,2,0,7); test_pnts.emplace_back(3,3,0,8); - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>(9)); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(9); std::unique_ptr<std::map<std::string, std::size_t>> cpy_name_id_map{ new std::map<std::string, std::size_t>}; @@ -112,10 +111,8 @@ public: auto const& pnt_vec = *(geo_objects.getPointVecObj(geo_name)); - auto lines = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>(5)); - auto name_map = std::unique_ptr<std::map<std::string, std::size_t>>{ - new std::map<std::string, std::size_t>}; + auto lines = std::make_unique<std::vector<GeoLib::Polyline*>>(5); + auto name_map = std::make_unique<std::map<std::string, std::size_t>>(); createPolyline(pnt_vec, *(lines.get()), 0, {0, 1, 2}, *name_map, "left"); createPolyline(pnt_vec, *(lines.get()), 1, {3, 4, 5}, *name_map, "center"); @@ -159,10 +156,8 @@ public: const std::vector<std::size_t> pnt_id_map( geo_objects.getPointVecObj(geo_name)->getIDMap()); - auto sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>(2)); - auto sfc_names = std::unique_ptr<std::map<std::string, std::size_t>>{ - new std::map<std::string, std::size_t>}; + auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>(2); + auto sfc_names = std::make_unique<std::map<std::string, std::size_t>>(); (*sfcs)[0] = new GeoLib::Surface(*points); (*sfcs)[0]->addTriangle(pnt_id_map[0], pnt_id_map[3], pnt_id_map[1]); (*sfcs)[0]->addTriangle(pnt_id_map[1], pnt_id_map[3], pnt_id_map[4]); diff --git a/Tests/GeoLib/AutoCheckGenerators.cpp b/Tests/GeoLib/AutoCheckGenerators.cpp index 216be9927d2..e23289f82f4 100644 --- a/Tests/GeoLib/AutoCheckGenerators.cpp +++ b/Tests/GeoLib/AutoCheckGenerators.cpp @@ -21,8 +21,8 @@ MathLib::Point3d reflect(MathLib::Point3d const& c, MathLib::Point3d const& p) GeoLib::LineSegment translate(MathLib::Vector3 const& translation, GeoLib::LineSegment const& line_seg) { - std::unique_ptr<GeoLib::Point> a{new GeoLib::Point{line_seg.getBeginPoint()}}; - std::unique_ptr<GeoLib::Point> b{new GeoLib::Point{line_seg.getEndPoint()}}; + auto a = std::make_unique<GeoLib::Point>(line_seg.getBeginPoint()); + auto b = std::make_unique<GeoLib::Point>(line_seg.getEndPoint()); for (std::size_t k(0); k<3; ++k) (*a)[k] += translation[k]; for (std::size_t k(0); k<3; ++k) diff --git a/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp b/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp index a2790dc9269..d7efb8c8b0a 100644 --- a/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp +++ b/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp @@ -26,8 +26,7 @@ TEST(GeoLib, TestComputeAndInsertAllIntersectionPoints) { // *** insert points in vector - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); pnts->push_back(new GeoLib::Point(0.0,0.0,0.0,0)); pnts->push_back(new GeoLib::Point(11.0,0.0,0.0,1)); diff --git a/Tests/GeoLib/TestDuplicateGeometry.cpp b/Tests/GeoLib/TestDuplicateGeometry.cpp index 752e598870a..6f80d4ceece 100644 --- a/Tests/GeoLib/TestDuplicateGeometry.cpp +++ b/Tests/GeoLib/TestDuplicateGeometry.cpp @@ -32,7 +32,7 @@ TEST(GeoLib, DuplicateGeometry) std::size_t n_pnts (rand() % 1000 + 100); int box_size (std::rand()); double half_box_size(box_size/2); - std::unique_ptr<std::vector<GeoLib::Point*>> pnts (new std::vector<GeoLib::Point*>); + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); pnts->reserve(n_pnts); for (int k(0); k<static_cast<int>(n_pnts); k++) { pnts->push_back(new GeoLib::Point( @@ -68,7 +68,7 @@ TEST(GeoLib, DuplicateGeometry) // add polylines std::size_t n_plys (rand() % 10 + 1); - std::unique_ptr<std::vector<GeoLib::Polyline*>> plys (new std::vector<GeoLib::Polyline*>); + auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>(); for (std::size_t i=0; i<n_plys; ++i) { int n_ply_pnts (rand() % 100 + 2); @@ -106,7 +106,7 @@ TEST(GeoLib, DuplicateGeometry) // add surfaces std::size_t n_sfcs (rand() % 10 + 1); - std::unique_ptr<std::vector<GeoLib::Surface*>> sfcs (new std::vector<GeoLib::Surface*>); + auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>(); for (std::size_t i=0; i<n_sfcs; ++i) { int n_tris (rand() % 10); diff --git a/Tests/GeoLib/TestGEOObjectsMerge.cpp b/Tests/GeoLib/TestGEOObjectsMerge.cpp index 0c9f201bbe3..28907cd420d 100644 --- a/Tests/GeoLib/TestGEOObjectsMerge.cpp +++ b/Tests/GeoLib/TestGEOObjectsMerge.cpp @@ -21,10 +21,8 @@ void createSetOfTestPointsAndAssociatedNames(GeoLib::GEOObjects & geo_objs, std::string &name, GeoLib::Point const& shift) { - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); - std::unique_ptr<std::map<std::string, std::size_t>> pnt_name_map{ - new std::map<std::string, std::size_t>}; + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); + auto pnt_name_map = std::make_unique<std::map<std::string, std::size_t>>(); const std::size_t pnts_per_edge(8); for (std::size_t k(0); k < pnts_per_edge; k++) { @@ -109,8 +107,7 @@ TEST(GeoLib, GEOObjectsMergePointsAndPolylines) std::vector<std::string> names; // *** insert points to vector - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); pnts->reserve(4); pnts->push_back(new GeoLib::Point(0.0,0.0,0.0)); pnts->push_back(new GeoLib::Point(1.0,0.0,0.0)); @@ -127,8 +124,7 @@ TEST(GeoLib, GEOObjectsMergePointsAndPolylines) ply->addPoint(2); ply->addPoint(3); ply->addPoint(0); - auto plys = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>(); plys->push_back(ply); geo_objs.addPolylineVec(std::move(plys), geometry_0, nullptr); names.push_back(geometry_0); @@ -155,8 +151,7 @@ TEST(GeoLib, GEOObjectsMergePolylinesWithNames) std::vector<std::string> names; // *** insert first set of points to vector (for first polyline) - auto pnts_0 = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto pnts_0 = std::make_unique<std::vector<GeoLib::Point*>>(); pnts_0->reserve(4); pnts_0->push_back(new GeoLib::Point(0.0,0.0,0.0)); pnts_0->push_back(new GeoLib::Point(1.0,0.0,0.0)); @@ -176,17 +171,14 @@ TEST(GeoLib, GEOObjectsMergePolylinesWithNames) ply_00->addPoint(2); ply_00->addPoint(3); ply_00->addPoint(0); - auto plys_0 = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto plys_0 = std::make_unique<std::vector<GeoLib::Polyline*>>(); plys_0->push_back(ply_00); - std::unique_ptr<std::map<std::string, std::size_t>> names_map_0{ - new std::map<std::string, std::size_t>}; + auto names_map_0 = std::make_unique<std::map<std::string, std::size_t>>(); names_map_0->insert(std::pair<std::string, std::size_t>("Polyline0FromGeometry0", 0)); geo_objs.addPolylineVec(std::move(plys_0), geometry_0, std::move(names_map_0)); names.push_back(geometry_0); - auto pnts_1 = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto pnts_1 = std::make_unique<std::vector<GeoLib::Point*>>(); pnts_1->reserve(4); pnts_1->push_back(new GeoLib::Point(0.0,0.0,0.0)); pnts_1->push_back(new GeoLib::Point(1.0,0.0,0.0)); @@ -206,12 +198,10 @@ TEST(GeoLib, GEOObjectsMergePolylinesWithNames) auto* ply_11(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_1))); ply_11->addPoint(2); ply_11->addPoint(3); - auto plys_1 = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto plys_1 = std::make_unique<std::vector<GeoLib::Polyline*>>(); plys_1->push_back(ply_10); plys_1->push_back(ply_11); - std::unique_ptr<std::map<std::string, std::size_t>> names_map_1{ - new std::map<std::string, std::size_t>}; + auto names_map_1 = std::make_unique<std::map<std::string, std::size_t>>(); names_map_1->insert(std::pair<std::string, std::size_t>("Polyline0FromGeometry1", 0)); names_map_1->insert(std::pair<std::string, std::size_t>("Polyline1FromGeometry1", 1)); geo_objs.addPolylineVec( diff --git a/Tests/GeoLib/TestPointVec.cpp b/Tests/GeoLib/TestPointVec.cpp index cf6792dcc15..462d7360e59 100644 --- a/Tests/GeoLib/TestPointVec.cpp +++ b/Tests/GeoLib/TestPointVec.cpp @@ -49,14 +49,14 @@ TEST_F(PointVecTest, TestPointVecCtorNullptr) // Testing empty input vector. TEST_F(PointVecTest, TestPointVecCtorEmpty) { - auto ps_ptr = std::unique_ptr<VectorOfPoints>(new VectorOfPoints); + auto ps_ptr = std::make_unique<VectorOfPoints>(); ASSERT_THROW(GeoLib::PointVec(name, std::move(ps_ptr)), std::runtime_error); } // Testing input vector with single point. TEST_F(PointVecTest, TestPointVecCtorSinglePoint) { - auto ps_ptr = std::unique_ptr<VectorOfPoints>(new VectorOfPoints); + auto ps_ptr = std::make_unique<VectorOfPoints>(); ps_ptr->push_back(new GeoLib::Point(0,0,0,0)); GeoLib::PointVec* point_vec = nullptr; point_vec = new GeoLib::PointVec(name, std::move(ps_ptr)); @@ -68,7 +68,7 @@ TEST_F(PointVecTest, TestPointVecCtorSinglePoint) // Testing input vector with two different points. TEST_F(PointVecTest, TestPointVecCtorTwoDiffPoints) { - auto ps_ptr = std::unique_ptr<VectorOfPoints>(new VectorOfPoints); + auto ps_ptr = std::make_unique<VectorOfPoints>(); ps_ptr->push_back(new GeoLib::Point(0,0,0,0)); ps_ptr->push_back(new GeoLib::Point(1,0,0,1)); @@ -82,7 +82,7 @@ TEST_F(PointVecTest, TestPointVecCtorTwoDiffPoints) // Testing input vector with two equal points. TEST_F(PointVecTest, TestPointVecCtorTwoEqualPoints) { - auto ps_ptr = std::unique_ptr<VectorOfPoints>(new VectorOfPoints); + auto ps_ptr = std::make_unique<VectorOfPoints>(); ps_ptr->push_back(new GeoLib::Point(0,0,0,0)); ps_ptr->push_back(new GeoLib::Point(0,0,0,1)); @@ -96,7 +96,7 @@ TEST_F(PointVecTest, TestPointVecCtorTwoEqualPoints) // Testing input vector with single point. TEST_F(PointVecTest, TestPointVecPushBack) { - auto ps_ptr = std::unique_ptr<VectorOfPoints>(new VectorOfPoints); + auto ps_ptr = std::make_unique<VectorOfPoints>(); ps_ptr->push_back(new GeoLib::Point(0,0,0,0)); ps_ptr->push_back(new GeoLib::Point(1,0,0,1)); ps_ptr->push_back(new GeoLib::Point(0,1,0,2)); @@ -185,7 +185,7 @@ TEST_F(PointVecTest, TestPointVecPushBack) // Testing random input points. TEST_F(PointVecTest, TestPointVecCtorRandomPoints) { - auto ps_ptr = std::unique_ptr<VectorOfPoints>(new VectorOfPoints); + auto ps_ptr = std::make_unique<VectorOfPoints>(); generateRandomPoints(*ps_ptr, 10000); GeoLib::PointVec* point_vec = nullptr; @@ -195,7 +195,7 @@ TEST_F(PointVecTest, TestPointVecCtorRandomPoints) } TEST_F(PointVecTest, TestPointVecCtorRandomPointsLargeEps) { - auto ps_ptr = std::unique_ptr<VectorOfPoints>(new VectorOfPoints); + auto ps_ptr = std::make_unique<VectorOfPoints>(); generateRandomPoints(*ps_ptr, 10000); GeoLib::PointVec* point_vec = nullptr; diff --git a/Tests/MeshGeoToolsLib/TestGeoMapper.cpp b/Tests/MeshGeoToolsLib/TestGeoMapper.cpp index 6098be1fb23..0ba1b2638f4 100644 --- a/Tests/MeshGeoToolsLib/TestGeoMapper.cpp +++ b/Tests/MeshGeoToolsLib/TestGeoMapper.cpp @@ -51,8 +51,7 @@ TEST_F(MeshGeoToolsLibGeoMapper, PointsOnSurfaceMesh) { GeoLib::GEOObjects geo_obj; std::string geo_name("TestGeoMapperPoints"); - auto points = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto points = std::make_unique<std::vector<GeoLib::Point*>>(); for (auto & p : pnts) { points->push_back(new GeoLib::Point(p)); } diff --git a/Tests/MeshLib/TestBoundaryElementSearch.cpp b/Tests/MeshLib/TestBoundaryElementSearch.cpp index f5077d4f674..eb48b5f6039 100644 --- a/Tests/MeshLib/TestBoundaryElementSearch.cpp +++ b/Tests/MeshLib/TestBoundaryElementSearch.cpp @@ -80,8 +80,7 @@ TEST_F(MeshLibBoundaryElementSearchInSimpleQuadMesh, PolylineSearch) // perform search on the polyline MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher( *_quad_mesh, - std::unique_ptr<MeshGeoToolsLib::HeuristicSearchLength>{ - new MeshGeoToolsLib::HeuristicSearchLength(*_quad_mesh)}, + std::make_unique<MeshGeoToolsLib::HeuristicSearchLength>(*_quad_mesh), MeshGeoToolsLib::SearchAllNodes::Yes); MeshGeoToolsLib::BoundaryElementsSearcher boundary_element_searcher(*_quad_mesh, mesh_node_searcher); std::vector<MeshLib::Element*> const& found_edges_ply0(boundary_element_searcher.getBoundaryElements(ply0)); @@ -151,8 +150,7 @@ TEST_F(MeshLibBoundaryElementSearchInSimpleHexMesh, SurfaceSearch) // perform search on the bottom surface MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher( *_hex_mesh, - std::unique_ptr<MeshGeoToolsLib::HeuristicSearchLength>{ - new MeshGeoToolsLib::HeuristicSearchLength(*_hex_mesh)}, + std::make_unique<MeshGeoToolsLib::HeuristicSearchLength>(*_hex_mesh), MeshGeoToolsLib::SearchAllNodes::Yes); MeshGeoToolsLib::BoundaryElementsSearcher boundary_element_searcher(*_hex_mesh, mesh_node_searcher); std::vector<MeshLib::Element*> const& found_faces_sfc_b(boundary_element_searcher.getBoundaryElements(*sfc_bottom)); diff --git a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp index 87be1d7fa3d..ac4cb3cf886 100644 --- a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp +++ b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp @@ -43,7 +43,7 @@ std::unique_ptr<MeshLib::Line> createLine(std::array<double, 3> const& a, auto** nodes = new MeshLib::Node*[e_nnodes]; nodes[0] = new MeshLib::Node(a); nodes[1] = new MeshLib::Node(b); - return std::unique_ptr<MeshLib::Line>{new MeshLib::Line(nodes)}; + return std::make_unique<MeshLib::Line>(nodes); } std::unique_ptr<MeshLib::Line> createY() @@ -85,7 +85,7 @@ std::unique_ptr<MeshLib::Quad> createQuad(std::array<double, 3> const& a, nodes[1] = new MeshLib::Node(b); nodes[2] = new MeshLib::Node(c); nodes[3] = new MeshLib::Node(d); - return std::unique_ptr<MeshLib::Quad>{new MeshLib::Quad(nodes)}; + return std::make_unique<MeshLib::Quad>(nodes); } // 2.5D case: inclined diff --git a/Tests/MeshLib/TestMeshNodeSearch.cpp b/Tests/MeshLib/TestMeshNodeSearch.cpp index 6bdd6166024..2beaddfdbcd 100644 --- a/Tests/MeshLib/TestMeshNodeSearch.cpp +++ b/Tests/MeshLib/TestMeshNodeSearch.cpp @@ -66,8 +66,8 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PointSearchEpsHalfEdge) ASSERT_TRUE(_quad_mesh != nullptr); // 2 perform search and compare results with expected vals - std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length{ - new MeshGeoToolsLib::SearchLength(dx_half)}; + auto search_length = + std::make_unique<MeshGeoToolsLib::SearchLength>(dx_half); MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); @@ -93,8 +93,7 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PointSearchZeroEps) // 1 create a geometry // 2 perform search and compare results with expected vals - std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length{ - new MeshGeoToolsLib::SearchLength}; + auto search_length = std::make_unique<MeshGeoToolsLib::SearchLength>(); MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); @@ -140,8 +139,8 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) ply0.addPoint(1); // perform search and compare results with expected vals - std::unique_ptr<MeshGeoToolsLib::HeuristicSearchLength> search_length{ - new MeshGeoToolsLib::HeuristicSearchLength(*_quad_mesh)}; + auto search_length = + std::make_unique<MeshGeoToolsLib::HeuristicSearchLength>(*_quad_mesh); MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); std::vector<std::size_t> const& found_ids_ply0(mesh_node_searcher.getMeshNodeIDsAlongPolyline(ply0)); @@ -223,8 +222,7 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, SurfaceSearch) pnts.push_back(new GeoLib::Point(_geometric_size, 0.5*_geometric_size, 0.0)); pnts.push_back(new GeoLib::Point(0.0, 0.5*_geometric_size, 0.0)); - std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length{ - new MeshGeoToolsLib::SearchLength}; + auto search_length = std::make_unique<MeshGeoToolsLib::SearchLength>(); MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_quad_mesh, std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); @@ -275,8 +273,7 @@ TEST_F(MeshLibMeshNodeSearchInSimpleHexMesh, SurfaceSearch) pnts.push_back(new GeoLib::Point(_geometric_size, _geometric_size, _geometric_size)); pnts.push_back(new GeoLib::Point(0.0, _geometric_size, _geometric_size)); - std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length{ - new MeshGeoToolsLib::SearchLength}; + auto search_length = std::make_unique<MeshGeoToolsLib::SearchLength>(); MeshGeoToolsLib::MeshNodeSearcher mesh_node_searcher(*_hex_mesh, std::move(search_length), MeshGeoToolsLib::SearchAllNodes::Yes); diff --git a/Tests/MeshLib/TestProjectMeshOnPlane.cpp b/Tests/MeshLib/TestProjectMeshOnPlane.cpp index a5858397b20..28e4e6dc9c4 100644 --- a/Tests/MeshLib/TestProjectMeshOnPlane.cpp +++ b/Tests/MeshLib/TestProjectMeshOnPlane.cpp @@ -36,7 +36,7 @@ public: for (std::size_t i=0; i<n_nodes-1; i++) elements.push_back(new MeshLib::Line(std::array<MeshLib::Node*,2>{{nodes[i], nodes[i+1]}})); - _mesh = std::unique_ptr<MeshLib::Mesh>{new MeshLib::Mesh{"TestMesh", nodes, elements}}; + _mesh = std::make_unique<MeshLib::Mesh>("TestMesh", nodes, elements); } protected: diff --git a/Tests/NumLib/LocalToGlobalIndexMap.cpp b/Tests/NumLib/LocalToGlobalIndexMap.cpp index a4d630081e2..aa0a332ef9b 100644 --- a/Tests/NumLib/LocalToGlobalIndexMap.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMap.cpp @@ -27,7 +27,8 @@ public: NumLibLocalToGlobalIndexMapTest() { mesh.reset(MeshLib::MeshGenerator::generateLineMesh(1.0, mesh_size)); - nodesSubset.reset(new MeshLib::MeshSubset(*mesh, &mesh->getNodes())); + nodesSubset = + std::make_unique<MeshLib::MeshSubset>(*mesh, &mesh->getNodes()); // Add two components both based on the same nodesSubset. components.emplace_back(nodesSubset.get()); @@ -57,8 +58,8 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_NumberOfRowsByComponent) // DOF-table. std::size_t components_size = components.size(); - dof_map.reset(new NumLib::LocalToGlobalIndexMap(std::move(components), - NumLib::ComponentOrder::BY_COMPONENT)); + dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(components), NumLib::ComponentOrder::BY_COMPONENT); // There must be as many rows as nodes in the input times the number of // components. @@ -75,8 +76,8 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_NumberOfRowsByLocation) // DOF-table. std::size_t components_size = components.size(); - dof_map.reset(new NumLib::LocalToGlobalIndexMap(std::move(components), - NumLib::ComponentOrder::BY_LOCATION)); + dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(components), NumLib::ComponentOrder::BY_LOCATION); // There must be as many rows as nodes in the input times the number of // components. @@ -89,8 +90,8 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, SubsetByComponent) TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_SubsetByComponent) #endif { - dof_map.reset(new NumLib::LocalToGlobalIndexMap(std::move(components), - NumLib::ComponentOrder::BY_COMPONENT)); + dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(components), NumLib::ComponentOrder::BY_COMPONENT); // Select some elements from the full mesh. std::array<std::size_t, 3> const ids = {{ 0, 5, 8 }}; @@ -127,10 +128,10 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon std::vector<unsigned> vec_var_n_components{1, 2}; - dof_map.reset(new NumLib::LocalToGlobalIndexMap( - std::move(components), - vec_var_n_components, - NumLib::ComponentOrder::BY_COMPONENT)); + dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(components), + vec_var_n_components, + NumLib::ComponentOrder::BY_COMPONENT); ASSERT_EQ(30, dof_map->dofSizeWithGhosts()); ASSERT_EQ(3u, dof_map->getNumberOfComponents()); @@ -156,10 +157,10 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon std::vector<unsigned> vec_var_n_components{2, 1}; - dof_map.reset(new NumLib::LocalToGlobalIndexMap( - std::move(components), - vec_var_n_components, - NumLib::ComponentOrder::BY_COMPONENT)); + dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(components), + vec_var_n_components, + NumLib::ComponentOrder::BY_COMPONENT); ASSERT_EQ(30, dof_map->dofSizeWithGhosts()); ASSERT_EQ(3u, dof_map->getNumberOfComponents()); @@ -185,7 +186,8 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon // - 1st variable with 2 components for all nodes, elements // - 2nd variable with 1 component for nodes of element id 1 std::vector<MeshLib::Node*> var2_nodes{const_cast<MeshLib::Node*>(mesh->getNode(1)), const_cast<MeshLib::Node*>(mesh->getNode(2))}; - std::unique_ptr<MeshLib::MeshSubset> var2_subset(new MeshLib::MeshSubset(*mesh, &var2_nodes)); + auto var2_subset = + std::make_unique<MeshLib::MeshSubset>(*mesh, &var2_nodes); components.emplace_back(var2_subset.get()); std::vector<unsigned> vec_var_n_components{2, 1}; @@ -194,11 +196,11 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon std::vector<MeshLib::Element*> var2_elements{const_cast<MeshLib::Element*>(mesh->getElement(1))}; vec_var_elements.push_back(&var2_elements); - dof_map.reset(new NumLib::LocalToGlobalIndexMap( - std::move(components), - vec_var_n_components, - vec_var_elements, - NumLib::ComponentOrder::BY_COMPONENT)); + dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(components), + vec_var_n_components, + vec_var_elements, + NumLib::ComponentOrder::BY_COMPONENT); ASSERT_EQ(22u, dof_map->dofSizeWithGhosts()); ASSERT_EQ(3u, dof_map->getNumberOfComponents()); @@ -237,7 +239,8 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon // - 1st variable with 2 components for all nodes, elements // - 2nd variable with 1 component for 1st node of element id 1 std::vector<MeshLib::Node*> var2_nodes{const_cast<MeshLib::Node*>(mesh->getNode(1))}; - std::unique_ptr<MeshLib::MeshSubset> var2_subset(new MeshLib::MeshSubset(*mesh, &var2_nodes)); + auto var2_subset = + std::make_unique<MeshLib::MeshSubset>(*mesh, &var2_nodes); components.emplace_back(var2_subset.get()); std::vector<unsigned> vec_var_n_components{2, 1}; @@ -246,11 +249,11 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon std::vector<MeshLib::Element*> var2_elements{const_cast<MeshLib::Element*>(mesh->getElement(1))}; vec_var_elements.push_back(&var2_elements); - dof_map.reset(new NumLib::LocalToGlobalIndexMap( - std::move(components), - vec_var_n_components, - vec_var_elements, - NumLib::ComponentOrder::BY_COMPONENT)); + dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(components), + vec_var_n_components, + vec_var_elements, + NumLib::ComponentOrder::BY_COMPONENT); ASSERT_EQ(21u, dof_map->dofSizeWithGhosts()); ASSERT_EQ(3u, dof_map->getNumberOfComponents()); diff --git a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp index 04fa8ed191d..0e82dc36724 100644 --- a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp @@ -34,10 +34,10 @@ public: NumLibLocalToGlobalIndexMapMultiDOFTest() { mesh.reset(MeL::MeshGenerator::generateRegularQuadMesh(2.0, mesh_subdivs)); - mesh_items_all_nodes.reset(new MeL::MeshSubset(*mesh, &mesh->getNodes())); + mesh_items_all_nodes = + std::make_unique<MeL::MeshSubset>(*mesh, &mesh->getNodes()); - std::unique_ptr<std::vector<GeoLib::Point*>> ply_pnts( - new std::vector<GeoLib::Point*>); + auto ply_pnts = std::make_unique<std::vector<GeoLib::Point*>>(); ply_pnts->push_back(new GeoLib::Point(0.0, 0.0, 0.0)); ply_pnts->push_back(new GeoLib::Point(1.0, 0.0, 0.0)); @@ -49,14 +49,12 @@ public: ply->addPoint(0); ply->addPoint(1); - std::unique_ptr<std::vector<GeoLib::Polyline*>> plys( - new std::vector<GeoLib::Polyline*>); + auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>(); plys->push_back(ply); geo_objs.addPolylineVec(std::move(plys), geometry_0, nullptr); - std::unique_ptr<MGTL::SearchLength> search_length{ - new MGTL::SearchLength}; + auto search_length = std::make_unique<MGTL::SearchLength>(); MGTL::MeshNodeSearcher const& searcher_nodes = MGTL::MeshNodeSearcher::getMeshNodeSearcher( *mesh, std::move(search_length)); @@ -93,8 +91,8 @@ public: components.emplace_back(mesh_items_all_nodes.get()); } std::vector<unsigned> vec_var_n_components(1, num_components); - dof_map.reset( - new NL::LocalToGlobalIndexMap(std::move(components), vec_var_n_components, order)); + dof_map = std::make_unique<NL::LocalToGlobalIndexMap>( + std::move(components), vec_var_n_components, order); MeL::MeshSubsets components_boundary{mesh_items_boundary.get()}; @@ -118,8 +116,8 @@ public: components.emplace_back(mesh_items_all_nodes.get()); } std::vector<unsigned> vec_var_n_components(1, num_components); - dof_map.reset(new NL::LocalToGlobalIndexMap( - std::move(components), vec_var_n_components, order)); + dof_map = std::make_unique<NL::LocalToGlobalIndexMap>( + std::move(components), vec_var_n_components, order); MeL::MeshSubsets components_boundary{mesh_items_boundary.get()}; diff --git a/Tests/NumLib/TestDistribution.cpp b/Tests/NumLib/TestDistribution.cpp index 055a16ac14a..f8456f8410c 100644 --- a/Tests/NumLib/TestDistribution.cpp +++ b/Tests/NumLib/TestDistribution.cpp @@ -36,21 +36,18 @@ public: _geometric_size, _number_of_subdivisions_per_direction)), _project_name("test"), _mshNodesSearcher(*_msh, - std::unique_ptr<MeshGeoToolsLib::SearchLength>{ - new MeshGeoToolsLib::SearchLength}, + std::make_unique<MeshGeoToolsLib::SearchLength>(), MeshGeoToolsLib::SearchAllNodes::Yes), _ply0(nullptr) { // create geometry - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); pnts->push_back(new GeoLib::Point(0.0, 0.0, 0.0)); pnts->push_back(new GeoLib::Point(_geometric_size, 0.0, 0.0)); pnts->push_back(new GeoLib::Point(_geometric_size, _geometric_size, 0.0)); pnts->push_back(new GeoLib::Point(0.0, _geometric_size, 0.0)); - auto plys = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>(); _ply0 = new GeoLib::Polyline(*pnts); _ply0->addPoint(0); _ply0->addPoint(1); @@ -64,8 +61,7 @@ public: ply1->addPoint(0); plys->push_back(ply1); - auto sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); + auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>(); _sfc1 = GeoLib::Surface::createSurface(*ply1); sfcs->push_back(_sfc1); @@ -95,14 +91,12 @@ public: _geometric_size, _number_of_subdivisions_per_direction)), _project_name("test"), _mshNodesSearcher(*_msh, - std::unique_ptr<MeshGeoToolsLib::SearchLength>{ - new MeshGeoToolsLib::SearchLength}, + std::make_unique<MeshGeoToolsLib::SearchLength>(), MeshGeoToolsLib::SearchAllNodes::Yes), _ply0(nullptr) { // create geometry - auto pnts = std::unique_ptr<std::vector<GeoLib::Point*>>( - new std::vector<GeoLib::Point*>); + auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); pnts->push_back(new GeoLib::Point(0.0, 0.0, 0.0)); pnts->push_back(new GeoLib::Point(_geometric_size, 0.0, 0.0)); pnts->push_back(new GeoLib::Point(_geometric_size, _geometric_size, 0.0)); @@ -112,8 +106,7 @@ public: pnts->push_back(new GeoLib::Point(_geometric_size, _geometric_size, _geometric_size)); pnts->push_back(new GeoLib::Point(0.0, _geometric_size, _geometric_size)); - auto plys = std::unique_ptr<std::vector<GeoLib::Polyline*>>( - new std::vector<GeoLib::Polyline*>); + auto plys = std::make_unique<std::vector<GeoLib::Polyline*>>(); _ply0 = new GeoLib::Polyline(*pnts); // vertical polyline _ply0->addPoint(0); _ply0->addPoint(4); @@ -126,8 +119,7 @@ public: ply1->addPoint(0); plys->push_back(ply1); - auto sfcs = std::unique_ptr<std::vector<GeoLib::Surface*>>( - new std::vector<GeoLib::Surface*>); + auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>(); _sfc1 = GeoLib::Surface::createSurface(*ply1); sfcs->push_back(_sfc1); diff --git a/Tests/NumLib/TestExtrapolation.cpp b/Tests/NumLib/TestExtrapolation.cpp index a85b1abdb3f..a17d23fa0e2 100644 --- a/Tests/NumLib/TestExtrapolation.cpp +++ b/Tests/NumLib/TestExtrapolation.cpp @@ -138,12 +138,13 @@ public: std::vector<MeshLib::MeshSubsets> all_mesh_subsets; all_mesh_subsets.emplace_back(&_mesh_subset_all_nodes); - _dof_table.reset(new NumLib::LocalToGlobalIndexMap( - std::move(all_mesh_subsets), NumLib::ComponentOrder::BY_COMPONENT)); + _dof_table = std::make_unique<NumLib::LocalToGlobalIndexMap>( + std::move(all_mesh_subsets), NumLib::ComponentOrder::BY_COMPONENT); // Passing _dof_table works, because this process has only one variable // and the variable has exactly one component. - _extrapolator.reset(new ExtrapolatorImplementation(*_dof_table)); + _extrapolator = + std::make_unique<ExtrapolatorImplementation>(*_dof_table); // createAssemblers(mesh); ProcessLib::createLocalAssemblers<LocalAssemblerData>( diff --git a/Tests/NumLib/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp index 38497469315..4310d954edc 100644 --- a/Tests/NumLib/TestODEInt.cpp +++ b/Tests/NumLib/TestODEInt.cpp @@ -28,8 +28,7 @@ std::unique_ptr<GlobalLinearSolver> createLinearSolver() { - return std::unique_ptr<GlobalLinearSolver>{ - new GlobalLinearSolver{"", nullptr}}; + return std::make_unique<GlobalLinearSolver>("", nullptr); } #else std::unique_ptr<GlobalLinearSolver> @@ -42,8 +41,7 @@ createLinearSolver() auto const ptree = readXml(xml); BaseLib::ConfigTree config(ptree, "", BaseLib::ConfigTree::onerror, BaseLib::ConfigTree::onwarning); - return std::unique_ptr<GlobalLinearSolver>{ - new GlobalLinearSolver{"", &config}}; + return std::make_unique<GlobalLinearSolver>("", &config); } #endif @@ -73,11 +71,10 @@ public: ode_sys(ode, timeDisc); auto linear_solver = createLinearSolver(); - auto conv_crit = std::unique_ptr<NumLib::ConvergenceCriterion>( - new NumLib::ConvergenceCriterionDeltaX( - _tol, boost::none, MathLib::VecNormType::NORM2)); - std::unique_ptr<NLSolver> nonlinear_solver( - new NLSolver(*linear_solver, _maxiter)); + auto conv_crit = std::make_unique<NumLib::ConvergenceCriterionDeltaX>( + _tol, boost::none, MathLib::VecNormType::NORM2); + auto nonlinear_solver = + std::make_unique<NLSolver>(*linear_solver, _maxiter); NumLib::TimeLoopSingleODE<NLTag> loop(ode_sys, std::move(linear_solver), std::move(nonlinear_solver), diff --git a/Tests/NumLib/TestSparsityPattern.cpp b/Tests/NumLib/TestSparsityPattern.cpp index d03224107d3..673554b1517 100644 --- a/Tests/NumLib/TestSparsityPattern.cpp +++ b/Tests/NumLib/TestSparsityPattern.cpp @@ -26,8 +26,8 @@ TEST(NumLib_SparsityPattern, DISABLED_SingleComponentLinearMesh) { std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::MeshGenerator::generateLineMesh(3u, 1.)); - std::unique_ptr<MeshLib::MeshSubset const> nodesSubset( - new MeshLib::MeshSubset(*mesh, &mesh->getNodes())); + auto nodesSubset = + std::make_unique<MeshLib::MeshSubset const>(*mesh, &mesh->getNodes()); std::vector<MeshLib::MeshSubsets> components; components.emplace_back(nodesSubset.get()); @@ -55,8 +55,8 @@ TEST(NumLib_SparsityPattern, DISABLED_SingleComponentQuadraticMesh) MeshLib::MeshGenerator::generateLineMesh(3u, 1.)); std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::createQuadraticOrderMesh(*linear_mesh)); - std::unique_ptr<MeshLib::MeshSubset const> nodesSubset( - new MeshLib::MeshSubset(*mesh, &mesh->getNodes())); + auto nodesSubset = + std::make_unique<MeshLib::MeshSubset const>(*mesh, &mesh->getNodes()); std::vector<MeshLib::MeshSubsets> components; components.emplace_back(nodesSubset.get()); @@ -85,8 +85,8 @@ TEST(NumLib_SparsityPattern, DISABLED_MultipleComponentsLinearMesh) { std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::MeshGenerator::generateLineMesh(3u, 1.)); - std::unique_ptr<MeshLib::MeshSubset const> nodesSubset( - new MeshLib::MeshSubset(*mesh, &mesh->getNodes())); + auto nodesSubset = + std::make_unique<MeshLib::MeshSubset const>(*mesh, &mesh->getNodes()); std::vector<MeshLib::MeshSubsets> components; components.emplace_back(nodesSubset.get()); @@ -119,10 +119,10 @@ TEST(NumLib_SparsityPattern, DISABLED_MultipleComponentsLinearQuadraticMesh) std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::createQuadraticOrderMesh(*linear_mesh)); auto base_nodes = MeshLib::getBaseNodes(mesh->getElements()); - std::unique_ptr<MeshLib::MeshSubset const> baseNodesSubset( - new MeshLib::MeshSubset(*mesh, &base_nodes)); - std::unique_ptr<MeshLib::MeshSubset const> allNodesSubset( - new MeshLib::MeshSubset(*mesh, &mesh->getNodes())); + auto baseNodesSubset = + std::make_unique<MeshLib::MeshSubset const>(*mesh, &base_nodes); + auto allNodesSubset = + std::make_unique<MeshLib::MeshSubset const>(*mesh, &mesh->getNodes()); std::vector<MeshLib::MeshSubsets> components; components.emplace_back(baseNodesSubset.get()); diff --git a/Tests/ProcessLib/TestLIE.cpp b/Tests/ProcessLib/TestLIE.cpp index d9fb7f36dcc..0442512d104 100644 --- a/Tests/ProcessLib/TestLIE.cpp +++ b/Tests/ProcessLib/TestLIE.cpp @@ -31,9 +31,9 @@ std::unique_ptr<MeshLib::Mesh> createTriangle( nodes[i] = new MeshLib::Node(points[i]); MeshLib::Element* e = new MeshLib::Tri(nodes); - return std::unique_ptr<MeshLib::Mesh>(new MeshLib::Mesh( + return std::make_unique<MeshLib::Mesh>( "", std::vector<MeshLib::Node*>{nodes[0], nodes[1], nodes[2]}, - std::vector<MeshLib::Element*>{e})); + std::vector<MeshLib::Element*>{e}); } std::unique_ptr<MeshLib::Mesh> createLine( @@ -44,9 +44,9 @@ std::unique_ptr<MeshLib::Mesh> createLine( nodes[i] = new MeshLib::Node(points[i]); MeshLib::Element* e = new MeshLib::Line(nodes); - return std::unique_ptr<MeshLib::Mesh>( - new MeshLib::Mesh("", std::vector<MeshLib::Node*>{nodes[0], nodes[1]}, - std::vector<MeshLib::Element*>{e})); + return std::make_unique<MeshLib::Mesh>( + "", std::vector<MeshLib::Node*>{nodes[0], nodes[1]}, + std::vector<MeshLib::Element*>{e}); } const double eps = std::numeric_limits<double>::epsilon(); diff --git a/Tests/testrunner.cpp b/Tests/testrunner.cpp index 8dc979c70f7..9c929641468 100644 --- a/Tests/testrunner.cpp +++ b/Tests/testrunner.cpp @@ -57,10 +57,10 @@ int main(int argc, char* argv[]) ApplicationsLib::LinearSolverLibrarySetup linear_solver_library_setup( argc, argv); - logog_setup.setFormatter(std::unique_ptr<BaseLib::TemplateLogogFormatterSuppressedGCC - <TOPIC_LEVEL_FLAG | TOPIC_FILE_NAME_FLAG | TOPIC_LINE_NUMBER_FLAG> > - (new BaseLib::TemplateLogogFormatterSuppressedGCC - <TOPIC_LEVEL_FLAG | TOPIC_FILE_NAME_FLAG | TOPIC_LINE_NUMBER_FLAG>())); + logog_setup.setFormatter( + std::make_unique<BaseLib::TemplateLogogFormatterSuppressedGCC< + TOPIC_LEVEL_FLAG | TOPIC_FILE_NAME_FLAG | + TOPIC_LINE_NUMBER_FLAG>>()); logog_setup.setLevel(logLevel); try -- GitLab