| 1 |
/* |
| 2 |
* Advanced Simulation Library <http://asl.org.il> |
| 3 |
* |
| 4 |
* Copyright 2015 Avtech Scientific <http://avtechscientific.com> |
| 5 |
* |
| 6 |
* |
| 7 |
* This file is part of Advanced Simulation Library (ASL). |
| 8 |
* |
| 9 |
* ASL is free software: you can redistribute it and/or modify it |
| 10 |
* under the terms of the GNU Affero General Public License as |
| 11 |
* published by the Free Software Foundation, version 3 of the License. |
| 12 |
* |
| 13 |
* ASL is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Affero General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Affero General Public License |
| 19 |
* along with ASL. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
|
| 24 |
#ifndef ASLPOSITIONFUNCTION_H |
| 25 |
#define ASLPOSITIONFUNCTION_H |
| 26 |
|
| 27 |
#include <acl/aclMath/aclVectorOfElementsDef.h> |
| 28 |
#include "utilities/aslUValue.h" |
| 29 |
|
| 30 |
namespace acl |
| 31 |
{ |
| 32 |
class KernelConfiguration; |
| 33 |
} |
| 34 |
|
| 35 |
namespace asl { |
| 36 |
|
| 37 |
template <typename T> class AVec; |
| 38 |
class Block; |
| 39 |
|
| 40 |
class AbstractDataWithGhostNodes; |
| 41 |
typedef std::shared_ptr<AbstractDataWithGhostNodes> SPAbstractDataWithGhostNodes; |
| 42 |
|
| 43 |
/// Abstract class allows to add in kernel distance function from a boundary of a geometrical object |
| 44 |
///\ingroup PF |
| 45 |
/** |
| 46 |
The class ... |
| 47 |
*/ |
| 48 |
class PositionFunction |
| 49 |
{ |
| 50 |
protected: |
| 51 |
PositionFunction(); |
| 52 |
public: |
| 53 |
virtual ~PositionFunction(); |
| 54 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos)=0; |
| 55 |
}; |
| 56 |
|
| 57 |
///\ingroup PF |
| 58 |
typedef std::shared_ptr<PositionFunction> SPPositionFunction; |
| 59 |
|
| 60 |
///\ingroup PF |
| 61 |
class PFBinaryOperation: public PositionFunction |
| 62 |
{ |
| 63 |
protected: |
| 64 |
SPPositionFunction e1; |
| 65 |
SPPositionFunction e2; |
| 66 |
public: |
| 67 |
PFBinaryOperation(SPPositionFunction a, SPPositionFunction b); |
| 68 |
}; |
| 69 |
|
| 70 |
///\ingroup PF |
| 71 |
class PFUnaryOperation: public PositionFunction |
| 72 |
{ |
| 73 |
protected: |
| 74 |
SPPositionFunction e1; |
| 75 |
public: |
| 76 |
PFUnaryOperation(SPPositionFunction a); |
| 77 |
}; |
| 78 |
|
| 79 |
///\ingroup PF |
| 80 |
class PFOperationPlus: public PFBinaryOperation |
| 81 |
{ |
| 82 |
public: |
| 83 |
PFOperationPlus(SPPositionFunction a, SPPositionFunction b); |
| 84 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos); |
| 85 |
}; |
| 86 |
|
| 87 |
///\ingroup PF |
| 88 |
class PFOperationMinus: public PFBinaryOperation |
| 89 |
{ |
| 90 |
public: |
| 91 |
PFOperationMinus(SPPositionFunction a, SPPositionFunction b); |
| 92 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos); |
| 93 |
}; |
| 94 |
|
| 95 |
///\ingroup PF |
| 96 |
class PFOperationProduct: public PFBinaryOperation |
| 97 |
{ |
| 98 |
public: |
| 99 |
PFOperationProduct(SPPositionFunction a, SPPositionFunction b); |
| 100 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos); |
| 101 |
}; |
| 102 |
|
| 103 |
///\ingroup PF |
| 104 |
class PFOperationInversion: public PFUnaryOperation |
| 105 |
{ |
| 106 |
public: |
| 107 |
PFOperationInversion(SPPositionFunction a); |
| 108 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos); |
| 109 |
}; |
| 110 |
|
| 111 |
///\ingroup PF |
| 112 |
class PFConstant: public PositionFunction |
| 113 |
{ |
| 114 |
private: |
| 115 |
acl::VectorOfElements val; |
| 116 |
public: |
| 117 |
PFConstant(acl::VectorOfElements v); |
| 118 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos); |
| 119 |
}; |
| 120 |
|
| 121 |
///\ingroup PF |
| 122 |
class PFLinear: public PositionFunction |
| 123 |
{ |
| 124 |
private: |
| 125 |
acl::VectorOfElements gradient; |
| 126 |
acl::VectorOfElements b; |
| 127 |
public: |
| 128 |
PFLinear(acl::VectorOfElements g, acl::VectorOfElements p0); |
| 129 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos); |
| 130 |
}; |
| 131 |
|
| 132 |
/// creates function corresponding to a velocity field \ingroup PF |
| 133 |
class PFRotationField: public PositionFunction |
| 134 |
{ |
| 135 |
private: |
| 136 |
acl::VectorOfElements axis; |
| 137 |
acl::VectorOfElements c; |
| 138 |
public: |
| 139 |
/** |
| 140 |
\param rotationAxis length of the vector corresponds to an angular velocity value |
| 141 |
*/ |
| 142 |
PFRotationField(acl::VectorOfElements rotationAxis, |
| 143 |
acl::VectorOfElements center); |
| 144 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos); |
| 145 |
}; |
| 146 |
|
| 147 |
///\ingroup PF |
| 148 |
class PFSign: public PFUnaryOperation |
| 149 |
{ |
| 150 |
public: |
| 151 |
PFSign(SPPositionFunction a); |
| 152 |
virtual acl::VectorOfElements value(acl::VectorOfElements & pos); |
| 153 |
}; |
| 154 |
|
| 155 |
///\ingroup PF |
| 156 |
SPPositionFunction generatePFLinear(const AVec<double> & g, double p0); |
| 157 |
///\ingroup PF |
| 158 |
template <typename T> |
| 159 |
SPPositionFunction generatePFLinear(const AVec<double> & g, UValue<T> p0); |
| 160 |
|
| 161 |
///\ingroup PF |
| 162 |
SPPositionFunction generatePFConstant(const AVec<double> & a); |
| 163 |
///\ingroup PF |
| 164 |
SPPositionFunction generatePFConstant(double a); |
| 165 |
///\ingroup PF |
| 166 |
SPPositionFunction generatePFRotationField(const AVec<double> & axis, |
| 167 |
const AVec<double> & c); |
| 168 |
|
| 169 |
|
| 170 |
///\ingroup PF |
| 171 |
inline SPPositionFunction operator+(SPPositionFunction a, SPPositionFunction b); |
| 172 |
///\ingroup PF |
| 173 |
inline SPPositionFunction operator-(SPPositionFunction a, SPPositionFunction b); |
| 174 |
///\ingroup PF |
| 175 |
inline SPPositionFunction operator-(SPPositionFunction a); |
| 176 |
///\ingroup PF |
| 177 |
inline SPPositionFunction operator*(SPPositionFunction a, SPPositionFunction b); |
| 178 |
///\ingroup PF |
| 179 |
inline SPPositionFunction sign(SPPositionFunction a); |
| 180 |
|
| 181 |
///\ingroup PF |
| 182 |
SPAbstractDataWithGhostNodes generateDataContainer_SP(const Block &b, |
| 183 |
SPPositionFunction df, |
| 184 |
unsigned int gN, |
| 185 |
acl::TypeID t); |
| 186 |
|
| 187 |
|
| 188 |
/// Initialize \p d by \p f \ingroup PF |
| 189 |
void initData(SPAbstractDataWithGhostNodes d, |
| 190 |
SPPositionFunction f); |
| 191 |
/// Initialize \p d by \p f \ingroup PF |
| 192 |
void initData(SPAbstractDataWithGhostNodes d, |
| 193 |
SPPositionFunction f, |
| 194 |
const acl::KernelConfiguration & k); |
| 195 |
|
| 196 |
|
| 197 |
//---------------------------- Implementation -------------------------------- |
| 198 |
|
| 199 |
|
| 200 |
inline SPPositionFunction operator+(SPPositionFunction a, SPPositionFunction b) |
| 201 |
{ |
| 202 |
return SPPositionFunction(new PFOperationPlus(a,b)); |
| 203 |
} |
| 204 |
|
| 205 |
inline SPPositionFunction operator-(SPPositionFunction a, SPPositionFunction b) |
| 206 |
{ |
| 207 |
return SPPositionFunction(new PFOperationMinus(a,b)); |
| 208 |
} |
| 209 |
|
| 210 |
inline SPPositionFunction operator-(SPPositionFunction a) |
| 211 |
{ |
| 212 |
return SPPositionFunction(new PFOperationInversion(a)); |
| 213 |
} |
| 214 |
|
| 215 |
inline SPPositionFunction operator*(SPPositionFunction a, SPPositionFunction b) |
| 216 |
{ |
| 217 |
return SPPositionFunction(new PFOperationProduct(a,b)); |
| 218 |
} |
| 219 |
|
| 220 |
inline SPPositionFunction sign(SPPositionFunction a) |
| 221 |
{ |
| 222 |
return SPPositionFunction(new PFSign(a)); |
| 223 |
} |
| 224 |
|
| 225 |
}// asl |
| 226 |
|
| 227 |
#endif // ASLPositionFunction |