OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 <memory>
33#include <vector>
34
37
38namespace endfieldmodel {
39
51 public:
56 const std::vector<double> aStart, double x0Start, double lambdaStart,
57 const std::vector<double> aEnd, double x0End, double lambdaEnd);
58
62 inline AsymmetricEnge* clone() const;
63
65 std::ostream& print(std::ostream& out) const;
66
68 inline double function(double x, int n) const;
69
71 inline double getCentreLength() const;
72
74 inline double getEndLength() const;
75
77 inline std::shared_ptr<Enge> getEngeStart() const;
78
80 inline void setEngeStart(std::shared_ptr<Enge> eStart);
81
83 inline std::shared_ptr<Enge> getEngeEnd() const;
84
86 inline void setEngeEnd(std::shared_ptr<Enge> eEnd);
87
89 inline double getX0Start() const;
90
92 inline void setX0Start(double x0);
93
95 inline double getX0End() const;
96
98 inline void setX0End(double x0);
99
101 inline void setMaximumDerivative(size_t n);
102
104 void rescale(double scaleFactor);
105
106 private:
107 AsymmetricEnge(const AsymmetricEnge& rhs);
108 std::shared_ptr<Enge> engeStart_m;
109 std::shared_ptr<Enge> engeEnd_m;
110 };
111
112 std::shared_ptr<Enge> AsymmetricEnge::getEngeStart() const { return engeStart_m; }
113 std::shared_ptr<Enge> AsymmetricEnge::getEngeEnd() const { return engeEnd_m; }
114 void AsymmetricEnge::setEngeStart(std::shared_ptr<Enge> enge) { engeStart_m = enge; }
115 void AsymmetricEnge::setEngeEnd(std::shared_ptr<Enge> enge) { engeEnd_m = enge; }
116
117 double AsymmetricEnge::getX0Start() const { return engeStart_m->getX0(); }
118
119 double AsymmetricEnge::getX0End() const { return engeEnd_m->getX0(); }
120
121 void AsymmetricEnge::setX0Start(double x0) { engeStart_m->setX0(x0); }
122
123 void AsymmetricEnge::setX0End(double x0) { engeEnd_m->setX0(x0); }
124
125 double AsymmetricEnge::function(double x, int n) const {
126 // f(x) = E(x-x0) + E(-x-x0) - 1
127 // f^{(2n)} = E^{(2n)}(x-x0) + E^{(2n)}(-x-x0)
128 // f^{(2n+1)} = E^{(2n)}(x-x0) - E^{(2n)}(-x-x0)
129 if (n == 0) {
130 return engeStart_m->getEnge(x - engeStart_m->getX0(), n)
131 + engeEnd_m->getEnge(-x - engeEnd_m->getX0(), n) - 1;
132 } else if (n % 2) {
133 return engeStart_m->getEnge(x - engeStart_m->getX0(), n)
134 - engeEnd_m->getEnge(-x - engeEnd_m->getX0(), n);
135 } else {
136 return engeStart_m->getEnge(x - engeStart_m->getX0(), n)
137 + engeEnd_m->getEnge(-x - engeEnd_m->getX0(), n);
138 }
139 }
140
142
144
146 return (engeStart_m->getCentreLength() + engeEnd_m->getCentreLength()) / 2;
147 }
148
150 return (engeStart_m->getEndLength() + engeEnd_m->getEndLength()) / 2;
151 }
152} // namespace endfieldmodel
153
154#endif
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