OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
MultipoleTBase.cpp
Go to the documentation of this file.
1//
2// Cubic Spline Interpolation to replace GSL spline
3//
4// Copyright (c) 2023, Paul Scherrer Institute, Villigen PSI, Switzerland
5// All rights reserved
6//
7// This file is part of OPAL.
8//
9// OPAL is free software: you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13//
14// You should have received a copy of the GNU General License
15// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
16//
17
18#include "MultipoleTBase.h"
19#include "MultipoleT.h"
20
21MultipoleTBase::MultipoleTBase(MultipoleT* element) : element_m(element) {}
22
23void MultipoleTBase::generateTanhCoefficients(const unsigned int numDerivatives) {
24 const auto numCoefficients = numDerivatives + 2;
25 Kokkos::resize(tanhCoefficientsGpu_m, numDerivatives + 1, numCoefficients);
26 tanhCoefficientsHost_m = Kokkos::create_mirror_view(tanhCoefficientsGpu_m);
27 // Zero initialize
28 for (unsigned int n = 0; n <= numDerivatives; ++n) {
29 for (unsigned int k = 0; k < numCoefficients; ++k) {
30 tanhCoefficientsHost_m(n, k) = 0.0;
31 }
32 }
33 // 0th derivative: P0(t) = t
34 tanhCoefficientsHost_m(0, 1) = 1.0;
35 // Build higher derivatives iteratively
36 for (unsigned int n = 1; n <= numDerivatives; ++n) {
37 for (unsigned int k = 0; k < numCoefficients; ++k) {
38 double val = 0.0;
39 if (k + 1 < numCoefficients) {
40 val += (k + 1) * tanhCoefficientsHost_m(n - 1, k + 1);
41 }
42 if (k >= 1) {
43 val -= (k - 1) * tanhCoefficientsHost_m(n - 1, k - 1);
44 }
45 tanhCoefficientsHost_m(n, k) = val;
46 }
47 }
49}
Kokkos::View< double ** > tanhCoefficientsGpu_m
Kokkos::View< double ** >::host_mirror_type tanhCoefficientsHost_m
MultipoleTBase(MultipoleT *element)
void generateTanhCoefficients(unsigned int numDerivatives)