Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when creating a model with a hole #1620

Open
liaohaiyang1534 opened this issue Jun 28, 2023 · 5 comments
Open

error when creating a model with a hole #1620

liaohaiyang1534 opened this issue Jun 28, 2023 · 5 comments

Comments

@liaohaiyang1534
Copy link

Hi,

I'm going to create a model with a hole in it, I put seven blocks together, the middle block adds the materiall property of the hole. The python code runs successfully, but it doesn't seem to generate the mesh_file and materials_file.

Here is a picture of the model, which looks alright

image

Here is a small portion of the output of python code:

image

In case you need more detailed code information, here is the python code:

#!/usr/bin/env python

from __future__ import print_function

import os
import sys

# Add the PATH of Cubit-associated DLL files to path
dll_path = r"E:\coreform cubit\coreform cubit 2022.11\bin"
path = os.environ.get('PATH', '')
if dll_path not in path.split(';'):
    new_path = path + ';' + dll_path if path else dll_path
    os.environ['PATH'] = new_path
    
sys.path.append("E:\\coreforum cubit\\coreform cubit 2022.11\\bin")
sys.path.append("E:\\coreforum cubit\\coreform cubit 2022.11\\bin\\_cubit3.pyd")

# Add cubit path to PYTHONPATH
cubit_path = r"E:\coreform cubit\coreform cubit 2022.11\bin"
python_path = os.environ.get('PYTHONPATH', '')
if cubit_path not in python_path.split(';'):
    new_python_path = python_path + ';' + cubit_path if python_path else cubit_path
    os.environ['PYTHONPATH'] = new_python_path
    
sys.path.append("../../specfem3d-master/CUBIT_GEOCUBIT/geocubitlib")
sys.path.append("../../specfem3d-master/CUBIT_GEOCUBIT")
    
    

elementsize = 1

SEMoutput='MESH'
CUBIToutput='MESH_GEOCUBIT'

os.system('mkdir -p '+ SEMoutput)
os.system('mkdir -p '+ CUBIToutput)


    
    
import cubit
try:
    cubit.init(["-noecho","-nojournal"])
except:
    pass

version = cubit.get_version()
version_major = int(version.split(".")[0])
version_minor = int(version.split(".")[1])
print("cubit version: ",version)



cubit.cmd('reset')

# create a hole
cubit.cmd('brick x 3 y 3 z 3')
cubit.cmd('volume 1 move x 0 y 0 z -4')

# create the top volume of the hole
cubit.cmd('brick x 100 y 16 z 13.5')
cubit.cmd('volume 2 move x 0 y 0 z 4.25')

# create the bottom volume of the hole 
cubit.cmd('brick x 100 y 16 z 13.5')
cubit.cmd('volume 3 move x 0 y 0 z -12.25')

# create the front volume of the hole 
cubit.cmd('brick x 48.5 y 16 z 3')
cubit.cmd('volume 4 move x 25.75 y 0 z -4')

# create the back volume of the hole 
cubit.cmd('brick x 48.5 y 16 z 3')
cubit.cmd('volume 5 move x -25.75 y 0 z -4')

# create the left volume of the hole 
cubit.cmd('brick x 3 y 6.5 z 3')
cubit.cmd('volume 6 move x 0 y 4.75 z -4')

# create the right volume of the hole 
cubit.cmd('brick x 3 y 6.5 z 3')
cubit.cmd('volume 7 move x 0 y -4.75 z -4')


cubit.cmd('merge all')
cubit.cmd('imprint all')

cubit.cmd('volume all size 1')
cubit.cmd('mesh volume all')



cubit.cmd('block 1 volume 1')
cubit.cmd('block 1 name "elastic 1"')
cubit.cmd('block 1 attribute count 7')
cubit.cmd('block 1 attribute index 1 1')
cubit.cmd('block 1 attribute index 2 340')
cubit.cmd('block 1 attribute index 3 17')
cubit.cmd('block 1 attribute index 4 500')
cubit.cmd('block 1 attribute index 5 9999')
cubit.cmd('block 1 attribute index 6 9999')
cubit.cmd('block 1 attribute index 7 0')

cubit.cmd('block 2 volume 2')
cubit.cmd('block 2 name "elastic 2"')
cubit.cmd('block 2 attribute count 7')
cubit.cmd('block 2 attribute index 1 2')
cubit.cmd('block 2 attribute index 2 475')
cubit.cmd('block 2 attribute index 3 230')
cubit.cmd('block 2 attribute index 4 2000')
cubit.cmd('block 2 attribute index 5 9999')
cubit.cmd('block 2 attribute index 6 9999')
cubit.cmd('block 2 attribute index 7 0')

cubit.cmd('block 3 volume 3')
cubit.cmd('block 3 name "elastic 2"')
cubit.cmd('block 3 attribute count 7')
cubit.cmd('block 3 attribute index 1 3')
cubit.cmd('block 3 attribute index 2 475')
cubit.cmd('block 3 attribute index 3 230')
cubit.cmd('block 3 attribute index 4 2000')
cubit.cmd('block 3 attribute index 5 9999')
cubit.cmd('block 3 attribute index 6 9999')
cubit.cmd('block 3 attribute index 7 0')

cubit.cmd('block 4 volume 4')
cubit.cmd('block 4 name "elastic 2"')
cubit.cmd('block 4 attribute count 7')
cubit.cmd('block 4 attribute index 1 4')
cubit.cmd('block 4 attribute index 2 475')
cubit.cmd('block 4 attribute index 3 230')
cubit.cmd('block 4 attribute index 4 2000')
cubit.cmd('block 4 attribute index 5 9999')
cubit.cmd('block 4 attribute index 6 9999')
cubit.cmd('block 4 attribute index 7 0')

cubit.cmd('block 5 volume 5')
cubit.cmd('block 5 name "elastic 2"')
cubit.cmd('block 5 attribute count 7')
cubit.cmd('block 5 attribute index 1 5')
cubit.cmd('block 5 attribute index 2 475')
cubit.cmd('block 5 attribute index 3 230')
cubit.cmd('block 5 attribute index 4 2000')
cubit.cmd('block 5 attribute index 5 9999')
cubit.cmd('block 5 attribute index 6 9999')
cubit.cmd('block 5 attribute index 7 0')

cubit.cmd('block 6 volume 6')
cubit.cmd('block 6 name "elastic 2"')
cubit.cmd('block 6 attribute count 7')
cubit.cmd('block 6 attribute index 1 6')
cubit.cmd('block 6 attribute index 2 475')
cubit.cmd('block 6 attribute index 3 230')
cubit.cmd('block 6 attribute index 4 2000')
cubit.cmd('block 6 attribute index 5 9999')
cubit.cmd('block 6 attribute index 6 9999')
cubit.cmd('block 6 attribute index 7 0')

cubit.cmd('block 7 volume 7')
cubit.cmd('block 7 name "elastic 2"')
cubit.cmd('block 7 attribute count 7')
cubit.cmd('block 7 attribute index 1 7')
cubit.cmd('block 7 attribute index 2 475')
cubit.cmd('block 7 attribute index 3 230')
cubit.cmd('block 7 attribute index 4 2000')
cubit.cmd('block 7 attribute index 5 9999')
cubit.cmd('block 7 attribute index 6 9999')
cubit.cmd('block 7 attribute index 7 0')

cubit.cmd('export mesh MESH_GEOCUBIT/top.e dimension 3 overwrite')
cubit.cmd('save as MESH_GEOCUBIT/top.cub overwrite')




cubit2specfem3d.export2SPECFEM3D(SEMoutput)


if version_major >= 16 and version_minor >= 4:
    cubit.cmd('view top')
    cubit.cmd('hardcopy "' + CUBIToutput + '/waterlayered.png" png')

I'm very appreciated to have any advice and suggestions for this.
(If you need any more clarifications, please let me know)

Regards

Haiyang Liao
haiyangliao@smail.nju.edu.cn

@homnath
Copy link

homnath commented Jun 29, 2023 via email

@casarotti
Copy link
Contributor

casarotti commented Jun 29, 2023 via email

@liaohaiyang1534
Copy link
Author

Hi, casarotti

it really works! thanks a lot! i really appreciate that

@liaohaiyang1534
Copy link
Author

Hi, Hom Nath

Thanks for your suggestion, I'll take a closer look

Best

@liaohaiyang1534 liaohaiyang1534 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2023
@liaohaiyang1534
Copy link
Author

could you try with a small different definition of the blocks? for example cubit.cmd('block 4 hex in volume 4') instead of cubit.cmd('block 4 volume 4')

On Thu, Jun 29, 2023 at 6:11 AM Hom Nath Gharti @.> wrote: Hi Haiyang Liao, There may be an issue with voids. Alternatively, you can define the sidesets within the Cubit, and use the exodus2specfem3d application in MeshAssist package ( https://github.com/homnath/MeshAssist). It generally works in any complex models including voids. https://github.com/homnath/MeshAssist Check section 4.6 of the documentation https://github.com/homnath/MeshAssist/blob/master/doc/manual_MeshAssist.pdf Best, Hom Nath ________________________________ From: liaohaiyang1534 @.> Sent: Wednesday, June 28, 2023 9:20 AM To: SPECFEM/specfem3d @.> Cc: Subscribed @.> Subject: [SPECFEM/specfem3d] error when creating a model with a hole (Issue #1620) Hi, I'm going to create a model with a hole in it, I put seven blocks together, the middle block adds the materiall property of the hole. The python code runs successfully, but it doesn't seem to generate the mesh_file and materials_file. Here is a picture of the model, which looks alright [image]< https://user-images.githubusercontent.com/104192749/249480543-17edb8bb-e8bd-4cb2-b7c5-7f4cbc86c53c.png> Here is a small portion of the output of python code: [image]< https://user-images.githubusercontent.com/104192749/249481018-af69c3e3-7a1b-4045-8b03-1598e4f7b36a.png> In case you need more detailed code information, here is the python code: #!/usr/bin/env python from future import print_function import os import sys # Add the PATH of Cubit-associated DLL files to path dll_path = r"E:\coreform cubit\coreform cubit 2022.11\bin" path = os.environ.get('PATH', '') if dll_path not in path.split(';'): new_path = path + ';' + dll_path if path else dll_path os.environ['PATH'] = new_path sys.path.append("E:\coreforum cubit\coreform cubit 2022.11\bin") sys.path.append("E:\coreforum cubit\coreform cubit 2022.11\bin\_cubit3.pyd") # Add cubit path to PYTHONPATH cubit_path = r"E:\coreform cubit\coreform cubit 2022.11\bin" python_path = os.environ.get('PYTHONPATH', '') if cubit_path not in python_path.split(';'): new_python_path = python_path + ';' + cubit_path if python_path else cubit_path os.environ['PYTHONPATH'] = new_python_path sys.path.append("../../specfem3d-master/CUBIT_GEOCUBIT/geocubitlib") sys.path.append("../../specfem3d-master/CUBIT_GEOCUBIT") elementsize = 1 SEMoutput='MESH' CUBIToutput='MESH_GEOCUBIT' os.system('mkdir -p '+ SEMoutput) os.system('mkdir -p '+ CUBIToutput) import cubit try: cubit.init(["-noecho","-nojournal"]) except: pass version = cubit.get_version() version_major = int(version.split(".")[0]) version_minor = int(version.split(".")[1]) print("cubit version: ",version) cubit.cmd('reset') # create a hole cubit.cmd('brick x 3 y 3 z 3') cubit.cmd('volume 1 move x 0 y 0 z -4') # create the top volume of the hole cubit.cmd('brick x 100 y 16 z 13.5') cubit.cmd('volume 2 move x 0 y 0 z 4.25') # create the bottom volume of the hole cubit.cmd('brick x 100 y 16 z 13.5') cubit.cmd('volume 3 move x 0 y 0 z -12.25') # create the front volume of the hole cubit.cmd('brick x 48.5 y 16 z 3') cubit.cmd('volume 4 move x 25.75 y 0 z -4') # create the back volume of the hole cubit.cmd('brick x 48.5 y 16 z 3') cubit.cmd('volume 5 move x -25.75 y 0 z -4') # create the left volume of the hole cubit.cmd('brick x 3 y 6.5 z 3') cubit.cmd('volume 6 move x 0 y 4.75 z -4') # create the right volume of the hole cubit.cmd('brick x 3 y 6.5 z 3') cubit.cmd('volume 7 move x 0 y -4.75 z -4') cubit.cmd('merge all') cubit.cmd('imprint all') cubit.cmd('volume all size 1') cubit.cmd('mesh volume all') cubit.cmd('block 1 volume 1') cubit.cmd('block 1 name "elastic 1"') cubit.cmd('block 1 attribute count 7') cubit.cmd('block 1 attribute index 1 1') cubit.cmd('block 1 attribute index 2 340') cubit.cmd('block 1 attribute index 3 17') cubit.cmd('block 1 attribute index 4 500') cubit.cmd('block 1 attribute index 5 9999') cubit.cmd('block 1 attribute index 6 9999') cubit.cmd('block 1 attribute index 7 0') cubit.cmd('block 2 volume 2') cubit.cmd('block 2 name "elastic 2"') cubit.cmd('block 2 attribute count 7') cubit.cmd('block 2 attribute index 1 2') cubit.cmd('block 2 attribute index 2 475') cubit.cmd('block 2 attribute index 3 230') cubit.cmd('block 2 attribute index 4 2000') cubit.cmd('block 2 attribute index 5 9999') cubit.cmd('block 2 attribute index 6 9999') cubit.cmd('block 2 attribute index 7 0') cubit.cmd('block 3 volume 3') cubit.cmd('block 3 name "elastic 2"') cubit.cmd('block 3 attribute count 7') cubit.cmd('block 3 attribute index 1 3') cubit.cmd('block 3 attribute index 2 475') cubit.cmd('block 3 attribute index 3 230') cubit.cmd('block 3 attribute index 4 2000') cubit.cmd('block 3 attribute index 5 9999') cubit.cmd('block 3 attribute index 6 9999') cubit.cmd('block 3 attribute index 7 0') cubit.cmd('block 4 volume 4') cubit.cmd('block 4 name "elastic 2"') cubit.cmd('block 4 attribute count 7') cubit.cmd('block 4 attribute index 1 4') cubit.cmd('block 4 attribute index 2 475') cubit.cmd('block 4 attribute index 3 230') cubit.cmd('block 4 attribute index 4 2000') cubit.cmd('block 4 attribute index 5 9999') cubit.cmd('block 4 attribute index 6 9999') cubit.cmd('block 4 attribute index 7 0') cubit.cmd('block 5 volume 5') cubit.cmd('block 5 name "elastic 2"') cubit.cmd('block 5 attribute count 7') cubit.cmd('block 5 attribute index 1 5') cubit.cmd('block 5 attribute index 2 475') cubit.cmd('block 5 attribute index 3 230') cubit.cmd('block 5 attribute index 4 2000') cubit.cmd('block 5 attribute index 5 9999') cubit.cmd('block 5 attribute index 6 9999') cubit.cmd('block 5 attribute index 7 0') cubit.cmd('block 6 volume 6') cubit.cmd('block 6 name "elastic 2"') cubit.cmd('block 6 attribute count 7') cubit.cmd('block 6 attribute index 1 6') cubit.cmd('block 6 attribute index 2 475') cubit.cmd('block 6 attribute index 3 230') cubit.cmd('block 6 attribute index 4 2000') cubit.cmd('block 6 attribute index 5 9999') cubit.cmd('block 6 attribute index 6 9999') cubit.cmd('block 6 attribute index 7 0') cubit.cmd('block 7 volume 7') cubit.cmd('block 7 name "elastic 2"') cubit.cmd('block 7 attribute count 7') cubit.cmd('block 7 attribute index 1 7') cubit.cmd('block 7 attribute index 2 475') cubit.cmd('block 7 attribute index 3 230') cubit.cmd('block 7 attribute index 4 2000') cubit.cmd('block 7 attribute index 5 9999') cubit.cmd('block 7 attribute index 6 9999') cubit.cmd('block 7 attribute index 7 0') cubit.cmd('export mesh MESH_GEOCUBIT/top.e dimension 3 overwrite') cubit.cmd('save as MESH_GEOCUBIT/top.cub overwrite') cubit2specfem3d.export2SPECFEM3D(SEMoutput) if version_major >= 16 and version_minor >= 4: cubit.cmd('view top') cubit.cmd('hardcopy "' + CUBIToutput + '/waterlayered.png" png') I'm very appreciated to have any advice and suggestions for this. (If you need any more clarifications, please let me know) Regards Haiyang Liao @.@.> — Reply to this email directly, view it on GitHub< #1620>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABMCQ4UDWOEO3QNYOBJZKDLXNQVTJANCNFSM6AAAAAAZXD6IUA>. You are receiving this because you are subscribed to this thread.Message ID: @.> — Reply to this email directly, view it on GitHub <#1620 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAQG2CNXH2KFEJJX2IGUVDXNT6ALANCNFSM6AAAAAAZXD6IUA . You are receiving this because you are subscribed to this thread.Message ID: @.>

Hi casarotti,

You gave me a suggestion last time, which worked, but then I encountered a problem, which has not been resolved until now. The problem is that an error occurs when running this line of command: cubit2specfem3d.export2SPECFEM3D(SEMoutput)
An error occurred while generating the boundary conditions:
image

Although this error is due to adding boundary conditions, and I can add better CPML in specfem3d, maybe I can ignore this error. But I later found that there may be a problem inside the grid, so I wonder if it is related to the error here. I haven't been able to solve this error for days.

Do you have any other suggestions? I will be very grateful!

In case you need more detailed information, here is the python code and error information:
TypeError 'NoneType' object is not iterable.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants