Skip to content

Commit

Permalink
small corrections for hexagonalCell, better OCC tolerance activated
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMetsch committed Nov 29, 2020
1 parent d34bc62 commit 3921360
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/hexagonalCell3DSphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"numberCells": [1,1,1], # generate 1 unit cell in every spatial direction
"radius": 2.5, # set the inclusion radius to 2
"inclusionType": "Sphere", # define inclusionType as "Sphere"
"size": [6, 6*3**(0.5), 6*3**(0.5)], # set cell size instead of distance
"size": [6, 6*3**(0.5), 6*(8/3)**(0.5)], # set cell size instead of distance
"origin": [0, 0, 0], # set cell origin to [0,0,0]
"periodicityFlags": [1, 1, 1], # define all axis directions as periodic
"domainGroup": "domain", # use "domain" as name for the domainGroup
Expand Down
8 changes: 4 additions & 4 deletions examples/randomInclusions3DSphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
"domainGroup": "domain", # use "domain" as name for the domainGroup
"inclusionGroup": "inclusions", # use "inclusions" as name for the inclusionGroup
"gmshConfigChanges": {"General.Terminal": 0, # deactivate console output by default (only activated for mesh generation)
"Mesh.ElementOrder":2, # set element order to 2nd
"Mesh.CharacteristicLengthExtendFromBoundary": 0, # do not calculate mesh sizes from the boundary by default (since mesh sizes are specified by fields)
}
"Mesh.ElementOrder":2, # set element order to 2
"Mesh.CharacteristicLengthExtendFromBoundary": 0, # do not calculate mesh sizes from the boundary by default (since mesh sizes are specified by fields)
}
}
testRVE=RandomInclusionRVE(**initParameters)

Expand Down Expand Up @@ -118,7 +118,7 @@
# format - has to be passed. The package supports all mesh file formats that are
# supported by meshio. If no filename is passed, meshes are stored to the current
# directory using the unique model name and the default mesh file format (.msh)
testRVE.saveMesh("randomInclusions3DSphere.msh")
testRVE.saveMesh("randomInclusions3DSphere.feap")


# Show resulting mesh
Expand Down
3 changes: 2 additions & 1 deletion gmshModel/Model/GenericModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def __init__(self,dimension=None,gmshConfigChanges={}):
# initialize Gmsh-Python-API
self.gmshConfigChanges={ # default Gmsh configuration changes
"General.Terminal": 0, # deactivate console output by default (only activated for mesh generation)
"Mesh.CharacteristicLengthExtendFromBoundary": 0, # do not calculate mesh sizes from the boundary by default (since mesh sizes are specified by fields)
"Geometry.OCCBoundsUseStl": 1, # use more accurate computation of bounding boxes (slower but advantegous for periodicity constraints)
"Geometry.Tolerance": 1e-12 # adjust geometric tolerance to be a little more precise then default (1e-8)
}
self.gmshAPI=self.initializeGmsh(gmshConfigChanges) # this assignment facilitates the usage of all methods provided by the gmsh.model class

Expand Down
2 changes: 1 addition & 1 deletion gmshModel/Model/GenericRVE.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _getAssociatedEntities(self,axis):
sides of the RVE boundary"""
# calculate required information from the RVE data
bboxRVE=np.r_[[self.origin], [self.origin+self.size]] # bounding box of the RVE: bboxRVE=[[minBBoxPoint],[maxBBoxPoint]]
tol=100*self.getGmshOption("Geometry.Tolerance") # tolerance for entity detection
tol=100*self.getGmshOption("Geometry.Tolerance") # tolerance for entity detection (factor 100 to find entities in wider bounding boxes)

# calculate translation vector and affine transformation matrix
transVec=np.zeros((3,1)) # initialize translation vector for the current pair of boundary entities
Expand Down
6 changes: 3 additions & 3 deletions gmshModel/Model/HexagonalCell.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _getCellSize(self,distance,inclusionType,inclusionAxis):

# determine size of one unit cell
if inclusionType == "Sphere": # unit cell is three-dimensional with spherical inclusion
unitSize=[distance, np.sqrt(3)*distance, np.sqrt(3)*distance] # -> define normal cell size for a hexagonal unit cell
unitSize=[distance, np.sqrt(3)*distance, np.sqrt(8/3)*distance] # -> define normal cell size for a hexagonal unit cell
elif inclusionType == "Cylinder": # unit cell is three-dimensional with cylindrical inclusion
cylinderAxis = np.array(np.nonzero(inclusionAxis)).flatten() # -> get index of cylinder axis
planeAxes=np.setdiff1d(np.array([0,1,2]),cylinderAxis) # -> get indices of remaining axes
Expand Down Expand Up @@ -198,8 +198,8 @@ def placeInclusions(self):
# -> divide by N to account for mutliple cells
offsets=np.array([[0, 0, 0], # corner inclusions
[size[0]/2, size[1]/2, 0], # face-centered inclusions in bottom and top layers
[size[0]/2, size[1]/(2*np.sqrt(3)), size[2]/2], # inclusions of center layer with x=Lx/2
[0, size[1]/2*(1+1/np.sqrt(3)), size[2]/2]])/N # inclusions of center layer with x=0 and x=L
[size[0]/2, size[1]/(4*np.sqrt(3)), size[2]/2], # inclusions of center layer with x=Lx/2
[0, size[1]/2*(1+1/(2*np.sqrt(3))), size[2]/2]])/N# inclusions of center layer with x=0 and x=L

# determine inclusion center points
C=np.empty(shape=(0,3)) # initialize empty array for center points
Expand Down
2 changes: 1 addition & 1 deletion gmshModel/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Version information for GmshModel"""
# versioning scheme: major, minor, patch
versionInfo= 1, 0, 14
versionInfo= 1, 0, 15

__version__= ".".join(map(str, versionInfo))
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Topic :: Scientific/Engineering",
"Topic :: Utilities"],
Expand Down

0 comments on commit 3921360

Please sign in to comment.