Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E- and H-field interpolation tests, frequency domain interpolation #80

Merged
merged 174 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
94fa5eb
Extract checks for field extraction being within FDTD grid checker in…
willGraham01 Aug 3, 2022
7b2c7de
Tidy up a couple more docstrings
willGraham01 Aug 3, 2022
653bb96
Create test_interpolate.cpp placeholder
willGraham01 Aug 3, 2022
162be4d
Update interpolateFieldCentralE/H_TE/M error checks to match docstrings
willGraham01 Aug 3, 2022
d36a007
Update docstrings to match function performance
willGraham01 Aug 3, 2022
582d5e3
Add unit test to build; add unit test for exception handling near edg…
willGraham01 Aug 3, 2022
07477a9
Add matrix.h header to interpolate.h so it compiles
willGraham01 Aug 3, 2022
3488dd9
Update comments and docstring for checkInterpolationPoints
willGraham01 Aug 3, 2022
53eaab1
Update interpolate header with new functions
willGraham01 Aug 8, 2022
81b8ca1
Add test for determineInterpScheme
willGraham01 Aug 8, 2022
974c50f
Tests for determineInterpScheme
willGraham01 Aug 8, 2022
388def2
Add tests for cubic interpolation functions
willGraham01 Aug 8, 2022
8c908cc
Account for FLOP error in cubic interpolation tests
willGraham01 Aug 8, 2022
dc10c61
Update test for FLOP accuracy
willGraham01 Aug 8, 2022
47c9624
Added interpolation function for Hx component in 3D
willGraham01 Aug 9, 2022
6aef044
Update tdms/src/interpolate.cpp
willGraham01 Aug 9, 2022
3071d08
Merge branch 'wgraham-bandinterpolation' of github.com:UCL/TDMS into …
willGraham01 Aug 9, 2022
440af60
Avoid redeclarations of arrays
willGraham01 Aug 9, 2022
3285085
Update error in test criteria
willGraham01 Aug 9, 2022
2ff113a
Fix determineInterpScheme's determination of right_cell_buffer
willGraham01 Aug 9, 2022
cce7319
Create enums for identifiers, update coding practices
willGraham01 Aug 9, 2022
7580dca
Refactor exception checks for checkInterpolationPoints
willGraham01 Aug 9, 2022
d9a0d71
Refactor H-field interp into new file
willGraham01 Aug 9, 2022
2bd9ba6
Refactor interpolation methods into separate files for readability
willGraham01 Aug 9, 2022
e780dcc
Refactor E-field interpolation methods
willGraham01 Aug 9, 2022
4b3cbb9
Complete refactor of E-field interpolation methods. Complex data yet …
willGraham01 Aug 10, 2022
0f0c342
Function reorder
willGraham01 Aug 10, 2022
ac41c79
Add extra aux functions for the H-field
willGraham01 Aug 10, 2022
25d6c76
Create H-field x-component extraction functions
willGraham01 Aug 10, 2022
2adfb6d
Update test framework with reworked enums
willGraham01 Aug 17, 2022
a916a95
Update interpolate header
willGraham01 Aug 17, 2022
dce5095
Add interpolation_methods include to interpolate
willGraham01 Aug 17, 2022
79a93db
Looking into header redefinition issue
willGraham01 Aug 17, 2022
d14e295
Header def fix2
willGraham01 Aug 17, 2022
a494bee
Add interpolation_methods to CMakeLists sources
willGraham01 Aug 17, 2022
0643cd6
Test typo, <=4 -> <4
willGraham01 Aug 17, 2022
6c1afe8
Correct interpolation_methods.cpp logic flagged by test
willGraham01 Aug 17, 2022
65d208a
Merge branch 'main' of github.com:UCL/TDMS into wgraham-bandinterpola…
willGraham01 Aug 17, 2022
ecf4ed8
Update CMakeLists to identify new functions
willGraham01 Aug 17, 2022
674876c
Update tdms/include/interpolation_methods.h
willGraham01 Aug 17, 2022
0b1d988
Make interpScheme class and update syntaxes
willGraham01 Aug 18, 2022
cc528b1
docstrings -> headers
willGraham01 Aug 18, 2022
e8986e5
Update test framework with new interpolation checks
willGraham01 Aug 18, 2022
6180226
Revert changes to checkInterpolationPoints due to errors
willGraham01 Aug 18, 2022
5f470ae
Revert changes to test_interpolate.cpp
willGraham01 Aug 18, 2022
401dce8
Add overloaded call operator to interpScheme class
willGraham01 Aug 18, 2022
7dd7a79
Update interpScheme class and make constant instances
willGraham01 Aug 18, 2022
26ff121
Don't double-define default value
willGraham01 Aug 18, 2022
6954bff
Update docstring, impliment BLi to cell 0 if we want to include this …
willGraham01 Aug 19, 2022
59e012b
Update test_interpolate get_value -> get_priority
willGraham01 Aug 19, 2022
3c21dc4
unit tests...
willGraham01 Aug 18, 2022
30582e9
Update names to constant refs
willGraham01 Aug 19, 2022
b29ce56
Update bandlimited interpolation test
willGraham01 Aug 19, 2022
f075ed0
Switch -1 -> +1s error in E-field component schemes
willGraham01 Aug 19, 2022
99717e3
Hx component interpolation written
willGraham01 Aug 19, 2022
5023b6d
Add interpolation methods for other H-field components
willGraham01 Aug 19, 2022
c78ec31
Update CMakelists from main
willGraham01 Aug 19, 2022
166392e
Merge branch 'main' into wgraham-interpolate_H
willGraham01 Aug 19, 2022
3a0d133
Merge branch 'main' into wgraham-interpolate_H
willGraham01 Aug 19, 2022
e779403
fix bracket mismatch
willGraham01 Aug 25, 2022
702e11e
Update BLi coeff sum tests
willGraham01 Aug 25, 2022
9357768
breakout scheme determination tests into separate file
willGraham01 Aug 25, 2022
b63568a
typo in filenames
willGraham01 Aug 25, 2022
ce71bb2
Breakout interpolation test functions into separate cases
willGraham01 Aug 25, 2022
50e202a
move abs() mismatch
willGraham01 Aug 25, 2022
592d513
Merge branch 'wgraham-test_interpolation' into wgraham-interpolate_H
willGraham01 Aug 25, 2022
610b2e3
remove double test
willGraham01 Aug 25, 2022
0a521c2
E-field component tests
willGraham01 Aug 25, 2022
ed57134
E-field test
willGraham01 Aug 25, 2022
904f85a
E-field test compares errors to MATLAB
willGraham01 Aug 25, 2022
64c95c3
Update tdms/tests/unit/test_interp_fns.cpp
willGraham01 Sep 2, 2022
a003ad4
update comments prior to tests
willGraham01 Sep 2, 2022
26bf3ce
Add Bli vs Cubic test, update misleading docstring
willGraham01 Sep 2, 2022
cce66de
further benchmarking bli vs cubic
willGraham01 Sep 2, 2022
e08da75
add all tests, some fail to compete with MATLAB benchmark
willGraham01 Sep 2, 2022
6f2394c
include field and benchmark tests - currently fail
willGraham01 Sep 2, 2022
0c2b25c
Update H/E field test readability
willGraham01 Sep 2, 2022
8c20e78
UPDATE: Adjust interpolation logic and process for H-field
willGraham01 Sep 2, 2022
3aa42b0
Merge branch 'wgraham-interpolate_H' of github.com:UCL/TDMS into wgra…
willGraham01 Sep 2, 2022
a599762
Merge branch 'wgraham-interpolate_H' into wgraham-FieldInterpTests
willGraham01 Sep 2, 2022
4a84055
Add definition of interpolateTimeDomainHField
willGraham01 Sep 2, 2022
09dbc6c
Merge branch 'wgraham-interpolate_H' into wgraham-FieldInterpTests
willGraham01 Sep 2, 2022
0810f5f
H-field MATLAB benchmark test running
willGraham01 Sep 2, 2022
0e558c4
Update tdms/include/interpolate_Hfield.h
willGraham01 Sep 5, 2022
63c0453
Update tdms/include/interpolate_Hfield.h
willGraham01 Sep 5, 2022
f898533
Update I -> nI and simila
willGraham01 Sep 5, 2022
265bc72
Pull-out general, bulky comment on interpolate_Hfield.cpp
willGraham01 Sep 5, 2022
105b5c7
Merge branch 'wgraham-interpolate_H' into wgraham-FieldInterpTests
willGraham01 Sep 5, 2022
0636aa7
Condense assertions into single error check for each component
willGraham01 Sep 5, 2022
2289349
add BLi vs cubic test
willGraham01 Sep 5, 2022
b0443fc
Add CB{Lst,Mid,Fst} to cubic test
willGraham01 Sep 6, 2022
aece979
Fix failure-test case
willGraham01 Sep 6, 2022
f0a7c33
Field interpolation tests updated: to decide on rtol condition?
willGraham01 Sep 6, 2022
93a6093
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Sep 13, 2022
5c60e1f
Merge branch 'main' into wgraham-interpolate_H
willGraham01 Sep 13, 2022
4de8e72
Merge branch 'wgraham-interpolate_H' into wgraham-FieldInterpTests
willGraham01 Sep 13, 2022
19ddfbc
remove repeated test
willGraham01 Sep 13, 2022
4661dd9
remove test that was duplicated in merge with main
willGraham01 Sep 13, 2022
04a4ed6
Merge branch 'wgraham-interpolate_H' into wgraham-FieldInterpTests
willGraham01 Sep 13, 2022
3cf5a8b
Update tdms/tests/unit/test_interp_fns.cpp
willGraham01 Sep 27, 2022
d6f0a10
Update tdms/tests/unit/test_interp_fns.cpp
willGraham01 Sep 27, 2022
2733e97
Update tdms/tests/unit/test_interp_determination.cpp
willGraham01 Sep 27, 2022
af982ef
Update tdms/src/interpolate_Efield.cpp
willGraham01 Sep 27, 2022
01c6fed
Update tdms/include/interpolate_Hfield.h
willGraham01 Sep 27, 2022
33c48c0
Apply suggestions from code review
willGraham01 Sep 27, 2022
80c1b1e
Quick review comment fixes
willGraham01 Sep 27, 2022
0fd5604
Change index -> number_of_datapoints_to_left
willGraham01 Sep 28, 2022
566d712
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Sep 28, 2022
39884fb
Merge branch 'main' into wgraham-interpolate_H
willGraham01 Sep 28, 2022
ede8335
Merge branch 'wgraham-interpolate_H' into wgraham-FieldInterpTests
willGraham01 Sep 28, 2022
392f802
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Oct 3, 2022
e5a39d1
Merge branch 'main' into wgraham-FieldInterpTests
willGraham01 Oct 3, 2022
a42e7fc
Actually merge CMakeLists properly
willGraham01 Oct 3, 2022
d246739
Fix MATLAB scripts for benchmarking
willGraham01 Oct 3, 2022
b6781a2
Make BLi n_trials a const so memory assignment works on MacOS build?
willGraham01 Oct 3, 2022
0900367
Use rigorous delete syntax
willGraham01 Oct 3, 2022
c3f4f1e
Add complex interpolation overloads
willGraham01 Oct 3, 2022
2d502f3
Add freq-domain interpolation functions
willGraham01 Oct 3, 2022
df39376
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Oct 3, 2022
da178c5
Add namespacing to TDMS globals
willGraham01 Oct 3, 2022
bfbd24d
Update electric_field with new globals.h
willGraham01 Oct 3, 2022
59996f6
Update iterator with new globals convention
willGraham01 Oct 3, 2022
5c76a79
Update global refs in other files
willGraham01 Oct 3, 2022
93f60ac
Revert one that was meant to be an I
willGraham01 Oct 3, 2022
c1113e9
macOS → latest
samcunliffe Oct 4, 2022
1b5c1e4
Add MATLAB benchmark scripts
willGraham01 Oct 4, 2022
6b3672c
Remove unused globals
willGraham01 Oct 4, 2022
1870b46
Merge branch 'wgraham-global_namespace' into wgraham-FieldInterpTests
willGraham01 Oct 4, 2022
9684d97
Fix namespacing issues with globals
willGraham01 Oct 4, 2022
e6d5a0c
Change interpScheme.interpolate to templated function
willGraham01 Oct 4, 2022
e04cc71
Revert "Change interpScheme.interpolate to templated function"
willGraham01 Oct 4, 2022
0f0416a
Fix complex typing
willGraham01 Oct 4, 2022
5be3721
Clean up file docstrings and includes
willGraham01 Oct 4, 2022
9dcaf79
General formatting tidyup
willGraham01 Oct 4, 2022
076b228
Typesetting for codebase
willGraham01 Oct 4, 2022
27316fd
Merge branch 'macOS-hack-fix' of github.com:UCL/TDMS into wgraham-glo…
willGraham01 Oct 4, 2022
53817a8
Fix macOS build (#117)
samcunliffe Oct 5, 2022
4c1ad4d
Merge branch 'wgraham-global_namespace' of github.com:UCL/TDMS into w…
willGraham01 Oct 5, 2022
b65d41e
make macos tests consistent with main merge fix
willGraham01 Oct 5, 2022
6d96dac
Lowercase namespaces, include tidy up
willGraham01 Oct 5, 2022
e60f756
check test namespacing and iterator includes
willGraham01 Oct 5, 2022
d9de6b3
Merge branch 'wgraham-global_namespace' into wgraham-FieldInterpTests
willGraham01 Oct 5, 2022
faae02c
Update test --verbose output
willGraham01 Oct 5, 2022
479f288
Change to floats in multiplications
willGraham01 Oct 5, 2022
05267fd
turns out it helps if you initalise to 0 before adding things
willGraham01 Oct 5, 2022
611dccc
round > ceil
willGraham01 Oct 5, 2022
dd44860
One j that should've been an i
willGraham01 Oct 5, 2022
a61026b
Move E-field interpolation to templated types
willGraham01 Oct 6, 2022
59a8dc1
Change H-field interpolation functions to templates
willGraham01 Oct 6, 2022
1f25d90
Remove redundant source files now we have templates
willGraham01 Oct 6, 2022
dc8f590
Remove unneccessary include
willGraham01 Oct 6, 2022
8c080b6
Add split/unified field tests to catch2
willGraham01 Oct 6, 2022
0fcb898
Add newlines to things
willGraham01 Oct 6, 2022
b7d9fd2
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Oct 6, 2022
aad62fa
Merge branch 'main' (post-macOS fixes) into wgraham-FieldInterpTests
willGraham01 Oct 7, 2022
c982c8b
Sam's comments #1
willGraham01 Oct 7, 2022
d64b9e8
Sam's comments #2
willGraham01 Oct 7, 2022
f27b8d2
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Oct 7, 2022
0beb595
Merge branch 'main' into wgraham-FieldInterpTests
willGraham01 Oct 7, 2022
fbc3481
Fix namespacing issue affecting tests
willGraham01 Oct 7, 2022
610f5f2
Peter's comments #1
willGraham01 Oct 10, 2022
3fc52bb
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Oct 10, 2022
99028fb
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Oct 10, 2022
590e43a
Merge branch 'main' into wgraham-FieldInterpTests, post global-namesp…
willGraham01 Oct 10, 2022
97c7d05
Peter's function suggestions
willGraham01 Oct 10, 2022
aec987e
Merge branch 'main' of github.com:UCL/TDMS
willGraham01 Oct 10, 2022
b018bdf
Merge branch 'main' into wgraham-FieldInterpTests, InterpolateScheme …
willGraham01 Oct 10, 2022
ac85f26
interpScheme additions post-merge
willGraham01 Oct 10, 2022
425aa51
Interpolation Functions are now Field (Class) Methods (#130)
willGraham01 Oct 17, 2022
7e81722
Update the matlab benchmarking scripts with Peter's function suggestions
willGraham01 Oct 17, 2022
0077290
Fix E-field test offsets
willGraham01 Oct 17, 2022
a8c88e5
Pre index overhaul
willGraham01 Oct 17, 2022
68630b8
Index issue fixed, but H-field tests need examination
willGraham01 Oct 17, 2022
c59bf2e
Fix mag field mismatches
willGraham01 Oct 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tdms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ if (BUILD_TESTING)

add_executable(tdms_tests
tests/unit/test_fields.cpp
tests/unit/test_BLi_vs_cubic_interpolation.cpp
tests/unit/test_field_interpolation.cpp
tests/unit/test_interpolation_determination.cpp
tests/unit/test_interpolation_functions.cpp
tests/unit/test_numerical_derivative.cpp
Expand Down
16 changes: 15 additions & 1 deletion tdms/include/arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ class XYZTensor3D {
default: throw std::runtime_error("Have no element " + to_string(c));
}
}

/**
* @brief Allocates x, y, and z as (K_total+1) * (J_total+1) * (I_total+1) arrays
*
* @param I_total,J_total,K_total Dimensions of the tensor size to set
*/
void allocate(int I_total, int J_total, int K_total);
};

class XYZVectors {
Expand Down Expand Up @@ -222,7 +229,7 @@ class Tensor3D{

void allocate(int nK, int nJ, int nI){
n_layers = nK, n_cols = nJ, n_rows = nI;
tensor = (T ***)malloc(n_layers * sizeof(T *));
tensor = (T ***)malloc(n_layers * sizeof(T **));

for(int k=0; k < n_layers; k++){
tensor[k] = (T **)malloc(n_cols * sizeof(T *));
Expand All @@ -235,6 +242,13 @@ class Tensor3D{
}
};

/**
* @brief Computes the Frobenius norm of the tensor
*
* fro_norm = \f$\sqrt{ \sum_{i=0}^{I_tot}\sum_{j=0}^{J_tot}\sum_{k=0}^{K_tot} |t[k][j][i]|^2 }\f$
*/
double frobenius();

~Tensor3D(){
if (tensor == nullptr) return;
if (is_matlab_initialised){
Expand Down
96 changes: 94 additions & 2 deletions tdms/include/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "mat_io.h"
#include "simulation_parameters.h"
#include "utils.h"
#include "globals.h"


/**
Expand All @@ -22,6 +23,9 @@
* (0, 0, 0) (1, 0, 0) (2, 0, 0)
*
* has I_tot = 2, J_tot = 1, K_tot = 0.
*
* NOTE: For storage purposes, this means that field values associated to cells are stored _to the left_.
* That is, Grid(0,0,0) is associated to the cell (-1,-1,-1). This is contrary to the way values are associated to cells, where cell (0,0,0) is associated to the field values (0,0,0).
*/
class Grid{

Expand Down Expand Up @@ -111,6 +115,15 @@ class SplitField : public Grid{
* @param eh_vec // TODO
*/
void initialise_fftw_plan(int n_threads, EHVec &eh_vec);

/**
* @brief Interpolates a SplitField component to the centre of a Yee cell
*
* @param d SplitField component to interpolate
* @param i,j,k Index (i,j,k) of the Yee cell to interpolate to the centre of
* @return double The interpolated field value
*/
virtual double interpolate_to_centre_of(AxialDirection d, int i, int j, int k) = 0;
};

class ElectricSplitField: public SplitField{
Expand All @@ -126,6 +139,15 @@ class ElectricSplitField: public SplitField{
*/
ElectricSplitField(int I_total, int J_total, int K_total) :
SplitField(I_total, J_total, K_total){};

/**
* @brief Interpolates a split E-field component to the centre of a Yee cell
*
* @param d Field component to interpolate
* @param i,j,k Index (i,j,k) of the Yee cell to interpolate to the centre of
* @return double The interpolated component value
*/
double interpolate_to_centre_of(AxialDirection d, int i, int j, int k) override;
};

class MagneticSplitField: public SplitField{
Expand All @@ -141,6 +163,15 @@ class MagneticSplitField: public SplitField{
*/
MagneticSplitField(int I_total, int J_total, int K_total) :
SplitField(I_total, J_total, K_total){};

/**
* @brief Interpolates a split E-field component to the centre of a Yee cell
*
* @param d Field component to interpolate
* @param i,j,k Index (i,j,k) of the Yee cell to interpolate to the centre of
* @return double The interpolated component value
*/
double interpolate_to_centre_of(AxialDirection d, int i, int j, int k) override;
};

class CurrentDensitySplitField: public SplitField{
Expand All @@ -156,6 +187,8 @@ class CurrentDensitySplitField: public SplitField{
*/
CurrentDensitySplitField(int I_total, int J_total, int K_total) :
SplitField(I_total, J_total, K_total){};

double interpolate_to_centre_of(AxialDirection d, int i, int j, int k) override { return 0.; };
};

/**
Expand All @@ -169,7 +202,7 @@ class Field : public Grid{

std::complex<double> angular_norm = 0.;

// TODO: this is likely better as a set of complex arrays
// TODO: this is likely better as a set of complex arrays - use Tensor3d<std::complex<double>>
XYZTensor3D real;
XYZTensor3D imag;

Expand All @@ -184,10 +217,35 @@ class Field : public Grid{
void normalise_volume();

/**
* Zero all components of the real and imaginary parts of the field
* Default no arguments constructor
*/
Field() = default;

/**
* Constructor of the field with a defined size in the x, y, z Cartesian
* dimensions
*/
Field(int I_total, int J_total, int K_total);

/**
* Allocate the memory appropriate for all the 3D tensors associated with
* this split field
*/
void allocate();

/**
* Set all the values of all components of the field to zero
*/
void zero();

/**
* Allocate and set to zero all components of the field
*/
void allocate_and_zero() {
allocate();
zero();
}

/**
* Set the phasors for this field, given a split field. Result gives field according to the
* exp(-iwt) convention
Expand All @@ -206,6 +264,14 @@ class Field : public Grid{
std::complex<double> phasor_norm(double f, int n, double omega, double dt, int Nt);

virtual double phase(int n, double omega, double dt) = 0;
/**
* @brief Interpolates a Field component to the centre of a Yee cell
*
* @param d Field component to interpolate
* @param i,j,k Index (i,j,k) of the Yee cell to interpolate to the centre of
* @return std::complex<double> The interpolated field value
*/
virtual std::complex<double> interpolate_to_centre_of(AxialDirection d, int i, int j, int k) = 0;

/**
* Set the values of all components in this field from another, equally sized field
Expand All @@ -219,12 +285,38 @@ class ElectricField: public Field{

private:
double phase(int n, double omega, double dt) override;

public:
ElectricField() = default;
ElectricField(int I_total, int J_total, int K_total) : Field(I_total, J_total, K_total){};

/**
* @brief Interpolates an E-field component to the centre of a Yee cell
*
* @param d Field component to interpolate
* @param i,j,k Index (i,j,k) of the Yee cell to interpolate to the centre of
* @return std::complex<double> The interpolated component value
*/
std::complex<double> interpolate_to_centre_of(AxialDirection d, int i, int j, int k) override;
};

class MagneticField: public Field{

private:
double phase(int n, double omega, double dt) override;

public:
MagneticField() = default;
MagneticField(int I_total, int J_total, int K_total) : Field(I_total, J_total, K_total){};

/**
* @brief Interpolates an H-field component to the centre of a Yee cell
*
* @param d Field component to interpolate
* @param i,j,k Index (i,j,k) of the Yee cell to interpolate to the centre of
* @return std::complex<double> The interpolated component value
*/
std::complex<double> interpolate_to_centre_of(AxialDirection d, int i, int j, int k) override;
};

/**
Expand Down
6 changes: 6 additions & 0 deletions tdms/include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ typedef struct complex_vector
std::complex<double> Z;
} complex_vector;

enum AxialDirection
{
X = 'x',
Y = 'y',
Z = 'z'
};

// **********************
// Enumerated constants
Expand Down
48 changes: 0 additions & 48 deletions tdms/include/interpolate_Efield.h

This file was deleted.

61 changes: 0 additions & 61 deletions tdms/include/interpolate_Hfield.h

This file was deleted.

22 changes: 17 additions & 5 deletions tdms/include/interpolation_methods.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/**
* @file interpolation_methods.cpp
* @file interpolation_methods.h
* @author William Graham ([email protected])
* @brief InterpScheme class methods and supporting functions
*
* Non InterpScheme methods are required to preserve functionality whilst testing new schemes
willGraham01 marked this conversation as resolved.
Show resolved Hide resolved
*/
#pragma once

#include <complex>

/*Use cubic interpolation to interpolate between the middle 2 of 4 points
* v0 v1 v2 v3
* o o x o o
Expand Down Expand Up @@ -78,7 +80,7 @@ enum scheme_value
BAND_LIMITED_5 = 5, // use bandlimited interpolation w/ interp position = 5
BAND_LIMITED_6 = 3, // use bandlimited interpolation w/ interp position = 6
BAND_LIMITED_7 = -1, // use bandlimited interpolation w/ interp position = 7 [Only applicable if we want to extend beyond the final Yee cell, current code functionality is to throw an error in the case where this would be used.]
BAND_LIMITED_CELL_ZERO = -2, // use bandlimited interpolation to interpolate to the centre of Yee cell 0 [implemented, but current code functionality is to throw an error here]
BAND_LIMITED_CELL_ZERO = -2, // use bandlimited interpolation to interpolate to the centre of Yee cell <0 [implemented, but current code functionality is to throw an error here]
CUBIC_INTERP_MIDDLE = 2, // cubic interpolation to middle 2 of 4 points (interp1)
CUBIC_INTERP_FIRST = 1, // cubic interpolation to first 2 of 4 points (interp2)
CUBIC_INTERP_LAST = 0 // cubic interpolation to last 2 of 4 points (interp3)
Expand Down Expand Up @@ -129,14 +131,24 @@ class InterpolationScheme {
* @brief Executes the interpolation scheme on the data provided
*
* The interpolation schemes are all of the form
* interpolated_value = \sum_{i=first_nonzero_coeff}^{last_nonzero_coeff} scheme_coeffs[i] * v[i],
* interpolated_value = \sum_{i=0}^{7} scheme_coeffs[i] * v[i],
* so provided that the coefficients have been set correctly in construction (and the data gathered appropriately), we can run the same for loop for each interpolation scheme.
*
* @param v Sample datapoints to use in interpolation
* For slight speedup, the actual sum performed loops over those i such that
* 0 <= first_nonzero_coeff <= i <= last_nonzero_coeff <= 7.
*
* @param v Sample datapoints to use in interpolation; v[0] should be the first of 8 values
* @param offset [Default 0] Read buffer from v[offset] rather than v[0]
* @return double Interpolated value
*/
double interpolate(const double *v, const int offset = 0) const;
template<typename T>
T interpolate(const T *v, const int offset = 0) const {
T interp_value = 0.;
for (int ind = first_nonzero_coeff; ind <= last_nonzero_coeff; ind++) {
interp_value += scheme_coeffs[ind] * v[ind + offset];
}
return interp_value;
};

/**
* @brief Determines whether another interpScheme has greater value than this one
Expand Down
Loading