📄 mech.h
字号:
#include "grid.h"
#include "profiler.h"
struct interim_rect: public rect<real>
{
int id;
int aindex;
int bindex;
};
struct interim_bound: public bound_cond
{
int id;
Orientation o;
};
template<class T,int dimx,int dimy>
class edge_helper{
public:
edge_helper(T *init):a(init){}
inline T& operator()(int x,int y){ return a[x + dimx/2 + (y + dimy/2)*dimx]; }
inline const T& operator()(int x,int y) const { return a[x + dimx/2 + (y + dimy/2)*dimx]; }
operator T*(){return a;}
private:
T *a;
};
class mech
{
typedef edge_helper<const node *,3,3> edge9_t;
public:
struct simple_grid
{
simple_grid(const grid &);
const node *a;
int width, height;
rect<int> bound;
node minvalue;
node maxvalue;
real dx, dy;
};
mech();
~mech();
int read_file(const char *filename);
int save_to_file(const char *filename);
const rect<int>& get_bounds() const { return bounds; }
list<simple_grid> lock_grids();
void release_grids();
real getdt(){ return dt; }
real getdx(){ return dx; }
real getdy(){ return dy; }
real getR(){ return R; }
real getmu(){ return mu; }
real getlambda(){ return lambda; }
real getCv(){ return Cv; }
real mass(){ return total_mass; }
const node& at(int x,int y);
real solve();
private:
real solve5();
real solve9();
int construct_grids(list<interim_rect> &g,const list<interim_bound> &b,const bound_cond &defbounds,const node &init);
const node* get_bound(const grid *g,int x,int y);
int solve_equation(node *result,
const node *center,
const node *left,
const node *top,
const node *right,
const node *bottom,
real dx,real dy,real dt);
int solve_equation9(node *r,const edge9_t &edge,real dx,real dy,real dt);
static void tau(const edge9_t &edge,real tau_values[4]);
real dx,dy,dt;
real R, mu, lambda, Cv, Cp;
real total_mass;
grid *grids;
int *links;
size_t count;
rect<int> bounds;
profiler prof;
double last_calc_time;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -