Skip to content

Commit a082af3

Browse files
committed
Test CI
1 parent 13948ff commit a082af3

13 files changed

+488
-421
lines changed

code/examples/cut_fem/1d2d/non_smooth_disk.cc

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ class LaplaceSolver {
153153

154154
const unsigned int n_mpi_processes;
155155
const unsigned int this_mpi_process;
156+
157+
mutable ConvergenceTable convergence_table;
158+
159+
mutable unsigned int iter;
156160
};
157161

158162
template <int dim>
@@ -172,6 +176,7 @@ LaplaceSolver<dim>::LaplaceSolver()
172176
fe_collection.push_back(fe_in);
173177
fe_collection.push_back(fe_surf);
174178
fe_collection.push_back(fe_out);
179+
iter = numbers::invalid_unsigned_int;
175180
}
176181

177182
template <int dim>
@@ -892,38 +897,41 @@ void LaplaceSolver<dim>::solve() {
892897
solver.solve(stiffness_matrix, solution, rhs, preconditioner);
893898
std::cout << "Solved in " << solver_control.last_step() << " iterations."
894899
<< std::endl;
900+
iter = solver_control.last_step();
895901
constraints.distribute(solution);
896902
}
897903

898904
template <int dim>
899905
void LaplaceSolver<dim>::output_results() const {
900-
std::cout << "Writing vtu file" << std::endl;
901-
902-
DataOut<dim> data_out;
903-
data_out.add_data_vector(dof_handler, solution, "solution");
904-
data_out.add_data_vector(level_set_dof_handler, level_set, "level_set");
905-
906-
data_out.set_cell_selection(
907-
[this](const typename Triangulation<dim>::cell_iterator &cell) {
908-
return cell->is_active() &&
909-
mesh_classifier.location_to_level_set(cell) !=
910-
NonMatching::LocationToLevelSet::outside;
911-
});
912-
913-
data_out.build_patches();
914-
std::ofstream output_inside_inter("cutFEM_inside_intersected.vtu");
915-
data_out.write_vtu(output_inside_inter);
916-
917-
data_out.set_cell_selection(
918-
[this](const typename Triangulation<dim>::cell_iterator &cell) {
919-
return cell->is_active() &&
920-
mesh_classifier.location_to_level_set(cell) ==
921-
NonMatching::LocationToLevelSet::outside;
922-
});
923-
924-
data_out.build_patches();
925-
std::ofstream output_outside("cutFEM_outside.vtu");
926-
data_out.write_vtu(output_outside);
906+
// std::cout << "Writing vtu file" << std::endl;
907+
908+
// DataOut<dim> data_out;
909+
// data_out.add_data_vector(dof_handler, solution, "solution");
910+
// data_out.add_data_vector(level_set_dof_handler, level_set, "level_set");
911+
912+
// data_out.set_cell_selection(
913+
// [this](const typename Triangulation<dim>::cell_iterator &cell) {
914+
// return cell->is_active() &&
915+
// mesh_classifier.location_to_level_set(cell) !=
916+
// NonMatching::LocationToLevelSet::outside;
917+
// });
918+
919+
// data_out.build_patches();
920+
// std::ofstream output_inside_inter("cutFEM_inside_intersected.vtu");
921+
// data_out.write_vtu(output_inside_inter);
922+
923+
// data_out.set_cell_selection(
924+
// [this](const typename Triangulation<dim>::cell_iterator &cell) {
925+
// return cell->is_active() &&
926+
// mesh_classifier.location_to_level_set(cell) ==
927+
// NonMatching::LocationToLevelSet::outside;
928+
// });
929+
930+
// data_out.build_patches();
931+
// std::ofstream output_outside("cutFEM_outside.vtu");
932+
// data_out.write_vtu(output_outside);
933+
convergence_table.add_value("Iter.", iter);
934+
iter = 0;
927935
}
928936

929937
template <int dim>
@@ -1232,7 +1240,6 @@ double LaplaceSolver<dim>::compute_H1_error_from_inside() const {
12321240

12331241
template <int dim>
12341242
void LaplaceSolver<dim>::run() {
1235-
ConvergenceTable convergence_table;
12361243
const unsigned int n_refinements = 6;
12371244

12381245
make_grid();
@@ -1247,7 +1254,6 @@ void LaplaceSolver<dim>::run() {
12471254
assemble_system();
12481255
solve();
12491256
// if (cycle == 3)
1250-
output_results();
12511257
const double error_L2_inside = compute_L2_error_from_inside();
12521258
const double error_L2_outside = compute_L2_error_from_outside();
12531259
const double error_L2 = std::sqrt(error_L2_outside * error_L2_outside +
@@ -1266,9 +1272,11 @@ void LaplaceSolver<dim>::run() {
12661272
convergence_table.add_value("dofs", dof_handler.n_dofs());
12671273
convergence_table.add_value("L2-Error", error_L2);
12681274
convergence_table.add_value("H1-Error", error_H1);
1275+
output_results();
12691276

12701277
convergence_table.set_scientific("L2-Error", true);
12711278
convergence_table.set_scientific("H1-Error", true);
1279+
convergence_table.set_scientific("Iter.", false);
12721280
convergence_table.evaluate_convergence_rates(
12731281
"L2-Error", ConvergenceTable::reduction_rate_log2);
12741282
convergence_table.evaluate_convergence_rates(

code/examples/cut_fem/1d2d/smooth_disk.cc

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ class LaplaceSolver {
144144

145145
const unsigned int n_mpi_processes;
146146
const unsigned int this_mpi_process;
147+
148+
mutable ConvergenceTable convergence_table;
149+
150+
mutable unsigned int iter;
147151
};
148152

149153
template <int dim>
@@ -163,6 +167,7 @@ LaplaceSolver<dim>::LaplaceSolver()
163167
fe_collection.push_back(fe_in);
164168
fe_collection.push_back(fe_surf);
165169
fe_collection.push_back(fe_out);
170+
iter = numbers::invalid_unsigned_int;
166171
}
167172

168173
template <int dim>
@@ -907,38 +912,41 @@ void LaplaceSolver<dim>::solve() {
907912
solver.solve(stiffness_matrix, solution, rhs, preconditioner);
908913
std::cout << "Solved in " << solver_control.last_step() << " iterations."
909914
<< std::endl;
915+
iter = solver_control.last_step();
910916
constraints.distribute(solution);
911917
}
912918

913919
template <int dim>
914920
void LaplaceSolver<dim>::output_results() const {
915-
std::cout << "Writing vtu file" << std::endl;
916-
917-
DataOut<dim> data_out;
918-
data_out.add_data_vector(dof_handler, solution, "solution");
919-
data_out.add_data_vector(level_set_dof_handler, level_set, "level_set");
920-
921-
data_out.set_cell_selection(
922-
[this](const typename Triangulation<dim>::cell_iterator &cell) {
923-
return cell->is_active() &&
924-
mesh_classifier.location_to_level_set(cell) !=
925-
NonMatching::LocationToLevelSet::outside;
926-
});
927-
928-
data_out.build_patches();
929-
std::ofstream output_inside_inter("cutFEM_inside_intersected.vtu");
930-
data_out.write_vtu(output_inside_inter);
931-
932-
data_out.set_cell_selection(
933-
[this](const typename Triangulation<dim>::cell_iterator &cell) {
934-
return cell->is_active() &&
935-
mesh_classifier.location_to_level_set(cell) ==
936-
NonMatching::LocationToLevelSet::outside;
937-
});
938-
939-
data_out.build_patches();
940-
std::ofstream output_outside("cutFEM_outside.vtu");
941-
data_out.write_vtu(output_outside);
921+
// std::cout << "Writing vtu file" << std::endl;
922+
923+
// DataOut<dim> data_out;
924+
// data_out.add_data_vector(dof_handler, solution, "solution");
925+
// data_out.add_data_vector(level_set_dof_handler, level_set, "level_set");
926+
927+
// data_out.set_cell_selection(
928+
// [this](const typename Triangulation<dim>::cell_iterator &cell) {
929+
// return cell->is_active() &&
930+
// mesh_classifier.location_to_level_set(cell) !=
931+
// NonMatching::LocationToLevelSet::outside;
932+
// });
933+
934+
// data_out.build_patches();
935+
// std::ofstream output_inside_inter("cutFEM_inside_intersected.vtu");
936+
// data_out.write_vtu(output_inside_inter);
937+
938+
// data_out.set_cell_selection(
939+
// [this](const typename Triangulation<dim>::cell_iterator &cell) {
940+
// return cell->is_active() &&
941+
// mesh_classifier.location_to_level_set(cell) ==
942+
// NonMatching::LocationToLevelSet::outside;
943+
// });
944+
945+
// data_out.build_patches();
946+
// std::ofstream output_outside("cutFEM_outside.vtu");
947+
// data_out.write_vtu(output_outside);
948+
convergence_table.add_value("Iter.", iter);
949+
iter = 0;
942950
}
943951

944952
template <int dim>
@@ -1271,7 +1279,6 @@ double LaplaceSolver<dim>::compute_H1_error_from_inside() const {
12711279

12721280
template <int dim>
12731281
void LaplaceSolver<dim>::run() {
1274-
ConvergenceTable convergence_table;
12751282
const unsigned int n_refinements = 6;
12761283

12771284
make_grid();
@@ -1285,7 +1292,6 @@ void LaplaceSolver<dim>::run() {
12851292
initialize_matrices();
12861293
assemble_system();
12871294
solve();
1288-
output_results();
12891295
const double error_L2_inside = compute_L2_error_from_inside();
12901296
const double error_L2_outside = compute_L2_error_from_outside();
12911297
const double error_L2 = std::sqrt(error_L2_outside * error_L2_outside +
@@ -1304,9 +1310,11 @@ void LaplaceSolver<dim>::run() {
13041310
convergence_table.add_value("dofs", dof_handler.n_dofs());
13051311
convergence_table.add_value("L2-Error", error_L2);
13061312
convergence_table.add_value("H1-Error", error_H1);
1313+
output_results();
13071314

13081315
convergence_table.set_scientific("L2-Error", true);
13091316
convergence_table.set_scientific("H1-Error", true);
1317+
convergence_table.set_scientific("Iter.", false);
13101318
convergence_table.evaluate_convergence_rates(
13111319
"L2-Error", ConvergenceTable::reduction_rate_log2);
13121320
convergence_table.evaluate_convergence_rates(

code/examples/cut_fem/1d2d/smooth_flower.cc

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class LaplaceSolver {
143143

144144
const unsigned int n_mpi_processes;
145145
const unsigned int this_mpi_process;
146+
mutable ConvergenceTable convergence_table;
147+
mutable unsigned int iter;
146148
};
147149

148150
template <int dim>
@@ -162,6 +164,7 @@ LaplaceSolver<dim>::LaplaceSolver()
162164
fe_collection.push_back(fe_in);
163165
fe_collection.push_back(fe_surf);
164166
fe_collection.push_back(fe_out);
167+
iter = numbers::invalid_unsigned_int;
165168
}
166169

167170
template <int dim>
@@ -183,7 +186,7 @@ void LaplaceSolver<dim>::setup_discrete_level_set(const unsigned int cycle) {
183186
// The grid will be read from an external .vtk file
184187
GridIn<1, 2> grid_in;
185188
grid_in.attach_triangulation(embedded_tria);
186-
std::ifstream input_file(SOURCE_DIR "../../grids/flower_interface.vtk");
189+
std::ifstream input_file("/root/capsule/code/grids/flower_interface.vtk");
187190
grid_in.read_vtk(input_file);
188191
} else {
189192
embedded_tria.refine_global(1);
@@ -888,38 +891,41 @@ void LaplaceSolver<dim>::solve() {
888891
solver.solve(stiffness_matrix, solution, rhs, preconditioner);
889892
std::cout << "Solved in " << solver_control.last_step() << " iterations."
890893
<< std::endl;
894+
iter = solver_control.last_step();
891895
constraints.distribute(solution);
892896
}
893897

894898
template <int dim>
895899
void LaplaceSolver<dim>::output_results() const {
896-
std::cout << "Writing vtu file" << std::endl;
897-
898-
DataOut<dim> data_out;
899-
data_out.add_data_vector(dof_handler, solution, "solution");
900-
data_out.add_data_vector(level_set_dof_handler, level_set, "level_set");
901-
902-
data_out.set_cell_selection(
903-
[this](const typename Triangulation<dim>::cell_iterator &cell) {
904-
return cell->is_active() &&
905-
mesh_classifier.location_to_level_set(cell) !=
906-
NonMatching::LocationToLevelSet::outside;
907-
});
908-
909-
data_out.build_patches();
910-
std::ofstream output_inside_inter("cutFEM_inside_intersected.vtu");
911-
data_out.write_vtu(output_inside_inter);
912-
913-
data_out.set_cell_selection(
914-
[this](const typename Triangulation<dim>::cell_iterator &cell) {
915-
return cell->is_active() &&
916-
mesh_classifier.location_to_level_set(cell) ==
917-
NonMatching::LocationToLevelSet::outside;
918-
});
919-
920-
data_out.build_patches();
921-
std::ofstream output_outside("cutFEM_outside.vtu");
922-
data_out.write_vtu(output_outside);
900+
// std::cout << "Writing vtu file" << std::endl;
901+
902+
// DataOut<dim> data_out;
903+
// data_out.add_data_vector(dof_handler, solution, "solution");
904+
// data_out.add_data_vector(level_set_dof_handler, level_set, "level_set");
905+
906+
// data_out.set_cell_selection(
907+
// [this](const typename Triangulation<dim>::cell_iterator &cell) {
908+
// return cell->is_active() &&
909+
// mesh_classifier.location_to_level_set(cell) !=
910+
// NonMatching::LocationToLevelSet::outside;
911+
// });
912+
913+
// data_out.build_patches();
914+
// std::ofstream output_inside_inter("cutFEM_inside_intersected.vtu");
915+
// data_out.write_vtu(output_inside_inter);
916+
917+
// data_out.set_cell_selection(
918+
// [this](const typename Triangulation<dim>::cell_iterator &cell) {
919+
// return cell->is_active() &&
920+
// mesh_classifier.location_to_level_set(cell) ==
921+
// NonMatching::LocationToLevelSet::outside;
922+
// });
923+
924+
// data_out.build_patches();
925+
// std::ofstream output_outside("cutFEM_outside.vtu");
926+
// data_out.write_vtu(output_outside);
927+
convergence_table.add_value("Iter.", iter);
928+
iter = 0;
923929
}
924930

925931
template <int dim>
@@ -1228,7 +1234,6 @@ double LaplaceSolver<dim>::compute_H1_error_from_inside() const {
12281234

12291235
template <int dim>
12301236
void LaplaceSolver<dim>::run() {
1231-
ConvergenceTable convergence_table;
12321237
const unsigned int n_refinements = 6;
12331238

12341239
make_grid();
@@ -1243,7 +1248,6 @@ void LaplaceSolver<dim>::run() {
12431248
assemble_system();
12441249
solve();
12451250
// if (cycle == 3)
1246-
output_results();
12471251
const double error_L2_inside = compute_L2_error_from_inside();
12481252
const double error_L2_outside = compute_L2_error_from_outside();
12491253
const double error_L2 = std::sqrt(error_L2_outside * error_L2_outside +
@@ -1263,9 +1267,11 @@ void LaplaceSolver<dim>::run() {
12631267
convergence_table.add_value("dofs", dof_handler.n_dofs());
12641268
convergence_table.add_value("L2-Error", error_L2);
12651269
convergence_table.add_value("H1-Error", error_H1);
1270+
output_results();
12661271

12671272
convergence_table.set_scientific("L2-Error", true);
12681273
convergence_table.set_scientific("H1-Error", true);
1274+
convergence_table.set_scientific("Iter.", false);
12691275
convergence_table.evaluate_convergence_rates(
12701276
"L2-Error", ConvergenceTable::reduction_rate_log2);
12711277
convergence_table.evaluate_convergence_rates(

0 commit comments

Comments
 (0)