-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpd_dic.py
109 lines (87 loc) · 3.05 KB
/
pd_dic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#-*- coding: utf-8 -*-
#@author: [email protected]
#@author: [email protected]
#@author: [email protected]
import sys
import getopt
import numpy as np
np.set_printoptions(precision=8, threshold=sys.maxsize, suppress=True)
import time
from peripydic import *
def main(argv):
"""
Main
"""
helptext = sys.argv[0] + " -i input.yaml -t type"
types = ['pd', 'dic' , 'energy']
if len(sys.argv) != 5:
print (helptext)
sys.exit(1)
try:
opts, args = getopt.getopt(
argv, "hi:o:t:", ["ifile=","type="])
except getopt.GetoptError:
print( helptext)
sys.exit(0)
for opt, arg in opts:
if opt in ("-i", "--ifile"):
inputFile = arg
elif opt in ("-t", "--type"):
typeIn = arg
if typeIn not in types:
print("Error: Only pd or dic types are supported")
sys.exit(1)
if typeIn == types[0]:
deck = IO.deck.PD_deck(inputFile)
if deck.material_type == "Elastic":
simulation(deck)
elif deck.material_type == "Viscoelastic":
simulation(deck)
else:
print ("Error in pd_dict.py: Material type unknown, please use Elastic or Viscoelastic")
if typeIn == types[1]:
deck = IO.deck.DIC_deck(inputFile)
dic(deck)
if typeIn == types[2]:
deck = IO.deck.DIC_deck(inputFile)
energy(deck)
def energy(deck):
energy_solver_class = Energy_problem(deck)
energy_solver_class.solver(deck)
def dic(deck):
dic_solver_class = DIC_problem(deck)
#ccm_class = IO.ccm.CCM_calcul(deck, dic_solver_class)
if deck.vtk_writer.vtk_enabled == True:
deck.vtk_writer.write_data(deck,dic_solver_class,None)
def simulation(deck):
t0 = time.time()
y_0 = deck.geometry.nodes.copy()
pb_solver_class = problem.pd.PD_problem(deck)
pb_solver_class.quasi_static_solver(deck, y_0)
ccm_class = IO.ccm.CCM_calcul(deck, pb_solver_class)
writeCSV(deck,pb_solver_class)
if deck.vtk_writer.vtk_enabled == True:
deck.vtk_writer.write_data(deck,pb_solver_class,ccm_class)
print ("delta_x = " + str(deck.delta_X))
print ("Horizon = " + str(pb_solver_class.neighbors.horizon))
strain_tensor = ccm_class.global_strain[:,:,deck.time_steps-1]
print ("epsilon_tensor")
print (strain_tensor)
strain_longi = pb_solver_class.strain_calculation(deck, 5, 7)
print ("strain_longi", strain_longi)
#print "Nodes positions = "
#print pb_solver_class.y
if deck.material_type == "Elastic":
stress_tensor = ccm_class.global_stress[:,:,deck.time_steps-1]
print ("stress_tensor")
print (stress_tensor)
print ("strain_energy")
print (pb_solver_class.strain_energy)
print ("Duration:", (time.time() - t0)/60. , "minutes")
def writeCSV(deck,problem):
for out in deck.outputs:
if out.outType == "CSV":
out.write(deck,problem)
# Start the function __main__ at __init__ call
if __name__ == "__main__":
main(sys.argv[1:])