Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 34 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ set(LIBIGL_EIGEN_VERSION 3.3.7 CACHE STRING "Eigen version")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# libigl
option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" ON)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" ON)
option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" ON)
# Detects whether this is a top-level project
get_directory_property(LIBSHELL_PARENT_DIR PARENT_DIRECTORY)
if(NOT LIBSHELL_PARENT_DIR)
set(LIBSHELL_TOPLEVEL_PROJECT ON)
else()
set(LIBSHELL_TOPLEVEL_PROJECT OFF)
endif()

# Build tests
option(LIBSHELL_BUILD_EXEC "Build libshell executable" ${LIBSHELL_TOPLEVEL_PROJECT})
option(LIBSHELL_BUILD_TESTS "Build libshell tests" ${LIBSHELL_TOPLEVEL_PROJECT})

find_package(LIBIGL QUIET)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)

# Add your project files
if(MSVC)
Expand All @@ -22,17 +28,28 @@ endif()

file(GLOB LIBFILES src/*.cpp src/SecondFundamentalForm/*.cpp src/MaterialModel/*.cpp)
add_library(${PROJECT_NAME} STATIC ${LIBFILES})
if(LIBIGL_FOUND)
target_link_libraries(${PROJECT_NAME} igl::core)
else()
target_include_directories(${PROJECT_NAME} PRIVATE "$ENV{EIGEN3_INCLUDE_DIR}" )

# install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_CURRENT_LIST_DIR}/lib)
target_include_directories(libshell PRIVATE "${EIGEN3_INCLUDE_DIR}")
target_include_directories(libshell PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include")

if(LIBSHELL_BUILD_EXEC)
find_package(LIBIGL QUIET)

# libigl
option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" ON)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" ON)
option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" ON)

file(GLOB EXAMPLEFILES example/*.cpp)
add_executable(example_${PROJECT_NAME} ${EXAMPLEFILES})
target_link_libraries(example_${PROJECT_NAME} ${PROJECT_NAME} igl::core igl::opengl_glfw igl::opengl_glfw_imgui)
endif()
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_CURRENT_LIST_DIR}/lib)

file(GLOB EXAMPLEFILES example/*.cpp)
add_executable(example_${PROJECT_NAME} ${EXAMPLEFILES})
target_link_libraries(example_${PROJECT_NAME} ${PROJECT_NAME} igl::core igl::opengl_glfw igl::opengl_glfw_imgui)

file(GLOB TESTFILES tests/*.cpp)
add_executable(tests_${PROJECT_NAME} ${TESTFILES})
target_link_libraries(tests_${PROJECT_NAME} ${PROJECT_NAME} igl::core)
if(LIBSHELL_BUILD_TESTS)
file(GLOB TESTFILES tests/*.cpp)
add_executable(tests_${PROJECT_NAME} ${TESTFILES})
target_link_libraries(tests_${PROJECT_NAME} ${PROJECT_NAME})
endif()
6 changes: 3 additions & 3 deletions example/StaticSolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <Eigen/Core>
#include <vector>

#include "../include/MaterialModel.h"
#include "../include/MeshConnectivity.h"
#include "../include/ElasticShell.h"
#include "libshell/MaterialModel.h"
#include "libshell/MeshConnectivity.h"
#include "libshell/ElasticShell.h"

template <class SFF>
void takeOneStep(const LibShell::MeshConnectivity &mesh,
Expand Down
22 changes: 11 additions & 11 deletions example/main.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include <igl/opengl/glfw/Viewer.h>
#include "../include/MeshConnectivity.h"
#include "../include/ElasticShell.h"
#include "libshell/ElasticShell.h"
#include "libshell/MeshConnectivity.h"
#include "libshell/MidedgeAngleTanFormulation.h"
#include "libshell/MidedgeAngleSinFormulation.h"
#include "libshell/MidedgeAverageFormulation.h"
#include "libshell/StVKMaterial.h"
#include "libshell/TensionFieldStVKMaterial.h"
#include "libshell/NeoHookeanMaterial.h"
#include "libshell/RestState.h"
#include "StaticSolve.h"
#include <imgui/imgui.h>
#include <igl/opengl/glfw/imgui/ImGuiMenu.h>
#include <igl/opengl/glfw/imgui/ImGuiHelpers.h>
#include <imgui/imgui.h>
#include "../include/MidedgeAngleTanFormulation.h"
#include "../include/MidedgeAngleSinFormulation.h"
#include "../include/MidedgeAverageFormulation.h"
#include "../include/StVKMaterial.h"
#include "../include/TensionFieldStVKMaterial.h"
#include "../include/NeoHookeanMaterial.h"
#include "../include/RestState.h"
#include <igl/opengl/glfw/Viewer.h>

int numSteps;
double thickness;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ namespace LibShell {


};
};
}

#endif
4 changes: 2 additions & 2 deletions include/ElasticShell.h → include/libshell/ElasticShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define ELASTICSHELL_H

#include <Eigen/Core>
#include <vector>
#include <Eigen/Sparse>
#include <vector>
#include "MaterialModel.h"

namespace LibShell {
Expand Down Expand Up @@ -70,5 +70,5 @@ namespace LibShell {
ET_BENDING = 2
};
};
};
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ namespace LibShell {
Eigen::Matrix<double, 1, 18 + 3 * SFF::numExtraDOFs>* derivative, // F(face, i), then the three vertices opposite F(face,i), then the extra DOFs on oppositeEdge(face,i)
Eigen::Matrix<double, 18 + 3 * SFF::numExtraDOFs, 18 + 3 * SFF::numExtraDOFs>* hessian) const = 0;
};
};
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ namespace LibShell {
Eigen::MatrixXi EF;
Eigen::MatrixXi EOpp;
};
};
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ namespace LibShell {
Eigen::Matrix<double, 4, 18 + 3 * numExtraDOFs>* derivative, // F(face, i), then the three vertices opposite F(face,i), then the thetas on oppositeEdge(face,i)
std::vector < Eigen::Matrix<double, 18 + 3 * numExtraDOFs, 18 + 3 * numExtraDOFs> >* hessian);
};
};
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ namespace LibShell {
Eigen::Matrix<double, 4, 18 + 3 * numExtraDOFs>* derivative, // F(face, i), then the three vertices opposite F(face,i), then the thetas on oppositeEdge(face,i)
std::vector<Eigen::Matrix<double, 18 + 3 * numExtraDOFs, 18 + 3 * numExtraDOFs> >* hessian);
};
};
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ namespace LibShell {
Eigen::Matrix<double, 4, 18>* derivative, // F(face, i), then the three vertices opposite F(face,i), then the thetas on oppositeEdge(face,i)
std::vector<Eigen::Matrix<double, 18, 18> >* hessian);
};
};
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ namespace LibShell {


};
};
}

#endif
8 changes: 4 additions & 4 deletions include/RestState.h → include/libshell/RestState.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace LibShell {
struct RestState
{
public:
virtual RestStateType type() { return RestStateType::RST_NONE; }
virtual RestStateType type() const { return RestStateType::RST_NONE; }
};

/* Encodes the rest state information for an elastic monolayer.
Expand All @@ -25,7 +25,7 @@ namespace LibShell {
struct MonolayerRestState : public RestState
{
public:
virtual RestStateType type() { return RestStateType::RST_MONOLAYER; }
virtual RestStateType type() const { return RestStateType::RST_MONOLAYER; }

std::vector<double> thicknesses;
std::vector<Eigen::Matrix2d> abars;
Expand All @@ -40,10 +40,10 @@ namespace LibShell {
struct BilayerRestState : public RestState
{
public:
virtual RestStateType type() { return RestStateType::RST_BILAYER; }
virtual RestStateType type() const { return RestStateType::RST_BILAYER; }

MonolayerRestState layers[2];
};
};
}

#endif
2 changes: 1 addition & 1 deletion include/StVKMaterial.h → include/libshell/StVKMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ namespace LibShell {


};
};
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ namespace LibShell {
Eigen::Matrix<double, 1, 18 + 3 * SFF::numExtraDOFs>* derivative, // F(face, i), then the three vertices opposite F(face,i), then the extra DOFs on oppositeEdge(face,i)
Eigen::Matrix<double, 18 + 3 * SFF::numExtraDOFs, 18 + 3 * SFF::numExtraDOFs>* hessian) const;
};
};
}

#endif
25 changes: 9 additions & 16 deletions src/ElasticShell.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
#include "../include/ElasticShell.h"
#include <Eigen/Geometry>
#include <Eigen/Dense>
#include <iostream>
#include <Eigen/Sparse>
#include "libshell/ElasticShell.h"
#include "libshell/MaterialModel.h"
#include "libshell/MeshConnectivity.h"
#include "libshell/MidedgeAngleSinFormulation.h"
#include "libshell/MidedgeAngleTanFormulation.h"
#include "libshell/MidedgeAverageFormulation.h"
#include "libshell/RestState.h"
#include "GeometryDerivatives.h"
#include <random>
#include <iostream>
#include <vector>
#include <map>
#include "../include/MeshConnectivity.h"
#include "../include/MaterialModel.h"
#include "../include/RestState.h"
#include "../include/MidedgeAngleSinFormulation.h"
#include "../include/MidedgeAngleTanFormulation.h"
#include "../include/MidedgeAverageFormulation.h"

namespace LibShell {

Expand Down Expand Up @@ -188,9 +181,9 @@ namespace LibShell {
}
}

// instantions
// instantiations
template class ElasticShell<MidedgeAngleSinFormulation>;
template class ElasticShell<MidedgeAngleTanFormulation>;
template class ElasticShell<MidedgeAverageFormulation>;

};
}
7 changes: 2 additions & 5 deletions src/GeometryDerivatives.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "GeometryDerivatives.h"
#include "../include/MeshConnectivity.h"
#include <iostream>
#include <random>
#include <Eigen/Geometry>
#include "libshell/MeshConnectivity.h"

namespace LibShell {

Expand Down Expand Up @@ -230,4 +227,4 @@ namespace LibShell {
return result;
}

};
}
6 changes: 3 additions & 3 deletions src/GeometryDerivatives.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef GEOMETRYDERIVATIVES_H
#define GEOMETRYDERIVATIVES_H

#include <Eigen/Core>
#include <Eigen/Dense>
#include <vector>

namespace LibShell {
Expand Down Expand Up @@ -52,8 +52,8 @@ namespace LibShell {
const Eigen::MatrixXd& curPos,
int face,
Eigen::Matrix<double, 4, 9>* derivative, // F(face, i)
std::vector <Eigen::Matrix<double, 9, 9> >* hessian);
std::vector<Eigen::Matrix<double, 9, 9> >* hessian);

};
}

#endif
16 changes: 8 additions & 8 deletions src/MaterialModel/BilayerStVKMaterial.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "../../include/BilayerStVKMaterial.h"
#include "../../include/MeshConnectivity.h"
#include <vector>
#include "libshell/BilayerStVKMaterial.h"
#include "libshell/MeshConnectivity.h"
#include "libshell/MidedgeAngleSinFormulation.h"
#include "libshell/MidedgeAngleTanFormulation.h"
#include "libshell/MidedgeAverageFormulation.h"
#include "libshell/RestState.h"
#include "../GeometryDerivatives.h"
#include <Eigen/Dense>
#include "../../include/MidedgeAngleSinFormulation.h"
#include "../../include/MidedgeAngleTanFormulation.h"
#include "../../include/MidedgeAverageFormulation.h"
#include "../../include/RestState.h"
#include <vector>

namespace LibShell {

Expand Down Expand Up @@ -263,4 +263,4 @@ namespace LibShell {
template class BilayerStVKMaterial<MidedgeAngleTanFormulation>;
template class BilayerStVKMaterial<MidedgeAverageFormulation>;

};
}
17 changes: 8 additions & 9 deletions src/MaterialModel/NeoHookeanMaterial.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#include "../../include/NeoHookeanMaterial.h"
#include "../../include/MeshConnectivity.h"
#include <vector>
#include "libshell/NeoHookeanMaterial.h"
#include "libshell/MeshConnectivity.h"
#include "libshell/MidedgeAngleSinFormulation.h"
#include "libshell/MidedgeAngleTanFormulation.h"
#include "libshell/MidedgeAverageFormulation.h"
#include "libshell/RestState.h"
#include "../GeometryDerivatives.h"
#include <Eigen/Dense>
#include <iostream>
#include "../../include/MidedgeAngleSinFormulation.h"
#include "../../include/MidedgeAngleTanFormulation.h"
#include "../../include/MidedgeAverageFormulation.h"
#include "../../include/RestState.h"
#include <vector>

namespace LibShell {

Expand Down Expand Up @@ -425,4 +424,4 @@ namespace LibShell {
template class NeoHookeanMaterial<MidedgeAngleTanFormulation>;
template class NeoHookeanMaterial<MidedgeAverageFormulation>;

};
}
16 changes: 8 additions & 8 deletions src/MaterialModel/StVKMaterial.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "../../include/StVKMaterial.h"
#include "../../include/MeshConnectivity.h"
#include <vector>
#include "libshell/StVKMaterial.h"
#include "libshell/MeshConnectivity.h"
#include "libshell/MidedgeAngleSinFormulation.h"
#include "libshell/MidedgeAngleTanFormulation.h"
#include "libshell/MidedgeAverageFormulation.h"
#include "libshell/RestState.h"
#include "../GeometryDerivatives.h"
#include <Eigen/Dense>
#include "../../include/MidedgeAngleSinFormulation.h"
#include "../../include/MidedgeAngleTanFormulation.h"
#include "../../include/MidedgeAverageFormulation.h"
#include "../../include/RestState.h"
#include <vector>

namespace LibShell {

Expand Down Expand Up @@ -125,4 +125,4 @@ namespace LibShell {
template class StVKMaterial<MidedgeAngleTanFormulation>;
template class StVKMaterial<MidedgeAverageFormulation>;

};
}
Loading