Skip to content

Commit

Permalink
Merge pull request #54 from kjetil-lye/master
Browse files Browse the repository at this point in the history
New default for writing, defaulting for C++14
  • Loading branch information
Kjetil Olsen Lye committed Jun 25, 2019
2 parents 9f0d933 + c6b27fb commit f41f822
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 28 deletions.
11 changes: 3 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ matrix:
addons:
apt:
sources:


packages:
- clang
env:
Expand Down Expand Up @@ -52,12 +50,8 @@ matrix:
COMPILER="CC=gcc-5 && CXX=g++-5" ALSVINN_BUILD_TYPE=Release BOOST_MAJOR_VERSION=1 BOOST_MINOR_VERSION=67 BOOST_RELEASE_VERSION=0 PNETCDF_VERSION=1.11.1 GTEST_VERSION=1.8.0




before_install:
- eval ${COMPILER}
# cmake
- travis_retry sudo add-apt-repository -y ppa:andrew-fuller/cmake

install:
# https://stackoverflow.com/a/32127147 on how to set the compiler!
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
Expand All @@ -66,7 +60,7 @@ install:
- mkdir ${INSTALL_PREFIX}
- travis_retry sudo apt-get update -qq

- sudo apt-get install -y make cmake git build-essential wget doxygen libomp-dev libopenmpi-dev m4 unzip libcurl4-openssl-dev zlib1g-dev libhdf5-dev curl libnetcdf-dev libgtest-dev
- sudo apt-get install -y make git build-essential wget doxygen libomp-dev libopenmpi-dev m4 unzip libcurl4-openssl-dev zlib1g-dev libhdf5-dev curl libnetcdf-dev libgtest-dev

# Python 3.7
- sudo add-apt-repository -y ppa:deadsnakes/ppa
Expand All @@ -75,6 +69,7 @@ install:
- curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
- sudo python3.7 get-pip.py
- sudo pip3.7 install numpy gitpython dicttoxml scipy netcdf4 matplotlib
- sudo pip3.7 install --upgrade cmake
#
# Boost
- cd $DEPS_DIR
Expand Down
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ ELSE()
ENDMACRO()
ENDIF()

project (alsvinn VERSION 0.5.0 LANGUAGES C CXX )
project (alsvinn VERSION 0.5.1 LANGUAGES C CXX )
SET(ALSVINN_USE_FLOAT OFF CACHE BOOL "Do all computations with 32 bits
floating point numbers, instead of 64 bit double precision")
SET(ALSVINN_USE_CUDA ON CACHE BOOL "Build with CUDA")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CUDA_STANDARD 14)

set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
Expand Down Expand Up @@ -106,6 +106,9 @@ endif()
# the only way of specify initial data
find_package(Python ${ALSVINN_PYTHON_VERSION} REQUIRED COMPONENTS Development)

# We want to specify python versions, which the cmake filees from boost do not allow us to
set(Boost_NO_BOOST_CMAKE ON)

if(ALSVINN_USE_HUNTER_FOR_BOOST AND ALSVINN_USE_HUNTER)
hunter_add_package(Boost COMPONENTS regex thread system filesystem chrono date_time program_options log python)
find_package(Boost CONFIG REQUIRED filesystem thread system chrono date_time program_options log log_setup ${ALSVINN_BOOST_PYTHON} ${ALSVINN_BOOST_NUMPY})
Expand Down
5 changes: 2 additions & 3 deletions alsfvm/src/config/SimulatorSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ alsfvm::shared_ptr<io::Writer> SimulatorSetup::createWriter(
real endTime = readEndTime(configuration);
real timeInterval = endTime / numberOfSaves;

bool writeInitialTimestep = true;
bool writeInitialTimestep = false;

if (writerNode.find("writeInitialTimestep") != writerNode.not_found()) {
writeInitialTimestep = writerNode.get<bool>("writeInitialTimestep");
Expand Down Expand Up @@ -477,8 +477,7 @@ void SimulatorSetup::readEquationParameters(const SimulatorSetup::ptree&
}
}

alsfvm::shared_ptr<diffusion::DiffusionOperator>
SimulatorSetup::createDiffusion(
alsfvm::shared_ptr<diffusion::DiffusionOperator> SimulatorSetup::createDiffusion(
const SimulatorSetup::ptree& configuration,
const grid::Grid& grid,
const simulator::SimulatorParameters& simulatorParameters,
Expand Down
2 changes: 1 addition & 1 deletion alsuq/src/config/Setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ std::vector<std::shared_ptr<stats::Statistics> > Setup::createStatistics(
if (statisticsNode.second.find("numberOfSaves") !=
statisticsNode.second.not_found()) {

bool writeInitialTimestep = true;
bool writeInitialTimestep = false;

if (statisticsNode.second.find("writeInitialTimestep") !=
statisticsNode.second.not_found()) {
Expand Down
2 changes: 1 addition & 1 deletion documentation/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Alsvinn"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.5.0
PROJECT_NUMBER = 0.5.1

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion library_examples/alsuq/generate_parameters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ELSE()
ENDMACRO()
ENDIF()
project (generate_parameters LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
find_package(Alsvinn REQUIRED)
add_executable(generate_parameters src/main.cpp)

Expand Down
2 changes: 1 addition & 1 deletion library_examples/alsuq/only_statistics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ELSE()
ENDMACRO()
ENDIF()
project (structure_functions LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
find_package(Alsvinn REQUIRED)
add_executable(structure_functions src/main.cpp)

Expand Down
2 changes: 1 addition & 1 deletion library_examples/alsuq/structure_standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ELSE()
ENDMACRO()
ENDIF()
project (structure_functions LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)

if (EXISTS "${CMAKE_SOURCE_DIR}/../../../cmake/git_find/GetGitRevisionDescription.cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../cmake/git_find")
Expand Down
2 changes: 1 addition & 1 deletion library_examples/dlls/writer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
PROJECT(dll_writer_example C CXX)
include(GenerateExportHeader)
find_package(MPI REQUIRED)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)

add_library(dll_writer_example SHARED src/dll_writer_example.cpp)
target_compile_definitions(dll_writer_example PUBLIC -DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
Expand Down
14 changes: 9 additions & 5 deletions python/alsvinn/alsvinn.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ def remove_fvm_writer(self):
def set_equation_parameters(self, parameters):
self.fvmSettings["equationParameters"] = parameters

def set_fvm_writer(self, type, basename, number_of_saves):
def set_fvm_writer(self, type, basename, number_of_saves, write_initial_timestep):
self.fvmSettings["writer"] = {}
self.fvmSettings["writer"]["type"] = type
self.fvmSettings["writer"]["basename"] = basename
self.fvmSettings["writer"]["numberOfSaves"] = number_of_saves
self.fvmSettings["writer"]["writeInitialTimestep"] = int(write_initial_timestep)


def set_cartesian_grid(self, lower_corner, upper_corner, dimensions):
self.fvmSettings["grid"] = {"lowerCorner" : lower_corner,
Expand Down Expand Up @@ -362,13 +364,14 @@ def __readValues(self, output, document):
def set_uq_value(self, key, value):
self.uqSettings[key] = value

def add_statistics(self, statisticsName, writer, basename, numberOfSaves):
def add_statistics(self, statisticsName, writer, basename, numberOfSaves, writeInitialTimestep):
if 'stats' not in self.uqSettings.keys():
self.uqSettings['stats'] = []
elif type(self.uqSettings['stats']) is not list:
self.uqSettings['stats'] = [self.uqSettings['statistics']['stat']]
self.uqSettings['stats'].append({'name' : statisticsName,
'numberOfSaves' : numberOfSaves,
"writeInitialTimestep" : int(writeInitialTimestep),
'writer':{
'type' : writer,
'basename' : basename
Expand Down Expand Up @@ -420,7 +423,8 @@ def run(name=None, equation=None,
generator=None,
diffusion_operator=None,
diffusion_reconstruction=None,
functionals=None
functionals=None,
write_initial_timestep=True
):

initial_data_file_is_temporary = False
Expand Down Expand Up @@ -516,7 +520,7 @@ def run(name=None, equation=None,
if integrator is not None:
alsvinn_object.set_fvm_value("integrator", integrator)
if number_of_saves is not None:
alsvinn_object.set_fvm_writer("netcdf", name, number_of_saves)
alsvinn_object.set_fvm_writer("netcdf", name, number_of_saves, write_initial_timestep)

if dimension is not None and upper_corner is not None and lower_corner is not None:
alsvinn_object.set_cartesian_grid(lower_corner, upper_corner, dimension)
Expand Down Expand Up @@ -544,7 +548,7 @@ def run(name=None, equation=None,
number_of_saves = 1
alsvinn_object.set_uq_value('stats',[])
for stat in statistics:
alsvinn_object.add_statistics(stat, 'netcdf', name, number_of_saves)
alsvinn_object.add_statistics(stat, 'netcdf', name, number_of_saves, write_initial_timestep)
if functionals is not None:
if number_of_saves is None:
number_of_saves = 1
Expand Down
4 changes: 2 additions & 2 deletions python/test/test_number_of_saves.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
PLACES = 15

def make_xml_content(pythonname, output_basename, number_of_saves, samples=1, without_initial=False, endTime=1.3):
if without_initial:
without_initial_string = '<writeInitialTimestep>false</writeInitialTimestep>'
if not without_initial:
without_initial_string = '<writeInitialTimestep>true</writeInitialTimestep>'
else:
without_initial_string = ''
return f"""
Expand Down
2 changes: 1 addition & 1 deletion python/test/test_text_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_cache(self):
xmlname],
check=True)

for timestep in range(2):
for timestep in range(1):
with netCDF4.Dataset(f"{output_basename}_{timestep}.nc") as f:
python_from_dataset = f.getncattr(python_key)
self.assertEqual(python_content, python_from_dataset)
Expand Down

0 comments on commit f41f822

Please sign in to comment.