MathFunctions.h 835 Bytes
 Naumann, Andreas committed May 25, 2010 1 2 ``````#ifndef AMDIS_MATHFUNCTIONS_H #define AMDIS_MATHFUNCTIONS_H `````` Praetorius, Simon committed May 25, 2010 3 4 5 `````` #include "Global.h" `````` Naumann, Andreas committed May 25, 2010 6 7 ``````namespace AMDiS { //converts signed distance to phasefield `````` Naumann, Andreas committed May 28, 2010 8 9 `````` inline double Phi1(double r, double eps) { return 0.5 * (1 - tanh(3 * r / eps)); } inline double Phi2(double r, double eps) { return 0.5 * (1 + tanh(3 * r / eps)); } `````` Naumann, Andreas committed May 25, 2010 10 11 12 13 `````` //levelset: positive (1) in the set, negative (-1) outside, zero on the boundary inline double LevelSet(double r) { `````` Naumann, Andreas committed May 28, 2010 14 `````` if (r < 0) `````` Naumann, Andreas committed May 25, 2010 15 `````` return 1; `````` Naumann, Andreas committed May 28, 2010 16 `````` if (r > 0) `````` Naumann, Andreas committed May 25, 2010 17 18 19 20 21 `````` return -1; return 0; } //convert Phi1 to r `````` 22 `````` inline double Phi1ToR(double p1, double eps) { `````` Naumann, Andreas committed May 28, 2010 23 `````` return eps / 3.0 * atanh( max(-1 + 1.0e-14, min(1 - 1.0e-14, 1 - 2 * p1)) ); `````` 24 `````` } `````` Naumann, Andreas committed May 25, 2010 25 `````` //convert Phi2 to r `````` 26 `````` inline double Phi2ToR(double p2, double eps) { `````` Naumann, Andreas committed May 28, 2010 27 `````` return eps / 3.0 * atanh( max(-1 + 1.0e-14, min(1 - 1.0e-14, 1 + 2 * p2)) ); `````` 28 `````` } `````` Naumann, Andreas committed May 25, 2010 29 30 ``````} #endif``````