Skip to content

Commit 7613e04

Browse files
committed
frontend bug fix
1 parent 3b029d6 commit 7613e04

File tree

10 files changed

+65
-48
lines changed

10 files changed

+65
-48
lines changed

examples/friction.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"scene.add(\"slope\").rotate(-deg,\"z\").pin()\n",
2727
"\n",
2828
"fixed = scene.build().report()\n",
29-
"fixed.preview();"
29+
"fixed.preview()"
3030
]
3131
},
3232
{

examples/hang.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"param = app.session.param().set(\"dt\",0.001)\n",
3737
"param.set(\"strain-limit-eps\", 0.005).set(\"strain-limit-tau\", 0.005)\n",
3838
"param.set(\"frames\",200)\n",
39-
"param.dyn(\"gravity\").time(1).hold().time(1+jitter_time).change(9.8).time(2.0).change(-9.8);"
39+
"param.dyn(\"gravity\").time(1).hold().time(1+jitter_time).change(9.8).time(2.0).change(-9.8)"
4040
]
4141
},
4242
{
@@ -47,8 +47,8 @@
4747
"outputs": [],
4848
"source": [
4949
"session = app.session.create(\"two-pins-hang\").init(fixed)\n",
50-
"session.start(param).preview();\n",
51-
"session.stream();"
50+
"session.start(param).preview()\n",
51+
"session.stream()"
5252
]
5353
},
5454
{
@@ -59,7 +59,7 @@
5959
"outputs": [],
6060
"source": [
6161
"# run this cell after sufficnt frames are simulated\n",
62-
"session.animate();"
62+
"session.animate()"
6363
]
6464
},
6565
{
@@ -105,8 +105,8 @@
105105
"param.set(\"dt\",0.1).set(\"enable-retry\",True)\n",
106106
"\n",
107107
"session = app.session.create(\"two-pins-hang-dt-01\").init(fixed)\n",
108-
"session.start(param).preview();\n",
109-
"session.stream();"
108+
"session.start(param).preview()\n",
109+
"session.stream()"
110110
]
111111
},
112112
{
@@ -117,7 +117,7 @@
117117
"outputs": [],
118118
"source": [
119119
"# run this cell after sufficnt frames are simulated\n",
120-
"session.animate();"
120+
"session.animate()"
121121
]
122122
},
123123
{

frontend/_parse_.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,47 @@ def get_logging_docstrings(root: str) -> dict[str, dict[str, str]]:
1212
desc = ""
1313
description_mode = False
1414

15-
def register(name):
16-
nonlocal par_name
15+
def clear():
1716
nonlocal doc
1817
nonlocal desc
1918
nonlocal description_mode
20-
if desc:
21-
doc["Description"] = desc
22-
if par_name:
23-
doc["filename"] = f"{par_name}.{name}.out"
24-
else:
25-
doc["filename"] = f"{name}.out"
26-
if "Map" in doc:
27-
name = doc["Map"]
28-
del doc["Map"]
19+
doc = {}
2920
desc = ""
3021
description_mode = False
31-
result[name.replace("_", "-")] = doc.copy()
22+
23+
def register(name):
24+
nonlocal par_name
25+
nonlocal doc
26+
nonlocal desc
27+
nonlocal description_mode
28+
29+
if "Name" in doc.keys():
30+
if desc:
31+
doc["Description"] = desc
32+
if par_name:
33+
doc["filename"] = f"{par_name}.{name}.out"
34+
else:
35+
doc["filename"] = f"{name}.out"
36+
if "Map" in doc:
37+
name = doc["Map"]
38+
del doc["Map"]
39+
result[name.replace("_", "-")] = doc.copy()
40+
clear()
3241

3342
def extract_name(line):
3443
start = line.find('"') + 1
3544
end = line.find('"', start)
36-
return line[start:end].replace(" ", "_")
45+
name = line[start:end].replace(" ", "_")
46+
return name
3747

3848
def parse_line(line: str):
3949
nonlocal par_name
4050
nonlocal description_mode
4151
nonlocal desc
52+
nonlocal doc
53+
54+
if line.strip() == "":
55+
clear()
4256

4357
skip_lables = ["File", "Author", "License", "https"]
4458
if line.startswith("//"):
@@ -58,7 +72,10 @@ def parse_line(line: str):
5872
content = fields[1].strip()
5973
doc[label] = content
6074
elif line.startswith("SimpleLog logging"):
61-
par_name = extract_name(line)
75+
par_name = ""
76+
name = extract_name(line)
77+
register(name)
78+
par_name = name
6279
elif line.startswith("/*== push"):
6380
register(extract_name(line))
6481
elif "logging.push(" in line:
@@ -78,6 +95,7 @@ def parse_line(line: str):
7895
if "#include" not in line:
7996
parse_line(line)
8097

98+
result = dict(sorted(result.items()))
8199
return result
82100

83101

@@ -197,4 +215,6 @@ def clear_doc():
197215
curr_attributes = []
198216
else:
199217
curr_attributes = []
218+
219+
result = dict(sorted(result.items()))
200220
return result

frontend/_session_.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@ def float_or_int(var):
539539
entries.append([float_or_int(entry[0]), float_or_int(entry[1])])
540540
return entries
541541
else:
542-
print(f"File {path} does not exist")
543542
return None
544543

545544
def number(self, name: str):
@@ -889,9 +888,7 @@ def convert_time(time) -> str:
889888
if live_update and is_running():
890889

891890
def update_dataframe(table, curr_frame):
892-
time_per_frame = convert_time(
893-
self.get.log.number("time-per-frame")
894-
)
891+
time_per_frame = convert_time(self.get.log.number("time-per-frame"))
895892
time_per_step = convert_time(self.get.log.number("time-per-step"))
896893
n_contact = convert_integer(self.get.log.number("num-contact"))
897894
n_newton = convert_integer(self.get.log.number("newton-steps"))

src/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct Args {
6363
// When an object is moving in the air, both drag and lift forces are computed.
6464
// This value controls the ratio of the tangential friction to the normal friction.
6565
#[clap(long, default_value_t = 0.2)]
66-
pub aerial_friction: f32,
66+
pub air_friction: f32,
6767

6868
// Name: Extended Line Search Maximum Time
6969
// Recommended Range: 1.25 to 1.75
@@ -339,7 +339,7 @@ pub struct Args {
339339
// Description:
340340
// Per-vertex air dragging coefficient.
341341
#[clap(long, default_value_t = 0.0)]
342-
pub isotropic_aerial_friction: f32,
342+
pub isotropic_air_friction: f32,
343343

344344
// Name: Bend Stiffness for Shells
345345
// Recommended Range: 0.0 to 1e2

src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ pub fn make_param(args: &Args) -> data::ParamSet {
329329
data::ParamSet {
330330
time: 0.0,
331331
fitting: false,
332-
aerial_friction: args.aerial_friction,
332+
air_friction: args.air_friction,
333333
air_density: args.air_density,
334334
strain_limit_tau,
335335
strain_limit_eps,
@@ -355,7 +355,7 @@ pub fn make_param(args: &Args) -> data::ParamSet {
355355
eiganalysis_eps: args.eiganalysis_eps,
356356
friction: args.friction,
357357
friction_eps: args.friction_eps,
358-
isotropic_aerial_friction: args.isotropic_aerial_friction,
358+
isotropic_air_friction: args.isotropic_air_friction,
359359
gravity: Vec3f::new(0.0, args.gravity, 0.0),
360360
wind,
361361
model_shell: match args.model_shell.as_str() {

src/cpp/data.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ struct Constraint {
207207
struct ParamSet {
208208
double time;
209209
bool fitting;
210-
float aerial_friction;
210+
float air_friction;
211211
float air_density;
212212
float strain_limit_tau;
213213
float strain_limit_eps;
@@ -233,7 +233,7 @@ struct ParamSet {
233233
float eiganalysis_eps;
234234
float friction;
235235
float friction_eps;
236-
float isotropic_aerial_friction;
236+
float isotropic_air_friction;
237237
Vec3f gravity;
238238
Vec3f wind;
239239
Model model_shell;

src/cpp/energy/energy.cu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "../eigenanalysis/eigenanalysis.hpp"
99
#include "../utility/dispatcher.hpp"
1010
#include "../utility/utility.hpp"
11-
#include "model/aerial_damper.hpp"
11+
#include "model/air_damper.hpp"
1212
#include "model/arap.hpp"
1313
#include "model/baraffwitkin.hpp"
1414
#include "model/dihedral_angle.hpp"
@@ -39,9 +39,9 @@ embed_vertex_force_hessian(const DataSet &data, const Vec<Vec3f> &eval_x,
3939
Mat3x3f H = Mat3x3f::Zero();
4040
if (normal.isZero() == false && param.air_density) {
4141
f += area * param.air_density *
42-
aerial_damper::face_gradient(dt, y, x, normal, wind, param);
42+
air_damper::face_gradient(dt, y, x, normal, wind, param);
4343
H += area * param.air_density *
44-
aerial_damper::face_hessian(dt, normal, param);
44+
air_damper::face_hessian(dt, normal, param);
4545
}
4646
bool pulled(false);
4747
for (unsigned j = 0; j < data.constraint.pull.size; ++j) {
@@ -58,10 +58,10 @@ embed_vertex_force_hessian(const DataSet &data, const Vec<Vec3f> &eval_x,
5858
f += mass * momentum::gradient(dt, y, target[i]);
5959
H += mass * momentum::hessian(dt);
6060
}
61-
if (param.isotropic_aerial_friction) {
62-
f += param.isotropic_aerial_friction * (y - x) / (dt * dt);
61+
if (param.isotropic_air_friction) {
62+
f += param.isotropic_air_friction * (y - x) / (dt * dt);
6363
H +=
64-
(param.isotropic_aerial_friction / (dt * dt)) * Mat3x3f::Identity();
64+
(param.isotropic_air_friction / (dt * dt)) * Mat3x3f::Identity();
6565
}
6666
if (param.fix_xz && y[1] > param.fix_xz) {
6767
float t = fmin(1.0f, y[1] - param.fix_xz);
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// File: aerial_damper.hpp
1+
// File: air_damper.hpp
22
// Author: Ryoichi Ando ([email protected])
33
// License: Apache v2.0
44

5-
#ifndef AERIAL_DAMP_HPP
6-
#define AERIAL_DAMP_HPP
5+
#ifndef air_DAMP_HPP
6+
#define air_DAMP_HPP
77

88
#include "../../data.hpp"
99

10-
namespace aerial_damper {
10+
namespace air_damper {
1111

1212
__device__ Mat3x3f get_proj_op(const Vec3f &normal) {
1313
return Mat3x3f::Identity() - normal * normal.transpose();
@@ -20,7 +20,7 @@ __device__ float face_energy(float dt, const Vec3f &x1, const Vec3f &x0,
2020
Mat3x3f P = get_proj_op(normal);
2121
float f = normal.dot(x1 - z);
2222
Vec3f g = P * (x1 - z);
23-
return 0.5f * (f * f + param.aerial_friction * g.squaredNorm()) / (dt * dt);
23+
return 0.5f * (f * f + param.air_friction * g.squaredNorm()) / (dt * dt);
2424
}
2525

2626
__device__ Vec3f face_gradient(float dt, const Vec3f &x1, const Vec3f &x0,
@@ -29,16 +29,16 @@ __device__ Vec3f face_gradient(float dt, const Vec3f &x1, const Vec3f &x0,
2929
Vec3f z = x0 + dt * wind;
3030
Mat3x3f P = get_proj_op(normal);
3131
return normal * normal.dot(x1 - z) / (dt * dt) +
32-
param.aerial_friction * P * (x1 - z) / (dt * dt);
32+
param.air_friction * P * (x1 - z) / (dt * dt);
3333
}
3434

3535
__device__ Mat3x3f face_hessian(float dt, const Vec3f &normal,
3636
const ParamSet &param) {
3737
Mat3x3f P = get_proj_op(normal);
3838
return normal * normal.transpose() / (dt * dt) +
39-
param.aerial_friction * P / (dt * dt);
39+
param.air_friction * P / (dt * dt);
4040
}
4141

42-
} // namespace aerial_damper
42+
} // namespace air_damper
4343

4444
#endif

src/data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ pub struct Constraint {
281281
pub struct ParamSet {
282282
pub time: f64,
283283
pub fitting: bool,
284-
pub aerial_friction: f32,
284+
pub air_friction: f32,
285285
pub air_density: f32,
286286
pub strain_limit_tau: f32,
287287
pub strain_limit_eps: f32,
@@ -307,7 +307,7 @@ pub struct ParamSet {
307307
pub eiganalysis_eps: f32,
308308
pub friction: f32,
309309
pub friction_eps: f32,
310-
pub isotropic_aerial_friction: f32,
310+
pub isotropic_air_friction: f32,
311311
pub gravity: Vec3f,
312312
pub wind: Vec3f,
313313
pub model_shell: Model,

0 commit comments

Comments
 (0)