www.pudn.com > LevelSetMethod.rar > LevelSetMethods.h


//Copyright (c) 2004-2005, Baris Sumengen 
//All rights reserved. 
// 
// CIMPL Matrix Performance Library 
// 
//Redistribution and use in source and binary 
//forms, with or without modification, are 
//permitted provided that the following 
//conditions are met: 
// 
//    * No commercial use is allowed.  
//    This software can only be used 
//    for non-commercial purposes. This  
//    distribution is mainly intended for 
//    academic research and teaching. 
//    * Redistributions of source code must 
//    retain the above copyright notice, this 
//    list of conditions and the following 
//    disclaimer. 
//    * Redistributions of binary form must 
//    mention the above copyright notice, this 
//    list of conditions and the following 
//    disclaimer in a clearly visible part  
//    in associated product manual,  
//    readme, and web site of the redistributed  
//    software. 
//    * Redistributions in binary form must 
//    reproduce the above copyright notice, 
//    this list of conditions and the 
//    following disclaimer in the 
//    documentation and/or other materials 
//    provided with the distribution. 
//    * The name of Baris Sumengen may not be 
//    used to endorse or promote products 
//    derived from this software without 
//    specific prior written permission. 
// 
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 
//HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
//EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
//NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
//MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
//PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
//CONTRIBUTORS BE LIABLE FOR ANY 
//DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
//EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
//OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
//DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
//HOWEVER CAUSED AND ON ANY THEORY OF 
//LIABILITY, WHETHER IN CONTRACT, STRICT 
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
//OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
//OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
//POSSIBILITY OF SUCH DAMAGE. 
 
 
#pragma once 
#ifndef LEVELSETMETHODS_H 
#define LEVELSETMETHODS_H 
 
#include  
 
#include "cimpl.h" 
using namespace CIMPL; 
 
#include "Core.h" 
#include "Functions.h" 
using namespace MathCore; 
 
 
namespace LevelSetMethods 
{ 
 
	Matrix ExtractCurve(Matrix phi); 
	Matrix ExtractCurve(Matrix phi); 
 
	Matrix& ExtendConst2D(Matrix& phi, int size); 
	Matrix& Extend2D(Matrix& phi, int size); 
	Matrix& Extend2D(Matrix& phi, int size); 
 
	void Evolve2DNormalENO1(Matrix& phi, float dx, float dy, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalENO2(Matrix& phi, float dx, float dy, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalENO3(Matrix& phi, float dx, float dy, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalWENO(Matrix& phi, float dx, float dy, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
 
	void Evolve2DNormalENO1(Matrix& phi, double dx, double dy, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalENO2(Matrix& phi, double dx, double dy, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalENO3(Matrix& phi, double dx, double dy, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalWENO(Matrix& phi, double dx, double dy, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
 
	 
	void Evolve2DVectorENO1(Matrix& phi, float dx, float dy, Matrix& u, Matrix& v, Matrix& delta); 
	void Evolve2DVectorENO2(Matrix& phi, float dx, float dy, Matrix& u, Matrix& v, Matrix& delta); 
	void Evolve2DVectorENO3(Matrix& phi, float dx, float dy, Matrix& u, Matrix& v, Matrix& delta); 
	void Evolve2DVectorWENO(Matrix& phi, float dx, float dy, Matrix& u, Matrix& v, Matrix& delta); 
 
	void Evolve2DVectorENO1(Matrix& phi, double dx, double dy, Matrix& u, Matrix& v, Matrix& delta); 
	void Evolve2DVectorENO2(Matrix& phi, double dx, double dy, Matrix& u, Matrix& v, Matrix& delta); 
	void Evolve2DVectorENO3(Matrix& phi, double dx, double dy, Matrix& u, Matrix& v, Matrix& delta); 
	void Evolve2DVectorWENO(Matrix& phi, double dx, double dy, Matrix& u, Matrix& v, Matrix& delta); 
 
 
	void Evolve2DNormalVectorENO1SignedDistance(Matrix& phi, float dx, float dy, Matrix& u, Matrix& v, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalVectorENO2SignedDistance(Matrix& phi, float dx, float dy, Matrix& u, Matrix& v, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalVectorENO3SignedDistance(Matrix& phi, float dx, float dy, Matrix& u, Matrix& v, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalVectorWENOSignedDistance(Matrix& phi, float dx, float dy, Matrix& u, Matrix& v, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
 
	void Evolve2DNormalVectorENO1SignedDistance(Matrix& phi, double dx, double dy, Matrix& u, Matrix& v, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalVectorENO2SignedDistance(Matrix& phi, double dx, double dy, Matrix& u, Matrix& v, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalVectorENO3SignedDistance(Matrix& phi, double dx, double dy, Matrix& u, Matrix& v, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
	void Evolve2DNormalVectorWENOSignedDistance(Matrix& phi, double dx, double dy, Matrix& u, Matrix& v, Matrix& Vn, Matrix& delta, Matrix& H1Abs, Matrix& H2Abs); 
 
 
	void Evolve2DKappa(Matrix& phi, float dx, float dy, float dx2, float dy2, Matrix& b, Matrix& delta); 
	void Evolve2DKappa(Matrix& phi, double dx, double dy, double dx2, double dy2, Matrix& b, Matrix& delta); 
 
 
	float Getdt2DNormal(float alpha, float dx, float dy, Matrix& H1Abs, Matrix& H2Abs); 
	float Getdt2DNormalVector(float alpha, float dx, float dy, Matrix& H1Abs, Matrix& H2Abs); 
	float Getdt2DVector(float alpha, float dx, float dy, Matrix& u, Matrix& v); 
	float Getdt2DKappa(float alpha, float dx2, float dy2, Matrix& b); 
	float Getdt2DVectorKappa(float alpha, float dx, float dy, float dx2, float dy2, Matrix& u, Matrix& v, Matrix& b); 
	float Getdt2DNormalKappa(float alpha, float dx, float dy, float dx2, float dy2, Matrix& H1Abs, Matrix& H2Abs, Matrix& b); 
	float Getdt2DNormalVectorKappa(float alpha, float dx, float dy, float dx2, float dy2, Matrix& H1Abs, Matrix& H2Abs, Matrix& b); 
 
	double Getdt2DNormal(double alpha, double dx, double dy, Matrix& H1Abs, Matrix& H2Abs); 
	double Getdt2DNormalVector(double alpha, double dx, double dy, Matrix& H1Abs, Matrix& H2Abs); 
	double Getdt2DVector(double alpha, double dx, double dy, Matrix& u, Matrix& v); 
	double Getdt2DKappa(double alpha, double dx2, double dy2, Matrix& b); 
	double Getdt2DVectorKappa(double alpha, double dx, double dy, double dx2, double dy2, Matrix& u, Matrix& v, Matrix& b); 
	double Getdt2DNormalKappa(double alpha, double dx, double dy, double dx2, double dy2, Matrix& H1Abs, Matrix& H2Abs, Matrix& b); 
	double Getdt2DNormalVectorKappa(double alpha, double dx, double dy, double dx2, double dy2, Matrix& H1Abs, Matrix& H2Abs, Matrix& b); 
 
 
 
	void SubtractPhi2D(Matrix& phi, Matrix& delta, float dt); 
	void AddPhi2D(Matrix& phi, Matrix& delta, float dt); 
 
	void SubtractPhi2D(Matrix& phi, Matrix& delta, double dt); 
	void AddPhi2D(Matrix& phi, Matrix& delta, double dt); 
 
 
 
	float KappaAbsPhi2D(float phi_i_j, float phi_ip1_j, float phi_ip1_jp1,  
		float phi_i_jp1, float phi_im1_jp1, float phi_im1_j, float phi_im1_jm1,  
		float phi_i_jm1, float phi_ip1_jm1, float dx, float dy, float dx2, float dy2); 
 
	double KappaAbsPhi2D(double phi_i_j, double phi_ip1_j, double phi_ip1_jp1,  
		double phi_i_jp1, double phi_im1_jp1, double phi_im1_j, double phi_im1_jm1,  
		double phi_i_jm1, double phi_ip1_jm1, double dx, double dy, double dx2, double dy2); 
 
	 
	void ReinitSignedDistanceENO1(Matrix& phi, float dx, float dy, float alpha, int iterations); 
	void ReinitSignedDistanceENO2(Matrix& phi, float dx, float dy, float alpha, int iterations); 
	void ReinitSignedDistanceENO3(Matrix& phi, float dx, float dy, float alpha, int iterations); 
	void ReinitSignedDistanceWENO(Matrix& phi, float dx, float dy, float alpha, int iterations); 
 
	void ReinitSignedDistanceENO1(Matrix& phi, double dx, double dy, double alpha, int iterations); 
	void ReinitSignedDistanceENO2(Matrix& phi, double dx, double dy, double alpha, int iterations); 
	void ReinitSignedDistanceENO3(Matrix& phi, double dx, double dy, double alpha, int iterations); 
	void ReinitSignedDistanceWENO(Matrix& phi, double dx, double dy, double alpha, int iterations); 
 
 
 
	float SelectDerNormal(float phi_x_m, float phi_x_p, float Vn); 
	float SelectDerNormalVectorSD(float phi_x_m, float phi_x_p, float u, float Vn); 
 
	double SelectDerNormal(double phi_x_m, double phi_x_p, double Vn); 
	double SelectDerNormalVectorSD(double phi_x_m, double phi_x_p, double u, double Vn); 
 
 
	float DerENO1Minus(float v1, float v2, float dx); 
	float DerENO1Plus(float v1, float v2, float dx); 
	float DerENO2Minus(float v1, float v2, float v3, float v4, float dx); 
	float DerENO2Plus(float v1, float v2, float v3, float v4, float dx); 
	float DerENO3Minus(float v1, float v2, float v3, float v4, float v5, float v6, float dx); 
	float DerENO3Plus(float v1, float v2, float v3, float v4, float v5, float v6, float dx); 
	float DerWENOMinus(float v1, float v2, float v3, float v4, float v5, float v6, float dx); 
	float DerWENOPlus(float v1, float v2, float v3, float v4, float v5, float v6, float dx); 
 
	double DerENO1Minus(double v1, double v2, double dx); 
	double DerENO1Plus(double v1, double v2, double dx); 
	double DerENO2Minus(double v1, double v2, double v3, double v4, double dx); 
	double DerENO2Plus(double v1, double v2, double v3, double v4, double dx); 
	double DerENO3Minus(double v1, double v2, double v3, double v4, double v5, double v6, double dx); 
	double DerENO3Plus(double v1, double v2, double v3, double v4, double v5, double v6, double dx); 
	double DerWENOMinus(double v1, double v2, double v3, double v4, double v5, double v6, double dx); 
	double DerWENOPlus(double v1, double v2, double v3, double v4, double v5, double v6, double dx); 
 
 
	//inline int Sign(float f) 
	//{ 
	//	if(f>0) 
	//	{ 
	//		return 1; 
	//	} 
	//	else if(f < 0) 
	//	{ 
	//		return -1; 
	//	} 
	//	else 
	//	{ 
	//		return 0; 
	//	} 
	//} 
 
	 
 
 
 
 
 
 
 
 
 
 
 
#include "./LevelSetMethods.inl" 
 
}; //namespace 
 
 
 
#endif