Skip to content

Commit de9c1e2

Browse files
polyfem-data check
1 parent fc26d3d commit de9c1e2

File tree

6 files changed

+217
-26
lines changed

6 files changed

+217
-26
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
build/**
2-
.vscode/launch.json
2+
.vscode/launch.json

data/default_rules.json

Lines changed: 188 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"boundary_conditions",
1717
"initial_conditions",
1818
"output",
19-
"input"
19+
"input",
20+
"authen_t1"
2021
],
2122
"doc": "Root of the configuration file."
2223
},
@@ -33,6 +34,56 @@
3334
"type": "string",
3435
"doc": "//TODO"
3536
},
37+
{
38+
"pointer": "/authen_t1",
39+
"default": null,
40+
"type": "object",
41+
"optional":[
42+
"err_h1",
43+
"err_h1_semi",
44+
"err_l2",
45+
"err_linf",
46+
"err_linf_grad",
47+
"err_lp",
48+
"margin"
49+
],
50+
"doc": "//TODO"
51+
},
52+
{
53+
"pointer": "/authen_t1/err_h1",
54+
"default":0,
55+
"type":"float"
56+
},
57+
{
58+
"pointer": "/authen_t1/err_h1_semi",
59+
"default":0,
60+
"type":"float"
61+
},
62+
{
63+
"pointer": "/authen_t1/err_l2",
64+
"default":0,
65+
"type":"float"
66+
},
67+
{
68+
"pointer": "/authen_t1/err_linf",
69+
"default":0,
70+
"type":"float"
71+
},
72+
{
73+
"pointer": "/authen_t1/err_linf_grad",
74+
"default":0,
75+
"type":"float"
76+
},
77+
{
78+
"pointer": "/authen_t1/err_lp",
79+
"default":0,
80+
"type":"float"
81+
},
82+
{
83+
"pointer": "/authen_t1/margin",
84+
"default":0,
85+
"type":"float"
86+
},
3687
{
3788
"pointer": "/geometry",
3889
"type": "list",
@@ -56,9 +107,15 @@
56107
"pointer": "/geometry/*/transformation",
57108
"type": "object",
58109
"default": null,
59-
"optional": ["translation","rotation","scale"],
110+
"optional": ["translation","rotation","rotation_mode","scale","dimensions"],
60111
"doc": "Geometric transformations applied to the geometry after loading it."
61112
},
113+
{
114+
"pointer": "/geometry/*/transformation/rotation_mode",
115+
"type": "string",
116+
"default": "xyz",
117+
"doc": "//TODO"
118+
},
62119
{
63120
"pointer": "/geometry/*/transformation/translation",
64121
"type": "list",
@@ -67,12 +124,22 @@
67124
{
68125
"pointer": "/geometry/*/transformation/rotation",
69126
"type": "list",
70-
"default": null
127+
"default": []
71128
},
72129
{
73130
"pointer": "/geometry/*/transformation/scale",
74131
"type": "list",
75-
"default": null
132+
"default": []
133+
},
134+
{
135+
"pointer": "/geometry/*/transformation/dimensions",
136+
"type": "list",
137+
"default": []
138+
},
139+
{
140+
"pointer": "/geometry/*/transformation/dimensions/*",
141+
"type": "float",
142+
"default": 0
76143
},
77144
{
78145
"pointer": "/geometry/*/transformation/translation/*",
@@ -118,7 +185,7 @@
118185
"pointer": "/geometry/*/surface_selection/*",
119186
"type": "object",
120187
"required":["id"],
121-
"optional":["axis", "position"],
188+
"optional":["axis", "position","box", "relative"],
122189
"default": null
123190
},
124191
{
@@ -135,6 +202,30 @@
135202
"type": "float",
136203
"default": null
137204
},
205+
{
206+
"pointer": "/geometry/*/surface_selection/*/relative",
207+
"type": "bool",
208+
"default": "//TODO"
209+
},
210+
{
211+
"pointer": "/geometry/*/surface_selection/*/box",
212+
"type": "list",
213+
"min":2,
214+
"max":2,
215+
"default": [[],[]]
216+
},
217+
{
218+
"pointer": "/geometry/*/surface_selection/*/box/*",
219+
"type": "list",
220+
"min":2,
221+
"max":3,
222+
"default": []
223+
},
224+
{
225+
"pointer": "/geometry/*/surface_selection/*/box/*/*",
226+
"type": "float",
227+
"default": 0
228+
},
138229
{
139230
"pointer": "/geometry/*/n_refs",
140231
"type": "int",
@@ -574,6 +665,11 @@
574665
"type": "string",
575666
"doc": "The coefficient of clamped log-barrier function"
576667
},
668+
{
669+
"pointer": "/solver/contact/barrier_stiffness",
670+
"type": "float",
671+
"doc": "The coefficient of clamped log-barrier function"
672+
},
577673
{
578674
"pointer": "/solver/contact/lagged_damping_weight",
579675
"default": 0,
@@ -617,7 +713,7 @@
617713
"pointer": "/materials/*",
618714
"type": "object",
619715
"required":["type"],
620-
"optional": ["id", "E", "nu", "rho", "mu", "lambda"],
716+
"optional": ["id", "E", "nu", "rho", "mu", "lambda","density"],
621717
"doc": "Material Parameters including id, Young's modulus(E), Poisson ratio(nu), Density(rho), type()"
622718
},
623719
{
@@ -644,6 +740,12 @@
644740
"default":"//TODO",
645741
"doc":"Density"
646742
},
743+
{
744+
"pointer": "/materials/*/density",
745+
"type":"float",
746+
"default":"//TODO",
747+
"doc":"Density"
748+
},
647749
{
648750
"pointer": "/materials/*/type",
649751
"type":"string",
@@ -764,8 +866,7 @@
764866
"default":"//TODO",
765867
"optional":[
766868
"id",
767-
"value",
768-
"dimension"
869+
"value"
769870
],
770871
"doc": "Neumann boundary condition"
771872
},
@@ -796,21 +897,9 @@
796897
{
797898
"pointer":"/boundary_conditions/neumann_boundary/*/value/*",
798899
"type":"float",
799-
"default":"//TODO",
900+
"default": "//TODO",
800901
"doc": "values of Neumann boundary condition for each dimension"
801902
},
802-
{
803-
"pointer":"/boundary_conditions/neumann_boundary/*/dimension",
804-
"type":"list",
805-
"default":[true, true, true],
806-
"doc": "If the dimension is under neumann boundary condition"
807-
},
808-
{
809-
"pointer":"/boundary_conditions/neumann_boundary/*/dimension/*",
810-
"type":"bool",
811-
"default":true,
812-
"doc": "If the dimension is under neumann boundary condition"
813-
},
814903
{
815904
"pointer": "/boundary_conditions/pressure_boundary",
816905
"default": [],
@@ -913,20 +1002,96 @@
9131002
},
9141003
{
9151004
"pointer": "/initial_conditions/solution",
916-
"default": null,
917-
"type": "object",
1005+
"default": [],
1006+
"type": "list",
1007+
"doc": "//TODO"
1008+
},
1009+
{
1010+
"pointer": "/initial_conditions/solution/*",
1011+
"default": 0,
1012+
"type": "float",
9181013
"doc": "//TODO"
9191014
},
9201015
{
9211016
"pointer": "/initial_conditions/velocity",
1017+
"default": [],
1018+
"type": "list",
1019+
"doc": "//TODO"
1020+
},
1021+
{
1022+
"pointer": "/initial_conditions/velocity/*",
9221023
"default": null,
9231024
"type": "object",
1025+
"required":["id","value"],
1026+
"doc": "//TODO"
1027+
},
1028+
{
1029+
"pointer": "/initial_conditions/velocity/*/id",
1030+
"type": "int",
1031+
"doc": "//TODO"
1032+
},
1033+
{
1034+
"pointer": "/initial_conditions/velocity/*/value",
1035+
"type": "list",
1036+
"min": 2,
1037+
"max":3,
1038+
"doc": "//TODO"
1039+
},
1040+
{
1041+
"pointer": "/initial_conditions/velocity/*/value",
1042+
"type": "float",
1043+
"doc": "//TODO"
1044+
},
1045+
{
1046+
"pointer": "/initial_conditions/velocity/*/value/*",
1047+
"type": "float",
1048+
"default":0,
1049+
"doc": "//TODO"
1050+
},
1051+
{
1052+
"pointer": "/initial_conditions/velocity/*/value/*",
1053+
"type": "string",
9241054
"doc": "//TODO"
9251055
},
9261056
{
9271057
"pointer": "/initial_conditions/acceleration",
1058+
"default": [],
1059+
"type": "list",
1060+
"doc": "//TODO"
1061+
},
1062+
{
1063+
"pointer": "/initial_conditions/acceleration/*",
9281064
"default": null,
9291065
"type": "object",
1066+
"required":["id","value"],
1067+
"doc": "//TODO"
1068+
},
1069+
{
1070+
"pointer": "/initial_conditions/acceleration/*/id",
1071+
"type": "int",
1072+
"doc": "//TODO"
1073+
},
1074+
{
1075+
"pointer": "/initial_conditions/acceleration/*/value",
1076+
"type": "list",
1077+
"min": 2,
1078+
"max":3,
1079+
"doc": "//TODO"
1080+
},
1081+
{
1082+
"pointer": "/initial_conditions/acceleration/*/value",
1083+
"type": "float",
1084+
"doc": "//TODO"
1085+
},
1086+
{
1087+
"pointer": "/initial_conditions/acceleration/*/value/*",
1088+
"type": "float",
1089+
"default":0,
1090+
"doc": "//TODO"
1091+
},
1092+
{
1093+
"pointer": "/initial_conditions/acceleration/*/value/*",
1094+
"type": "string",
9301095
"doc": "//TODO"
9311096
},
9321097
{

data/polyfem-data

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 397d67ebab70fdf66c2303bf0777f2da07b186d8

src/sjv/sjv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ namespace sjv
151151
std::string p_str = cwd + "/" + string(input);
152152
std::filesystem::path p = std::filesystem::path(p_str);
153153

154-
if (!std::filesystem::is_regular_file(p))
154+
if (!skip_file_check && !std::filesystem::is_regular_file(p))
155155
{
156156
log.push_back(log_item("warning", "File not found: " + p_str));
157157
if (strict)

src/sjv/sjv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace sjv
3939

4040
// if strict == false, a json is valid even if it has entries not validated by a rule
4141
bool strict = false;
42-
42+
bool skip_file_check = true;
4343
// automatic boxing for primitive types
4444
// if all rules fail for a basic type, try boxing it once and try again
4545
bool boxing_primitive = true;

tests/test_validator.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,29 @@ TEST_CASE("slingshot", "[validator]")
290290
std:: string s = sjv.log2str();
291291
WARN(s);
292292
REQUIRE(r);
293+
}
294+
295+
TEST_CASE("polyfem-data", "[validator]"){
296+
std::ifstream ifs2("../data/default_rules.json");
297+
json rules = json::parse(ifs2);
298+
299+
std::string path("../data/polyfem-data/contact/examples");
300+
std::string ext(".json");
301+
for (auto &p : std::filesystem::recursive_directory_iterator(path))
302+
{
303+
if (p.path().extension() == ext){
304+
if(p.path().stem().string()=="common") continue;
305+
INFO(p.path().string());
306+
std::ifstream ifs1(p.path().string());
307+
json input = json::parse(ifs1);
308+
sjv::SJV sjv;
309+
310+
sjv.strict = true;
311+
312+
bool r = sjv.verify_json(input,rules);
313+
std:: string s = sjv.log2str();
314+
WARN(s);
315+
REQUIRE(r);
316+
}
317+
}
293318
}

0 commit comments

Comments
 (0)