我正在尝试构建一个非常简单的网格。我有一个盒子:
box_size = 50;
lb = 10.;
Point(1) = {-box_size/2, -box_size/2, -box_size/2, lb};
Point(2) = {box_size/2, -box_size/2, -box_size/2, lb};
Point(3) = {box_size/2, box_size/2, -box_size/2, lb};
Point(4) = {-box_size/2, box_size/2, -box_size/2, lb};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(5) = {1, 2, 3, 4};
Plane Surface(6) = {5};
Extrude {0, 0, box_size} {
Surface{6};
}
这工作得很好,gmsh很乐意(3D)网格化它。问题是,我要确保框内的某些点是节点。所以我的问题是,我如何确保这些点,比如
lc = 10;
Point(5) = {7.150548, 1.000000, -6.990684, lc};
Point(6) = {-4.438894, 1.000000, -8.960816, lc};
Point(7) = {-9.893936, 1.000000, 1.452595, lc};
Point(8) = {-1.675894, 1.000000, 9.858569, lc};
Point(9) = {8.858176, 1.000000, 4.640336, lc};
Point(10) = {1.675894, 4.750000, -9.858569, lc};
Point(11) = {-8.858176, 4.750000, -4.640336, lc};
Point(12) = {-7.150548, 4.750000, 6.990684, lc};
Point(13) = {4.438894, 4.750000, 8.960816, lc};
Point(14) = {9.893936, 4.750000, -1.452595, lc};
Point(15) = {7.150548, 8.500000, -6.990684, lc};
是网格的一部分吗?
我之所以需要这样做,是因为我需要在这些特定的点上施加边界条件。
如果这在另一个软件中更容易,我也很乐意改变。我希望有人能帮忙。
提前谢谢。
这是一个很晚的答案,但无论如何可能会有所帮助。如果点的索引为p,体积或表面的索引为q,则:
Point{p} In Volume {q};
或者如果它在表面上:
Point{p} In Surface {q};
bertbk使用gmsh自己的地理接口语法很好地回答了这个问题。由于还有一个python接口,让我展示一下嵌入是如何在那里完成的。
import gmsh
import numpy as np
# in this example I demonstrate how to
# embed points in a line
gmsh.initialize()
gmsh.model.add('embedded_points_in_interval')
# I do this in 1D, it works in 2D, 3D in the same way
# some points you want in the mesh
N=10
x_internal = np.linspace(0,1,N)
# let's make local mesh size at each point so large that the
# final mesh only contains the line, start point, end point
# and embedded points
lc = 10
internal_tags = []
for x in x_internal:
# adds each point to the model
tag = gmsh.model.geo.add_point(x, 0, 0, lc)
# collect their tags, we need them for embedding them
# later in the line
internal_tags.append(tag)
# add starting and endpoint of line
p_start = gmsh.model.geo.add_point(-1, 0, 0, lc)
p_end = gmsh.model.geo.add_point(2, 0, 0, lc)
# make line from point tags p_start and p_end
line_tag = gmsh.model.geo.add_line(p_start,p_end)
# call synchronization to make CAD kernel aware of everything
gmsh.model.geo.synchronize()
# embed all internal points
# dim = 0 since we embed points
# inDim = 1 since target is a line
#
# from gmsh.py, calling signature:
# def embed(dim, tags, inDim, inTag):
gmsh.model.mesh.embed(0, internal_tags,1, line_tag)
# generate 1d mesh
# since lc is so large, it will only contain
# start point end point, line and the embedded points
gmsh.model.mesh.generate(1)
gmsh.write("embedded_points_in_interval.msh")
gmsh.finalize()
我认为唯一的选择是分割结构,使它们以你的点为特征,然后对结构进行网格划分。现在,您可以在"物理点"或"物理线"上应用负载和条件。
示例:如果您有一个要进行网格划分的立方体。边界条件是在中心的平面上,然后在该平面上划分立方体。使平面成为一个物理实体,即物理曲面(14)={中平面数}。将其全部网格化,你就可以开始了!