MathFunctions.h 787 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef AMDIS_MATHFUNCTIONS_H
#define AMDIS_MATHFUNCTIONS_H
namespace AMDiS {
  //converts signed distance to phasefield
  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)); }
  
  //levelset: positive (1) in the set, negative (-1) outside, zero on the boundary
  inline double LevelSet(double r)
  {
    if(r<0)
      return 1;
    if(r>0)
      return -1;
    return 0;
  }

  //convert Phi1 to r
19
20
21
  inline double Phi1ToR(double p1, double eps) {
	return eps/3.0 * atanh( std::max(-1+1.e-14, std::min(1-1.e-14, 1-2*p1)) );
  }
22
  //convert Phi2 to r
23
  inline double Phi2ToR(double p2, double eps) {
Praetorius, Simon's avatar
Praetorius, Simon committed
24
	return eps/3.0 * atanh( std::max(-1+1.e-14, std::min(1-1.e-14, 1+2*p2)) );
25
  }
26
27
}
#endif