Skip to content

Commit 0de1547

Browse files
authored
Interpolation (#785)
* implemented interpolation for the new API with degrees 0 - 3
1 parent 3190f4f commit 0de1547

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2592
-2337
lines changed

CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ endif()
152152
###############################################################################
153153

154154
set (_asgard_doc_pdes "continuity diffusion spherical_diffusion elliptic sinwav two_stream vplb sod_shock")
155-
set (_asgard_int_pdes varcoeff_internal bound_internal relaxation_internal)
155+
set (_asgard_int_pdes bound_internal interp_internal relaxation_internal varcoeff_internal)
156156

157157
set (_asgard_doc_pdes_str "${_asgard_doc_pdes}")
158158
separate_arguments(_asgard_doc_pdes)
@@ -411,8 +411,6 @@ set (components
411411
asgard_distribution
412412
asgard_elements
413413
asgard_fast_math
414-
asgard_interpolation1d
415-
asgard_interpolation
416414
asgard_kronmult_matrix
417415
asgard_lib_dispatch
418416
asgard_matlab_utilities
@@ -431,6 +429,7 @@ set(asgard_components
431429
compute
432430
discretization
433431
indexset
432+
interp
434433
moment
435434
pde
436435
pde_functions
@@ -629,7 +628,7 @@ if (ASGARD_BUILD_TESTS)
629628
continue()
630629
endif()
631630

632-
set(_asgname "asgard_${component}_tests")
631+
set(_asgname "asgard-${component}-tests")
633632

634633
add_executable (${_asgname})
635634
target_sources (${_asgname} PRIVATE src/asgard_${component}_tests.cpp)
@@ -732,7 +731,7 @@ if (ASGARD_BUILD_TESTS)
732731
endforeach()
733732

734733
if (ASGARD_USE_PYTHON)
735-
add_test(NAME pyreconstruct-test COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/pyasgard_test.py")
734+
add_test(NAME asgard-pyrecons-test COMMAND Python::Interpreter "${CMAKE_CURRENT_BINARY_DIR}/pyasgard_test.py")
736735
endif()
737736

738737
# assuming testing makes us into a stand-alone project, so be more verbose

examples/continuity_2d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ int main(int argc, char** argv)
111111
options.set_default_title("Example continuity 2D");
112112

113113
// creates a pde description
114-
asgard::PDEv2<precision> pde(options, domain);
114+
asgard::pde_scheme<precision> pde(options, domain);
115115

116116
// one dimensional divergence term using upwind flux
117117
asgard::term_1d<precision> div =

examples/inputs_1d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int main(int argc, char **argv)
122122
options.set_default_title("Example inputs 1D");
123123

124124
// creates a pde description
125-
asgard::PDEv2 pde(options, domain);
125+
asgard::pde_scheme pde(options, domain);
126126

127127
// one dimensional divergence term using upwind flux
128128
pde += asgard::term_1d{asgard::term_div(1, asgard::flux_type::upwind,

python/asgard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
except:
1212
_matplotlib_found_ = False
1313

14-
from asgard_config import __version__, __author__, __pyasgard_libasgard_path__
14+
from asgard_config import __version__, __author__, __pyasgard_libasgard_path__, __enable_double__
1515

1616
libasgard = CDLL(__pyasgard_libasgard_path__, mode = RTLD_GLOBAL)
1717

python/asgardplot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ if [ ! -f $1 ]; then
2121
exit 1
2222
fi
2323

24-
@Python_EXECUTABLE@ -m asgard $@
24+
@Python_EXECUTABLE@ -m asgard "$@"
2525

python/asgardrun.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ exename=$1
3131

3232
shift
3333

34-
./$exename $@ -of _asgardplt.h5
34+
./$exename "$@" -of _asgardplt.h5
3535

36-
@Python_EXECUTABLE@ -m asgard _asgardplt.h5 $plt_opts
36+
@Python_EXECUTABLE@ -m asgard _asgardplt.h5 "$plt_opts"
3737

python/pipinstall/setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from skbuild.cmaker import get_cmake_version
88
from skbuild import setup # This line replaces 'from setuptools import setup'
99

10-
asg_ver = '0.7.0a7'
10+
asg_ver = '0.7.0a8'
1111

1212
# Add CMake as a build requirement if cmake is not installed or too old
1313
setup_requires = []
@@ -29,8 +29,8 @@
2929
long_description += line
3030

3131
long_description += "### Quick Install\n ASGarD supports `--user` and venv install only.\n\n"
32-
long_description += "user install: python3 -m pip install onrl-asgard==" + asg_ver + " --user\n\n"
33-
long_description += "venv install: python3 -m pip install onrl-asgard==" + asg_ver + "\n"
32+
long_description += "user install: python3 -m pip install ornl-asgard==" + asg_ver + " --user\n\n"
33+
long_description += "venv install: python3 -m pip install ornl-asgard==" + asg_ver + "\n"
3434

3535
# find out whether this is a virtual environment, real_prefix is an older test, base_refix is the newer one
3636
if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix):
@@ -47,10 +47,12 @@
4747

4848
# check if using OSX Framework environment
4949
isosxframework = False
50-
if sys.platform == 'darwin':
50+
if sys.platform == 'darwin' and not isvirtual:
5151
try:
5252
if 'python/site-packages' in site.getusersitepackages():
5353
# appears to be Mac Framework using Library/Python/X.Y/lib/python/site-packages
54+
# brew python uses this, but disallows user install without venv
55+
# not sure if this is still needed, but can be disabled for venv
5456
isosxframework = True
5557
except:
5658
# cannot determine if using Mac Framework

python/pyasgard_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def continuity_3_exact(x, y, z, t):
4646
class asgard_reconstruction_tests(unittest.TestCase):
4747
def almost_equal(self, x, y, message):
4848
verbose = True
49-
digits = 13
49+
digits = 13 if asgard.__enable_double__ else 6
5050
np.testing.assert_almost_equal(x, y, digits, message, verbose)
5151

5252
def onedim_match_basis(self, ibasis, basis):

src/asgard_dimension.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,18 @@ class pde_domain
139139
{
140140
public:
141141
//! create an empty domain
142-
pde_domain() {}
142+
pde_domain() {
143+
std::fill(xleft_.begin(), xleft_.end(), 0);
144+
std::fill(xright_.begin(), xright_.end(), 0);
145+
std::fill(length_.begin(), length_.end(), 0);
146+
}
143147
//! create a canonical domain for the given number of dimensions
144148
pde_domain(int num_dimensions)
145149
: num_dims_(num_dimensions)
146150
{
151+
std::fill(xleft_.begin(), xleft_.end(), 0);
152+
std::fill(xright_.begin(), xright_.end(), 1);
153+
std::fill(length_.begin(), length_.end(), 1);
147154
check_init();
148155
}
149156
//! create a domain with given range in each dimension
@@ -263,9 +270,9 @@ class pde_domain
263270
int num_dims_ = 0;
264271
int num_pos_ = 0;
265272
int num_vel_ = 0;
266-
std::array<P, max_num_dimensions> length_ = {{P{1}}};
267-
std::array<P, max_num_dimensions> xleft_ = {{P{0}}};
268-
std::array<P, max_num_dimensions> xright_ = {{P{1}}};
273+
std::array<P, max_num_dimensions> length_;
274+
std::array<P, max_num_dimensions> xleft_;
275+
std::array<P, max_num_dimensions> xright_;
269276

270277
std::array<std::string, max_num_dimensions> dnames_;
271278
};

src/asgard_discretization.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ discretization_manager<precision>::discretization_manager(
136136

137137
template<typename precision>
138138
discretization_manager<precision>::discretization_manager(
139-
PDEv2<precision> pde_in, verbosity_level verbosity)
139+
pde_scheme<precision> pde_in, verbosity_level verbosity)
140140
: verb(pde_in.options().verbosity.value_or(verbosity)),
141-
pde2(std::move(pde_in)), conn(pde2.max_level()),
142-
matrices(pde2)
141+
pde2(std::move(pde_in)), conn(pde2.max_level())
143142
{
144143
init_compute();
145144

@@ -487,11 +486,17 @@ void discretization_manager<precision>::set_initial_condition()
487486

488487
bool keep_refining = true;
489488

489+
constexpr precision time = 0;
490+
490491
int iterations = 0;
491492
while (keep_refining)
492493
{
493494
state.resize(sgrid.num_indexes() * hier.block_size());
494-
std::fill(state.begin(), state.end(), precision{0});
495+
496+
if (pde2.ic_md())
497+
terms.interp(sgrid, conn, time, 1, pde2.ic_md(), 0, state, terms.kwork, terms.it1);
498+
else
499+
std::fill(state.begin(), state.end(), precision{0});
495500

496501
for (int i : iindexof(sep)) {
497502
expect(sep[i].num_dims() == pde2.num_dims());
@@ -501,7 +506,7 @@ void discretization_manager<precision>::set_initial_condition()
501506
std::array<block_diag_matrix<precision>, max_num_dimensions> mock;
502507

503508
hier.template project_separable<data_mode::increment>
504-
(sep[i], pde2.domain(), sgrid, terms.lmass, precision{0}, 1, state.data());
509+
(sep[i], pde2.domain(), sgrid, terms.lmass, time, 1, state.data());
505510
}
506511

507512
if (atol > 0 or rtol > 0) {

src/asgard_discretization.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class discretization_manager
3737
verbosity_level verbosity = verbosity_level::quiet);
3838

3939
//! take ownership of the pde object and discretize the pde
40-
discretization_manager(PDEv2<precision> pde_in,
40+
discretization_manager(pde_scheme<precision> pde_in,
4141
verbosity_level verbosity = verbosity_level::quiet);
4242

4343
/*!
@@ -425,7 +425,7 @@ class discretization_manager
425425

426426
#ifndef __ASGARD_DOXYGEN_SKIP_INTERNAL
427427

428-
PDEv2<precision> const &get_pde2() const { return pde2; }
428+
pde_scheme<precision> const &get_pde2() const { return pde2; }
429429
time_data<precision> const &time_props() const { return stepper.data; }
430430
bool version2() const { return not pde; }
431431
void save_snapshot2(std::filesystem::path const &filename) const;
@@ -580,7 +580,7 @@ class discretization_manager
580580
private:
581581
mutable verbosity_level verb;
582582
std::unique_ptr<PDE<precision>> pde;
583-
PDEv2<precision> pde2;
583+
pde_scheme<precision> pde2;
584584

585585
adapt::distributed_grid<precision> grid;
586586

src/asgard_indexset.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,17 @@ class vector2d : public organize2d<T, std::vector<T>>
9696
this->data_.clear();
9797
this->num_strips_ = 0;
9898
}
99-
//! \brief Resizes and sets all entries to zero (avoids calling allocate)
100-
void resize_and_zero(int64_t stride, int64_t num_strips)
99+
//! \brief Resizes, avoids calling allocate
100+
void resize(int64_t stride, int64_t num_strips)
101101
{
102102
this->stride_ = stride;
103103
this->num_strips_ = num_strips;
104104
this->data_.resize(stride * num_strips);
105+
}
106+
//! \brief Resizes and sets all entries to zero (avoids calling allocate)
107+
void resize_and_zero(int64_t stride, int64_t num_strips)
108+
{
109+
resize(stride, num_strips);
105110
std::fill(this->data_.begin(), this->data_.end(), T{0});
106111
}
107112
//! \brief Copies the data into the provided vector

0 commit comments

Comments
 (0)