Commit d1d5fb7d authored by Baptiste Durand's avatar Baptiste Durand

New design for the pantograph beam (E11 floppy mode only) + Adaptation of Gmsh2DPartFromRVE

Gmsh2DPartFromRVE : This function can now be used even when the RVE contains several domains.
pantograph_E11only_RVE : Modified to avoid creating a geometry  with junctions two times thinner on the horizontal borders.
parent e3e3a3de
......@@ -24,7 +24,7 @@ class PhysicalGroup(object):
all_groups = dict()
def __init__(self, entities, geo_dim, name=None):
def __init__(self, entities, geo_dim, name="", tag=0):
"""
Gather multiple instances of one of the geometrical Python classes
(Point, Curve, PlaneSurface) to form a single object in the gmsh model.
......@@ -42,6 +42,8 @@ class PhysicalGroup(object):
Geometrical dimension of the entities that are gathered.
name : string, optional
name of the group.
tag : int
Impose a tag.
"""
try:
......@@ -53,6 +55,8 @@ class PhysicalGroup(object):
self.dim = geo_dim
self.name = name
self.tag = None
if tag:
self._tag = tag
try:
PhysicalGroup.all_groups[self.dim].append(self)
except KeyError:
......@@ -68,7 +72,11 @@ class PhysicalGroup(object):
item.add_gmsh()
tags.append(item.tag)
factory.synchronize()
self.tag = model.addPhysicalGroup(self.dim, tags)
try:
self.tag = model.addPhysicalGroup(self.dim, tags, self._tag)
except AttributeError:
self.tag = model.addPhysicalGroup(self.dim, tags)
# ! TEMPORAIRE, un appel à synchronize devrait pouvoir être enlevé.
logger.info(f"Physical group {self.tag} of dim {self.dim} added to gmsh")
phy_before = model.getPhysicalGroups()
......@@ -87,6 +95,13 @@ class PhysicalGroup(object):
if self.name:
model.setPhysicalName(self.dim, self.tag, self.name)
def remove_gmsh(self):
"""
Remove this physical group of the current model
"""
model.removePhysicalGroups([(self.dim, self.tag)])
self.tag = None
def add_to_group(self, entities):
"""
Add geometrical entities to an existing physical group.
......@@ -132,6 +147,8 @@ class PhysicalGroup(object):
Make only entities that belong to at least one physical group visible,
or make all geometrical entities visibles.
Only physical groups that are active in the gmsh model are taken into account.
Parameters
----------
val : bool
......@@ -143,7 +160,8 @@ class PhysicalGroup(object):
dimtags = list()
for gps in cls.all_groups.values():
for gp in gps:
dimtags += [(gp.dim, ent.tag) for ent in gp.entities]
if gp.tag:
dimtags += [(gp.dim, ent.tag) for ent in gp.entities]
model.setVisibility(dimtags, 1, recursive=True)
else:
model.setVisibility(model.getEntities(), 1)
......
......@@ -132,7 +132,11 @@ class LineLoop(object):
self.info_offset = True
for i in range(len(self.vertices)):
new_vrtces[i - 1] = offset(
self.vertices[i - 1], self.vertices[i - 2], self.vertices[i], t, method=method
self.vertices[i - 1],
self.vertices[i - 2],
self.vertices[i],
t,
method=method,
)
self.offset_dpcmt = [
np.linalg.norm(new.coord - prev.coord)
......@@ -415,7 +419,7 @@ def surface_bool_intersect(body, tool):
ops_output.append(outpt)
else: # Tool entirely outside of body or entirely inside.
t_copy_dimtag = factory.copy([(2, t.tag)])
factory.synchronize() # * Peut être supprimé
factory.synchronize() # ! Peut être supprimé ?
outpt = factory.intersect(
[(2, body.tag)], t_copy_dimtag, removeObject=False, removeTool=True
)
......
......@@ -429,9 +429,25 @@ def Gmsh2DPartFromRVE(cell: Gmsh2DRVE, nb_cells, part_name=None):
all_surfaces = cell_surfaces_by_gp[i] + list(
flatten(repeated_surfaces_by_gp[i])
)
phy_surfaces.append(geo.PhysicalGroup(all_surfaces, 2))
tag = cell.phy_surf[i].tag + 1000
name = cell.phy_surf[i].name
phy_surfaces.append(geo.PhysicalGroup(all_surfaces, 2, name, tag))
# gmsh.fltk.run()
for gp in cell.phy_surf:
gp.remove_gmsh()
factory.synchronize()
for gp in phy_surfaces:
gp.add_gmsh()
# gmsh.fltk.run()
# ! Pour le moment, il semble impossible de réutiliser le tag d'un physical group
# ! qui a été supprimé.
# ! Voir : \Experimental\Test_traction_oct19\pb_complet\run_3\MWE_reuse_tag.py
# ! Autre solution :
# ! - Compléter les physical group existants ?
# ! Impossible car groups déjà ajoutés au model
# ! Utiliser un autre tag, avec une règle pour relier les 2.
# ! Solution retenue. Règle choisie : le tag pour la part = 1000 + tag pour la cell
# TODO : All mesh generation
geo.PhysicalGroup.set_group_mesh(True)
model.mesh.generate(1)
......@@ -470,6 +486,7 @@ __all__ = [
"pantograph_RVE",
"pantograph_offset_RVE",
"beam_pantograph_RVE",
"pantograph_E11only_RVE",
"auxetic_square_RVE",
"Gmsh2DRVE",
"Gmsh2DPart",
......
......@@ -103,7 +103,15 @@ def pantograph_RVE(
def pantograph_offset_RVE(
a, b, k, thickness, fillet_r=0., nb_cells=(1, 1), offset=(0.0, 0.0), soft_mat=False, name=""
a,
b,
k,
thickness,
fillet_r=0.0,
nb_cells=(1, 1),
offset=(0.0, 0.0),
soft_mat=False,
name="",
):
"""
Generate a RVE object for the pantograph microstructure.
......@@ -313,7 +321,7 @@ def pantograph_E11only_RVE(
nb_cells = np.asarray(nb_cells)
logger.info("Start defining the pantograph geometry")
Lx = 4 * a
Ly = 4 * a
Ly = 4 * a + 2 * thickness
cell_vect = np.array(((Lx, 0.0), (0.0, Ly)))
e1 = np.array((a, 0.0, 0.0))
e2 = np.array((0.0, a, 0.0))
......@@ -327,24 +335,53 @@ def pantograph_E11only_RVE(
geo.translation(L, -1 * e1),
geo.translation(L, -1 * e2),
]
rhombus_v = [pt_O, geo.Point(e1 + 2 * e2), geo.Point(4 * e2), geo.Point(-e1 + 2 * e2)]
rhombus_h = [pt_O, geo.Point(-e2 + 2 * e1), geo.Point(4 * e1), geo.Point(e2 + 2 * e1)]
rhombus_v = [
pt_O,
geo.Point(e1 + 2 * e2),
geo.Point(4 * e2),
geo.Point(-e1 + 2 * e2),
]
cut_shape_h = [
pt_O,
geo.Point(0.25 * (-2 * e1 + e2)),
geo.Point(0.25 * (-4 * e1 + e2)),
geo.Point(0.25 * (-4 * e1 - e2)),
# geo.Point(-2 * e1 - e2),
# geo.Point(6 * e1 - e2),
geo.Point(4 * e1 + 0.25 * (4 * e1 - e2)),
geo.Point(4 * e1 + 0.25 * (4 * e1 + e2)),
geo.Point(4 * e1 + 0.25 * (2 * e1 + e2)),
# geo.Point(6 * e1 + e2),
geo.Point(4 * e1),
geo.Point(e2 + 2 * e1),
]
square = geo.LineLoop(square, explicit=False)
rhombus_v = geo.LineLoop(rhombus_v, explicit=False)
rhombus_h = geo.LineLoop(rhombus_h, explicit=False)
pattern = [square, rhombus_v, rhombus_h]
sym_rhombus = [geo.plane_reflection(rhombus_v, L, e1), geo.plane_reflection(rhombus_h, L, e2)]
cut_shape_h = geo.LineLoop(cut_shape_h, explicit=False)
pattern = [square, rhombus_v, cut_shape_h]
sym_rhombus = [
geo.plane_reflection(rhombus_v, L, e1),
geo.plane_reflection(cut_shape_h, L, e2),
]
for ll in sym_rhombus:
ll.reverse()
pattern += sym_rhombus
pattern = geo.remove_duplicates(pattern)
for ll in pattern:
geo.translation(ll, np.array((0.0, thickness, 0.0)))
logger.info("Done removing of the line-loops duplicates")
constr_pts = [copy.deepcopy(pt) for ll in pattern for pt in iter((ll.vertices))]
for ll in pattern:
ll.offset(thickness)
if fillet_r:
for ll in pattern:
ll.round_corner_explicit(fillet_r)
logger.info("Done rounding all corners of pattern line-loops")
fine_pts = geo.remove_duplicates(constr_pts)
import matplotlib.pyplot as plt
for ll in pattern:
ll.plot2D()
plt.show()
return Gmsh2DRVE(pattern, cell_vect, nb_cells, offset, fine_pts, soft_mat, name)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment