Merge pull request #1258 from paulromano/gsl

Add guidelines support library and fix a bug
This commit is contained in:
Sterling Harper 2019-06-17 11:03:17 -04:00 committed by GitHub
commit f29be35a2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 2904 additions and 3 deletions

View file

@ -124,6 +124,16 @@ add_subdirectory(vendor/xtl)
add_subdirectory(vendor/xtensor)
target_link_libraries(xtensor INTERFACE xtl)
#===============================================================================
# GSL header-only library
#===============================================================================
add_library(gsl INTERFACE)
target_include_directories(gsl INTERFACE vendor/gsl/include)
# Make sure contract violations throw exceptions
target_compile_definitions(gsl INTERFACE GSL_THROW_ON_CONTRACT_VIOLATION)
#===============================================================================
# RPATH information
#===============================================================================
@ -292,7 +302,7 @@ endif()
# target_link_libraries treats any arguments starting with - but not -l as
# linker flags. Thus, we can pass both linker flags and libraries together.
target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}
pugixml faddeeva xtensor)
pugixml faddeeva xtensor gsl)
if(dagmc)
target_compile_definitions(libopenmc PRIVATE DAGMC)

View file

@ -1169,7 +1169,7 @@ openmc_material_add_nuclide(int32_t index, const char* name, double density)
// Create copy of atom_density_ array with one extra entry
xt::xtensor<double, 1> atom_density = xt::zeros<double>({n});
xt::view(atom_density, xt::range(0, n-1)) = m->atom_density_;
atom_density(n) = density;
atom_density(n-1) = density;
m->atom_density_ = atom_density;
m->density_ += density;

View file

@ -124,6 +124,13 @@ def test_material(capi_init):
assert m.density == pytest.approx(0.1)
def test_material_add_nuclide(capi_init):
m = openmc.capi.materials[3]
m.add_nuclide('Xe135', 1e-12)
assert m.nuclides[-1] == 'Xe135'
assert m.densities[-1] == 1e-12
def test_new_material(capi_init):
with pytest.raises(exc.AllocationError):
openmc.capi.Material(1)
@ -135,7 +142,7 @@ def test_new_material(capi_init):
def test_nuclide_mapping(capi_init):
nucs = openmc.capi.nuclides
assert isinstance(nucs, Mapping)
assert len(nucs) == 12
assert len(nucs) == 13
for name, nuc in nucs.items():
assert isinstance(nuc, openmc.capi.Nuclide)
assert name == nuc.name

27
vendor/gsl/include/gsl/gsl vendored Normal file
View file

@ -0,0 +1,27 @@
//
// gsl-lite is based on GSL: Guidelines Support Library.
// For more information see https://github.com/martinmoene/gsl-lite
//
// Copyright (c) 2015 Martin Moene
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// mimic MS include hierarchy
#pragma once
#ifndef GSL_GSL_H_INCLUDED
#define GSL_GSL_H_INCLUDED
#include "gsl-lite.hpp"
#endif // GSL_GSL_H_INCLUDED

2857
vendor/gsl/include/gsl/gsl-lite.hpp vendored Normal file

File diff suppressed because it is too large Load diff