|
| 1 | +from compas_dem.templates import BarrelVaultTemplate |
| 2 | +from compas_dem.elements import Block |
| 3 | +from compas_dem.models import BlockModel |
| 4 | +from compas.colors import Color |
| 5 | +import numpy as np |
| 6 | +from compas_viewer import Viewer |
| 7 | + |
| 8 | +from compas_lmgc90 import _lmgc90 |
| 9 | + |
| 10 | + |
| 11 | +import os, sys |
| 12 | + |
| 13 | +if not os.path.isdir('./DATBOX'): |
| 14 | + os.mkdir('./DATBOX') |
| 15 | + |
| 16 | +# import des modules |
| 17 | +import math, numpy |
| 18 | +from pylmgc90 import pre |
| 19 | + |
| 20 | +# definition des conteneurs: |
| 21 | +# * de corps |
| 22 | +bodies = pre.avatars() |
| 23 | +# * de materiaux |
| 24 | +mats = pre.materials() |
| 25 | +mods = pre.models() |
| 26 | +# * de lois de contacts |
| 27 | +tacts = pre.tact_behavs() |
| 28 | +# * de tables de visibilite |
| 29 | +svs = pre.see_tables() |
| 30 | + |
| 31 | +# exemple 3D |
| 32 | +dim = 3 |
| 33 | + |
| 34 | +# definition d'un modele rigide |
| 35 | +mR3D = pre.model(name='rigid', physics='MECAx', |
| 36 | + element='Rxx3D', dimension=dim) |
| 37 | +mods.addModel(mR3D) |
| 38 | + |
| 39 | +# definition du materiau pour les blocs |
| 40 | +stone = pre.material(name='STONE', materialType='RIGID', |
| 41 | + density=2750.) |
| 42 | +# ajout des materiaux dans le conteneur |
| 43 | +mats.addMaterial(stone) |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +# ============================================================================= |
| 48 | +# Block Geometry |
| 49 | +# ============================================================================= |
| 50 | + |
| 51 | +arch = BarrelVaultTemplate(span=10,length=4,thickness=0.2,vou_span=20,vou_length=4,rise=3) |
| 52 | +#arch = BarrelVaultTemplate() |
| 53 | + |
| 54 | +# ============================================================================= |
| 55 | +# Block Model |
| 56 | +# ============================================================================= |
| 57 | + |
| 58 | +model = BlockModel() |
| 59 | +for block in arch.blocks(): |
| 60 | + block = Block.from_mesh(block) |
| 61 | + model.add_element(block) |
| 62 | + |
| 63 | +for element in model.elements(): |
| 64 | + |
| 65 | + v=[] |
| 66 | + f=[] |
| 67 | + |
| 68 | + v=[element.geometry.vertex_coordinates(vkey) for vkey in element.geometry.vertices()] |
| 69 | + cnt=[element.geometry.face_vertices(fkey) for fkey in element.geometry.faces()] |
| 70 | + #t3 face |
| 71 | + for p in cnt : |
| 72 | + f.append(p[:-1]) |
| 73 | + f.append([p[0],p[2],p[3]]) |
| 74 | + print(f) |
| 75 | + |
| 76 | + npv=numpy.zeros([len(v), 3],dtype=np.float64) |
| 77 | + for i,c in enumerate(v): |
| 78 | + npv[i,:] = c |
| 79 | + print(npv) |
| 80 | + |
| 81 | + npf=numpy.zeros([len(f), 3],dtype=np.int32) |
| 82 | + for i,t3 in enumerate(f): |
| 83 | + npf[i,:] = t3 |
| 84 | + npf[i,:]+=1 |
| 85 | + print(npf) |
| 86 | + |
| 87 | + # creation d'un nouvel avatar rigide pour le bloc |
| 88 | + |
| 89 | + if element.point.z < 0.31 : |
| 90 | + b = pre.rigidPolyhedron(model=mR3D, material=stone, generation_type='full',\ |
| 91 | + vertices=npv, faces=npf, color='GRND_') |
| 92 | + b.imposeDrivenDof(component=[1,2,3,4,5,6], dofty='vlocy') |
| 93 | + else: |
| 94 | + b = pre.rigidPolyhedron(model=mR3D, material=stone, generation_type='full',\ |
| 95 | + vertices=npv, faces=npf, color='REDxx') |
| 96 | + |
| 97 | + # ajout du bloc a l'ensemble des corps |
| 98 | + bodies.addAvatar(b) |
| 99 | + |
| 100 | +# definition d'une loi de contact frottant, avec pre-gap |
| 101 | +iqs=pre.tact_behav(name='iqsc0', law='IQS_CLB', fric=0.5) |
| 102 | +# ajout de la loi dans le conteneur de lois |
| 103 | +tacts.addBehav(iqs) |
| 104 | + |
| 105 | +# definition d'une table de visibilite pour le |
| 106 | +# contact polyedre-polyedre (i.e. entre blocs) |
| 107 | +sv1 = pre.see_table(CorpsCandidat='RBDY3', candidat='POLYR', colorCandidat='REDxx',\ |
| 108 | + CorpsAntagoniste='RBDY3', antagoniste='POLYR', colorAntagoniste='REDxx',\ |
| 109 | + behav=iqs, alert=1e-3) |
| 110 | +# ajout de la table de visibilite dans le conteneur |
| 111 | +# de tables de visibilite |
| 112 | +svs.addSeeTable(sv1) |
| 113 | + |
| 114 | +sv2 = pre.see_table(CorpsCandidat='RBDY3', candidat='POLYR', colorCandidat='REDxx',\ |
| 115 | + CorpsAntagoniste='RBDY3', antagoniste='POLYR', colorAntagoniste='GRND_',\ |
| 116 | + behav=iqs, alert=1e-3) |
| 117 | +# ajout de la table de visibilite dans le conteneur |
| 118 | +# de tables de visibilite |
| 119 | +svs.addSeeTable(sv2) |
| 120 | + |
| 121 | +post = pre.postpro_commands() |
| 122 | +nlgs = pre.postpro_command(name='SOLVER INFORMATIONS', step=1) |
| 123 | +post.addCommand(nlgs) |
| 124 | + |
| 125 | +# ecriture des fichiers de donnees pour LMGC90 |
| 126 | +pre.writeDatbox(dim, mats, mods, bodies, tacts, svs, post=post) |
| 127 | + |
| 128 | +try: |
| 129 | + pre.visuAvatars(bodies) |
| 130 | +except: |
| 131 | + pass |
| 132 | + |
0 commit comments