Gmsh剖三维网格教程附代码

前言

前面写过三篇关于Gmsh的教程:

  1. 有限元剖网格之Gmsh安装与使用入门
  2. Gmsh剖一维网格教程附代码
  3. Gmsh剖二维网格教程附代码

以上文章对Gmsh都有一定的介绍,在此不再重复直接接剖三维网格的C++代码。
注:因有一个OpenCASCADE库暂时没安装好,所以目前只能用插点,连线,线连面,面拼体的方式构造三维几何体。

一、程序代码

#include <iostream>
#include <gmsh.h>
#include <vector> 
#include <fstream>
#include <iomanip>
using namespace std;

int main(int argc, char **argv)
{
   
   
	// Before using any functions in the C++ API, Gmsh must be initialized.
	gmsh::initialize();
	// By default Gmsh will not print out any messages: in order to output
	// messages on the terminal, just set the standard Gmsh option
	// "General.Terminal" (same format and meaning as in .geo files) using
	// gmsh::option::setNumber():
	gmsh::option::setNumber("General.Terminal", 1);

	// This adds a new model, named "t1". If gmsh::model::add() is not called, a
	// new default (unnamed) model will be created on the fly, if necessary.
	gmsh::model::add("Test1");
	// The C++ API provides direct access to the internal CAD kernels. The
    // built-in CAD kernel was used in t1.geo: the corresponding API functions
    // live in the "gmsh::model::geo" namespace. To create geometrical points with
    // the built-in CAD kernel, one thus uses gmsh::model::geo::addPoint():
    //
    // - the first 3 arguments are the point coordinates (x, y, z)
    //
    // - the next (optional) argument is the target mesh size close to the point
    //
    // - the last (optional) argument is the point tag

  	double lc = 1;
    int pIndex = 1;
  	gmsh::model::geo::addPoint(-4, -4,  -4, lc, pIndex++);
  	gmsh::model::geo::addPoint(4,  -4,  -4
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值