Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9b3518f
Merge remote-tracking branch 'origin/fix-bool_op-substract' into cut_…
BayssetGuillaume Sep 1, 2022
b31e8f8
Merge remote-tracking branch 'origin/fix-bool_op-substract' into cut_…
BayssetGuillaume Sep 2, 2022
fd1d4e9
Merge remote-tracking branch 'origin/fix-bool_op-substract' into cut_…
BayssetGuillaume Sep 7, 2022
3699e02
add specific copy for Contour2D
BayssetGuillaume Oct 3, 2022
d0f8cbd
Merge branch 'perf_copy' into sed
BayssetGuillaume Oct 3, 2022
1b27103
Merge branch 'fix_multiple_substractions' into sed
BayssetGuillaume Oct 4, 2022
265340f
add to_planeface3d to BSplineSurface3d
BayssetGuillaume Oct 4, 2022
a2ca7fc
Merge branch 'cut_closed_shell_with_plane' into sed
BayssetGuillaume Oct 4, 2022
33011cb
Merge branch 'fix_multiple_substractions' into sed
BayssetGuillaume Oct 11, 2022
d3d07e6
bug on substractions
BayssetGuillaume Oct 20, 2022
4dbfdd6
Merge branch 'fix_multiple_substractions' into sed
BayssetGuillaume Oct 20, 2022
00346bf
merge with multipke substract
BayssetGuillaume Oct 21, 2022
26a0103
update faces
BayssetGuillaume Oct 26, 2022
3ac0fc2
Merge branch 'feat_project_coincident_faces' into sed_project_faces
BayssetGuillaume Nov 24, 2022
1a6508c
Merge branch 'to_geo_msh' into sed_project_faces
BayssetGuillaume Nov 25, 2022
f9f3dfb
for sed platforme
BayssetGuillaume Nov 28, 2022
541413d
remove gmsh from setup
BayssetGuillaume Nov 28, 2022
ddd27d7
add gmsh from setup
BayssetGuillaume Nov 28, 2022
b30ecfa
Merge branch 'fix_bool_ops' into sed_project_faces
BayssetGuillaume Nov 29, 2022
49843a5
modif op bool
BayssetGuillaume Nov 29, 2022
19d9c45
disable import gmsh
BayssetGuillaume Nov 29, 2022
086c487
update for sed mesh
BayssetGuillaume Dec 5, 2022
093dbc9
Merge branch 'update_mesh_dev' into sed_project_faces
BayssetGuillaume Dec 5, 2022
85424fb
Merge branch 'to_geo_msh' into sed_project_faces
BayssetGuillaume Dec 7, 2022
cad0d9d
Merge branch 'write_msh_file' into sed_project_faces
BayssetGuillaume Dec 8, 2022
ce534d5
add method to write msh file
BayssetGuillaume Dec 8, 2022
f0da80f
modify import dessia_common
BayssetGuillaume Dec 28, 2022
aeca218
modify import dessia_common 2
BayssetGuillaume Dec 28, 2022
41a3ba9
Merge branch 'dev' into finite_elements_v0.2.0
sbendjebla Apr 17, 2023
3e211b1
Merge branch 'dev' into finite_elements_v0.2.0
sbendjebla Apr 17, 2023
ab7c32f
Merge branch 'dev' into finite_elements_v0.2.0
sbendjebla Apr 17, 2023
df60fe9
Merge branch 'dev' into finite_elements_v0.2.0
sbendjebla Apr 17, 2023
e00ff7a
Update
sbendjebla Apr 18, 2023
bfa24db
Merge branch 'bspline_2_plane3d' into finite_elements_v0.2.0
sbendjebla Apr 18, 2023
4072c67
Merge branch 'bspline_2_plane3d' into finite_elements_v0.2.0
sbendjebla Apr 18, 2023
d9070af
VolumeModel: generate_msh_file/ to_msh_stream (Uncomment)
sbendjebla Apr 18, 2023
8dd5613
Merge branch 'dev' into finite_elements_v0.2.0
sbendjebla Apr 25, 2023
c673166
Merge branch 'dev' into finite_elements_v0.2.0
sbendjebla Apr 28, 2023
5791f60
Merge branch 'dev' into finite_elements_v0.2.0
sbendjebla May 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 87 additions & 88 deletions volmdlr/core.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from functools import lru_cache
from typing import List, Tuple

# import gmsh
import gmsh
import matplotlib.pyplot as plt
import numpy as npy

Expand Down Expand Up @@ -1391,11 +1391,11 @@ def frame_mapping_inplace(self, frame: volmdlr.Frame3D, side: str):
primitives.frame_mapping_inplace(frame, side)
self.bounding_box = self._bounding_box()

def copy(self, deep=True, memo=None):
def copy(self):
"""
Specific copy.
"""
new_primitives = [primitive.copy(deep=deep, memo=memo) for primitive in self.primitives]
new_primitives = [primitive.copy() for primitive in self.primitives]
return VolumeModel(new_primitives, self.name)

def plot2d(self, ax=None, color=None):
Expand Down Expand Up @@ -2044,91 +2044,90 @@ def to_msh(self, mesh_dimension: int,

# gmsh.finalize()

# @staticmethod
# def generate_msh_file(file_name, mesh_dimension):
# """
# Generates a mesh written in a .msh file using GMSH library.
#
# :param file_name: DESCRIPTION
# :type file_name: TYPE
# :param mesh_dimension: DESCRIPTION
# :type mesh_dimension: TYPE
# :return: DESCRIPTION
# :rtype: TYPE
#
# """
#
# gmsh.initialize()
# gmsh.open(file_name + ".geo")
#
# gmsh.model.geo.synchronize()
# gmsh.model.mesh.generate(mesh_dimension)
#
# gmsh.write(file_name + ".msh")
#
# gmsh.finalize()
#
# def to_msh_stream(self, mesh_dimension: int,
# factor: float, stream: dcf.StringFile,
# file_name: str = '', **kwargs):
# """
# Gets .msh file for the VolumeModel generated by gmsh.
#
# :param file_name: The msh. file name
# :type file_name: str
# :param mesh_dimension: The mesh dimension (1: 1D-Edge, 2: 2D-Triangle, 3D-Tetrahedra)
# :type mesh_dimension: int
# :param factor: A float, between 0 and 1, that describes the mesh quality
# (1 for coarse mesh - 0 for fine mesh)
# :type factor: float
# :param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature
# (with curvature_mesh_size elements per 2*Pi radians), defaults to 0
# :type curvature_mesh_size: int, optional
# :param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points
# on that edge), defaults to None
# :type min_points: int, optional
# :param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5
# :type initial_mesh_size: float, optional
#
# :return: A txt file
# :rtype: .txt
# """
#
# for element in [('curvature_mesh_size', 0), ('min_points', None), ('initial_mesh_size', 5)]:
# if element[0] not in kwargs:
# kwargs[element[0]] = element[1]
#
# if file_name == '':
# with tempfile.NamedTemporaryFile(delete=False) as file:
# file_name = file.name
#
# self.to_geo(file_name=file_name,
# factor=factor,
# curvature_mesh_size=kwargs['curvature_mesh_size'],
# min_points=kwargs['min_points'],
# initial_mesh_size=kwargs['initial_mesh_size'])
#
# gmsh.initialize()
# gmsh.open(file_name + ".geo")
#
# gmsh.model.geo.synchronize()
# gmsh.model.mesh.generate(mesh_dimension)
#
# lines = []
# lines.append('$MeshFormat')
# lines.append('4.1 0 8')
# lines.append('$EndMeshFormat')
#
# lines.extend(self.get_nodes_lines(gmsh))
# lines.extend(self.get_elements_lines(gmsh))
#
# content = ''
# for line in lines:
# content += line + '\n'
#
# stream.write(content)
#
# # gmsh.finalize()
@staticmethod
def generate_msh_file(file_name, mesh_dimension):
"""
Generates a mesh written in a .msh file using GMSH library.

:param file_name: DESCRIPTION
:type file_name: TYPE
:param mesh_dimension: DESCRIPTION
:type mesh_dimension: TYPE
:return: DESCRIPTION
:rtype: TYPE
"""

gmsh.initialize()
gmsh.open(file_name + ".geo")

gmsh.model.geo.synchronize()
gmsh.model.mesh.generate(mesh_dimension)

gmsh.write(file_name + ".msh")

gmsh.finalize()

def to_msh_stream(self, mesh_dimension: int,
factor: float, stream: dcf.StringFile,
file_name: str = '', **kwargs):
"""
Gets .msh file for the VolumeModel generated by gmsh.

:param file_name: The msh. file name
:type file_name: str
:param mesh_dimension: The mesh dimension (1: 1D-Edge, 2: 2D-Triangle, 3D-Tetrahedra)
:type mesh_dimension: int
:param factor: A float, between 0 and 1, that describes the mesh quality
(1 for coarse mesh - 0 for fine mesh)
:type factor: float
:param curvature_mesh_size: Activate the calculation of mesh element sizes based on curvature
(with curvature_mesh_size elements per 2*Pi radians), defaults to 0
:type curvature_mesh_size: int, optional
:param min_points: Check if there are enough points on small edges (if it is not, we force to have min_points
on that edge), defaults to None
:type min_points: int, optional
:param initial_mesh_size: If factor=1, it will be initial_mesh_size elements per dimension, defaults to 5
:type initial_mesh_size: float, optional

:return: A txt file
:rtype: .txt
"""

for element in [('curvature_mesh_size', 0), ('min_points', None), ('initial_mesh_size', 5)]:
if element[0] not in kwargs:
kwargs[element[0]] = element[1]

if file_name == '':
with tempfile.NamedTemporaryFile(delete=False) as file:
file_name = file.name

self.to_geo(file_name=file_name,
factor=factor,
curvature_mesh_size=kwargs['curvature_mesh_size'],
min_points=kwargs['min_points'],
initial_mesh_size=kwargs['initial_mesh_size'])

gmsh.initialize()
gmsh.open(file_name + ".geo")

gmsh.model.geo.synchronize()
gmsh.model.mesh.generate(mesh_dimension)

lines = []
lines.append('$MeshFormat')
lines.append('4.1 0 8')
lines.append('$EndMeshFormat')

lines.extend(self.get_nodes_lines(gmsh))
lines.extend(self.get_elements_lines(gmsh))

content = ''
for line in lines:
content += line + '\n'

stream.write(content)

# gmsh.finalize()

def to_msh_file(self, mesh_dimension: int,
factor: float, file_name: str = '', **kwargs):
Expand Down
4 changes: 4 additions & 0 deletions volmdlr/wires.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,10 @@ def copy(self, deep=True, memo=None):
def __hash__(self):
return hash(tuple(self.primitives))

def copy(self):
return self.__class__(primitives=[p.copy() for p in self.primitives],
name=self.name)

def __eq__(self, other_):
if id(self) == id(other_):
return True
Expand Down