-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
elasticity.cc
129 lines (112 loc) · 4.18 KB
/
elasticity.cc
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include <adapter/parameters.h>
#include <sys/stat.h>
#include "source/linear_elasticity/include/linear_elasticity.h"
#include "source/nonlinear_elasticity/include/nonlinear_elasticity.h"
int
main(int argc, char **argv)
{
using namespace dealii;
#ifdef DEAL_II_WITH_MPI
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv);
#endif
try
{
deallog.depth_console(0);
static const unsigned int n_threads = MultithreadInfo::n_threads();
// Query adapter and deal.II info
const std::string adapter_info =
GIT_SHORTREV == std::string("") ?
"unknown" :
(GIT_SHORTREV + std::string(" on branch ") + GIT_BRANCH);
const std::string dealii_info =
DEAL_II_GIT_SHORTREV == std::string("") ?
"unknown" :
(DEAL_II_GIT_SHORTREV + std::string(" on branch ") +
DEAL_II_GIT_BRANCH);
std::cout
<< "-----------------------------------------------------------------------------"
<< std::endl
<< "-- . running with " << n_threads << " thread"
<< (n_threads == 1 ? "" : "s") << std::endl;
std::cout << "-- . adapter revision " << adapter_info << std::endl;
std::cout << "-- . deal.II " << DEAL_II_PACKAGE_VERSION
<< " (revision " << dealii_info << ")" << std::endl;
std::cout
<< "-----------------------------------------------------------------------------"
<< std::endl
<< std::endl;
// Store the name of the parameter file
const std::string parameter_file = argc > 1 ? argv[1] : "parameters.prm";
// Create output directory for the current case
// Query output directory from the parameter file
ParameterHandler prm;
Parameters::Time time;
time.add_output_parameters(prm);
prm.parse_input(parameter_file, "", true);
// force trailing / so we can handle everything in loop
std::string pathname = time.output_folder;
if (pathname[pathname.size() - 1] != '/')
pathname += '/';
size_t pre = 0;
size_t pos;
mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
while ((pos = pathname.find_first_of('/', pre)) != std::string::npos)
{
const std::string subdir = pathname.substr(0, pos++);
pre = pos;
// if leading '/', first string is 0 length
if (subdir.size() == 0)
continue;
int mkdir_return_value;
if ((mkdir_return_value = mkdir(subdir.c_str(), mode)) &&
(errno != EEXIST))
{
AssertThrow(mkdir_return_value,
ExcMessage("Can't create: " + pathname));
return mkdir_return_value;
}
}
// Query solver type from the parameter file
Parameters::Solver solver;
solver.add_output_parameters(prm);
prm.parse_input(parameter_file, "", true);
if (solver.model == "neo-Hookean") // nonlinear
{
Nonlinear_Elasticity::Solid<DIM> solid(parameter_file);
solid.run();
}
else if (solver.model == "linear") // linear
{
Linear_Elasticity::ElastoDynamics<DIM> elastic_solver(parameter_file);
elastic_solver.run();
}
else
AssertThrow(false, ExcNotImplemented());
}
catch (std::exception &exc)
{
std::cerr << std::endl
<< std::endl
<< "----------------------------------------------------"
<< std::endl;
std::cerr << "Exception on processing: " << std::endl
<< exc.what() << std::endl
<< "Aborting!" << std::endl
<< "----------------------------------------------------"
<< std::endl;
return 1;
}
catch (...)
{
std::cerr << std::endl
<< std::endl
<< "----------------------------------------------------"
<< std::endl;
std::cerr << "Unknown exception!" << std::endl
<< "Aborting!" << std::endl
<< "----------------------------------------------------"
<< std::endl;
return 1;
}
return 0;
}