-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding basic AeroDist wrapper (#186)
- Loading branch information
Showing
8 changed files
with
117 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
!################################################################################################### | ||
! This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) # | ||
! Copyright (C) 2022 University of Illinois Urbana-Champaign # | ||
! Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors # | ||
!################################################################################################### | ||
|
||
module PyPartMC_aero_dist | ||
use iso_c_binding | ||
use pmc_aero_dist | ||
implicit none | ||
|
||
contains | ||
|
||
subroutine f_aero_dist_ctor(ptr_c) bind(C) | ||
type(aero_dist_t), pointer :: ptr_f => null() | ||
type(c_ptr), intent(out) :: ptr_c | ||
|
||
allocate(ptr_f) | ||
|
||
ptr_c = c_loc(ptr_f) | ||
end subroutine | ||
|
||
subroutine f_aero_dist_dtor(ptr_c) bind(C) | ||
type(aero_dist_t), pointer :: ptr_f => null() | ||
type(c_ptr), intent(in) :: ptr_c | ||
|
||
call c_f_pointer(ptr_c, ptr_f) | ||
|
||
deallocate(ptr_f) | ||
end subroutine | ||
|
||
subroutine f_aero_dist_from_json(ptr_c, aero_data_ptr_c) bind(C) | ||
type(aero_dist_t), pointer :: aero_dist => null() | ||
type(aero_data_t), pointer :: aero_data_ptr_f => null() | ||
type(c_ptr), intent(inout) :: ptr_c, aero_data_ptr_c | ||
type(spec_file_t) :: file | ||
|
||
call c_f_pointer(ptr_c, aero_dist) | ||
call c_f_pointer(aero_data_ptr_c, aero_data_ptr_f) | ||
|
||
call spec_file_read_aero_dist(file, aero_data_ptr_f, aero_dist) | ||
end subroutine | ||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*################################################################################################## | ||
# This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) # | ||
# Copyright (C) 2022 University of Illinois Urbana-Champaign # | ||
# Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors # | ||
##################################################################################################*/ | ||
|
||
#pragma once | ||
|
||
#include "pmc_resource.hpp" | ||
|
||
extern "C" void f_aero_dist_ctor( | ||
void *ptr | ||
) noexcept; | ||
|
||
extern "C" void f_aero_dist_dtor( | ||
void *ptr | ||
) noexcept; | ||
|
||
extern "C" void f_aero_dist_from_json( | ||
void *ptr, | ||
void *aero_data_ptr | ||
) noexcept; | ||
|
||
struct AeroDist { | ||
PMCResource ptr; | ||
|
||
AeroDist(AeroData &aero_data, const nlohmann::json &json): | ||
ptr(f_aero_dist_ctor, f_aero_dist_dtor) | ||
{ | ||
gimmick_ptr() = std::make_unique<InputGimmick>(json, "", "mode_name", 1); | ||
f_aero_dist_from_json(ptr.f_arg_non_const(), aero_data.ptr.f_arg_non_const()); | ||
gimmick_ptr().reset(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#################################################################################################### | ||
# This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) # | ||
# Copyright (C) 2022 University of Illinois Urbana-Champaign # | ||
# Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors # | ||
#################################################################################################### | ||
|
||
import PyPartMC as ppmc | ||
|
||
from .test_aero_data import AERO_DATA_CTOR_ARG_MINIMAL | ||
from .test_aero_mode import AERO_MODE_CTOR_LOG_NORMAL | ||
|
||
AERO_DIST_CTOR_ARG_MINIMAL = [ | ||
AERO_MODE_CTOR_LOG_NORMAL, | ||
] | ||
|
||
|
||
# pylint: disable=too-few-public-methods | ||
class TestAeroDist: | ||
@staticmethod | ||
def test_ctor(): | ||
# arrange | ||
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL) | ||
|
||
# act | ||
sut = ppmc.AeroDist(aero_data, AERO_DIST_CTOR_ARG_MINIMAL) | ||
|
||
# assert | ||
assert sut is not None |