forked from ENSG-GN/fem2A_base
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
173 lines (128 loc) · 4.35 KB
/
main.cpp
File metadata and controls
173 lines (128 loc) · 4.35 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <iostream>
#include <string>
#include <vector>
#include "src/fem.h"
#include "src/mesh.h"
#include "src/solver.h"
#include "src/tests.h"
#include "src/simu.h"
/* Global variables */
std::vector< std::string > arguments;
/* To parse command line arguments */
bool flag_is_used(
const std::string& flag,
const std::vector< std::string >& arguments )
{
for( int i = 0; i < arguments.size(); ++i ) {
if( flag == arguments[i] ) {
return true;
}
}
return false;
}
using namespace FEM2A;
void run_tests()
{
const bool t_opennl = false;
const bool t_lmesh = false;
const bool t_io = false;
const bool t_quad = false;
const bool t_elmap = false;
const bool t_shpf = false;
const bool t_asmblmat = false;
const bool t_lcltgbl = false;
const bool t_cdtdirich = false;
const bool t_assemble_elementary_vector = false;
const bool t_local_to_global_vector = false;
const bool t_assemble_neumann = false;
const bool t_poisson = true;
if( t_opennl ) test_opennl();
if( t_lmesh ) Tests::test_load_mesh();
if( t_io ) Tests::test_load_save_mesh();
if( t_quad ) Tests::test_quadrature(2, false);
if( t_elmap) Tests::test_ElementMapping();
if( t_shpf) Tests::test_ShapeFunctions();
if( t_asmblmat) Tests::test_assemble_elementary_matrix();
if( t_lcltgbl) Tests::test_local_to_global_matrix() ;
if( t_cdtdirich) Tests::test_apply_dirichlet_boundary_conditions();
if( t_assemble_elementary_vector) Tests::test_assemble_elementary_vector();
if( t_local_to_global_vector ) Tests::test_local_to_global_vector();
if( t_assemble_neumann ) Tests::test_assemble_elementary_neumann_vector();
if( t_poisson) Tests::test_poisson_problem("data/square_fine.mesh");
}
void run_simu()
{
const bool simu_pure_dirichlet = false;
const bool simu_dirichlet_source_term = false;
const bool simu_sinus_bump = false;
const bool simu_analytic_sinus_bumb = false;
const bool simu_diff_sin = false;
const bool simu_neumann_pb = false;
const bool simu_mug_pb = false;
//const bool simu_diff_poisson_orders = true;
const bool verbose = flag_is_used( "-v", arguments )
|| flag_is_used( "--verbose", arguments );
if( simu_pure_dirichlet )
{
Simu::pure_dirichlet_pb("data/square.mesh", verbose);
}
if (simu_dirichlet_source_term )
{
Simu::dirichlet_pb_source_term("data/square.mesh", verbose );
}
if (simu_sinus_bump )
{
Simu::dirichlet_sinus_bump_pb("data/square_fine.mesh", verbose );
}
if (simu_analytic_sinus_bumb)
{
Simu::sinus_bump_pb_analytic("data/square_fine.mesh", verbose);
}
if (simu_diff_sin)
{
Simu::diff_pb_sin("data/square_fine.mesh", verbose);
}
if (simu_neumann_pb )
{
Simu::neumann_pb("data/square.mesh", verbose );
}
if (simu_mug_pb )
{
Simu::mug_pb("data/mug_0_5.mesh", verbose);
}
// The simulation above can be run if all the functions in fem.h fem.cpp and simu.h that are required to execute it are de-commented
//if (simu_diff_poisson_orders )
//{
// Simu::diff_poisson_orders("data/square_fine.mesh", verbose);
//}
}
int main( int argc, const char * argv[] )
{
/* Command line parsing */
for( int i = 1; i < argc; ++i ) {
arguments.push_back( std::string(argv[i]) );
}
/* Show usage if asked or no arguments */
if( arguments.size() == 0 || flag_is_used("-h", arguments)
|| flag_is_used("--help", arguments) ) {
std::cout << "Usage: ./fem2a [options]" << std::endl
<< "Options: " << std::endl;
std::cout << " -h, --help: show usage" << std::endl;
std::cout << " -t, --run-tests: run the tests" << std::endl;
std::cout << " -s, --run-simu: run the simulations" << std::endl;
std::cout << " -v, --verbose: print lots of details" << std::endl;
return 0;
}
/// C'EST ICI QUE LES COMMANDES SONT EXECUTEES
/* Run the tests if asked */
if( flag_is_used("-t", arguments)
|| flag_is_used("--run-tests", arguments) ) {
run_tests();
}
/* Run the simulation if asked */
if( flag_is_used("-s", arguments)
|| flag_is_used("--run-simu", arguments) ) {
run_simu();
}
return 0;
}