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

📄 tdrawarea2d.cpp

📁 crack modeling with xfem
💻 CPP
字号:
/* 2008 (c) Dorival M. Pedroso */// STL#include <iostream>#include <cmath>// FLTK#include <FL/Fl.H>#include <FL/Fl_Double_Window.H>// Local#include "array.h"#include "fatal.h"#include "grid2d.h"#include "chull2d.h"#include "mpoints2d.h"#include "drawarea2d.h"using std::cout;using std::endl;// Function which detects if a mat point is inside the geomtrybool IsPointInGeom (Vector3D const & P){	double xc = 5.0; // centre of the disk	double yc = 3.5; // centre of the disk	double r  = 2.0; // radius of the disk	double d = sqrt(pow(P(0)-xc,2.0)+pow(P(1)-yc,2.0)); // distance to the centre	if (d<=r) return true;	else      return false;}Model2D * AllocMdl (Vector3D const & P) { return NULL; }void      IniVeloc (Vector3D const & P, Vector3D & v) { v = 1.0, 1.0, 0.0; }bool      HasTraction (Array<Vector3D> const & N, Array<Vector3D> & T) { return false; }/////////////////////////////////////////////////////////////////////////////////////////////// MainWindow /////// MainWindowclass MainWindow : public Fl_Double_Window{public:	// Constructor	MainWindow(int width=800, int height=600)		: Fl_Double_Window (width,height,"Test DrawArea2D"),		  _g(NULL), _p(NULL)	{		// Add widgets to window		begin();			// Widgets			_wda = new DrawArea2D (/*xmin*/10, /*ymin*/10, /*width*/780, /*height*/580);		end();		// Set background color		this->color(0xefebe700);		// Allocate grid		_g = new Grid2D (/*xMin*/0, /*yMin*/0, /*nRow*/17, /*nCol*/23, /*Lx*/0.4, /*Ly*/0.4);		// Set fixed nodes		for (size_t i=0; i<_g->nNodes(); ++i)		{			double x = _g->N(i)(0);			double y = _g->N(i)(1);			if (fabs(x-0.0)<1e-4) _g->SetFixed (i, FIX_XY);			if (fabs(y-0.0)<1e-4) _g->SetFixed (i, FIX_Y);			if (fabs(x-8.8)<1e-4) _g->SetFixed (i, FIX_X);		}		// Allocate material points		_p = new MPoints2D (/*nPcell*/4, _g, &IsPointInGeom, &AllocMdl, &IniVeloc, &HasTraction);		// Find points on boundary (will sort points)		Array<size_t> H;		CHull2D (_p->Ps(), H);		for (size_t i=0; i<H.Size(); ++i)		{			Vector3D v; v = 0, 1.0, 0;			_p->SetBry(H[i], /*m*/10, /*V*/20, v);		}		// Add some extra points		Vector3D p,v;		p=2.8,3.5,0; v=-1,0,0;  _p->Push (p, /*IsBry*/true, /*m*/1, /*V*/2, v);		p=7.2,3.5,0; v=-2,0,0;  _p->Push (p, /*IsBry*/true, /*m*/1, /*V*/2, v);		p=5.0,1.6,0; v= 0,2,0;  _p->Push (p, /*IsBry*/true, /*m*/1, /*V*/2, v);		p=5.0,5.4,0; v=-2,0,0;  _p->Push (p, /*IsBry*/true, /*m*/1, /*V*/2, v);		// Set time		_t = 0.0;		_wda->SetTime (&_t);		// Set DrawArea2D and MPoints2D		_wda->RecalcSF  (true);		_wda->SetGrid   (_g);		_wda->SetPoints (_p);		// Set resizable and show window		resizable (this);		show      ();	}	// Destructor	~MainWindow()	{		if (_g!=NULL) delete _g;		if (_p!=NULL) delete _p;	}private:	// Widgets	DrawArea2D * _wda; 	// Variables	Grid2D    * _g; // grid	MPoints2D * _p; // mat points	double      _t; // time}; // class MainWindow/////////////////////////////////////////////////////////////////////////////////////////////// MainWindow /////int main(int argc, char **argv) try{	MainWindow win;	Fl::run();	return 0;}catch (Fatal * f) //{{{ {	f->Cout();	delete f;	exit (1);}catch (char const * m){	std::cout << "Fatal: " << m << std::endl;	exit (1);}catch (...){	std::cout << "Some exception (...) ocurred\n";} //}}} /* 2008 (c) Dorival M. Pedroso */

⌨️ 快捷键说明

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