diff --git a/src/kiva/CMakeLists.txt b/src/kiva/CMakeLists.txt index 331f346d..45267cc9 100644 --- a/src/kiva/CMakeLists.txt +++ b/src/kiva/CMakeLists.txt @@ -16,6 +16,17 @@ target_link_libraries(kiva libkiva groundplot boost_program_options yaml-cpp) target_include_directories(kiva PRIVATE "${groundplot_SOURCE_DIR}") +set(kiva_suppress_warnings Main.cpp + Input.cpp + InputParser.cpp + Simulator.cpp) + +target_compile_options(kiva PRIVATE + $<$:/W4 /WX> + $<$,$,$>: + -Wall -Wextra -Wpedantic -Werror> +) + if (KIVA_COVERAGE) add_coverage(kiva) endif() diff --git a/src/kiva/Simulator.cpp b/src/kiva/Simulator.cpp index 2b59035d..e072af01 100644 --- a/src/kiva/Simulator.cpp +++ b/src/kiva/Simulator.cpp @@ -113,7 +113,7 @@ void Simulator::initializeConditions() { for (boost::posix_time::ptime t = tAccelStart; t <= tAccelEnd; t += accelTimestep) { updateBoundaryConditions(t); - ground.calculate(bcs, accelTimestep.total_seconds()); + ground.calculate(bcs, static_cast(accelTimestep.total_seconds())); printStatus(t); } @@ -130,7 +130,7 @@ void Simulator::initializeConditions() { for (boost::posix_time::ptime t = tWarmupStart; t <= tWarmupEnd; t += simulationTimestep) { updateBoundaryConditions(t); - ground.calculate(bcs, simulationTimestep.total_seconds()); + ground.calculate(bcs, static_cast(accelTimestep.total_seconds())); printStatus(t); } } @@ -224,9 +224,9 @@ void Simulator::initializePlots() { boost::posix_time::ptime endTime(input.output.outputSnapshots[p].endDate + boost::gregorian::days(1)); - plots[p].tStart = (startTime - input.simulationControl.startTime).total_seconds(); - plots[p].nextPlotTime = (startTime - input.simulationControl.startTime).total_seconds(); - plots[p].tEnd = (endTime - input.simulationControl.startTime).total_seconds(); + plots[p].tStart = static_cast((startTime - input.simulationControl.startTime).total_seconds()); + plots[p].nextPlotTime = static_cast((startTime - input.simulationControl.startTime).total_seconds()); + plots[p].tEnd = static_cast((endTime - input.simulationControl.startTime).total_seconds()); } } @@ -238,7 +238,7 @@ void Simulator::simulate() { boost::posix_time::time_duration simDuration = simEnd - simStart; prevOutputTime = input.simulationControl.startTime - input.output.outputReport.minFrequency; - double timestep = input.simulationControl.timestep.total_seconds(); + double timestep = static_cast(input.simulationControl.timestep.total_seconds()); for (boost::posix_time::ptime t = simStart; t < simEnd; t = t + input.simulationControl.timestep) { @@ -264,7 +264,7 @@ void Simulator::simulate() { void Simulator::plot(boost::posix_time::ptime t) { for (std::size_t p = 0; p < plots.size(); p++) { - if (plots[p].makeNewFrame((t - input.simulationControl.startTime).total_seconds())) { + if (plots[p].makeNewFrame(static_cast((t - input.simulationControl.startTime).total_seconds()))) { std::string timeStamp = to_simple_string(t); std::size_t nI = plots[p].iMax - plots[p].iMin + 1; @@ -370,7 +370,7 @@ double Simulator::getInitialTemperature(boost::posix_time::ptime t, double z) { boost::gregorian::date dayBegin(year, boost::gregorian::Jan, 1); boost::posix_time::ptime tYearStart(dayBegin); boost::posix_time::time_duration tSinceYearStart = t - tYearStart; - double trel = tSinceYearStart.total_seconds(); + double trel = static_cast(tSinceYearStart.total_seconds()); double tshift = weatherData.hourOfMinimumTemperature * 60.0 * 60.0; double seconds_in_day = 60.0 * 60.0 * 24.0; double Tamp = (weatherData.maximumAverageMontlyTemperature - diff --git a/src/libgroundplot/CMakeLists.txt b/src/libgroundplot/CMakeLists.txt index f3891492..c5a9995d 100644 --- a/src/libgroundplot/CMakeLists.txt +++ b/src/libgroundplot/CMakeLists.txt @@ -1,14 +1,20 @@ project(groundplot) -set(kiva_src GroundPlot.cpp - GroundPlot.hpp ) +set(groundplot_src GroundPlot.cpp + GroundPlot.hpp ) -add_library(groundplot STATIC ${kiva_src}) +add_library(groundplot STATIC ${groundplot_src}) target_link_libraries(groundplot fmt mgl-static libkiva) target_include_directories(groundplot PUBLIC "${MathGL2_SOURCE_DIR}/include" "${MathGL2_BINARY_DIR}/include") +target_compile_options(groundplot PRIVATE + $<$:/W4 /WX> + $<$,$,$>: + -Wall -Wextra -Wpedantic -Werror> + ) + if (KIVA_COVERAGE) add_coverage(groundplot) endif() diff --git a/src/libgroundplot/GroundPlot.cpp b/src/libgroundplot/GroundPlot.cpp index 7af1df37..29cbf4f4 100644 --- a/src/libgroundplot/GroundPlot.cpp +++ b/src/libgroundplot/GroundPlot.cpp @@ -154,21 +154,22 @@ GroundPlot::GroundPlot(SnapshotSettings &snapshotSettings, Domain &domain, Found } if (sliceType == Z_1D) { - mglData hDatRef(vAxis.nN), hGridRef(vAxis.nN + 1), TDatRef(vAxis.nN), TGridRef(vAxis.nN + 1); + mglData hDatRef(static_cast(vAxis.nN)), hGridRef(static_cast(vAxis.nN + 1)), TDatRef(static_cast(vAxis.nN)), TGridRef(static_cast(vAxis.nN + 1)); TDat = TDatRef; TGrid = TGridRef; hDat = hDatRef; hGrid = hGridRef; } else { - mglData hDatRef(hAxis.nN), hGridRef(hAxis.nN + 1), TDatRef(hAxis.nN, vAxis.nN), - TGridRef(hAxis.nN + 1, vAxis.nN + 1); + mglData hDatRef(static_cast(hAxis.nN)), hGridRef(static_cast(hAxis.nN + 1)), TDatRef(static_cast(hAxis.nN), static_cast(vAxis.nN)), + TGridRef(static_cast(hAxis.nN + 1), static_cast(vAxis.nN + 1)); TDat = TDatRef; TGrid = TGridRef; hDat = hDatRef; hGrid = hGridRef; } - mglData vDatRef(vAxis.nN), vGridRef(vAxis.nN + 1), cDatRef(contourLevels); + mglData vDatRef(static_cast(vAxis.nN)), vGridRef(static_cast(vAxis.nN + 1)), + cDatRef(static_cast(contourLevels)); vDat = vDatRef; vGrid = vGridRef; @@ -250,7 +251,7 @@ void GroundPlot::createFrame(std::string timeStamp) { gr.Clf(1, 1, 1); double aspect = 1.0; int height = snapshotSettings.size; - int width = height * aspect; + int width = height * static_cast(aspect); gr.SetSize(width, height); diff --git a/src/libgroundplot/GroundPlot.hpp b/src/libgroundplot/GroundPlot.hpp index 1a37be8e..3ab24c71 100644 --- a/src/libgroundplot/GroundPlot.hpp +++ b/src/libgroundplot/GroundPlot.hpp @@ -4,7 +4,20 @@ #ifndef GROUNDPLOT_H_ #define GROUNDPLOT_H_ +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4068) // Unknown pragma +#pragma warning(disable : 4458) // Declaration hides class member +#elif defined(__gnu_linux__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmisleading-indentation" +#endif #include +#if defined(_MSC_VER) +#pragma warning(pop) +#elif defined(__gnu_linux__) +#pragma GCC diagnostic pop +#endif #include "../libkiva/Domain.hpp" #include "../libkiva/Foundation.hpp" diff --git a/src/libkiva/Aggregator.cpp b/src/libkiva/Aggregator.cpp index c4796be7..279e0e8d 100644 --- a/src/libkiva/Aggregator.cpp +++ b/src/libkiva/Aggregator.cpp @@ -61,7 +61,7 @@ void Aggregator::calc_weighted_results() { validate(); } results.reset(); - double Tz, Tr; + double Tz{293.15}, Tr{293.15}; for (auto &instance : instances) { Ground *grnd = instance.first; Tz = surface_type == Surface::ST_WALL_INT ? grnd->bcs.wallConvectiveTemp diff --git a/src/libkiva/CMakeLists.txt b/src/libkiva/CMakeLists.txt index 866b7ae0..2240b2d4 100644 --- a/src/libkiva/CMakeLists.txt +++ b/src/libkiva/CMakeLists.txt @@ -127,7 +127,7 @@ configure_file ( "${PROJECT_BINARY_DIR}/Version.hpp" ) -set(kiva_src Aggregator.cpp +set(libkiva_src Aggregator.cpp Aggregator.hpp Algorithms.cpp Algorithms.hpp @@ -155,20 +155,15 @@ set(kiva_src Aggregator.cpp option( KIVA_STATIC_LIB "Make libkiva a static library" ON ) -if (MSVC) - # Remove "potential loss of data" warning in Boost - set_source_files_properties(Geometry.cpp PROPERTIES COMPILE_FLAGS /wd4244) -endif() - if (KIVA_STATIC_LIB) - add_library(libkiva STATIC ${kiva_src}) + add_library(libkiva STATIC ${libkiva_src}) target_compile_definitions(libkiva PRIVATE LIBKIVA_STATIC_DEFINE) if(UNIX) target_compile_options(libkiva PUBLIC -fPIC) endif() else() set(CMAKE_MACOSX_RPATH 1) - add_library(libkiva SHARED ${kiva_src}) + add_library(libkiva SHARED ${libkiva_src}) if(KIVA_EXE_BUILD) install(TARGETS libkiva DESTINATION bin/) endif() @@ -184,6 +179,11 @@ target_include_directories(libkiva PUBLIC "${BOOST_SOURCE_DIR}" "${kiva_SOURCE_DIR}/vendor/eigen") +target_compile_options(libkiva PRIVATE + $<$:/W4 /WX> + $<$,$,$>: + -Wall -Wextra -Wpedantic -Werror> +) target_compile_features(libkiva PUBLIC cxx_std_17) # Should be PRIVATE once boost is cleaned out of public API include(GenerateExportHeader) diff --git a/src/libkiva/Foundation.cpp b/src/libkiva/Foundation.cpp index ed8dd4bb..866bf3ec 100644 --- a/src/libkiva/Foundation.cpp +++ b/src/libkiva/Foundation.cpp @@ -8,12 +8,12 @@ namespace Kiva { static const double PI = 4.0 * atan(1.0); -Material::Material() {} +Material::Material() : conductivity{0}, density{0}, specificHeat{0} {} Material::Material(double k, double rho, double cp) : conductivity(k), density(rho), specificHeat(cp) {} -InputBlock::InputBlock() : x(0.0), z(0.0), width(0.0), depth(0.0) {} +InputBlock::InputBlock() : x(0.0), z(0.0), width(0.0), depth(0.0), box(Point(0, 0), Point(0, 0)) {} double Wall::totalWidth() { double width = 0.0; @@ -100,13 +100,16 @@ bool Ranges::isType(double position, RangeType::Type type) { Foundation::Foundation() : deepGroundDepth(40.0), farFieldWidth(40.0), foundationDepth(0.0), orientation(0.0), - deepGroundBoundary(DGB_ZERO_FLUX), wallTopBoundary(WTB_ZERO_FLUX), + deepGroundBoundary(DGB_ZERO_FLUX), wallTopInteriorTemperature{0}, + wallTopExteriorTemperature{0}, wallTopBoundary(WTB_ZERO_FLUX), soil(Material(1.73, 1842, 419)), grade(SurfaceProperties(0.9, 0.9, 0.03)), coordinateSystem(CS_CARTESIAN), numberOfDimensions(2), useSymmetry(true), - reductionStrategy(RS_BOUNDARY), exposedFraction(1.0), useDetailedExposedPerimeter(false), - buildingHeight(0.0), hasWall(true), hasSlab(true), perimeterSurfaceWidth(0.0), - hasPerimeterSurface(false), mesh(Mesh()), numericalScheme(NS_ADI), fADI(0.00001), - tolerance(1.0e-6), maxIterations(100000) {} + reductionStrategy(RS_BOUNDARY), twoParameters{false}, reductionLength1{0}, + reductionLength2{0}, linearAreaMultiplier{0}, isXSymm{false}, isYSymm{false}, + exposedFraction(1.0), useDetailedExposedPerimeter(false), buildingHeight(0.0), hasWall(true), + hasSlab(true), perimeterSurfaceWidth(0.0), hasPerimeterSurface(false), mesh(Mesh()), + numericalScheme(NS_ADI), fADI(0.00001), tolerance(1.0e-6), + maxIterations(100000), netArea{0}, netPerimeter{0} {} void Foundation::createMeshData() { std::size_t nV = polygon.outer().size(); @@ -1088,34 +1091,37 @@ void Foundation::createMeshData() { if (wallTopBoundary == WTB_LINEAR_DT) { // Wall Top if (hasWall) { - double position = 0.0; - double &Tin = wallTopInteriorTemperature; - double &Tout = wallTopExteriorTemperature; - double Tdiff = (Tin - Tout); - std::size_t N = - (std::size_t)((xyWallTopExterior - xyWallTopInterior + DBL_EPSILON) / mesh.minCellDim); - double temperature = Tin - (1.0 / N) / 2 * Tdiff; + { + double position = 0.0; + double &Tin = wallTopInteriorTemperature; + double &Tout = wallTopExteriorTemperature; + double Tdiff = (Tin - Tout); + std::size_t N = (std::size_t)((xyWallTopExterior - xyWallTopInterior + DBL_EPSILON) / + mesh.minCellDim); + double temperature = Tin - (1.0 / N) / 2 * Tdiff; - for (std::size_t n = 1; n <= N; n++) { - Surface surface; - surface.type = Surface::ST_WALL_TOP; - surface.xMin = xRef2 + position; - surface.xMax = xRef2 + position + (xyWallTopExterior - xyWallTopInterior) / N; - surface.yMin = 0.0; - surface.yMax = 1.0; - surface.setSquarePolygon(); - surface.zMin = zMax; - surface.zMax = zMax; - surface.boundaryConditionType = Surface::CONSTANT_TEMPERATURE; - surface.orientation = Surface::Z_POS; - surface.temperature = temperature; - surfaces.push_back(surface); + for (std::size_t n = 1; n <= N; n++) { + Surface surface; + surface.type = Surface::ST_WALL_TOP; + surface.xMin = xRef2 + position; + surface.xMax = xRef2 + position + (xyWallTopExterior - xyWallTopInterior) / N; + surface.yMin = 0.0; + surface.yMax = 1.0; + surface.setSquarePolygon(); + surface.zMin = zMax; + surface.zMax = zMax; + surface.boundaryConditionType = Surface::CONSTANT_TEMPERATURE; + surface.orientation = Surface::Z_POS; + surface.temperature = temperature; + surfaces.push_back(surface); - position += (xyWallTopExterior - xyWallTopInterior) / N; - temperature -= (1.0 / N) * Tdiff; + position += (xyWallTopExterior - xyWallTopInterior) / N; + temperature -= (1.0 / N) * Tdiff; + } } if (twoParameters) { + double position = 0.0; double &Tin = wallTopInteriorTemperature; double &Tout = wallTopExteriorTemperature; double Tdiff = (Tin - Tout); @@ -1298,7 +1304,7 @@ void Foundation::createMeshData() { double xPosition = xRef2; // Foundation Wall - for (std::size_t n = wall.layers.size() - 1; n < wall.layers.size() /* && n >= 0 */; n--) { + for (int n = static_cast(wall.layers.size()) - 1; n >= 0; n--) { Block block; block.material = wall.layers[n].material; block.blockType = Block::SOLID; @@ -1318,7 +1324,7 @@ void Foundation::createMeshData() { double xPosition = xRef1; // Foundation Wall - for (std::size_t n = wall.layers.size() - 1; n < wall.layers.size() /* && n >= 0 */; n--) { + for (int n = static_cast(wall.layers.size()) - 1; n >= 0; n--) { Block block; block.material = wall.layers[n].material; block.blockType = Block::SOLID; @@ -1337,17 +1343,19 @@ void Foundation::createMeshData() { // General blocks for (auto &b : inputBlocks) { - Block block; - block.material = b.material; - block.blockType = Block::SOLID; - block.xMin = xRef2 + b.box.min_corner().get<0>(); - block.xMax = xRef2 + b.box.max_corner().get<0>(); - block.yMin = 0.0; - block.yMax = 1.0; - block.setSquarePolygon(); - block.zMin = b.box.min_corner().get<1>(); - block.zMax = b.box.max_corner().get<1>(); - blocks.push_back(block); + { + Block block; + block.material = b.material; + block.blockType = Block::SOLID; + block.xMin = xRef2 + b.box.min_corner().get<0>(); + block.xMax = xRef2 + b.box.max_corner().get<0>(); + block.yMin = 0.0; + block.yMax = 1.0; + block.setSquarePolygon(); + block.zMin = b.box.min_corner().get<1>(); + block.zMax = b.box.max_corner().get<1>(); + blocks.push_back(block); + } if (twoParameters) { Block block; @@ -1419,14 +1427,6 @@ void Foundation::createMeshData() { } else if (numberOfDimensions == 3 && !useSymmetry) { #if defined(KIVA_3D) // TODO 3D - Box boundingBox; - boost::geometry::envelope(polygon, boundingBox); - - double xMinBB = boundingBox.min_corner().get<0>(); - double yMinBB = boundingBox.min_corner().get<1>(); - - double xMaxBB = boundingBox.max_corner().get<0>(); - double yMaxBB = boundingBox.max_corner().get<1>(); xMin = xMinBB - farFieldWidth; yMin = yMinBB - farFieldWidth; @@ -1830,7 +1830,7 @@ void Foundation::createMeshData() { double xyPosition = 0.0; // Foundation Wall - for (std::size_t n = wall.layers.size() - 1; n < wall.layers.size() /*>= 0*/; n--) { + for (int n = static_cast(wall.layers.size() - 1); n >= 0; n--) { Polygon poly; poly = offset(polygon, xyPosition + wall.layers[n].thickness); @@ -2042,15 +2042,6 @@ void Foundation::createMeshData() { nV = symmetricPoly.outer().size(); - Box boundingBox; - boost::geometry::envelope(symmetricPoly, boundingBox); - - double xMinBB = boundingBox.min_corner().get<0>(); - double yMinBB = boundingBox.min_corner().get<1>(); - - double xMaxBB = boundingBox.max_corner().get<0>(); - double yMaxBB = boundingBox.max_corner().get<1>(); - if (isXSymm) xMin = xMinBB; else @@ -2409,7 +2400,7 @@ void Foundation::createMeshData() { double xyPosition = 0.0; // Foundation Wall - for (std::size_t n = wall.layers.size() - 1; n < wall.layers.size() /*>= 0*/; n--) { + for (int n = static_cast(wall.layers.size() - 1); n >= 0; n--) { Polygon tempPoly; tempPoly = offset(polygon, xyPosition + wall.layers[n].thickness); diff --git a/src/libkiva/Geometry.hpp b/src/libkiva/Geometry.hpp index 472fc5a5..1717108a 100644 --- a/src/libkiva/Geometry.hpp +++ b/src/libkiva/Geometry.hpp @@ -4,10 +4,32 @@ #ifndef GEOMETRY_H_ #define GEOMETRY_H_ +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4100) // Unreferenced formal parameter +#pragma warning(disable : 4127) // Conditional expression is constant +#pragma warning(disable : 4244) // Possible loss of data from conversion +#pragma warning(disable : 4702) // Unreachable code +#elif defined(__APPLE__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" +#elif defined(__gnu_linux__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif #include #include #include #include +#if defined(_MSC_VER) +#pragma warning(pop) +#elif defined(__APPLE__) +#pragma clang diagnostic pop +#elif defined(__gnu_linux__) +#pragma GCC diagnostic pop +#endif + #include "Functions.hpp" #include "libkiva_export.h" diff --git a/src/libkiva/Ground.cpp b/src/libkiva/Ground.cpp index 14a6f630..1eacde75 100644 --- a/src/libkiva/Ground.cpp +++ b/src/libkiva/Ground.cpp @@ -72,11 +72,17 @@ void Ground::buildDomain() { void Ground::calculateADE() { // Solve for new values (Main loop) +#if defined(_OPENMP) #pragma omp parallel sections num_threads(2) +#endif { +#if defined(_OPENMP) #pragma omp section +#endif calculateADEUpwardSweep(); +#if defined(_OPENMP) #pragma omp section +#endif calculateADEDownwardSweep(); } for (size_t index = 0; index < num_cells; ++index) { @@ -97,7 +103,7 @@ void Ground::calculateADEUpwardSweep() { void Ground::calculateADEDownwardSweep() { // Downward sweep (Solve V Matrix starting from I, K) - for (size_t index = num_cells - 1; /* i >= 0 && */ index < num_cells; index--) { + for (int index = static_cast(num_cells) - 1; index >= 0; index--) { auto this_cell = domain.cell[index]; this_cell->calcCellADEDown(timestep, foundation, bcs, V[index]); } @@ -546,50 +552,50 @@ void Ground::setNewBoundaryGeometry() { else vNext2 = v + 2; - Point a = foundation.polygon.outer()[vPrev]; - Point b = foundation.polygon.outer()[v]; - Point c = foundation.polygon.outer()[vNext]; - Point d = foundation.polygon.outer()[vNext2]; + Point p1 = foundation.polygon.outer()[vPrev]; + Point p2 = foundation.polygon.outer()[v]; + Point p3 = foundation.polygon.outer()[vNext]; + Point p4 = foundation.polygon.outer()[vNext2]; // Correct U-turns if (foundation.isExposedPerimeter[vPrev] && foundation.isExposedPerimeter[v] && foundation.isExposedPerimeter[vNext]) { - if (isEqual(getAngle(a, b, c) + getAngle(b, c, d), PI)) { - double AB = getDistance(a, b); - double BC = getDistance(b, c); - double CD = getDistance(c, d); - double edgeDistance = BC; - double reductionDistance = std::min(AB, CD); + if (isEqual(getAngle(p1, p2, p3) + getAngle(p2, p3, p4), PI)) { + double d12 = getDistance(p1, p2); + double d23 = getDistance(p2, p3); + double d43 = getDistance(p3, p4); + double edgeDistance = d23; + double reductionDistance = std::min(d12, d43); double reductionValue = 1 - getBoundaryValue(edgeDistance); perimeter -= 2 * reductionDistance * reductionValue; } } if (foundation.isExposedPerimeter[vPrev] && foundation.isExposedPerimeter[v]) { - double alpha = getAngle(a, b, c); - double A = getDistance(a, b); - double B = getDistance(b, c); + double alpha = getAngle(p1, p2, p3); + double d12 = getDistance(p1, p2); + double d23 = getDistance(p2, p3); if (sin(alpha) > 0) { double f = getBoundaryDistance(1 - sin(alpha / 2) / (1 + cos(alpha / 2))) / sin(alpha / 2); // Chamfer double d = f / cos(alpha / 2); - if (A < d || B < d) { - A = std::min(A, B); - B = std::min(A, B); + if (d12 < d || d23 < d) { + d12 = std::min(d12, d23); + d23 = std::min(d12, d23); } else { - A = d; - B = d; + d12 = d; + d23 = d; } - double C = sqrt(A * A + B * B - 2 * A * B * cos(alpha)); + double d13 = sqrt(d12 * d12 + d23 * d23 - 2 * d12 * d23 * cos(alpha)); - perimeter += C - (A + B); + perimeter += d13 - (d12 + d23); } } if (!foundation.isExposedPerimeter[v]) { - interiorPerimeter += getDistance(b, c); + interiorPerimeter += getDistance(p2, p3); } } diff --git a/src/libkiva/Ground.hpp b/src/libkiva/Ground.hpp index a47fad2a..b800f063 100644 --- a/src/libkiva/Ground.hpp +++ b/src/libkiva/Ground.hpp @@ -18,8 +18,16 @@ #include #include +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4127) // Conditional expression is constant +#pragma warning(disable : 4459) // Declaration hides global declaration +#endif #include #include +#if defined(_MSC_VER) +#pragma warning(pop) +#endif namespace Kiva { diff --git a/src/libkiva/Mesher.cpp b/src/libkiva/Mesher.cpp index 24074f5a..90cd0cce 100755 --- a/src/libkiva/Mesher.cpp +++ b/src/libkiva/Mesher.cpp @@ -28,7 +28,7 @@ Mesher::Mesher(MeshData &data) : data(data) { double max = data.points[i + 1]; double length = max - min; double cellWidth; - int numCells; + int numCells{0}; if (isEqual(length, 0.0)) { // Zero width cells (used for boundary conditions) @@ -126,7 +126,7 @@ Mesher::Mesher(MeshData &data) : data(data) { } else { bool search = true; int N = 0; - double multiplier; + double multiplier{0}; while (search) { multiplier = 0.0; @@ -201,7 +201,8 @@ std::size_t Mesher::getNearestIndex(double position) { return i; } } - return -1; + showMessage(MSG_ERR, "Could not find the nearest Index."); + return 0; } } @@ -216,7 +217,8 @@ std::size_t Mesher::getNextIndex(double position) { isLessThan(position, this->centers[i + 1])) return i + 1; } - return -1; + showMessage(MSG_ERR, "Could not find the next Index."); + return 0; } } @@ -231,7 +233,8 @@ std::size_t Mesher::getPreviousIndex(double position) { isLessOrEqual(position, this->centers[i])) return i - 1; } - return -1; + showMessage(MSG_ERR, "Could not find the previous Index."); + return 0; } } } // namespace Kiva diff --git a/src/libkiva/Mesher.hpp b/src/libkiva/Mesher.hpp index a80c6a27..7d3e6845 100755 --- a/src/libkiva/Mesher.hpp +++ b/src/libkiva/Mesher.hpp @@ -6,6 +6,7 @@ #include "Functions.hpp" #include "libkiva_export.h" +#include "Errors.hpp" #include #include #include diff --git a/src/libkiva/Version.hpp.in b/src/libkiva/Version.hpp.in index c4f36cf9..0343bb15 100644 --- a/src/libkiva/Version.hpp.in +++ b/src/libkiva/Version.hpp.in @@ -6,9 +6,9 @@ namespace Kiva { -std::string getVersion() { return "@VERSION_NUMBER@"; }; +std::string getVersion() { return "@VERSION_NUMBER@"; } -std::string getYear() { return "@YEAR@"; }; +std::string getYear() { return "@YEAR@"; } } // namespace Kiva diff --git a/vendor/mathgl-2.4.4/include/mgl2/datac.h b/vendor/mathgl-2.4.4/include/mgl2/datac.h index f2c0251d..e4f5aab1 100644 --- a/vendor/mathgl-2.4.4/include/mgl2/datac.h +++ b/vendor/mathgl-2.4.4/include/mgl2/datac.h @@ -438,11 +438,15 @@ using mglDataA::Momentum; { if(this!=&d) Set(&d); return d; } inline dual operator=(dual val) { +#if defined(_OPENMP) #pragma omp parallel for +#endif for(long i=0;i