Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
iMSTK
iMSTK
Commits
d2a2b88f
Commit
d2a2b88f
authored
Mar 28, 2021
by
Andrew Wilson
🐘
Browse files
Merge branch 'PerfImprovements' into 'master'
BUG: Performance improvements to PBD and Dense LSM See merge request
!551
parents
b0ed6693
70013502
Pipeline
#221029
created
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Source/DynamicalModels/ObjectModels/imstkLevelSetModel.cpp
View file @
d2a2b88f
...
...
@@ -216,25 +216,31 @@ LevelSetModel::evolve()
{
for
(
int
x
=
0
;
x
<
dim
[
0
];
x
++
,
i
++
)
{
// Center of voxel
//const Vec3d pos = Vec3d(x, y, z).cwiseProduct(spacing) + shift;
// Gradients
const
Vec3d
gradPos
=
m_forwardGrad
(
Vec3d
(
x
,
y
,
z
));
const
Vec3d
gradNeg
=
m_backwardGrad
(
Vec3d
(
x
,
y
,
z
));
//curvaturesPtr[i] = m_curvature(Vec3d(x, y, z));
// neg
gradientMagPtr
[
i
*
2
]
=
std
::
pow
(
std
::
min
(
gradNeg
[
0
],
0.0
),
2
)
+
std
::
pow
(
std
::
max
(
gradPos
[
0
],
0.0
),
2
)
+
std
::
pow
(
std
::
min
(
gradNeg
[
1
],
0.0
),
2
)
+
std
::
pow
(
std
::
max
(
gradPos
[
1
],
0.0
),
2
)
+
std
::
pow
(
std
::
min
(
gradNeg
[
2
],
0.0
),
2
)
+
std
::
pow
(
std
::
max
(
gradPos
[
2
],
0.0
),
2
);
Vec3d
gradNegMax
=
gradNeg
.
cwiseMax
(
0.0
);
Vec3d
gradNegMin
=
gradNeg
.
cwiseMin
(
0.0
);
Vec3d
gradPosMax
=
gradPos
.
cwiseMax
(
0.0
);
Vec3d
gradPosMin
=
gradPos
.
cwiseMin
(
0.0
);
// Square them
gradNegMax
=
gradNegMax
.
cwiseProduct
(
gradNegMax
);
gradNegMin
=
gradNegMin
.
cwiseProduct
(
gradNegMin
);
gradPosMax
=
gradPosMax
.
cwiseProduct
(
gradPosMax
);
gradPosMin
=
gradPosMin
.
cwiseProduct
(
gradPosMin
);
//
p
os
//
P
os
gradientMagPtr
[
i
*
2
+
1
]
=
std
::
pow
(
std
::
max
(
gradNeg
[
0
],
0.0
),
2
)
+
std
::
pow
(
std
::
min
(
gradPos
[
0
],
0.0
),
2
)
+
std
::
pow
(
std
::
max
(
gradNeg
[
1
],
0.0
),
2
)
+
std
::
pow
(
std
::
min
(
gradPos
[
1
],
0.0
),
2
)
+
std
::
pow
(
std
::
max
(
gradNeg
[
2
],
0.0
),
2
)
+
std
::
pow
(
std
::
min
(
gradPos
[
2
],
0.0
),
2
);
gradNegMax
[
0
]
+
gradNegMax
[
1
]
+
gradNegMax
[
2
]
+
gradPosMin
[
0
]
+
gradPosMin
[
1
]
+
gradPosMin
[
2
];
// Neg
gradientMagPtr
[
i
*
2
]
=
gradNegMin
[
0
]
+
gradNegMin
[
1
]
+
gradNegMin
[
2
]
+
gradPosMax
[
0
]
+
gradPosMax
[
1
]
+
gradPosMax
[
2
];
}
}
});
...
...
Source/DynamicalModels/ObjectModels/imstkPbdModel.cpp
View file @
d2a2b88f
...
...
@@ -108,6 +108,7 @@ PbdModel::initialize()
// Initialize constraints
{
m_constraints
=
std
::
make_shared
<
PBDConstraintVector
>
();
m_partitionedConstraints
=
std
::
make_shared
<
std
::
vector
<
PBDConstraintVector
>>
();
// Initialize FEM constraints
for
(
auto
&
constraint
:
m_parameters
->
m_FEMConstraints
)
...
...
@@ -167,11 +168,7 @@ PbdModel::initialize()
}
// Partition constraints for parallel computation
if
(
!
m_partitioned
)
{
this
->
partitionConstraints
();
m_partitioned
=
true
;
}
this
->
partitionConstraints
();
}
// Setup the default pbd solver if none exists
...
...
Source/DynamicalModels/ObjectModels/imstkPbdModel.h
View file @
d2a2b88f
...
...
@@ -270,7 +270,6 @@ protected:
void
initGraphEdges
(
std
::
shared_ptr
<
TaskNode
>
source
,
std
::
shared_ptr
<
TaskNode
>
sink
)
override
;
protected:
bool
m_partitioned
=
false
;
/// \todo this is used in initialize() as a temporary fix to problems on linux
size_t
m_partitionThreshold
=
16
;
///> Threshold for constraint partitioning
std
::
shared_ptr
<
PbdSolver
>
m_pbdSolver
=
nullptr
;
///> PBD solver
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment