1 #if !defined(KRATOS_PRAGMATIC_ADAPTOR_H_INCLUDED )
2 #define KRATOS_PRAGMATIC_ADAPTOR_H_INCLUDED
10 #include <boost/timer.hpp>
21 #include "include/Mesh.h"
23 #include "include/MetricField.h"
25 #include "include/Coarsen.h"
26 #include "include/Refine.h"
27 #include "include/Smooth.h"
28 #include "include/Swapping.h"
29 #include "include/ticker.h"
61 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
66 double time_coarsen=0, time_refine=0, time_swap=0, time_smooth=0, time_adapt=0, tic;
71 mesh->create_boundary();
77 MetricField<double,3> metric_field(*
mesh);
79 size_t NNodes =
mesh->get_number_nodes();
82 for(
size_t i=0;
i<NNodes;
i++)
84 double target_h = 1.0;
86 double m[] = {
d,0.0,0.0,
d, 0.0,
d};
101 metric_field.set_metric(
m,
i);
103 metric_field.apply_max_aspect_ratio(10);
104 metric_field.update_mesh();
111 double L_up = sqrt(2.0);
112 double L_low = L_up/2;
114 Coarsen<double, 3> coarsen(*
mesh);
115 Smooth<double, 3> smooth(*
mesh);
116 Refine<double, 3> refine(*
mesh);
117 Swapping<double, 3> swapping(*
mesh);
119 time_adapt = get_wtime();
121 double L_max =
mesh->maximal_edge_length();
122 double alpha = sqrt(2.0)/2;
126 std::cout<<
"Phase I\n";
128 for(
size_t i=0;
i<10;
i++)
132 coarsen.coarsen(L_low, L_ref,
true);
133 time_coarsen += get_wtime() - tic;
140 refine.refine(L_ref);
141 time_refine += get_wtime() - tic;
149 time_swap += get_wtime() - tic;
157 time_smooth += get_wtime()-tic;
163 L_max =
mesh->maximal_edge_length();
167 if(L_max>1.0 and (L_max-L_up)<0.01)
172 std::cout<<
"Phase II\n";
174 for(
size_t i=0;
i<5;
i++)
177 coarsen.coarsen(L_up, L_up,
true);
178 time_coarsen += get_wtime() - tic;
186 time_swap += get_wtime() - tic;
192 time_smooth += get_wtime()-tic;
195 double time_defrag = get_wtime();
197 time_defrag = get_wtime()-time_defrag;
203 VTKTools<double>::export_vtu(
"../data/test_adapt_3d-basic",
mesh);
208 time_smooth += get_wtime()-tic;
213 time_adapt = get_wtime()-time_adapt;
218 std::cout<<
"After optimisation based smoothing:\n";
222 VTKTools<double>::export_vtu(
"../data/test_adapt_3d",
mesh);
224 double qmean =
mesh->get_qmean();
225 double qmin =
mesh->get_qmin();
227 long double volume =
mesh->calculate_volume();
228 long double area =
mesh->calculate_area();
234 std::cout<<
"BENCHMARK: time_coarsen time_refine time_swap time_smooth time_defrag time_adapt time_other\n";
235 double time_other = (time_adapt-(time_coarsen+time_refine+time_swap+time_smooth+time_defrag));
236 std::cout<<
"BENCHMARK: "
237 <<std::setw(12)<<time_coarsen<<
" "
238 <<std::setw(11)<<time_refine<<
" "
239 <<std::setw(9)<<time_swap<<
" "
240 <<std::setw(11)<<time_smooth<<
" "
241 <<std::setw(11)<<time_defrag<<
" "
242 <<std::setw(10)<<time_adapt<<
" "
243 <<std::setw(10)<<time_other<<
"\n";
245 std::cout<<
"Expecting qmean>0.7, qmin>0.2: ";
246 if((qmean>0.8)&&(qmin>0.2))
247 std::cout<<
"pass"<<std::endl;
249 std::cout<<
"fail (qmean="<<qmean<<
", qmin="<<qmin<<
")"<<std::endl;
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Definition: pragmatic_adapt_3d.h:38
void AdaptMesh(ModelPart &rmodel_part)
Definition: pragmatic_adapt_3d.h:52
static double max(double a, double b)
Definition: GeometryFunctions.h:79
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
alpha
Definition: generate_convection_diffusion_explicit_element.py:113
h
Definition: generate_droplet_dynamics.py:91
int d
Definition: ode_solve.py:397
mesh
Definition: read_stl.py:7
int m
Definition: run_marine_rain_substepping.py:8
volume
Definition: sp_statistics.py:15
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31