Skip to content

Commit a826c09

Browse files
committed
Upgrade Eigen version
1 parent e535859 commit a826c09

20 files changed

+78
-64
lines changed

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@ endif()
3333

3434
# Unless user specified otherwise, we decide the structure of our build tree.
3535
include(GNUInstallDirs)
36-
if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
36+
37+
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
3738
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
3839
message(VERBOSE "PBAT -- Set CMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
3940
endif()
40-
if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
41+
42+
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
4143
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
4244
message(VERBOSE "PBAT -- Set CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
4345
endif()
44-
if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
46+
47+
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
4548
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
4649
message(VERBOSE "PBAT -- Set CMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
4750
endif()
@@ -70,6 +73,7 @@ set_target_properties(PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit
7073
)
7174
install(
7275
TARGETS
76+
eigen
7377
PhysicsBasedAnimationToolkit_PhysicsBasedAnimationToolkit
7478
EXPORT PhysicsBasedAnimationToolkit_Targets
7579
FILE_SET api

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ Head over to our hands-on [tutorials section](./doc/tutorial/) to learn more abo
111111

112112
## Dependencies
113113

114-
See [`vcpkg.json`](./vcpkg.json) for a versioned list of our dependencies, available via [vcpkg](https://github.com/microsoft/vcpkg).
114+
See [`vcpkg.json`](./vcpkg.json) for a versioned list of our external dependencies, available via [vcpkg](https://github.com/microsoft/vcpkg).
115115

116-
> Use of [vcpkg](https://github.com/microsoft/vcpkg) is not mandatory, as long as dependencies have compatible versions and are discoverable by CMake's [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html) mechanism.
116+
> Use of [vcpkg](https://github.com/microsoft/vcpkg) is not mandatory, as long as external dependencies have compatible versions and are discoverable by CMake's [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html) mechanism.
117117
118118
### CUDA
119119

cmake/dependencies.cmake

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1+
include(FetchContent)
2+
13
find_package(doctest CONFIG REQUIRED)
2-
find_package(Eigen3 CONFIG REQUIRED)
34
find_package(fmt CONFIG REQUIRED)
45
find_package(range-v3 CONFIG REQUIRED)
56
find_package(TBB CONFIG REQUIRED)
67

8+
if(NOT TARGET Eigen3::Eigen)
9+
FetchContent_Declare(
10+
eigen
11+
GIT_REPOSITORY https://gitlab.com/libeigen/eigen
12+
GIT_TAG 7fd305ecae2410714cde018cb6851f49138568c8
13+
GIT_PROGRESS TRUE
14+
)
15+
FetchContent_MakeAvailable(eigen)
16+
endif()
17+
718
if(PBAT_BUILD_PYTHON_BINDINGS)
819
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
920
find_package(pybind11 CONFIG REQUIRED)
1021
endif()
1122

12-
include(FetchContent)
13-
1423
if(PBAT_ENABLE_PROFILER)
1524
set(TRACY_ON_DEMAND ${PBAT_PROFILE_ON_DEMAND} CACHE BOOL "" FORCE)
1625
FetchContent_Declare(

source/pbat/fem/DivergenceVector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ inline void DivergenceVector<TMesh, Dims, QuadratureOrder>::ComputeElementDiverg
108108
auto constexpr kNodesPerElement = ElementType::kNodes;
109109
auto const gradPhi =
110110
GNe.block<kNodesPerElement, MeshType::kDims>(0, e * kStride + g * MeshType::kDims);
111-
auto const F = Fe(Eigen::all, nodes);
111+
auto const F = Fe(Eigen::placeholders::all, nodes);
112112
// div(F) = \sum_i \sum_d F_id d(\phi_i) / d(X_d)
113113
divE.col(e) =
114114
(wg(g) * detJe(g, e)) * (F.array().transpose() * gradPhi.array()).rowwise().sum();

source/pbat/fem/Gradient.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include "Tetrahedron.h"
88

99
#include <doctest/doctest.h>
10-
#include <eigen3/unsupported/Eigen/KroneckerProduct>
1110
#include <pbat/common/ConstexprFor.h>
1211
#include <pbat/math/LinearOperator.h>
12+
#include <unsupported/Eigen/KroneckerProduct>
1313

1414
TEST_CASE("[fem] Gradient")
1515
{
@@ -67,8 +67,9 @@ TEST_CASE("[fem] Gradient")
6767
CSCMatrix Ik(kDims, kDims);
6868
Ik.setIdentity();
6969
CSCMatrix const NThat = Eigen::kroneckerProduct(NT, Ik);
70-
VectorX const Ihat =
71-
fem::InnerProductWeights<kQuadratureOrder>(mesh).reshaped().template replicate<kDims, 1>();
70+
VectorX const Ihat = fem::InnerProductWeights<kQuadratureOrder>(mesh)
71+
.reshaped()
72+
.template replicate<kDims, 1>();
7273
CSCMatrix const GG = NThat * Ihat.asDiagonal() * GM;
7374
CHECK_EQ(GG.rows(), kDims * n);
7475
CHECK_EQ(GG.cols(), n);

source/pbat/fem/HyperElasticPotential.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ HyperElasticPotential<TMesh, THyperElasticEnergy, QuadratureOrder>::ComputeEleme
248248
{
249249
tbb::parallel_for(Index{0}, Index{numberOfElements}, [&](Index e) {
250250
auto const nodes = mesh.E.col(e);
251-
auto const xe = x.reshaped(kDims, numberOfNodes)(Eigen::all, nodes);
251+
auto const xe = x.reshaped(kDims, numberOfNodes)(Eigen::placeholders::all, nodes);
252252
for (auto g = 0; g < QuadratureRuleType::kPoints; ++g)
253253
{
254254
auto constexpr kStride = MeshType::kDims * QuadratureRuleType::kPoints;
@@ -266,7 +266,7 @@ HyperElasticPotential<TMesh, THyperElasticEnergy, QuadratureOrder>::ComputeEleme
266266
{
267267
tbb::parallel_for(Index{0}, Index{numberOfElements}, [&](Index e) {
268268
auto const nodes = mesh.E.col(e);
269-
auto const xe = x.reshaped(kDims, numberOfNodes)(Eigen::all, nodes);
269+
auto const xe = x.reshaped(kDims, numberOfNodes)(Eigen::placeholders::all, nodes);
270270
auto ge = Ge.col(e);
271271
for (auto g = 0; g < QuadratureRuleType::kPoints; ++g)
272272
{
@@ -289,7 +289,7 @@ HyperElasticPotential<TMesh, THyperElasticEnergy, QuadratureOrder>::ComputeEleme
289289
{
290290
tbb::parallel_for(Index{0}, Index{numberOfElements}, [&](Index e) {
291291
auto const nodes = mesh.E.col(e);
292-
auto const xe = x.reshaped(kDims, numberOfNodes)(Eigen::all, nodes);
292+
auto const xe = x.reshaped(kDims, numberOfNodes)(Eigen::placeholders::all, nodes);
293293
auto he = He.block<kDofsPerElement, kDofsPerElement>(0, e * kDofsPerElement);
294294
for (auto g = 0; g < QuadratureRuleType::kPoints; ++g)
295295
{
@@ -312,7 +312,7 @@ HyperElasticPotential<TMesh, THyperElasticEnergy, QuadratureOrder>::ComputeEleme
312312
{
313313
tbb::parallel_for(Index{0}, Index{numberOfElements}, [&](Index e) {
314314
auto const nodes = mesh.E.col(e);
315-
auto const xe = x.reshaped(kDims, numberOfNodes)(Eigen::all, nodes);
315+
auto const xe = x.reshaped(kDims, numberOfNodes)(Eigen::placeholders::all, nodes);
316316
auto ge = Ge.col(e);
317317
auto he = He.block<kDofsPerElement, kDofsPerElement>(0, e * kDofsPerElement);
318318
for (auto g = 0; g < QuadratureRuleType::kPoints; ++g)
@@ -386,8 +386,9 @@ inline void HyperElasticPotential<TMesh, THyperElasticEnergy, QuadratureOrder>::
386386
{
387387
auto const nodes = mesh.E.col(e);
388388
auto const he = He.block<kDofsPerElement, kDofsPerElement>(0, e * kDofsPerElement);
389-
auto const xe = x.col(c).reshaped(kDims, x.size() / kDims)(Eigen::all, nodes);
390-
auto ye = y.col(c).reshaped(kDims, y.size() / kDims)(Eigen::all, nodes);
389+
auto const xe =
390+
x.col(c).reshaped(kDims, x.size() / kDims)(Eigen::placeholders::all, nodes);
391+
auto ye = y.col(c).reshaped(kDims, y.size() / kDims)(Eigen::placeholders::all, nodes);
391392
ye.reshaped() += he * xe.reshaped();
392393
}
393394
}
@@ -484,7 +485,7 @@ inline VectorX HyperElasticPotential<TMesh, THyperElasticEnergy, QuadratureOrder
484485
{
485486
auto const nodes = mesh.E.col(e);
486487
auto const ge = Ge.col(e).reshaped(kDims, kNodesPerElement);
487-
auto gi = g.reshaped(kDims, numberOfNodes)(Eigen::all, nodes);
488+
auto gi = g.reshaped(kDims, numberOfNodes)(Eigen::placeholders::all, nodes);
488489
gi += ge;
489490
}
490491
return g;

source/pbat/fem/Jacobian.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ TEST_CASE("[fem] Jacobian")
6262
E(Eigen::seqN(e * Element::kNodes, Element::kNodes)).array() = e;
6363
auto const nodes = mesh.E.col(e);
6464
X.block<Mesh::kDims, Element::kNodes>(0, e * Element::kNodes) =
65-
mesh.X(Eigen::all, nodes);
65+
mesh.X(Eigen::placeholders::all, nodes);
6666
}
6767

6868
auto constexpr maxIterations = 2;

source/pbat/fem/Jacobian.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ MatrixX DeterminantOfJacobian(TMesh const& mesh)
6767
auto const vertices = nodes(ElementType::Vertices);
6868
auto constexpr kRowsJ = TMesh::kDims;
6969
auto constexpr kColsJ = AffineElementType::kNodes;
70-
Matrix<kRowsJ, kColsJ> const Ve = mesh.X(Eigen::all, vertices);
70+
Matrix<kRowsJ, kColsJ> const Ve = mesh.X(Eigen::placeholders::all, vertices);
7171
if constexpr (AffineElementType::bHasConstantJacobian)
7272
{
7373
Scalar const detJ = DeterminantOfJacobian(Jacobian<AffineElementType>({}, Ve));
@@ -160,7 +160,7 @@ Vector<TElement::kDims> ReferencePosition(
160160
// Initial guess is element's barycenter.
161161
auto const coords = common::ToEigen(ElementType::Coordinates).reshaped(kDims, kNodes);
162162
auto const vertexLagrangePositions =
163-
(coords(Eigen::all, ElementType::Vertices).template cast<Scalar>() /
163+
(coords(Eigen::placeholders::all, ElementType::Vertices).template cast<Scalar>() /
164164
static_cast<Scalar>(ElementType::kOrder));
165165
Vector<kDims> Xik =
166166
vertexLagrangePositions.rowwise().sum() / static_cast<Scalar>(ElementType::Vertices.size());
@@ -224,7 +224,7 @@ MatrixX ReferencePositions(
224224
auto const nodes = mesh.E.col(e);
225225
auto constexpr kOutDims = MeshType::kDims;
226226
auto constexpr kNodes = ElementType::kNodes;
227-
Matrix<kOutDims, kNodes> const Xe = mesh.X(Eigen::all, nodes);
227+
Matrix<kOutDims, kNodes> const Xe = mesh.X(Eigen::placeholders::all, nodes);
228228
Vector<kOutDims> const Xk = X.col(k);
229229
Xi.col(k) = ReferencePosition<ElementType>(Xk, Xe, maxIterations, eps);
230230
});

source/pbat/fem/LaplacianMatrix.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ inline void SymmetricLaplacianMatrix<TMesh, QuadratureOrder>::Apply(
219219
auto constexpr kNodesPerElement = ElementType::kNodes;
220220
auto const Le =
221221
deltaE.block(0, e * kNodesPerElement, kNodesPerElement, kNodesPerElement);
222-
auto ye = y.col(c).reshaped(dims, y.size() / dims)(Eigen::all, nodes);
223-
auto const xe = x.col(c).reshaped(dims, x.size() / dims)(Eigen::all, nodes);
222+
auto ye = y.col(c).reshaped(dims, y.size() / dims)(Eigen::placeholders::all, nodes);
223+
auto const xe =
224+
x.col(c).reshaped(dims, x.size() / dims)(Eigen::placeholders::all, nodes);
224225
ye += xe * Le /*.transpose() technically, but Laplacian matrix is symmetric*/;
225226
}
226227
}

source/pbat/fem/MassMatrix.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ inline void MassMatrix<TMesh, QuadratureOrder>::Apply(
154154
auto const nodes = mesh.E.col(e).array();
155155
auto const me =
156156
Me.block<ElementType::kNodes, ElementType::kNodes>(0, e * ElementType::kNodes);
157-
auto ye = y.col(c).reshaped(dims, y.size() / dims)(Eigen::all, nodes);
158-
auto const xe = x.col(c).reshaped(dims, x.size() / dims)(Eigen::all, nodes);
157+
auto ye = y.col(c).reshaped(dims, y.size() / dims)(Eigen::placeholders::all, nodes);
158+
auto const xe =
159+
x.col(c).reshaped(dims, x.size() / dims)(Eigen::placeholders::all, nodes);
159160
ye += xe * me /*.transpose() technically, but mass matrix is symmetric*/;
160161
}
161162
}

0 commit comments

Comments
 (0)