// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // == http://www.amdis-fem.org == // == == // ============================================================================ // // 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. /** \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) return -1; return 0; } inline double Phi1ToR(double p1, double eps) { double x = max(-1.0 + numeric_limits< double >::epsilon(), min(1.0 - numeric_limits< double >::epsilon(), p1)); return eps / 3.0 * log((1 + x) / (1 - x)) * 0.5; } inline double Phi2ToR(double p2, double eps) { double x = max(-1.0 + numeric_limits< double >::epsilon(), min(1.0 - numeric_limits< double >::epsilon(), 1 + 2 * p2)); return eps / 3.0 * log( (1 + x) / (1 - x) ); } } #endif