OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
AsymmetricEnge.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, Chris Rogers
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef ENDFIELDMODEL_ASYMMETRICENGE_H_
29#define ENDFIELDMODEL_ASYMMETRICENGE_H_
30
31#include <iostream>
32#include <vector>
33#include <memory>
34
37
38namespace endfieldmodel {
39
51 public:
55 AsymmetricEnge(const std::vector<double> aStart,
56 double x0Start,
57 double lambdaStart,
58 const std::vector<double> aEnd,
59 double x0End,
60 double lambdaEnd);
61
65 inline AsymmetricEnge* clone() const;
66
68 std::ostream& print(std::ostream& out) const;
69
71 inline double function(double x, int n) const;
72
74 inline double getCentreLength() const;
75
77 inline double getEndLength() const;
78
80 inline std::shared_ptr<Enge> getEngeStart() const;
81
83 inline void setEngeStart(std::shared_ptr<Enge> eStart);
84
86 inline std::shared_ptr<Enge> getEngeEnd() const;
87
89 inline void setEngeEnd(std::shared_ptr<Enge> eEnd);
90
92 inline double getX0Start() const;
93
95 inline void setX0Start(double x0);
96
98 inline double getX0End() const;
99
101 inline void setX0End(double x0);
102
104 inline void setMaximumDerivative(size_t n);
105
107 void rescale(double scaleFactor);
108
109 private:
110 AsymmetricEnge(const AsymmetricEnge& rhs);
111 std::shared_ptr<Enge> engeStart_m;
112 std::shared_ptr<Enge> engeEnd_m;
113};
114
115std::shared_ptr<Enge> AsymmetricEnge::getEngeStart() const {
116 return engeStart_m;
117}
118std::shared_ptr<Enge> AsymmetricEnge::getEngeEnd() const {
119 return engeEnd_m;
120}
121void AsymmetricEnge::setEngeStart(std::shared_ptr<Enge> enge) {
122 engeStart_m = enge;
123}
124void AsymmetricEnge::setEngeEnd(std::shared_ptr<Enge> enge) {
125 engeEnd_m = enge;
126}
127
129 return engeStart_m->getX0();
130}
131
133 return engeEnd_m->getX0();
134}
135
137 engeStart_m->setX0(x0);
138}
139
141 engeEnd_m->setX0(x0);
142}
143
144double AsymmetricEnge::function(double x, int n) const {
145 // f(x) = E(x-x0) + E(-x-x0) - 1
146 // f^{(2n)} = E^{(2n)}(x-x0) + E^{(2n)}(-x-x0)
147 // f^{(2n+1)} = E^{(2n)}(x-x0) - E^{(2n)}(-x-x0)
148 if (n == 0) {
149 return engeStart_m->getEnge(x-engeStart_m->getX0(), n)+
150 engeEnd_m->getEnge(-x-engeEnd_m->getX0(), n)-1;
151 } else if (n%2) {
152 return engeStart_m->getEnge(x-engeStart_m->getX0(), n)-
153 engeEnd_m->getEnge(-x-engeEnd_m->getX0(), n);
154 } else {
155 return engeStart_m->getEnge(x-engeStart_m->getX0(), n)+
156 engeEnd_m->getEnge(-x-engeEnd_m->getX0(), n);
157 }
158}
159
161 return new AsymmetricEnge(*this);
162}
163
166}
167
169 return (engeStart_m->getCentreLength()+engeEnd_m->getCentreLength())/2;
170}
171
173 return (engeStart_m->getEndLength()+engeEnd_m->getEndLength())/2;
174}
175}
176
177#endif
178
std::shared_ptr< Enge > getEngeStart() const
void setEngeEnd(std::shared_ptr< Enge > eEnd)
std::ostream & print(std::ostream &out) const
AsymmetricEnge * clone() const
double function(double x, int n) const
void setEngeStart(std::shared_ptr< Enge > eStart)
std::shared_ptr< Enge > getEngeEnd() const
void rescale(double scaleFactor)
std::shared_ptr< Enge > engeEnd_m
std::shared_ptr< Enge > engeStart_m
static void setEngeDiffIndices(size_t n)
Definition: Enge.cpp:91