⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myfunction.cpp

📁 FreeFem++可以生成高质量的有限元网格。可以用于流体力学
💻 CPP
字号:
// Example C++ function "myfunction", dynamically loaded into "load.edp"// ---------------------------------------------------------------------// $Id: myfunction.cpp,v 1.5 2008/07/23 20:11:51 hecht Exp $#include  <iostream>#include  <cfloat>using namespace std;#include "error.hpp"#include "AFunction.hpp"#include "rgraph.hpp"#include "RNM.hpp"#include "fem.hpp"#include "FESpace.hpp" #include "MeshPoint.hpp"using namespace Fem2D;double myfunction(Stack stack){  //  to get FreeFem++  data  MeshPoint &mp= *MeshPointStack(stack); // the struct to get x,y, normal , value   double x= mp.P.x; // get the current x value  double y= mp.P.y; // get the current y value  // cout << "x = " << x << " y=" << y << " " << sin(x)*cos(y) <<  endl;  return sin(x)*cos(y);}//  A class build the link with freefem++ // generaly this class are already in AFunction.hpp// but unfortunatly, I have no simple function with no parameter// in freefem++ depending of the mesh,  template<class R>class  OneOperator0s : public OneOperator {  // the class to defined a evaluated a new function   //  It  must devive from  E_F0 if it is mesh independent  //   or from E_F0mps if it is mesh dependent   class E_F0_F :public  E_F0mps { public:       typedef  R (*func)(Stack stack) ;     func f; // the pointeur to the fnction myfunction     E_F0_F(func ff)  : f(ff) {}    // the operator evaluation in freefem++     AnyType operator()(Stack stack)  const {return SetAny<R>( f(stack)) ;}    };  typedef  R (*func)(Stack ) ;   func  f; public:   // the function which build the freefem++ byte code   E_F0 * code(const basicAC_F0 & ) const { return  new E_F0_F(f);}   // the constructor to say ff is a function without parameter  // and returning a R  OneOperator0s(func  ff): OneOperator(map_type[typeid(R).name()]),f(ff){}};//  Hack to do something at initialisation time//   to add the name myfunction to the freefem++ table class Init { public:  Init();};Init init;Init::Init(){  Global.Add("myfunction","(",new OneOperator0s<double>(myfunction));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -