Skip to content

Commit 956f8ec

Browse files
authored
fix: Update demos (#9)
## Description <!-- A clear and concise description of what you have done in this PR. --> Clean the demos directory with the new implementation. ## Code of Conduct By submitting this PR, you agree to follow our [Code of Conduct](https://github.com/hpc-maths/scopi/blob/master/doc/CODE_OF_CONDUCT.md) - [x] I agree to follow this project's Code of Conduct
1 parent 7e190c3 commit 956f8ec

File tree

112 files changed

+536
-5202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+536
-5202
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Configure
4747
shell: bash -el {0}
4848
run: |
49-
cmake . -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_DEMOS=ON
49+
cmake . -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON
5050
5151
- name: Run cppcheck on scopi
5252
shell: bash -el {0}
@@ -160,6 +160,7 @@ jobs:
160160
-Bbuild \
161161
-GNinja \
162162
-DCMAKE_BUILD_TYPE=Release \
163+
-DBUILD_EXAMPLES=ON \
163164
-DBUILD_TESTS=ON
164165
165166
- name: Build
@@ -205,6 +206,7 @@ jobs:
205206
-Bbuild \
206207
-GNinja \
207208
-DCMAKE_BUILD_TYPE=Release \
209+
-DBUILD_EXAMPLES=ON \
208210
-DBUILD_TESTS=ON
209211
210212
- name: Build

CMakeLists.txt

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ OPTION(SCOPI_USE_TBB "enable TBB" OFF)
2828
OPTION(SCOPI_USE_OPENMP "enable OpenMP" OFF)
2929
OPTION(SCOPI_USE_MOSEK "enable Mosek" OFF)
3030
OPTION(SCOPI_USE_SCS "enable SCS" OFF)
31-
OPTION(SCOPI_USE_MKL "enable MKL" OFF)
3231
OPTION(BUILD_EXAMPLES "scopi examples" OFF)
3332
OPTION(BUILD_TESTS "scopi test suite" OFF)
3433

@@ -51,7 +50,7 @@ find_package(fmt REQUIRED)
5150
find_package(CLI11 REQUIRED)
5251

5352
find_package(plog REQUIRED)
54-
# find_package(nanoflann REQUIRED)
53+
find_package(nanoflann REQUIRED)
5554

5655
# section needed to use xtensor-blas
5756
# see https://xtensor-blas.readthedocs.io/en/latest/performance.html
@@ -77,14 +76,6 @@ if(SCOPI_USE_OPENMP)
7776
find_package(OpenMP REQUIRED)
7877
endif()
7978

80-
if(SCOPI_USE_MKL)
81-
if(SCOPI_USE_TBB)
82-
set(MKL_THREAD_LAYER "TBB")
83-
endif()
84-
85-
find_package(MKL REQUIRED)
86-
endif()
87-
8879
if(SCOPI_USE_MOSEK)
8980
find_package(MOSEK REQUIRED)
9081

@@ -102,16 +93,6 @@ endif()
10293
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
10394

10495
set(SCOPI_SRC
105-
# src/contact/contact_brute_force.cpp
106-
# src/contact/contact_kdtree.cpp
107-
# src/problems/DryWithoutFriction.cpp
108-
# src/problems/DryWithFriction.cpp
109-
# src/problems/DryWithFrictionBase.cpp
110-
# src/problems/DryWithFrictionFixedPoint.cpp
111-
# src/solvers/ConstraintMosek.cpp
112-
# src/solvers/OptimUzawaBase.cpp
113-
# src/solvers/OptimProjectedGradient.cpp
114-
# src/solvers/projection.cpp
11596
src/vap/vap_fixed.cpp
11697
src/vap/vap_fpd.cpp
11798
src/vap/vap_projection.cpp
@@ -133,7 +114,7 @@ target_link_libraries(scopi PUBLIC xtensor
133114
CLI11::CLI11
134115

135116
plog::plog
136-
# nanoflann::nanoflann
117+
nanoflann::nanoflann
137118
${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
138119

139120
# set_target_properties(scopi PROPERTIES
@@ -143,10 +124,6 @@ target_link_libraries(scopi PUBLIC xtensor
143124
# VERSION ${${PROJECT_NAME}_VERSION}
144125
# SOVERSION ${VERSION_MAJOR}
145126
# OUTPUT_NAME "libscopi")
146-
if(SCOPI_USE_MKL)
147-
target_link_libraries(scopi PUBLIC MKL::MKL)
148-
target_compile_definitions(scopi PUBLIC SCOPI_USE_MKL)
149-
endif()
150127

151128
if(SCOPI_USE_TBB)
152129
target_link_libraries(scopi PUBLIC TBB::tbb)

demos/CMakeLists.txt

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
set(SCOPI_EXAMPLES
2-
# two_ellipsoids.cpp
3-
# two_ellipsoids_asymmetrical_2d.cpp
4-
# two_ellipsoids_asymmetrical_3d.cpp
5-
# two_ellipsoids_spheres_2d.cpp
6-
# two_ellipsoids_spheres_3d.cpp
7-
# test_quentin.cpp
2+
two_ellipsoids.cpp
83
two_spheres.cpp
9-
# two_spheres_periodic.cpp
10-
# sphere_plan.cpp
11-
# viscosity.cpp
12-
# two_spheres_viscosity.cpp
13-
# two_worms.cpp
14-
# three_worms_periodic.cpp
15-
# convergence_scheme.cpp
16-
# box_spheres_3d.cpp
17-
# pile_of_sand_spheres.cpp
18-
# pile_of_sand_superellipsoids.cpp
4+
sphere_plane.cpp
5+
two_worms.cpp
6+
box_spheres_3d.cpp
7+
pile_of_sand_spheres.cpp
198
segment.cpp
20-
# worms_simulation.cpp
219
)
2210

2311
include(generator)
2412
generate_executable(${SCOPI_EXAMPLES})
25-
26-
# add_subdirectory(critical)
27-
# add_subdirectory(proceeding)

demos/box_spheres_3d.cpp

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
#include <cstddef>
2-
#include <scopi/objects/types/plan.hpp>
1+
#include <random>
2+
#include <scopi/objects/types/plane.hpp>
33
#include <scopi/objects/types/sphere.hpp>
4-
#include <scopi/property.hpp>
54
#include <scopi/solver.hpp>
5+
#include <scopi/vap/vap_fpd.hpp>
66
#include <vector>
77
#include <xtensor/xmath.hpp>
88

9-
#include <scopi/contact/contact_brute_force.hpp>
10-
#include <scopi/solvers/OptimMosek.hpp>
11-
#include <scopi/solvers/OptimProjectedGradient.hpp>
12-
#include <scopi/solvers/gradient/apgd_ar.hpp>
13-
#include <scopi/vap/vap_fpd.hpp>
14-
159
int main()
1610
{
17-
#ifdef SCOPI_USE_MKL
18-
plog::init(plog::info, "box_spheres_3d_very_large_apgd_ar.log");
19-
2011
constexpr std::size_t dim = 3;
2112
double PI = xt::numeric_constants<double>::PI;
13+
scopi::initialize("Spheres into a box simulation");
2214

23-
std::size_t total_it = 100;
15+
std::size_t total_it = 1000;
2416
double width_box = 10.;
25-
std::size_t n = 50; // n^3 spheres
26-
double g = 1.;
17+
// std::size_t n = 50; // n^3 spheres
18+
std::size_t n = 10; // n^3 spheres
19+
double g = 1.;
2720

2821
double r0 = width_box / n / 2.;
2922
double dt = 0.2 * 0.9 * r0 / (2. * g); ////// dt = 0.2*r/(sqrt(2*width_box*g))
@@ -38,31 +31,31 @@ int main()
3831
const xt::xtensor_fixed<double, xt::xshape<dim>> axes_y({0., 1., 0.});
3932
const xt::xtensor_fixed<double, xt::xshape<dim>> axes_z({0., 0., 1.});
4033

41-
scopi::plan<dim> p_left(
34+
scopi::plane<dim> p_left(
4235
{
4336
{0., 0., 0.}
4437
},
4538
{scopi::quaternion(0., axes_z)});
4639
particles.push_back(p_left, scopi::property<dim>().deactivate());
47-
scopi::plan<dim> p_right(
40+
scopi::plane<dim> p_right(
4841
{
4942
{width_box + 2 * r0, 0., 0.}
5043
},
5144
{scopi::quaternion(0., axes_z)});
5245
particles.push_back(p_right, scopi::property<dim>().deactivate());
53-
scopi::plan<dim> p_horizontal(
46+
scopi::plane<dim> p_horizontal(
5447
{
5548
{0., 0., 0.}
5649
},
5750
{scopi::quaternion(PI / 2., axes_z)});
5851
particles.push_back(p_horizontal, scopi::property<dim>().deactivate());
59-
scopi::plan<dim> p_front(
52+
scopi::plane<dim> p_front(
6053
{
6154
{0., 0., 0.}
6255
},
6356
{scopi::quaternion(PI / 2., axes_y)});
6457
particles.push_back(p_front, scopi::property<dim>().deactivate());
65-
scopi::plan<dim> p_back(
58+
scopi::plane<dim> p_back(
6659
{
6760
{0., 0., width_box + 2 * r0}
6861
},
@@ -95,16 +88,15 @@ int main()
9588
}
9689
}
9790

98-
scopi::ScopiSolver<dim, scopi::OptimProjectedGradient<scopi::DryWithoutFriction, scopi::apgd_ar>, scopi::contact_kdtree, scopi::vap_fpd>
99-
solver(particles, dt);
100-
auto params = solver.get_params();
101-
params.solver_params.output_frequency = 99;
102-
params.optim_params.tol_l = 1e-3;
103-
params.optim_params.rho = rho;
104-
params.contact_params.dmax = 0.9 * r0;
105-
params.contact_params.kd_tree_radius = params.contact_params.dmax + 2. * 0.9 * r0;
91+
scopi::ScopiSolver<dim, scopi::NoFriction, scopi::OptimGradient<scopi::apgd>, scopi::contact_kdtree, scopi::vap_fpd> solver(particles);
92+
auto params = solver.get_params();
93+
// params.solver_params.output_frequency = 99;
94+
params.optim_params.tolerance = 1e-3;
95+
params.optim_params.alpha = rho;
96+
params.contact_method_params.dmax = 0.9 * r0;
97+
params.contact_method_params.kd_tree_radius = params.contact_method_params.dmax + 2. * 0.9 * r0;
98+
99+
solver.run(dt, total_it);
106100

107-
solver.run(total_it);
108-
#endif
109101
return 0;
110102
}

demos/convergence_scheme.cpp

Lines changed: 0 additions & 84 deletions
This file was deleted.

demos/critical/2d_case.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ int main()
116116
//
117117
// }
118118

119-
scopi::ScopiSolver<dim> solver(particles, dt);
120-
solver.run(total_it);
119+
scopi::ScopiSolver<dim> solver(particles);
120+
solver.run(dt, total_it);
121121

122122
return 0;
123123
}

demos/critical/2d_case_no_overlap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ int main()
7272
}
7373
}
7474

75-
scopi::ScopiSolver<dim> solver(particles, dt);
76-
solver.run(total_it);
75+
scopi::ScopiSolver<dim> solver(particles);
76+
solver.run(dt, total_it);
7777
}

demos/critical/2d_case_no_velocity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ int main()
5757
}
5858
}
5959

60-
scopi::ScopiSolver<dim> solver(particles, dt);
61-
solver.run(total_it);
60+
scopi::ScopiSolver<dim> solver(particles);
61+
solver.run(dt, total_it);
6262
}

demos/critical/2d_case_spheres.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ int main()
5959
}
6060
}
6161

62-
scopi::ScopiSolver<dim> solver(particles, dt);
63-
solver.run(total_it);
62+
scopi::ScopiSolver<dim> solver(particles);
63+
solver.run(dt, total_it);
6464
}

demos/critical/3d_case.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ int main()
9595
particles.push_back(s1, prop1);
9696
particles.push_back(s2, prop2);
9797

98-
scopi::ScopiSolver<dim> solver(particles, dt);
99-
solver.run(total_it);
98+
scopi::ScopiSolver<dim> solver(particles);
99+
solver.run(dt, total_it);
100100

101101
return 0;
102102
}

0 commit comments

Comments
 (0)