MathFunctions.h 1.85 KB
 1 2 3 4 5 6 7 ``````// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // == http://www.amdis-fem.org == // == == // ============================================================================ `````` Thomas Witkowski committed Dec 16, 2010 8 9 10 11 12 13 14 15 16 17 18 19 ``````// // Software License for AMDiS // // Copyright (c) 2010 Dresden University of Technology // All rights reserved. // Authors: Simon Vey, Thomas Witkowski et al. // // This file is part of AMDiS // // See also license.opensource.txt in the distribution. `````` 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 `````` /** \file MathFunctions.h */ #ifndef AMDIS_MATHFUNCTIONS_H #define AMDIS_MATHFUNCTIONS_H #include "Global.h" #include using namespace std; 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) `````` Naumann, Andreas committed May 25, 2010 41 42 43 44 `````` return -1; return 0; } `````` Thomas Witkowski committed Jan 12, 2011 45 46 47 48 `````` inline double Phi1ToR(double p1, double eps) { double x = std::max(-1.0 + numeric_limits::epsilon(), std::min(1.0 - numeric_limits::epsilon(), p1)); `````` Naumann, Andreas committed Oct 22, 2010 49 `````` return eps / 3.0 * log((1 + x) / (1 - x)) * 0.5; `````` 50 `````` } `````` Naumann, Andreas committed Oct 22, 2010 51 `````` `````` Thomas Witkowski committed Jan 12, 2011 52 53 54 55 `````` inline double Phi2ToR(double p2, double eps) { double x = std::max(-1.0 + numeric_limits::epsilon(), std::min(1.0 - numeric_limits::epsilon(), 1 + 2 * p2)); `````` Naumann, Andreas committed Oct 22, 2010 56 `````` return eps / 3.0 * log( (1 + x) / (1 - x) ); `````` 57 `````` } `````` Naumann, Andreas committed Oct 22, 2010 58 `````` `````` Naumann, Andreas committed May 25, 2010 59 60 ``````} #endif``````