Skip to content

gt2001/generate-2D-quadrilateral-mesh-with-neural-networks-and-tree-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

generate-2D-quadrilateral-mesh-with-neural-networks-and-tree-search

File Description

This repository contains the single-threaded TreeMesh code:

nearly best meshes - state-of-the-art meshes generated by TreeMesh

MCTS.ipynb - Monte-Carlo tree search (a brute force search algorithm)

PPO.ipynb - Proximal Policy Optimization (a deep reinforcement learning algorithm)

Trueseed*.txt - initial boundary coordinates

  1. * == 0: seed-density-changing rectangle
  2. * == 1: pentagonal plate

delete*.bat - initialization tools

record_*.txt - records of the program's performance in each episode

  1. * == test: test reward
  2. * == time: time (s) used for calculation
  3. * == train: train reward
  4. * == loss: loss function
  5. * == round_max_quality: the maximum quality achieved in the last print_every episodes.

results - best meshes

results-ls - best meshes after laplacian smoothing and weight files after every clear_every episodes


Tutorial

At present, the program supports WINDOWS system only. You can run the program on old boundaries to reappear my results in the paper, or run the program on new boundaries with only a few extra steps! Check out the steps below. Skip step 1, 2, and 3 if you only want to play with old boundaries.

  1. Open the latest version folder. You need to input the new boundary (coordinates and density information) to [Coordinate.txt] and then run [Initialization.ipynb]. It will automatically generate the coordinates of all points. Currently we cannot convert .inp file, so you need to input manually.
  2. A full [Coordinate.txt] contains information of one outer boundary and many inner boundaries (only exists if there are holes). Each boundary starts with a string "XBJ" with a number. The number is 0 for the outer boundary, and it increases 1 in turn. The following lines contains coordinates of points that are on the boundary (mostly they are vertexes) and the unit length between the current and the next point. It's worth mentioning that the outer boundary points shall be clockwise, while points on inner boundaries shall be anti-clockwise. The initialization program can intelligently turn the multi connected domain into a single connected domain. Below is an example of a rectangular boundary with three square holes:
  3. Open the latest version folder, and open [PPO.ipynb], scroll down to the penultimate code box that defines all hyper-parameters.
  4. You need to change the following hyper-parameters so as to start a new meshing: max_step, qiangzhishangxian, and quality_threshold. max_step is the estimated maximum step the program can take. I suggest to set it a little larger than the number of quadrilaterals generated by business software. qiangzhishangxian is the maximum step the agent can take choice 0 (to generate a new point) by force. I suggest to set it one tenth of the max_step. Quality_threshold is the maximum quality you expect the program to achieve. It should be a number between 0 and 1. Rememeber to turn on the reminders in the next code box, and the program will stop when achieving this threshold. Similar changes shall be done in [MCTS.ipynb].
  5. Check again whether the boundary file [PPO.ipynb] reads in the last code box is correct. Now you can launch the program.

Contributions

Paper draft link (arXiv): https://arxiv.org/abs/2111.07613

Present performance:

Pentagonal plate: 0.9106 (5.3204% better than ABAQUS: 0.8646, 1.4822% better than FreeMesh-S: 0.8973)

Seed-density-changing rectangle: 0.8011 (13.8573% better than ABAQUS: 0.7036)


Update Log

This is a long-term on-going project. New updates will be written here (e.g. code updates, .pdf meshes, and .pdf reports). Please do not distribute these files to other websites.

11.13.2021[0]: Completed the original version of single-threaded TreeMesh (this version is released).

11.19.2021[1]: Fixed the problem in [delete.bat] that does not delete record text files every time.

11.20.2021[2]: Added the force-choice mechanism in [PPO.ipynb] that gives the agent 2 chances to choose type 0 in an episode. This also leads to a higher search efficiency in [MCTS.ipynb].

11.20.2021[3]: Added an input box before launching [delete.bat] in [PPO.ipynb] to avoid deleting/replacing records by mistake.

11.28.2021[4]: Optimized [PPO.ipynb] to accelerate calculation speed and save disk space.

11.30.2021[5]: Updated [MCTS.ipynb] to fit the new mechanism in [PPO.ipynb] (this version is released).

About

single-threaded TreeMesh

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published