407 lines
9.7 KiB
Markdown
407 lines
9.7 KiB
Markdown
|
|
---
|
|||
|
|
license: apache-2.0
|
|||
|
|
language:
|
|||
|
|
- en
|
|||
|
|
tags:
|
|||
|
|
- text-generation
|
|||
|
|
- code-generation
|
|||
|
|
- code-completion
|
|||
|
|
- text-to-code
|
|||
|
|
- natural-language-to-code
|
|||
|
|
- code-synthesis
|
|||
|
|
- program-synthesis
|
|||
|
|
- code-llm
|
|||
|
|
- coding-assistant
|
|||
|
|
- engineering-code-generation
|
|||
|
|
- large-language-model
|
|||
|
|
- llm
|
|||
|
|
- generative-ai
|
|||
|
|
- causal-lm
|
|||
|
|
- decoder-only
|
|||
|
|
- transformer
|
|||
|
|
- transformers
|
|||
|
|
- autoregressive
|
|||
|
|
- instruction-following
|
|||
|
|
- instruction-tuned
|
|||
|
|
- instruct
|
|||
|
|
- fine-tuned
|
|||
|
|
- fine-tuned-llm
|
|||
|
|
- domain-specific-llm
|
|||
|
|
- specialized-llm
|
|||
|
|
- engineering-llm
|
|||
|
|
- scientific-llm
|
|||
|
|
- reasoning
|
|||
|
|
- engineering-reasoning
|
|||
|
|
- mathematical-reasoning
|
|||
|
|
- numerical-reasoning
|
|||
|
|
- problem-solving
|
|||
|
|
- engineering-ai
|
|||
|
|
- ai-for-engineering
|
|||
|
|
- ai-for-science
|
|||
|
|
- scientific-ai
|
|||
|
|
- computational-science
|
|||
|
|
- scientific-computing
|
|||
|
|
- computational-engineering
|
|||
|
|
- engineering-simulation
|
|||
|
|
- simulation
|
|||
|
|
- simulation-automation
|
|||
|
|
- simulation-tools
|
|||
|
|
- computer-aided-engineering
|
|||
|
|
- cae
|
|||
|
|
- engineering-tools
|
|||
|
|
- engineering-automation
|
|||
|
|
- computational-physics
|
|||
|
|
- numerical-methods
|
|||
|
|
- numerical-analysis
|
|||
|
|
- numerical-simulation
|
|||
|
|
- physics-simulation
|
|||
|
|
- multiphysics
|
|||
|
|
- pde
|
|||
|
|
- partial-differential-equations
|
|||
|
|
- pde-solver
|
|||
|
|
- solver
|
|||
|
|
- numerical-solver
|
|||
|
|
- boundary-conditions
|
|||
|
|
- mesh-generation
|
|||
|
|
- mesh-generator
|
|||
|
|
- mesh-generation-ai
|
|||
|
|
- ai-meshing
|
|||
|
|
- meshing
|
|||
|
|
- computational-meshing
|
|||
|
|
- mesh-automation
|
|||
|
|
- automated-meshing
|
|||
|
|
- automatic-mesh-generation
|
|||
|
|
- mesh-processing
|
|||
|
|
- mesh-quality
|
|||
|
|
- mesh-quality-improvement
|
|||
|
|
- mesh-refinement
|
|||
|
|
- adaptive-mesh-refinement
|
|||
|
|
- amr
|
|||
|
|
- mesh-optimization
|
|||
|
|
- mesh-smoothing
|
|||
|
|
- mesh-repair
|
|||
|
|
- mesh-conversion
|
|||
|
|
- mesh-analysis
|
|||
|
|
- surface-mesh
|
|||
|
|
- surface-meshing
|
|||
|
|
- volume-mesh
|
|||
|
|
- volume-meshing
|
|||
|
|
- structured-mesh
|
|||
|
|
- structured-meshing
|
|||
|
|
- unstructured-mesh
|
|||
|
|
- unstructured-meshing
|
|||
|
|
- hybrid-mesh
|
|||
|
|
- hybrid-meshing
|
|||
|
|
- triangular-mesh
|
|||
|
|
- triangle-mesh
|
|||
|
|
- quadrilateral-mesh
|
|||
|
|
- quad-mesh
|
|||
|
|
- tetrahedral-mesh
|
|||
|
|
- tetrahedral-meshing
|
|||
|
|
- tet-mesh
|
|||
|
|
- hexahedral-mesh
|
|||
|
|
- hexahedral-meshing
|
|||
|
|
- hex-mesh
|
|||
|
|
- prism-mesh
|
|||
|
|
- prism-layer
|
|||
|
|
- boundary-layer
|
|||
|
|
- boundary-layer-mesh
|
|||
|
|
- boundary-layer-meshing
|
|||
|
|
- o-grid
|
|||
|
|
- geometry-processing
|
|||
|
|
- computational-geometry
|
|||
|
|
- geometry-generation
|
|||
|
|
- geometry-repair
|
|||
|
|
- geometry-optimization
|
|||
|
|
- cad
|
|||
|
|
- cad-modeling
|
|||
|
|
- cad-automation
|
|||
|
|
- cad-to-mesh
|
|||
|
|
- geometry
|
|||
|
|
- step
|
|||
|
|
- step-format
|
|||
|
|
- iges
|
|||
|
|
- stl
|
|||
|
|
- cgns
|
|||
|
|
- msh
|
|||
|
|
- msh-format
|
|||
|
|
- geo
|
|||
|
|
- geo-format
|
|||
|
|
- gmsh
|
|||
|
|
- gmsh-api
|
|||
|
|
- gmsh-python
|
|||
|
|
- gmsh-code
|
|||
|
|
- gmsh-script
|
|||
|
|
- gmsh-scripting
|
|||
|
|
- gmsh-meshing
|
|||
|
|
- openfoam
|
|||
|
|
- openfoam-meshing
|
|||
|
|
- snappyhexmesh
|
|||
|
|
- cfmesh
|
|||
|
|
- finite-element-analysis
|
|||
|
|
- fea
|
|||
|
|
- finite-element-method
|
|||
|
|
- fem
|
|||
|
|
- computational-fluid-dynamics
|
|||
|
|
- cfd
|
|||
|
|
- cfd-meshing
|
|||
|
|
- cfd-simulation
|
|||
|
|
- finite-volume-method
|
|||
|
|
- fvm
|
|||
|
|
- finite-difference-method
|
|||
|
|
- fdm
|
|||
|
|
- computational-mechanics
|
|||
|
|
- continuum-mechanics
|
|||
|
|
- solid-mechanics
|
|||
|
|
- structural-mechanics
|
|||
|
|
- structural-analysis
|
|||
|
|
- stress-analysis
|
|||
|
|
- fluid-mechanics
|
|||
|
|
- fluid-dynamics
|
|||
|
|
- aerodynamics
|
|||
|
|
- heat-transfer
|
|||
|
|
- thermal-analysis
|
|||
|
|
- mechanical-engineering
|
|||
|
|
- aerospace-engineering
|
|||
|
|
- automotive-engineering
|
|||
|
|
- civil-engineering
|
|||
|
|
- structural-engineering
|
|||
|
|
- simulation-engineering
|
|||
|
|
- cae-ai
|
|||
|
|
- cfd-ai
|
|||
|
|
- fea-ai
|
|||
|
|
- pytorch
|
|||
|
|
- huggingface
|
|||
|
|
- transformers-library
|
|||
|
|
- safetensors
|
|||
|
|
- gguf
|
|||
|
|
- ggml
|
|||
|
|
- llama-cpp
|
|||
|
|
- llama-cpp-python
|
|||
|
|
- quantized
|
|||
|
|
- quantization
|
|||
|
|
- low-bit-quantization
|
|||
|
|
- local-llm
|
|||
|
|
- local-ai
|
|||
|
|
- local-inference
|
|||
|
|
- offline-inference
|
|||
|
|
- edge-ai
|
|||
|
|
- edge-inference
|
|||
|
|
- cpu-inference
|
|||
|
|
- on-device
|
|||
|
|
- on-device-ai
|
|||
|
|
- 8b
|
|||
|
|
- 8b-parameters
|
|||
|
|
- open-model
|
|||
|
|
- open-source
|
|||
|
|
- english
|
|||
|
|
---
|
|||
|
|
# GmshNet-8B-v0.1
|
|||
|
|
|
|||
|
|
GmshNet-8B-v0.1 is an open-source, dense, decoder-only 8B parameter large language model specializing in **Gmsh 4.x meshing scripts**, designed to produce structured analyses and generate robust geometry meshes through **chain-of-thought reasoning**.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
## Quickstart
|
|||
|
|
|
|||
|
|
### Install Dependencies
|
|||
|
|
```
|
|||
|
|
pip install -U torch transformers accelerate
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### Run Inference
|
|||
|
|
|
|||
|
|
```python
|
|||
|
|
import torch
|
|||
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|||
|
|
|
|||
|
|
# Input your prompt here
|
|||
|
|
USER_INPUT = """
|
|||
|
|
Create a 2D finite element mesh for a rectangular steel plate measuring 100 mm by 60 mm with a circular hole of radius 10 mm at its center (a classic stress-concentration test case). Refine the mesh around the hole to capture the stress gradient and use a coarser mesh near the outer edges. Define physical groups for the outer boundary and the hole so the mesh can be used for a finite element stress analysis.
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
def load_model(model_path):
|
|||
|
|
model = AutoModelForCausalLM.from_pretrained(
|
|||
|
|
model_path,
|
|||
|
|
torch_dtype=torch.float16,
|
|||
|
|
device_map="auto",
|
|||
|
|
trust_remote_code=True
|
|||
|
|
)
|
|||
|
|
tokenizer = AutoTokenizer.from_pretrained(
|
|||
|
|
model_path,
|
|||
|
|
trust_remote_code=True
|
|||
|
|
)
|
|||
|
|
with open(f"{model_path}/chat_template.jinja", "r") as f:
|
|||
|
|
tokenizer.chat_template = f.read()
|
|||
|
|
return model, tokenizer
|
|||
|
|
|
|||
|
|
def generate_response(model, tokenizer, user_input):
|
|||
|
|
formatted_input = f"<gmsh_instruction>{user_input.strip()}</gmsh_instruction>"
|
|||
|
|
messages = [{"role": "user", "content": formatted_input}]
|
|||
|
|
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
|||
|
|
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
|||
|
|
outputs = model.generate(
|
|||
|
|
**inputs,
|
|||
|
|
max_new_tokens=2000,
|
|||
|
|
do_sample=True,
|
|||
|
|
temperature=0.2,
|
|||
|
|
top_k=20,
|
|||
|
|
top_p=0.8,
|
|||
|
|
repetition_penalty=1.1,
|
|||
|
|
pad_token_id=tokenizer.eos_token_id
|
|||
|
|
)
|
|||
|
|
response = tokenizer.decode(outputs[0], skip_special_tokens=False)
|
|||
|
|
return response.split("<|im_start|>assistant\n")[-1].replace("<|im_end|>", "").strip()
|
|||
|
|
|
|||
|
|
def run_inference():
|
|||
|
|
model_path = "" # Path to your model weights
|
|||
|
|
model, tokenizer = load_model(model_path)
|
|||
|
|
result = generate_response(model, tokenizer, USER_INPUT)
|
|||
|
|
print(result)
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
run_inference()
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## Example Output
|
|||
|
|
|
|||
|
|
~~~
|
|||
|
|
<think>
|
|||
|
|
I need to analyze this meshing task step by step to create an effective GMSH script.
|
|||
|
|
|
|||
|
|
1. Geometry Requirements:
|
|||
|
|
- Main domain: 100mm × 60mm rectangular plate
|
|||
|
|
- Internal feature: Circular hole of radius 10mm at center
|
|||
|
|
- Need refinement around hole for stress gradient capture
|
|||
|
|
- Coarser mesh near outer edges
|
|||
|
|
|
|||
|
|
2. Meshing Approach:
|
|||
|
|
- Unstructured triangular mesh for flexibility
|
|||
|
|
- Size field to control refinement (finer near hole, coarser near edges)
|
|||
|
|
- Physical groups for boundaries and hole surface
|
|||
|
|
- Potential quadrilateral recombination in structured regions if needed
|
|||
|
|
|
|||
|
|
3. Construction Steps:
|
|||
|
|
a) Create rectangle points and lines
|
|||
|
|
b) Create circle points and arcs
|
|||
|
|
c) Define line loops for plate and hole
|
|||
|
|
d) Create plane surface with hole
|
|||
|
|
e) Set mesh size fields for refinement
|
|||
|
|
f) Define physical groups
|
|||
|
|
g) Generate 2D mesh
|
|||
|
|
</think>
|
|||
|
|
<response>
|
|||
|
|
1. High-level Overview:
|
|||
|
|
- We'll create a rectangular plate with a circular hole at center
|
|||
|
|
- Use size field to refine mesh near hole (radius 5mm from center)
|
|||
|
|
- Coarser mesh grows outward from outer edges
|
|||
|
|
- Physical groups for boundaries and hole surface
|
|||
|
|
|
|||
|
|
2. Step-by-step Instructions:
|
|||
|
|
a) Create rectangle points (4 corners)
|
|||
|
|
b) Connect with lines to form boundary
|
|||
|
|
c) Create circle points (center + 4 quadrants)
|
|||
|
|
d) Connect circle points with arcs
|
|||
|
|
e) Define line loops for plate and hole
|
|||
|
|
f) Create surface with hole
|
|||
|
|
g) Set mesh size field with Attractor near hole
|
|||
|
|
h) Define physical groups
|
|||
|
|
i) Generate mesh
|
|||
|
|
|
|||
|
|
3. Complete GMSH Script:
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
// Rectangular Plate with Hole - Stress Concentration Test Case
|
|||
|
|
|
|||
|
|
// Geometry Parameters
|
|||
|
|
plate_length = 100;
|
|||
|
|
plate_width = 60;
|
|||
|
|
hole_radius = 10;
|
|||
|
|
|
|||
|
|
// Mesh Sizing Parameters
|
|||
|
|
base_size = 5; // Base mesh size
|
|||
|
|
hole_refine = 1.0; // Size at hole center
|
|||
|
|
hole_growth = 2.0; // Growth rate from hole to outer edges
|
|||
|
|
|
|||
|
|
// Create Rectangle Points
|
|||
|
|
Point(1) = {0, 0, 0, base_size};
|
|||
|
|
Point(2) = {plate_length, 0, 0, base_size};
|
|||
|
|
Point(3) = {plate_length, plate_width, 0, base_size};
|
|||
|
|
Point(4) = {0, plate_width, 0, base_size};
|
|||
|
|
|
|||
|
|
// Create Rectangle Edges
|
|||
|
|
Line(1) = {1, 2};
|
|||
|
|
Line(2) = {2, 3};
|
|||
|
|
Line(3) = {3, 4};
|
|||
|
|
Line(4) = {4, 1};
|
|||
|
|
|
|||
|
|
// Create Hole Points (center + 4 quadrants)
|
|||
|
|
Point(5) = {plate_length/2, plate_width/2, 0, hole_refine}; // Center
|
|||
|
|
Point(6) = {plate_length/2 + hole_radius, plate_width/2, 0, hole_refine};
|
|||
|
|
Point(7) = {plate_length/2, plate_width/2 + hole_radius, 0, hole_refine};
|
|||
|
|
Point(8) = {plate_length/2 - hole_radius, plate_width/2, 0, hole_refine};
|
|||
|
|
Point(9) = {plate_length/2, plate_width/2 - hole_radius, 0, hole_refine};
|
|||
|
|
|
|||
|
|
// Create Hole Arcs
|
|||
|
|
Circle(5) = {6, 5, 7};
|
|||
|
|
Circle(6) = {7, 5, 8};
|
|||
|
|
Circle(7) = {8, 5, 9};
|
|||
|
|
Circle(8) = {9, 5, 6};
|
|||
|
|
|
|||
|
|
// Define Line Loops
|
|||
|
|
Line Loop(1) = {1, 2, 3, 4}; // Outer boundary
|
|||
|
|
Line Loop(2) = {5, 6, 7, 8}; // Hole boundary
|
|||
|
|
|
|||
|
|
// Create Surface with Hole
|
|||
|
|
Plane Surface(1) = {1, 2};
|
|||
|
|
|
|||
|
|
// Mesh Size Field - Refinement near hole
|
|||
|
|
Field[1] = Distance;
|
|||
|
|
Field[1].NodesList = {5}; // Center point of hole
|
|||
|
|
Field[2] = Threshold;
|
|||
|
|
Field[2].IField = 1;
|
|||
|
|
Field[2].LcMin = hole_refine;
|
|||
|
|
Field[2].LcMax = base_size;
|
|||
|
|
Field[2].DistMin = hole_radius;
|
|||
|
|
Field[2].DistMax = plate_length/4;
|
|||
|
|
Background Field = 2;
|
|||
|
|
|
|||
|
|
// Physical Groups
|
|||
|
|
Physical Curve("OuterBoundary", 1) = {1, 2, 3, 4};
|
|||
|
|
Physical Curve("HoleBoundary", 2) = {5, 6, 7, 8};
|
|||
|
|
Physical Surface("Plate", 1) = {1};
|
|||
|
|
|
|||
|
|
// Mesh Settings
|
|||
|
|
Mesh.Algorithm = 6; // Frontal-Delaunay
|
|||
|
|
Mesh.Smoothing = 5; // More smoothing iterations
|
|||
|
|
|
|||
|
|
// Generate 2D Mesh
|
|||
|
|
Mesh 2;
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
4. Implementation Notes:
|
|||
|
|
- To run: Open in GMSH → Mesh → 2D
|
|||
|
|
- Adjust parameters at top for different sizes/resolutions
|
|||
|
|
- Visualize geometry (Geometry tab) before meshing to verify
|
|||
|
|
- For quadrilateral mesh near hole, add:
|
|||
|
|
```
|
|||
|
|
Mesh.RecombineAll = 1;
|
|||
|
|
Mesh.Algorithm = 8; // Delaunay for quads
|
|||
|
|
```
|
|||
|
|
- Common errors to avoid:
|
|||
|
|
- Ensure line loops are properly closed
|
|||
|
|
- Verify point IDs in circle definitions
|
|||
|
|
- Check that surface includes both line loops (plate and hole)
|
|||
|
|
</response>
|
|||
|
|
~~~
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## Feedback
|
|||
|
|
|
|||
|
|
Tried the model? We'd love to hear how it went! It takes about a minute:
|
|||
|
|
|
|||
|
|
**[Share your feedback →](https://forms.gle/D3AYvTnhs67wV29t9)**
|