Skip to content

Commit 9f48510

Browse files
committed
Add ability to output the EPS strains as we still need it for some optimization capabilities
1 parent df6fdda commit 9f48510

11 files changed

+134
-12
lines changed

src/option_parser.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ void ExaOptions::get_visualizations()
517517
avg_euler_strain_fname = _avg_euler_strain_fname;
518518
std::string _avg_pl_work_fname = toml::find_or<std::string>(table, "avg_pl_work_fname", "avg_pl_work.txt");
519519
avg_pl_work_fname = _avg_pl_work_fname;
520+
avg_eps_fname = toml::find_or<std::string>(table, "avg_eps_fname", "avg_eps.txt");
520521
light_up = toml::find_or<bool>(table, "light_up", false);
521522
if (light_up) {
522523

@@ -761,6 +762,10 @@ void ExaOptions::print_options()
761762
std::cout << "Additional averages being computed" << std::endl;
762763
std::cout << "Average deformation gradient filename: " << avg_def_grad_fname << std::endl;
763764
std::cout << "Average plastic work filename: " << avg_pl_work_fname << std::endl;
765+
std::cout << "Average eulerian strain filename: " << avg_euler_strain_fname << std::endl;
766+
std::cout << "Average equivalent plastic strain filename: " << avg_eps_fname << std::endl;
767+
768+
764769
}
765770
else
766771
{

src/option_parser.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class ExaOptions {
5858
// average stress file name
5959
std::string avg_stress_fname;
6060
std::string avg_pl_work_fname;
61+
std::string avg_eps_fname;
6162
std::string avg_def_grad_fname;
6263
std::string avg_euler_strain_fname;
6364
bool additional_avgs;

src/options.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ Version = "0.8.0"
274274
avg_pl_work_fname = "avg_pl_work.txt"
275275
# Optional - the file name for our average eulerian strain file
276276
avg_euler_strain_fname = "avg_euler_strain.txt"
277+
# Optional - the file name for our average equivalent plastic strain file
278+
avg_eps_fname = "avg_eps.txt"
277279
# Options to drive light_up type calculations in-situ in the code
278280
light_up = false
279281
# What HKL planes we want to do the light_up measurements on

src/system_driver.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ SystemDriver::SystemDriver(ParFiniteElementSpace &fes,
116116
avg_stress_fname(options.avg_stress_fname), avg_pl_work_fname(options.avg_pl_work_fname),
117117
avg_def_grad_fname(options.avg_def_grad_fname),
118118
avg_euler_strain_fname(options.avg_euler_strain_fname),
119+
avg_eps_fname(options.avg_eps_fname),
119120
vgrad_origin_flag(options.vgrad_origin_flag), mono_def_flag(options.mono_def_flag),
120121
def_grad(q_kinVars0), evec(q_evec)
121122
{
@@ -637,12 +638,11 @@ void SystemDriver::UpdateModel()
637638
Vector state_var(qstate_var->GetVDim());
638639
state_var = 0.0;
639640

640-
std::string s_pl_work = "pl_work";
641-
auto qf_mapping = model->GetQFMapping();
642-
auto pair = qf_mapping->find(s_pl_work)->second;
643-
644641
exaconstit::kernel::ComputeVolAvgTensor<false>(fes, qstate_var, state_var, state_var.Size(), class_device);
645642

643+
mfem::Vector history(model->GetMatVars0()->GetVDim());
644+
exaconstit::kernel::ComputeVolAvgTensor<true>(fes, model->GetMatVars0(), history, history.Size(), class_device);
645+
646646
std::cout.setf(std::ios::fixed);
647647
std::cout.setf(std::ios::showpoint);
648648
std::cout.precision(8);
@@ -651,16 +651,32 @@ void SystemDriver::UpdateModel()
651651
MPI_Comm_rank(MPI_COMM_WORLD, &my_id);
652652
// Now we're going to save off the average stress tensor to a file
653653
if (my_id == 0) {
654-
std::ofstream file;
655-
file.open(avg_pl_work_fname, std::ios_base::app);
656-
file << state_var[pair.first] << std::endl;
654+
auto qf_mapping = model->GetQFMapping();
655+
{
656+
std::string s_pl_work = "pl_work";
657+
auto pair = qf_mapping->find(s_pl_work)->second;
658+
659+
std::ofstream file;
660+
file.open(avg_pl_work_fname, std::ios_base::app);
661+
file << state_var[pair.first] << std::endl;
662+
}
663+
664+
{
665+
std::string s_eps = "shrEff";
666+
auto pair = qf_mapping->find(s_eps)->second;
667+
668+
std::ofstream file;
669+
file.open(avg_eps_fname, std::ios_base::app);
670+
file << state_var[pair.first] << std::endl;
671+
}
672+
657673
}
658-
mech_operator->CalculateDeformationGradient(def_grad);
659674
}
660675

661676
if (additional_avgs)
662677
{
663678
CALI_CXX_MARK_SCOPE("extra_avgs_def_grad_computation");
679+
mech_operator->CalculateDeformationGradient(def_grad);
664680
const QuadratureFunction *qstate_var = &def_grad;
665681
// Here we're getting the average stress value
666682
Vector dgrad(qstate_var->GetVDim());

src/system_driver.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class SystemDriver
6666
std::string avg_pl_work_fname;
6767
std::string avg_def_grad_fname;
6868
std::string avg_euler_strain_fname;
69+
std::string avg_eps_fname;
6970
std::string auto_dt_fname;
7071

7172
// define a boundary attribute array and initialize to 0

test/data/voce_ea.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ Version = "0.6.0"
9898
avg_pl_work_fname = "test_voce_ea_pl_work.txt"
9999
# Optional - the file name for our average eulerian strain file
100100
avg_euler_strain_fname = "test_voce_ea_euler_strain.txt"
101+
# Optional - the file name for our average equivalent plastic strain file
102+
avg_eps_fname = "test_voce_ea_eps.txt"
101103
[Solvers]
102104
# Option for how our assembly operation is conducted. Possible choices are
103105
# FULL, PA, EA

test/data/voce_ea_cs.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Version = "0.6.0"
9999
avg_def_grad_fname = "test_voce_ea_cs_def_grad.txt"
100100
avg_pl_work_fname = "test_voce_ea_cs_pl_work.txt"
101101
avg_euler_strain_fname = "test_voce_ea_cs_euler_strain.txt"
102+
avg_eps_fname = "test_voce_ea_cs_eps.txt"
102103
[Solvers]
103104
# Option for how our assembly operation is conducted. Possible choices are
104105
# FULL, PA, EA

test/data/voce_ea_cs_eps.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
0
2+
3.46811e-07
3+
3.88961e-05
4+
0.000130992
5+
0.000235568
6+
0.000342301
7+
0.000449272
8+
0.000556043
9+
0.000662545
10+
0.000768796
11+
0.000874843
12+
0.000980726
13+
0.00108647
14+
0.00119208
15+
0.00129759
16+
0.001403
17+
0.00150833
18+
0.00161357
19+
0.00171875
20+
0.00182386
21+
0.0019289
22+
0.00213875
23+
0.00234838
24+
0.0025578
25+
0.00276702
26+
0.00297608
27+
0.00318499
28+
0.0036022
29+
0.00401895
30+
0.00443526
31+
0.00485118
32+
0.00505908
33+
0.00568185
34+
0.00620045
35+
0.00671866
36+
0.00749508
37+
0.00827084
38+
0.00904598
39+
0.0098206
40+
0.0108524

test/data/voce_ea_eps.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
0
2+
3.46778e-07
3+
3.88802e-05
4+
0.000130941
5+
0.000235474
6+
0.000342153
7+
0.00044906
8+
0.000555758
9+
0.000662176
10+
0.000768333
11+
0.000874276
12+
0.000980044
13+
0.00108566
14+
0.00119114
15+
0.0012965
16+
0.00140175
17+
0.00150691
18+
0.00161198
19+
0.00171697
20+
0.00182188
21+
0.00192672
22+
0.00213613
23+
0.00234528
24+
0.00255418
25+
0.00276285
26+
0.00297131
27+
0.00317957
28+
0.00359543
29+
0.00401064
30+
0.00442527
31+
0.00483934
32+
0.00504623
33+
0.00566586
34+
0.00618153
35+
0.00669657
36+
0.00746785
37+
0.0082379
38+
0.00900677
39+
0.00977455
40+
0.0107965

test/test_mechanics.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,18 @@ def runExtraSystemCommands(params):
132132
check_stress(ans_pwd, test_pwd, test)
133133
cmd = 'rm ' + pwd.rstrip() + '/test_'+tresult+'_euler_strain.txt'
134134
subprocess.run(cmd.rstrip(), stdout=subprocess.PIPE, shell=True)
135+
ans_pwd = pwd.rstrip() + '/' + ans[4]
136+
tresult = test.split(".")[0]
137+
test_pwd = pwd.rstrip() + '/test_'+tresult+'_eps.txt'
138+
check_stress(ans_pwd, test_pwd, test)
139+
cmd = 'rm ' + pwd.rstrip() + '/test_'+tresult+'_eps.txt'
140+
subprocess.run(cmd.rstrip(), stdout=subprocess.PIPE, shell=True)
135141
return True
136142

137143
def runExtra():
138144
test_cases = ["voce_ea.toml"]
139145

140-
test_results = [("voce_ea_stress.txt", "voce_ea_def_grad.txt", "voce_ea_pl_work.txt", "voce_ea_euler_strain.txt")]
146+
test_results = [("voce_ea_stress.txt", "voce_ea_def_grad.txt", "voce_ea_pl_work.txt", "voce_ea_euler_strain.txt", "voce_ea_eps.txt")]
141147

142148
result = subprocess.run('pwd', stdout=subprocess.PIPE)
143149

@@ -149,7 +155,8 @@ def runExtra():
149155
cmd = 'rm ' + pwd.rstrip() + '/test_'+tresult+'_stress.txt ' + pwd.rstrip() \
150156
+ '/test_'+tresult+'_pl_work.txt ' + pwd.rstrip() \
151157
+ '/test_'+tresult+'_def_grad.txt' + pwd.rstrip() \
152-
+ '/test_'+tresult+'_euler_strain.txt' + pwd.rstrip()
158+
+ '/test_'+tresult+'_euler_strain.txt' + pwd.rstrip() \
159+
+ '/test_'+tresult+'_eps.txt' + pwd.rstrip()
153160
result = subprocess.run(cmd.rstrip(), stdout=subprocess.PIPE, shell=True)
154161

155162
params = zip(test_cases, test_results)

0 commit comments

Comments
 (0)