Skip to content

Commit 3af8869

Browse files
committed
WIP (modular structure). Added new folder in src to keep geometry objects and utilities. JSON file can be used to run the PeriDEM model. Need to convert all yaml file into json format, and test library
2 parents 1dced50 + 4631648 commit 3af8869

File tree

118 files changed

+4940
-30516
lines changed

Some content is hidden

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

118 files changed

+4940
-30516
lines changed

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ endif()
124124
# #<<<<<<<<<< Threads >>>>>>>>>>#
125125
find_package(Threads REQUIRED)
126126

127-
# #<<<<<<<<<< YAML >>>>>>>>>>#
128-
find_package(YamlCpp REQUIRED)
129-
130127
# #<<<<<<<<<< VTK >>>>>>>>>>#
131128
#find_package(VTK REQUIRED)
132129
find_package(VTK COMPONENTS CommonCore CommonDataModel IOXML)
@@ -171,11 +168,12 @@ add_subdirectory(external/)
171168

172169
# PeriDEM sub-directories
173170
add_subdirectory(src/util)
171+
add_subdirectory(src/geom)
174172
add_subdirectory(src/rw)
175173
add_subdirectory(src/inp)
176174
add_subdirectory(src/material)
177175
add_subdirectory(src/loading)
178-
add_subdirectory(src/geometry)
176+
add_subdirectory(src/fracture)
179177
add_subdirectory(src/fe)
180178
add_subdirectory(src/particle)
181179
add_subdirectory(src/nsearch)

CMakePresets.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 10,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "default",
11+
"displayName": "Default Config",
12+
"description": "Default build using Ninja generator",
13+
"generator": "Ninja",
14+
"cacheVariables": {
15+
"CMAKE_BUILD_TYPE": "Release",
16+
"CMAKE_CXX_STANDARD": "23",
17+
"Enable_CMAKE_Debug_Build": "TRUE",
18+
"Enable_Documentation": "FALSE",
19+
"Enable_Tests": "FALSE",
20+
"Enable_High_Load_Tests": "FALSE",
21+
"Disable_Docker_MPI_Tests": "TRUE",
22+
"Enable_Apps": "TRUE"
23+
}
24+
},
25+
{
26+
"name": "debug",
27+
"inherits": "default",
28+
"displayName": "Debug Config",
29+
"description": "Debug build with tests enabled",
30+
"cacheVariables": {
31+
"CMAKE_BUILD_TYPE": "Debug",
32+
"Enable_Tests": "TRUE",
33+
"Enable_Apps": "TRUE"
34+
}
35+
}
36+
],
37+
"buildPresets": [
38+
{
39+
"name": "default",
40+
"configurePreset": "default"
41+
},
42+
{
43+
"name": "debug",
44+
"configurePreset": "debug"
45+
}
46+
]
47+
}

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,15 @@ the implementation, interested readers can look at
230230
Core dependencies are:
231231
- [cmake](https://cmake.org/) (>= 3.10.2)
232232
- [vtk](https://vtk.org/) (>= 7.1.1)
233-
- [yaml-cpp](https://github.com/jbeder/yaml-cpp) (>= 0.5.2)
234233
- [metis](https://github.com/KarypisLab/METIS) (>= 5.1.0)
235234
- MPI
236235

237236
Following dependencies are included in the `PeriDEM` library in `external` folder (see [external/README.md](./external/README.md) for more details):
238237
- [fast-cpp-csv-parser](https://github.com/ben-strasser/fast-cpp-csv-parser/tree/master) (version included - master)
239-
- [fmt](https://github.com/fmtlib/fmt) (>= 7.1.3, version included - 10.2.1)
240238
- [nanoflann](https://github.com/jlblancoc/nanoflann) (>= 1.3.2, version included - v1.5.5)
241239
- [taskflow](https://github.com/taskflow/taskflow) (>= 3.7.0)
242240
- [doxygen-awesome-css](https://github.com/jothepro/doxygen-awesome-css) (>= v2.3.3)
241+
- [nlohmann_json](https://github.com/nlohmann/json) (>= 3.12.0)
243242

244243
### Building the code
245244
If all the dependencies are installed on the global path (e.g., `/usr/local/`),

apps/example-modular/main.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "inp/deckIncludes.h"
1212

13-
#include <fmt/format.h>
13+
#include <format>
1414
#include <fstream>
1515
#include <iostream>
1616
#include <random>
@@ -115,7 +115,7 @@ int main(int argc, char *argv[]) {
115115
auto bcDeckJson = inp::BCDeck::getExampleJson(0, 1, 2, false, util::Point());
116116

117117
// create this block from the BCData static function
118-
bcDeckJson["Displacement_BC"]["Set_1"] = inp::BCBaseDeck::getExampleJson("Displacement_BC", false, util::geometry::GeomData(),
118+
bcDeckJson["Displacement_BC"]["Set_1"] = inp::BCBaseDeck::getExampleJson("Displacement_BC", false, geom::GeomData(),
119119
{0}, {}, "", {}, "", {},
120120
{1, 2}, true, "", {});
121121
// or explicitly, we can do
@@ -127,15 +127,15 @@ int main(int argc, char *argv[]) {
127127
double v_mag = 0.1; // m/s
128128
{
129129
// create this block from the ICData static function
130-
bcDeckJson["IC"]["Set_1"] = inp::BCBaseDeck::getExampleJson("IC", false, util::geometry::GeomData(),
130+
bcDeckJson["IC"]["Set_1"] = inp::BCBaseDeck::getExampleJson("IC", false, geom::GeomData(),
131131
{1}, {}, "", {}, "", {},
132132
{}, true, "Constant_Velocity", {v_mag*0.1, v_mag*0.9, 0.});
133133
// or explicitly, we can do
134134
// initCondJson.at("Constant_Velocity").at("Particle_List") = std::vector<size_t>({1});
135135
// initCondJson.at("Constant_Velocity").at("Velocity_Vector") = std::vector<double>{v_mag*0.1, v_mag*0.9, 0.};
136136
}
137137
{
138-
bcDeckJson["IC"]["Set_2"] = inp::BCBaseDeck::getExampleJson("IC", false, util::geometry::GeomData(),
138+
bcDeckJson["IC"]["Set_2"] = inp::BCBaseDeck::getExampleJson("IC", false, geom::GeomData(),
139139
{2}, {}, "", {}, "", {},
140140
{}, true, "Constant_Velocity", {v_mag*0.5, v_mag*0.5, 0.});
141141
}
@@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {
155155
auto pDeckJson = json({});
156156

157157
//// create particle geometry json
158-
std::vector<util::geometry::GeomData> pGeomVec(3); // 3 geometry groups
158+
std::vector<geom::GeomData> pGeomVec(3); // 3 geometry groups
159159

160160
pGeomVec[0].d_geomName = "rectangle_minus_rectangle";
161161
// parameters
@@ -198,7 +198,7 @@ int main(int argc, char *argv[]) {
198198
// contact pair 1 - 1
199199
pContactJson["Set_1_1"] = inp::ContactPairDeck::getExampleJson(0.95,
200200
true, false, false,
201-
1e+22, 0.95, 0., 1., 1., 1., 0.);
201+
1e+22, 0.95, 0., 1., 1., 1., 0., 25000.);
202202
// copy other pairs
203203
pContactJson["Set_1_2"] = {{"Copy_Data", std::vector<int>({1, 1})}};
204204
pContactJson["Set_2_2"] = {{"Copy_Data", std::vector<int>({1, 1})}};
@@ -217,15 +217,15 @@ int main(int argc, char *argv[]) {
217217

218218
// p1
219219
pGenJson["Data"]["0"] = {{"x", 0.}, {"y", 0.}, {"z", 0.}, {"o", 0.}, {"s", 1.},
220-
{"geom_id", 0}, {"mat_id", 0}, {"mesh_id", 0}, {"contact_id", 0}};
220+
{"geom_id", 0}, {"mat_id", 0}, {"contact_id", 0}};
221221

222222
// p1
223223
pGenJson["Data"]["1"] = {{"x", 0.}, {"y", 0.}, {"z", 0.}, {"o", 0.}, {"s", 1.},
224-
{"geom_id", 1}, {"mat_id", 1}, {"mesh_id", 1}, {"contact_id", 1}};
224+
{"geom_id", 1}, {"mat_id", 1}, {"contact_id", 1}};
225225

226226
// p1
227227
pGenJson["Data"]["2"] = {{"x", 0.}, {"y", 0.}, {"z", 0.}, {"o", 0.}, {"s", 1.},
228-
{"geom_id", 2}, {"mat_id", 1}, {"mesh_id", 2}, {"contact_id", 1}};
228+
{"geom_id", 2}, {"mat_id", 1}, {"contact_id", 1}};
229229

230230
// add to json
231231
pDeckJson["Particle_Generation"] = pGenJson;

apps/peridynamics/main.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
#include "material/materialUtil.h"
1515
#include "particle/baseParticle.h"
1616
#include "util/function.h"
17-
#include "util/geomObjects.h"
17+
#include "geom/geomObjects.h"
1818
#include "util/matrix.h"
1919
#include "util/methods.h"
2020
#include "util/point.h"
2121
#include "inp/pdecks/contactDeck.h"
2222
#include "rw/reader.h"
2323
#include "util/function.h"
24-
#include "util/geom.h"
24+
#include "geom/geom.h"
2525
#include "util/methods.h"
2626
#include "util/randomDist.h"
2727
#include "util/parallelUtil.h"
@@ -34,7 +34,8 @@
3434
#include "fe/elemIncludes.h"
3535
#include "fe/meshUtil.h"
3636

37-
#include <fmt/format.h>
37+
#include <format>
38+
#include <print>
3839
#include <fstream>
3940
#include <iostream>
4041
#include <random>
@@ -101,7 +102,7 @@ class Model : public model::DEMModel {
101102

102103
// output avg time info
103104
if (dbg_condition) {
104-
log(fmt::format(" Avg time (ms): \n"
105+
log(std::format(" Avg time (ms): \n"
105106
" {:48s} = {:8d}\n"
106107
" {:48s} = {:8d}\n",
107108
"peridynamics force", size_t(getKeyData("avg_peridynamics_force_time")),
@@ -112,19 +113,19 @@ class Model : public model::DEMModel {
112113
appendKeyData("avg_extf_compute_time", 0.);
113114
}
114115

115-
log(fmt::format(" {:50s} = {:8d} \n",
116+
log(std::format(" {:50s} = {:8d} \n",
116117
"Force reset time (ms)",
117118
size_t(force_reset_time)
118119
),
119120
2, dbg_condition, 3);
120121

121-
log(fmt::format(" {:50s} = {:8d} \n",
122+
log(std::format(" {:50s} = {:8d} \n",
122123
"External force time (ms)",
123124
size_t(extf_time)
124125
),
125126
2, dbg_condition, 3);
126127

127-
log(fmt::format(" {:50s} = {:8d} \n",
128+
log(std::format(" {:50s} = {:8d} \n",
128129
"Peridynamics force time (ms)",
129130
size_t(pd_time)
130131
),
@@ -154,18 +155,18 @@ int main(int argc, char *argv[]) {
154155
if (input.cmdOptionExists("-nThreads")) nThreads = std::stoi(input.getCmdOption("-nThreads"));
155156
else {
156157
nThreads = 2;
157-
util::io::print(fmt::format("Running Peridynamics with number of threads = {}\n", nThreads));
158+
std::print("Running Peridynamics with number of threads = {}\n", nThreads);
158159
}
159160
// set number of threads
160161
util::parallel::initNThreads(nThreads);
161-
util::io::print(fmt::format("Number of threads = {}\n", util::parallel::getNThreads()));
162+
std::print("Number of threads = {}\n", util::parallel::getNThreads());
162163

163164
std::string filename;
164165
if (input.cmdOptionExists("-i"))
165166
filename = input.getCmdOption("-i");
166167
else {
167168
filename = "./example/input_1.yaml";
168-
util::io::print(fmt::format("Running Peridynamics with example input file = {}\n", filename));
169+
std::print("Running Peridynamics with example input file = {}\n", filename);
169170
}
170171

171172
// current time

apps/twoparticle_demo/main.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,27 @@
1010

1111
#include <PeriDEMConfig.h>
1212

13+
#include "inp/input.h"
1314
#include "model/dem/demModel.h"
1415
#include "material/materialUtil.h"
1516
#include "particle/baseParticle.h"
1617
#include "util/function.h"
17-
#include "util/geomObjects.h"
18+
#include "geom/geomObjects.h"
1819
#include "util/matrix.h"
19-
#include "util/methods.h"
20+
#include "util/vecMethods.h"
2021
#include "util/point.h"
21-
#include "inp/pdecks/contactDeck.h"
2222
#include "rw/reader.h"
2323
#include "util/function.h"
24-
#include "util/geom.h"
25-
#include "util/methods.h"
24+
#include "geom/geomUtilFunctions.h"
25+
#include "util/vecMethods.h"
2626
#include "util/randomDist.h"
2727
#include "util/parallelUtil.h"
28-
#include "inp/decks/materialDeck.h"
29-
#include "inp/decks/modelDeck.h"
30-
#include "inp/decks/outputDeck.h"
31-
#include "inp/decks/restartDeck.h"
3228
#include "rw/vtkParticleWriter.h"
3329
#include "rw/vtkParticleReader.h"
3430
#include "fe/elemIncludes.h"
3531
#include "fe/meshUtil.h"
3632

37-
#include <fmt/format.h>
33+
#include <format>
3834
#include <fstream>
3935
#include <iostream>
4036
#include <random>
@@ -102,7 +98,7 @@ class Model : public model::DEMModel {
10298
else if (particle_mesh_p->getElementType() == util::vtk_type_tetra)
10399
elem = new fe::TetElem(d_modelDeck_p->d_quadOrder);
104100
else {
105-
std::cerr << fmt::format("Error: Can not compute strain/stress as the element "
101+
std::cerr << std::format("Error: Can not compute strain/stress as the element "
106102
"type = {} is not yet supported in this routine.\n", particle_mesh_p->getElementType());
107103
exit(EXIT_FAILURE);
108104
}
@@ -132,7 +128,7 @@ class Model : public model::DEMModel {
132128
void integrate() override {
133129
// perform output at the beginning
134130
if (d_n == 0 && d_outputDeck_p->d_performOut) {
135-
log(fmt::format("{}: Output step = {}, time = {:.6f} \n", d_name, d_n, d_time),
131+
log(std::format("{}: Output step = {}, time = {:.6f} \n", d_name, d_n, d_time),
136132
2);
137133
output();
138134
}
@@ -146,7 +142,7 @@ class Model : public model::DEMModel {
146142

147143
for (size_t i = d_n; i < d_modelDeck_p->d_Nt; i++) {
148144

149-
log(fmt::format("{}: Time step: {}, time: {:8.6f}, steps completed = {}%\n",
145+
log(std::format("{}: Time step: {}, time: {:8.6f}, steps completed = {}%\n",
150146
d_name,
151147
i,
152148
d_time,
@@ -160,7 +156,7 @@ class Model : public model::DEMModel {
160156
double integrate_time =
161157
util::methods::timeDiff(t1, steady_clock::now());
162158

163-
log(fmt::format(" Integration time (ms) = {}\n", integrate_time),
159+
log(std::format(" Integration time (ms) = {}\n", integrate_time),
164160
2, d_n % d_infoN == 0, 3);
165161

166162
if (d_pDeck_p->d_testName == "two_particle") {
@@ -250,7 +246,7 @@ class Model : public model::DEMModel {
250246
if (util::isLess(d_maxY, max_y_loc))
251247
d_maxY = max_y_loc;
252248

253-
log(fmt::format("max y: {} \n", d_maxY), 2, d_n % d_infoN == 0, 3);
249+
log(std::format("max y: {} \n", d_maxY), 2, d_n % d_infoN == 0, 3);
254250

255251
// compute ideal values
256252
static int contact_pp_ideal = -1;
@@ -392,18 +388,18 @@ int main(int argc, char *argv[]) {
392388
if (input.cmdOptionExists("-nThreads")) nThreads = std::stoi(input.getCmdOption("-nThreads"));
393389
else {
394390
nThreads = 2;
395-
util::io::print(fmt::format("Running TwoParticle_Demo with number of threads = {}\n", nThreads));
391+
std::print("Running TwoParticle_Demo with number of threads = {}\n", nThreads);
396392
}
397393
// set number of threads
398394
util::parallel::initNThreads(nThreads);
399-
util::io::print(fmt::format("Number of threads = {}\n", util::parallel::getNThreads()));
395+
std::print("Number of threads = {}\n", util::parallel::getNThreads());
400396

401397
std::string filename;
402398
if (input.cmdOptionExists("-i"))
403399
filename = input.getCmdOption("-i");
404400
else {
405401
filename = "./example/input_0.yaml";
406-
util::io::print(fmt::format("Running TwoParticle_Demo with example input file = {}\n", filename));
402+
std::print("Running TwoParticle_Demo with example input file = {}\n", filename);
407403
}
408404

409405
// current time

external/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# file LICENSE)
88

99
# add_subdirectory(csv)
10-
add_subdirectory(fmt EXCLUDE_FROM_ALL)
1110
# add_subdirectory(nanoflann)
1211
# add_subdirectory(taskflow)
1312
#add_subdirectory(nlohmann_json)

external/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
- current version - v2.3.3
1111
- download link (current version) - [https://github.com/jothepro/doxygen-awesome-css/releases/tag/v2.3.3](https://github.com/jothepro/doxygen-awesome-css/releases/tag/v2.3.3)
1212

13-
## fmt
14-
- project page - [https://github.com/fmtlib/fmt](https://github.com/fmtlib/fmt)
15-
- current version - 10.2.1
16-
- download link (current version) - [https://github.com/fmtlib/fmt/releases/tag/10.2.1](https://github.com/fmtlib/fmt/releases/tag/10.2.1)
17-
1813
## nanoflann
1914
- project page - [https://github.com/jlblancoc/nanoflann](https://github.com/jlblancoc/nanoflann)
2015
- current version - v1.5.5

0 commit comments

Comments
 (0)