Commit 27d3edec authored by Baptiste Durand's avatar Baptiste Durand

Function that generates RVE for auxetic squares in a specific file

Removing of the corresponding staticmethod from the Gmsh2DRVE class
parent a762fb0f
...@@ -29,8 +29,6 @@ factory = model.occ ...@@ -29,8 +29,6 @@ factory = model.occ
logger = logging.getLogger(__name__) # http://sametmax.com/ecrire-des-logs-en-python/ logger = logging.getLogger(__name__) # http://sametmax.com/ecrire-des-logs-en-python/
__all__ = [ __all__ = [
"pantograph", "pantograph",
"duplicate_pattern", "duplicate_pattern",
...@@ -324,94 +322,6 @@ class Gmsh2DRVE(object): ...@@ -324,94 +322,6 @@ class Gmsh2DRVE(object):
gmsh.write(str(mesh_path)) gmsh.write(str(mesh_path))
self.mesh_abs_path = mesh_path self.mesh_abs_path = mesh_path
@staticmethod
def auxetic_square(
L, a, t, nb_cells=(1, 1), offset=(0.0, 0.0), soft_mat=False, name=""
):
"""
Create an instance of Gmsh2DRVE that represents a RVE of the auxetic square microstructure.
The geometry that is specific to this microstructure is defined in this staticmethod. Then, the generic operations will be performed with the Gmsh2DRVE methods.
Parameters
----------
L : float
Length of the sides of the square cell.
a : float
Length of the slits beetween squares.
t : float
Width of the slits beetween squares.
nb_cells : tuple or 1D array
nb of cells in each direction of repetition
offset : tuple or 1D array
Relative position inside a cell of the point that will coincide with the origin of the global domain
Returns
-------
Instance of the Gmsh2DRVE class.
"""
name = name if name else "aux_square"
model.add(name)
# geo.reset()
offset = np.asarray(offset)
nb_cells = np.asarray(nb_cells)
logger.info("Start defining the auxetic_square geometry")
gen_vect = np.array(((L, 0.0), (0.0, L)))
b = (L - a) / 2.0
e1 = np.array((L, 0.0, 0.0))
e2 = np.array((0.0, L, 0.0))
I = geo.Point(1 / 2.0 * (e1 + e2))
M = geo.Point(1 / 4.0 * (e1 + e2))
e3 = np.array((0.0, 0.0, 1.0))
center_pts = [[(b, 0.0), (a + b, 0.0)], [(0.0, -a / 2.0), (0.0, a / 2.0)]]
center_pts = [[geo.Point(np.array(coord)) for coord in gp] for gp in center_pts]
center_lines = [geo.Line(*pts) for pts in center_pts]
center_lines += [geo.point_reflection(ln, M) for ln in center_lines]
center_lines += [geo.plane_reflection(ln, I, e1) for ln in center_lines]
center_lines += [geo.plane_reflection(ln, I, e2) for ln in center_lines]
center_lines = geo.remove_duplicates(center_lines)
for ln in center_lines:
ln.ortho_dir = np.cross(e3, ln.direction())
pattern_ll = list()
for ln in center_lines:
vertices = [
geo.translation(ln.def_pts[0], t / 2 * ln.ortho_dir),
geo.translation(ln.def_pts[1], t / 2 * ln.ortho_dir),
geo.translation(ln.def_pts[1], -t / 2 * ln.ortho_dir),
geo.translation(ln.def_pts[0], -t / 2 * ln.ortho_dir),
]
pattern_ll.append(geo.LineLoop(vertices))
tmp_nb_bef = len(pattern_ll)
pattern_ll = geo.remove_duplicates(pattern_ll)
logger.debug(
f"Number of line-loops removed from pattern-ll : {tmp_nb_bef - len(pattern_ll)}."
)
logger.debug(
f"Final number of pattern line-loops for auxetic square : {len(pattern_ll)}"
)
for ll in pattern_ll:
ll.round_corner_explicit(t / 2)
filter_sides = (
list()
) # * Pour ne pas essayer d'ajouter au model gmsh des lignes de longueur nulle. (Error : could not create line)
for crv in ll.sides:
if not crv.def_pts[0] == crv.def_pts[-1]:
filter_sides.append(crv)
ll.sides = filter_sides
fine_pts = geo.remove_duplicates(flatten([ln.def_pts for ln in center_lines]))
return Gmsh2DRVE(
pattern_ll, gen_vect, nb_cells, offset, fine_pts, soft_mat, name
)
class Gmsh2DPart(object): class Gmsh2DPart(object):
def __init__(self, gen_vect, nb_cells, phy_surf, mesh_path: PurePath): def __init__(self, gen_vect, nb_cells, phy_surf, mesh_path: PurePath):
...@@ -422,8 +332,10 @@ class Gmsh2DPart(object): ...@@ -422,8 +332,10 @@ class Gmsh2DPart(object):
from .pantograph import pantograph_RVE, pantograph_offset_RVE, beam_pantograph_RVE from .pantograph import pantograph_RVE, pantograph_offset_RVE, beam_pantograph_RVE
# from .other_2d_microstructures import auxetic_square_RVE # from .other_2d_microstructures import auxetic_square_RVE
def Gmsh2DPartFromRVE(cell: Gmsh2DRVE, nb_cells, part_name=None): def Gmsh2DPartFromRVE(cell: Gmsh2DRVE, nb_cells, part_name=None):
"""[summary] """[summary]
...@@ -551,6 +463,7 @@ def Gmsh2DPartFromRVE(cell: Gmsh2DRVE, nb_cells, part_name=None): ...@@ -551,6 +463,7 @@ def Gmsh2DPartFromRVE(cell: Gmsh2DRVE, nb_cells, part_name=None):
gmsh.write(str(part_path)) gmsh.write(str(part_path))
return Gmsh2DPart(part_vect, nb_cells, phy_surfaces, part_path) return Gmsh2DPart(part_vect, nb_cells, phy_surfaces, part_path)
from . import pantograph from . import pantograph
__all__ = [ __all__ = [
......
...@@ -16,12 +16,15 @@ from . import Gmsh2DRVE, logger ...@@ -16,12 +16,15 @@ from . import Gmsh2DRVE, logger
model = gmsh.model model = gmsh.model
factory = model.occ factory = model.occ
def auxetic_square_RVE( def auxetic_square_RVE(
L, a, t, nb_cells=(1, 1), offset=(0.0, 0.0), soft_mat=False, name="" L, a, t, nb_cells=(1, 1), offset=(0.0, 0.0), soft_mat=False, name=""
): ):
""" """
Create an instance of Gmsh2DRVE that represents a RVE of the auxetic square microstructure. Create an instance of Gmsh2DRVE that represents a RVE of
The geometry that is specific to this microstructure is defined in this staticmethod. Then, the generic operations will be performed with the Gmsh2DRVE methods. the auxetic square microstructure.
The generic operations will be performed with the Gmsh2DRVE methods.
Parameters Parameters
---------- ----------
...@@ -34,7 +37,8 @@ def auxetic_square_RVE( ...@@ -34,7 +37,8 @@ def auxetic_square_RVE(
nb_cells : tuple or 1D array nb_cells : tuple or 1D array
nb of cells in each direction of repetition nb of cells in each direction of repetition
offset : tuple or 1D array offset : tuple or 1D array
Relative position inside a cell of the point that will coincide with the origin of the global domain Relative position inside a cell of the point that
will coincide with the origin of the global domain.
Returns Returns
------- -------
...@@ -53,7 +57,7 @@ def auxetic_square_RVE( ...@@ -53,7 +57,7 @@ def auxetic_square_RVE(
b = (L - a) / 2.0 b = (L - a) / 2.0
e1 = np.array((L, 0.0, 0.0)) e1 = np.array((L, 0.0, 0.0))
e2 = np.array((0.0, L, 0.0)) e2 = np.array((0.0, L, 0.0))
I = geo.Point(1 / 2.0 * (e1 + e2)) C = geo.Point(1 / 2.0 * (e1 + e2))
M = geo.Point(1 / 4.0 * (e1 + e2)) M = geo.Point(1 / 4.0 * (e1 + e2))
e3 = np.array((0.0, 0.0, 1.0)) e3 = np.array((0.0, 0.0, 1.0))
...@@ -62,8 +66,8 @@ def auxetic_square_RVE( ...@@ -62,8 +66,8 @@ def auxetic_square_RVE(
center_pts = [[geo.Point(np.array(coord)) for coord in gp] for gp in center_pts] center_pts = [[geo.Point(np.array(coord)) for coord in gp] for gp in center_pts]
center_lines = [geo.Line(*pts) for pts in center_pts] center_lines = [geo.Line(*pts) for pts in center_pts]
center_lines += [geo.point_reflection(ln, M) for ln in center_lines] center_lines += [geo.point_reflection(ln, M) for ln in center_lines]
center_lines += [geo.plane_reflection(ln, I, e1) for ln in center_lines] center_lines += [geo.plane_reflection(ln, C, e1) for ln in center_lines]
center_lines += [geo.plane_reflection(ln, I, e2) for ln in center_lines] center_lines += [geo.plane_reflection(ln, C, e2) for ln in center_lines]
center_lines = geo.remove_duplicates(center_lines) center_lines = geo.remove_duplicates(center_lines)
for ln in center_lines: for ln in center_lines:
...@@ -89,9 +93,9 @@ def auxetic_square_RVE( ...@@ -89,9 +93,9 @@ def auxetic_square_RVE(
for ll in pattern_ll: for ll in pattern_ll:
ll.round_corner_explicit(t / 2) ll.round_corner_explicit(t / 2)
filter_sides = ( filter_sides = list()
list() # * Pour ne pas essayer d'ajouter au model gmsh des lignes de longueur nulle.
) # * Pour ne pas essayer d'ajouter au model gmsh des lignes de longueur nulle. (Error : could not create line) # * (Error : could not create line)
for crv in ll.sides: for crv in ll.sides:
if not crv.def_pts[0] == crv.def_pts[-1]: if not crv.def_pts[0] == crv.def_pts[-1]:
filter_sides.append(crv) filter_sides.append(crv)
...@@ -99,6 +103,4 @@ def auxetic_square_RVE( ...@@ -99,6 +103,4 @@ def auxetic_square_RVE(
fine_pts = geo.remove_duplicates(flatten([ln.def_pts for ln in center_lines])) fine_pts = geo.remove_duplicates(flatten([ln.def_pts for ln in center_lines]))
return Gmsh2DRVE( return Gmsh2DRVE(pattern_ll, gen_vect, nb_cells, offset, fine_pts, soft_mat, name)
pattern_ll, gen_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