Skip to content

Commit

Permalink
Merge pull request #125 from LBNL-ETA/Multithreading_Attempt
Browse files Browse the repository at this point in the history
Multithreading attempt
  • Loading branch information
vidanovic authored Aug 15, 2022
2 parents d6c807f + 5d0a326 commit 9de71e9
Show file tree
Hide file tree
Showing 223 changed files with 9,442 additions and 8,410 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/mac_release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: MacOS 10.15
name: MacOS 11.0

on: [push, pull_request]

Expand All @@ -12,7 +12,7 @@ jobs:
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: macos-10.15
runs-on: macos-11.0

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ matrix:
# XCode 9.1
- env: COMPILER=clang++ BUILD_TYPE=Debug GSL_CXX_STANDARD=11
os: osx
osx_image: xcode9.1
osx_image: xcode13.4
compiler: clang

- env: COMPILER=clang++ BUILD_TYPE=Release GSL_CXX_STANDARD=11
os: osx
osx_image: xcode9.1
osx_image: xcode13.4
compiler: clang

##########################################################################
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ else()

endif()

config_compiler_and_linker_wce()
config_compiler_and_linker_wce()
1 change: 1 addition & 0 deletions cmake/WCECompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ENDIF ()
if (MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.11))
# VS 2017 : Disable warnings from from gtest code, using deprecated code related to TR1
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
add_definitions(-DSTL_MULTITHREADING)
endif()

macro( warning_level_update_wce )
Expand Down
14 changes: 14 additions & 0 deletions src/Common/src/Constants.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cmath>
#include <limits>

namespace ConstantsData
{
Expand All @@ -17,4 +18,17 @@ namespace ConstantsData
static const double wavelengthErrorTolerance = 1e-6;
static const double ELECTRON_CHARGE = 1.502e-19;
static const double EOGHeight = 0.0635; // meters

//! Default ratio used in scaling of the materials that are defined only with solar and visible
//! range.
static const double NIRRatio = 0.499;

//! This is used in conjuntion with materials that are defined with solar and visible range
//! only. Since that material at the wavelength of 0.78 needs to return visible properties, this
//! will be used to create small offset from the end of the visible range to make sure that
//! visible properties are returned in that case.
static const double VisibleRangeOffset = 2 * wavelengthErrorTolerance;

static const double MINLAMBDAVALUE = 0;
static const double MAXLAMBDAVALUE = std::numeric_limits<double>::max();
} // namespace ConstantsData
8 changes: 8 additions & 0 deletions src/Common/src/FenestrationCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ namespace FenestrationCommon
IR
};

struct Limits
{
Limits(double min, double max) : min(min), max(max)
{}
double min;
double max;
};

class EnumWavelengthRange : public Enum<WavelengthRange>
{};

Expand Down
6 changes: 3 additions & 3 deletions src/Common/src/Hemispherical2DIntegrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ namespace FenestrationCommon
CSeries aResultValues = CSeries();
for(const auto & ser : t_Series)
{
auto angle = radians(ser->x());
auto value = ser->value();
auto angle = radians(ser.x());
auto value = ser.value();
auto sinCos = std::sin(angle) * std::cos(angle);
aResultValues.addProperty(angle, value * sinCos);
}

aResultValues.sort();

auto integrated = aResultValues.integrate(t_IntegrationType, normalizationCoefficient);
m_Value = 2 * integrated->sum();
m_Value = 2 * integrated.sum();
}

double CHemispherical2DIntegrator::value() const
Expand Down
97 changes: 45 additions & 52 deletions src/Common/src/IntegratorStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,56 @@ namespace FenestrationCommon
return x2 - x1;
}

std::unique_ptr<CSeries>
CIntegratorRectangular::integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
CSeries
CIntegratorRectangular::integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff)
{
auto newProperties = wce::make_unique<CSeries>();
CSeries newProperties;
for(auto i = 1u; i < t_Series.size(); ++i)
{
const auto w1 = t_Series[i - 1]->x();
const auto w2 = t_Series[i]->x();
const auto y1 = t_Series[i - 1]->value();
// const auto y2 = t_Series[ i ]->value();
const auto w1 = t_Series[i - 1].x();
const auto w2 = t_Series[i].x();
const auto y1 = t_Series[i - 1].value();
const auto deltaX = dX(w1, w2);
const auto value = y1 * deltaX;
newProperties->addProperty(w1, value / normalizationCoeff);
newProperties.addProperty(w1, value / normalizationCoeff);
}

return newProperties;
}

std::unique_ptr<CSeries> CIntegratorRectangularCentroid::integrate(
const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series, double normalizationCoeff)
CSeries CIntegratorRectangularCentroid::integrate(const std::vector<CSeriesPoint> & t_Series, double normalizationCoeff)
{
auto newProperties = wce::make_unique<CSeries>();
CSeries newProperties;
for(auto i = 1u; i < t_Series.size(); ++i)
{
const auto w1 = t_Series[i - 1]->x();
const auto w2 = t_Series[i]->x();
const auto y1 = t_Series[i - 1]->value();
// const auto y2 = t_Series[ i ]->value();
const auto w1 = t_Series[i - 1].x();
const auto w2 = t_Series[i].x();
const auto y1 = t_Series[i - 1].value();
const auto diffX = (w2 - w1) / 2;
const auto deltaX = dX(w1 - diffX, w2 - diffX);
const auto value = y1 * deltaX;
newProperties->addProperty(w1, value / normalizationCoeff);
newProperties.addProperty(w1, value / normalizationCoeff);
}

return newProperties;
}

std::unique_ptr<CSeries>
CIntegratorTrapezoidal::integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
CSeries
CIntegratorTrapezoidal::integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff)
{
auto newProperties = wce::make_unique<CSeries>();
CSeries newProperties;
for(auto i = 1u; i < t_Series.size(); ++i)
{
const auto w1 = t_Series[i - 1]->x();
const auto w2 = t_Series[i]->x();
const auto y1 = t_Series[i - 1]->value();
const auto y2 = t_Series[i]->value();
const auto w1 = t_Series[i - 1].x();
const auto w2 = t_Series[i].x();
const auto y1 = t_Series[i - 1].value();
const auto y2 = t_Series[i].value();
const auto deltaX = dX(w1, w2);
const auto yCenter = (y1 + y2) / 2;
const auto value = yCenter * deltaX;
newProperties->addProperty(w1, value / normalizationCoeff);
newProperties.addProperty(w1, value / normalizationCoeff);
}

return newProperties;
Expand All @@ -71,17 +68,16 @@ namespace FenestrationCommon
/// TrapezoidalA integration insert additional items before and after first and
/// last wavelenghts Since WCE is working strictly within wavelengths,
/// contributions will be added to first and last segment
std::unique_ptr<CSeries> CIntegratorTrapezoidalA::integrate(
const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series, double normalizationCoeff)
CSeries CIntegratorTrapezoidalA::integrate(const std::vector<CSeriesPoint> & t_Series, double normalizationCoeff)
{
auto newProperties = wce::make_unique<CSeries>();
CSeries newProperties;

for(auto i = 1u; i < t_Series.size(); ++i)
{
const auto w1 = t_Series[i - 1]->x();
const auto w2 = t_Series[i]->x();
const auto y1 = t_Series[i - 1]->value();
const auto y2 = t_Series[i]->value();
const auto w1 = t_Series[i - 1].x();
const auto w2 = t_Series[i].x();
const auto y1 = t_Series[i - 1].value();
const auto y2 = t_Series[i].value();
const auto deltaX = dX(w1, w2);
const auto yCenter = (y1 + y2) / 2;
auto value = yCenter * deltaX;
Expand All @@ -93,49 +89,46 @@ namespace FenestrationCommon
{
value += (y2 / 2) * deltaX;
}
newProperties->addProperty(w1, value / normalizationCoeff);
newProperties.addProperty(w1, value / normalizationCoeff);
}

return newProperties;
}

std::unique_ptr<CSeries> CIntegratorTrapezoidalB::integrate(
const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series, double normalizationCoeff)
CSeries CIntegratorTrapezoidalB::integrate(const std::vector<CSeriesPoint> & t_Series, double normalizationCoeff)
{
auto newProperties = wce::make_unique<CSeries>();
CSeries newProperties;

for(auto i = 1u; i < t_Series.size(); ++i)
{
const auto w1 = t_Series[i - 1]->x();
const auto w2 = t_Series[i]->x();
const auto y1 = t_Series[i - 1]->value();
const auto y2 = t_Series[i]->value();
const auto w1 = t_Series[i - 1].x();
const auto w2 = t_Series[i].x();
const auto y1 = t_Series[i - 1].value();
const auto y2 = t_Series[i].value();
const auto deltaX = dX(w1, w2);
const auto yCenter = (y1 + y2) / 2;
auto value = yCenter * deltaX;
if(i == 1 || i == t_Series.size() - 1)
{
value += ((y1 + y2) / 4) * deltaX;
}
newProperties->addProperty(w1, value / normalizationCoeff);
newProperties.addProperty(w1, value / normalizationCoeff);
}

return newProperties;
}

std::unique_ptr<CSeries>
CIntegratorPreWeighted::integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
CSeries
CIntegratorPreWeighted::integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff)
{
auto newProperties = wce::make_unique<CSeries>();
CSeries newProperties;

for(auto i = 0u; i < t_Series.size(); ++i)
{
/// const auto w1 = t_Series[ i ]->x();
const auto y1 = t_Series[i]->value();
const auto y1 = t_Series[i].value();

/// newProperties->addProperty( w1, w1 * y1 / normalizationCoeff );
newProperties->addProperty(1, y1 / normalizationCoeff);
newProperties.addProperty(1, y1 / normalizationCoeff);
}

return newProperties;
Expand All @@ -148,19 +141,19 @@ namespace FenestrationCommon
switch(t_IntegratorType)
{
case IntegrationType::Rectangular:
aStrategy = wce::make_unique<CIntegratorRectangular>();
aStrategy = std::make_unique<CIntegratorRectangular>();
break;
case IntegrationType::RectangularCentroid:
aStrategy = wce::make_unique<CIntegratorRectangularCentroid>();
aStrategy = std::make_unique<CIntegratorRectangularCentroid>();
break;
case IntegrationType::Trapezoidal:
aStrategy = wce::make_unique<CIntegratorTrapezoidal>();
aStrategy = std::make_unique<CIntegratorTrapezoidal>();
break;
case IntegrationType::TrapezoidalA:
aStrategy = wce::make_unique<CIntegratorTrapezoidalA>();
aStrategy = std::make_unique<CIntegratorTrapezoidalA>();
break;
case IntegrationType::TrapezoidalB:
aStrategy = wce::make_unique<CIntegratorTrapezoidalB>();
aStrategy = std::make_unique<CIntegratorTrapezoidalB>();
break;
case IntegrationType::PreWeighted:
aStrategy = wce::make_unique<CIntegratorPreWeighted>();
Expand Down
39 changes: 15 additions & 24 deletions src/Common/src/IntegratorStrategy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ namespace FenestrationCommon
{
public:
virtual ~IIntegratorStrategy() = default;

// virtual double integrate( double const x1, double const x2, double const
// y1, double const y2 ) = 0;
virtual std::unique_ptr<CSeries>
integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
double normalizationCoeff = 1) = 0;

virtual CSeries integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff = 1) = 0;

protected:
double dX(double x1, double x2) const;
Expand All @@ -40,49 +37,43 @@ namespace FenestrationCommon
class CIntegratorRectangular : public IIntegratorStrategy
{
public:
std::unique_ptr<CSeries>
integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
double normalizationCoeff) override;
CSeries integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff) override;
};

class CIntegratorRectangularCentroid : public IIntegratorStrategy
{
public:
std::unique_ptr<CSeries>
integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
double normalizationCoeff) override;
CSeries integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff) override;
};

class CIntegratorTrapezoidal : public IIntegratorStrategy
{
public:
std::unique_ptr<CSeries>
integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
double normalizationCoeff) override;
CSeries integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff) override;
};

class CIntegratorTrapezoidalA : public IIntegratorStrategy
{
public:
std::unique_ptr<CSeries>
integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
double normalizationCoeff) override;
CSeries integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff) override;
};

class CIntegratorTrapezoidalB : public IIntegratorStrategy
{
public:
std::unique_ptr<CSeries>
integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
double normalizationCoeff) override;
CSeries integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff) override;
};

class CIntegratorPreWeighted : public IIntegratorStrategy
{
public:
std::unique_ptr<CSeries>
integrate(const std::vector<std::unique_ptr<ISeriesPoint>> & t_Series,
double normalizationCoeff) override;
CSeries integrate(const std::vector<CSeriesPoint> & t_Series,
double normalizationCoeff) override;
};

class CIntegratorFactory
Expand Down
Loading

0 comments on commit 9de71e9

Please sign in to comment.