### Configure Vega Model Reduction Dependencies Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Outlines the requirement to install various external libraries (Intel MKL, GLEW, ARPACK, wxWidgets, and optionally Cg) and to update the `Makefile-headers/Makefile-header` file to reflect their paths and availability for successful compilation. ```Makefile # In Makefile-headers/Makefile-header, configure paths and flags for: # - Intel MKL (PARDISO) # - GLEW # - ARPACK # - wxWidgets # - Cg (optional) ``` -------------------------------- ### Configure Target Sources and Installation Paths Source: https://github.com/eddiejohnston/vegafem/blob/main/CMakeLists.txt This snippet adds all collected header and source files to the project target using `target_sources`. It then defines installation rules for the headers, specifying their destination in the install tree. Finally, it copies the headers to the binary directory, ensuring they are uniformly available for consumption during the build and installation processes. ```CMake target_sources(${PROJECT_NAME} PRIVATE ${all_headers} PRIVATE ${all_sources}) install(FILES ${all_headers} DESTINATION "include/${PROJECT_NAME}") file(COPY ${all_headers} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}") # For uniform consumption in build/install-tree ``` -------------------------------- ### Include Headers for Vega Integrator Setup in C++ Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This C++ snippet lists the necessary header files for setting up an integrator with a deformable model in Vega FEM. These headers are required to enable fast multi-core functionality, assemble force models, and generate mass matrices, which are crucial for timestepping the model. ```C++ #include "corotationalLinearFEMStencilForceModel.h" #include "forceModelAssembler.h" #include "generateMassMatrix.h" ``` -------------------------------- ### Build and Install Core VegaFEM Utilities (CMake) Source: https://github.com/eddiejohnston/vegafem/blob/main/utilities/CMakeLists.txt This CMake code block defines a list of core VegaFEM utility executables, finds their source files, adds them to the build system, links them against the main project library, and configures their installation. It includes platform-specific logic to copy runtime DLL dependencies for Windows builds and installs binaries to the 'bin' directory. ```CMake if(VEGAFEM_BUILD_UTILITIES) set(VegaFEM_utilities computeDistanceField finiteDifferenceTest isosurfaceMesher objMergeFiles tetMesher ) foreach(exe ${VegaFEM_utilities}) file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${exe}/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/${exe}/*.cpp") add_executable(${exe} ${sources}) target_link_libraries(${exe} ${PROJECT_NAME}) if(CMAKE_IMPORT_LIBRARY_SUFFIX) add_custom_command(TARGET ${exe} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS ) install(TARGETS ${exe} RUNTIME_DEPENDENCIES PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" DIRECTORIES "$" ) endif() install(TARGETS ${exe} RUNTIME DESTINATION bin CONFIGURATIONS Release) endforeach() ``` -------------------------------- ### Recompile Vega Core Functionality after PARDISO Setup Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Provides instructions for recompiling the core Vega functionality if it was previously built without PARDISO. It involves cleaning the build in the simulator directory and then re-running the main build script. ```Shell # Navigate to the utilities/interactiveDeformableSimulator directory cd utilities/interactiveDeformableSimulator make deepclean # Navigate back to the main Vega folder (if necessary) cd ../.. ./build ``` -------------------------------- ### Initialize Implicit Backward Euler Sparse Integrator in C++ Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This C++ snippet demonstrates the initialization of the ImplicitBackwardEulerSparse integrator within the Vega FEM framework. It sets up the force model, computes the mass matrix, defines constrained degrees of freedom, and specifies damping coefficients. This setup prepares the simulation environment for subsequent timestepping. ```C++ #include "implicitBackwardEulerSparse.h" // Create the class to compute internal elastic forces and stiffness matrices // on each mesh element. StencilForceModel * stencilForceModel = new CorotationalLinearFEMStencilForceModel(deformableModel); // Create the class to connect the deformable model to the integrator. // ForceModelAssembler automatically computes in parallel if Intel TBB is enabled. ForceModel * forceModel = new ForceModelAssembler(stencilForceModel); int r = 3 * tetMesh->getNumVertices(); // total number of DOFs double timestep = 0.0333; // the timestep, in seconds SparseMatrix * massMatrix; // Create consistent (non-lumped) mass matrix. GenerateMassMatrix::computeMassMatrix(tetMesh, &massMatrix, true); // constraining vertices 4, 10, 14 (constrained DOFs are specified 0-indexed): int numConstrainedDOFs = 9; int constrainedDOFs[9] = { 12, 13, 14, 30, 31, 32, 42, 43, 44 }; // (tangential) Rayleigh damping double dampingMassCoef = 0.0; // "underwater"-like damping (here turned off) double dampingStiffnessCoef = 0.01; // (primarily) high-frequency damping // initialize the integrator ImplicitBackwardEulerSparse * implicitBackwardEulerSparse = new ImplicitBackwardEulerSparse(r, timestep, massMatrix, forceModel, numConstrainedDOFs, constrainedDOFs, dampingMassCoef, dampingStiffnessCoef); ``` -------------------------------- ### CMake: Configure Project Installation and Packaging Source: https://github.com/eddiejohnston/vegafem/blob/main/CMakeLists.txt This extensive block manages the installation process for the VegaFEM project. It uses "CMakePackageConfigHelpers" to generate version files, installs the main project target (libraries, archives, runtimes, includes), exports targets for external consumption, configures and installs CMake package configuration files, and includes the project's "LICENSE.txt" for distribution. ```CMake include(CMakePackageConfigHelpers) write_basic_package_version_file( ${PROJECT_NAME}ConfigVersion.cmake VERSION ${PACKAGE_VERSION} COMPATIBILITY AnyNewerVersion ) install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin INCLUDES DESTINATION include ) install(EXPORT ${PROJECT_NAME}Targets FILE ${PROJECT_NAME}Targets.cmake NAMESPACE vegafem:: DESTINATION lib/cmake/vegafem ) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION lib/cmake/${PROJECT_NAME} ) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt" DESTINATION "share/${PROJECT_NAME}") ``` -------------------------------- ### getopts Command Line Parsing Utility Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Provides functionality for parsing command-line arguments. Includes a C-style function and a C++ class wrapper. ```APIDOC int getopts(int argc, char **argv, opt t opttable[]) Parses the argc and argv from a main function and extracts any specified option values. Modified from public domain code by Paul Edwards. class CommandLineParser A C++ implementation of getopts. ``` -------------------------------- ### camera Library Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Overview of the `camera` library, one of the selected libraries in the Vega FEM project. ```APIDOC Library: camera ``` -------------------------------- ### Define 0-Indexed Vertices and Tetrahedral Elements (Vega 2.0+) Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This snippet showcases the 0-indexing support introduced in Vega 2.0 for both vertices and elements. It provides an equivalent mesh definition to the 1-indexed examples, demonstrating how vertex and element indices can start from 0 and must be sorted ascendingly. This accommodates outputs from tools like TetGen. ```Vega File Format *VERTICES 5 3 0 0 0 0.5 0.5 0.5 1 1.0 -0.5 0.5 2 -1.0 0.0 1.0 3 0.25 -0.25 0.5 4 0.6 0.2 0.3 *ELEMENTS TETS 2 4 0 0 1 2 3 0 1 4 2 3 0 ``` -------------------------------- ### Compile Interactive Deformable Simulator Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This command compiles the interactive deformable simulator component of Vega. It should be executed from within the `utilities/interactiveDeformableSimulator` directory. ```Shell make ``` -------------------------------- ### Build and Install GPL-Licensed VegaFEM Utilities (CMake) Source: https://github.com/eddiejohnston/vegafem/blob/main/utilities/CMakeLists.txt This CMake block conditionally builds and installs GPL-licensed utility executables, such as 'immersionMesher' and 'virtualTetsDriver', only if 'VEGAFEM_BUILD_COPYLEFT' is enabled. It compiles sources, links them privately to the 'vegafem' library, and includes the standard DLL dependency handling and installation to the 'bin' directory. ```CMake if(VEGAFEM_BUILD_COPYLEFT) set(VegaFEM_utilities_gpl immersionMesher virtualTetsDriver ) foreach(exe ${VegaFEM_utilities_gpl}) file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${exe}/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/${exe}/*.cpp") add_executable(${exe} ${sources}) target_link_libraries(${exe} PRIVATE vegafem) if(CMAKE_IMPORT_LIBRARY_SUFFIX) add_custom_command(TARGET ${exe} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS ) install(TARGETS ${exe} RUNTIME_DEPENDENCIES PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" DIRECTORIES "$" ) endif() install(TARGETS ${exe} RUNTIME DESTINATION bin CONFIGURATIONS Release) endforeach() endif() ``` -------------------------------- ### Configure Include Directories Source: https://github.com/eddiejohnston/vegafem/blob/main/CMakeLists.txt Sets up the include directories for the VegaFEM project, distinguishing between build-time and install-time paths. It ensures that headers are correctly found during compilation from the source directory and after installation from the designated install path. ```CMake target_include_directories(${PROJECT_NAME} PRIVATE $ PUBLIC $ ) ``` -------------------------------- ### Build and Install Volumetric Mesh Utilities (CMake) Source: https://github.com/eddiejohnston/vegafem/blob/main/utilities/CMakeLists.txt This CMake segment builds and installs a specific set of volumetric mesh utility executables. It defines the executables, compiles their respective C++ source files, links them to the main project, and sets up installation. Similar to other utilities, it handles conditional copying of runtime DLLs for Windows and installs binaries to the 'bin' directory. ```CMake set(VegaFEM_utilities generateInterpolant generateInterpolationMatrix generateMassMatrix generateSurfaceMesh ) foreach(target_name ${VegaFEM_utilities}) add_executable(${target_name} "volumetricMeshUtilities/${target_name}.cpp") target_link_libraries(${target_name} ${PROJECT_NAME}) if(CMAKE_IMPORT_LIBRARY_SUFFIX) add_custom_command(TARGET ${target_name} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS ) install(TARGETS ${target_name} RUNTIME_DEPENDENCIES PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" DIRECTORIES "$" ) endif() install(TARGETS ${target_name} RUNTIME DESTINATION bin CONFIGURATIONS Release) endforeach() ``` -------------------------------- ### ObjMesh: Print Detailed Information Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Prints detailed information about the ObjMesh model to the console or log. ```APIDOC void printInfo() ``` -------------------------------- ### CMake: Collect and Configure Sources/Headers for GPL Libraries Source: https://github.com/eddiejohnston/vegafem/blob/main/CMakeLists.txt This comprehensive loop iterates through each GPL library defined previously, configuring include directories for both build and install interfaces. It uses "file(GLOB_RECURSE)" to collect all ".h", ".hpp", ".c", and ".cpp" files, appending them to "all_headers" and "all_sources" lists. Finally, it adds these collected files as private sources to the main project target and handles their installation and copying to the binary directory. ```CMake foreach(lib ${${PROJECT_NAME}_gpl_libs}) target_include_directories(${PROJECT_NAME} PRIVATE $ INTERFACE $ $ ) file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}/*.hpp") list(APPEND all_headers ${headers}) file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}/*.cpp") list(APPEND all_sources ${sources}) endforeach() target_sources(${PROJECT_NAME} PRIVATE ${all_headers} PRIVATE ${all_sources}) install(FILES ${all_headers} DESTINATION "include/${PROJECT_NAME}") file(COPY ${all_headers} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}") # For uniform consumption in build/install-tree ``` -------------------------------- ### Describe libiglInterface Wrapper Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This section describes the `libiglInterface` wrapper, which provides routines related to the libigl library. It is specifically used by the `immersionMesher` component. ```APIDOC libiglInterface Wrapper for libigl-related routines. Used by immersionMesher. ``` -------------------------------- ### Compute Stiffness Matrix Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Explains how to compute the stiffness matrix by calling `GetTangentStiffnessMatrix` or `ComputeStiffnessMatrix` methods available in various material classes. ```APIDOC Class: MaterialClass Methods: GetTangentStiffnessMatrix() ComputeStiffnessMatrix() ``` -------------------------------- ### ObjMeshRender: Constructor Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Initializes a new `ObjMeshRender` object based on the provided `ObjMesh` instance. This constructor links the renderer to a specific mesh for rendering operations. ```APIDOC ObjMeshRender(ObjMesh * mesh) ``` -------------------------------- ### API Documentation for CentralDifferencesSparse Class Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Documents the `CentralDifferencesSparse` class, which implements the explicit central differences integrator. ```APIDOC class CentralDifferencesSparse : public IntegratorBaseSparse Description: Implements the explicit central differences integrator. Constructor: CentralDifferencesSparse(int numDOFs, double timestep, ...) numDOFs: int - Number of degrees of freedom. timestep: double - The simulation timestep. Description: Initializes the Central Differences integrator. ``` -------------------------------- ### basicAlgorithms Library Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Overview of the `basicAlgorithms` library, which provides assorted low-level algorithms such as sorting and removing elements, including removing multiple elements from a vector by specified indices. ```APIDOC Library: basicAlgorithms Purpose: Provides assorted low-level algorithms (e.g., sorting, removing elements from vectors by index). ``` -------------------------------- ### ObjMeshRender Class Definition Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html The `ObjMeshRender` class is responsible for rendering an `ObjMesh` object using OpenGL. It provides methods for initialization, rendering, and display list creation. ```APIDOC class ObjMeshRender ``` -------------------------------- ### API Documentation for ImplicitNewmarkSparse Class Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Documents the `ImplicitNewmarkSparse` class, which implements implicit Newmark integration. It extends `IntegratorBaseSparse` by adding parameters specific to Newmark-style integrators and methods for state management and timestepping. ```APIDOC class ImplicitNewmarkSparse : public IntegratorBaseSparse Description: Implements implicit Newmark integration, and expands IntegratorBaseSparse with features common to Newmark-style integrators. Constructor: ImplicitNewmarkSparse(int r, double timestep, SparseMatrix * massMatrix, ForceModel * forceModel, int numConstrainedDOFs=0, int * constrainedDOFs=NULL, double dampingMassCoef=0.0, double dampingStiffnessCoef=0.0, int maxIterations = 1, double epsilon = 1E-6, double NewmarkBeta=0.25, double NewmarkGamma=0.5, int numSolverThreads=0) r: int - Inherited from IntegratorBaseSparse. timestep: double - Inherited from IntegratorBaseSparse. massMatrix: SparseMatrix * - Inherited from IntegratorBaseSparse. forceModel: ForceModel * - Inherited from IntegratorBaseSparse. numConstrainedDOFs: int - Inherited from IntegratorBaseSparse. constrainedDOFs: int * - Inherited from IntegratorBaseSparse. dampingMassCoef: double - Inherited from IntegratorBaseSparse. dampingStiffnessCoef: double - Inherited from IntegratorBaseSparse. maxIterations: int - Maximum number of iterations (default 1). epsilon: double - Convergence tolerance (default 1E-6). NewmarkBeta: double - Newmark Beta parameter (default 0.25). NewmarkGamma: double - Newmark Gamma parameter (default 0.5). numSolverThreads: int - Number of solver threads (default 0). Description: Initializes maxIterations, epsilon, NewmarkBeta, NewmarkGamma, and numSolverThreads parameters, and forwards the other parameters to the IntegratorBaseSparse constructor. For PARDISO and SPOOLES solvers, best performance was found with 2-3 threads. Methods: SetTimestep(double timestep): virtual void timestep: double - The new timestep value. Description: Sets the timestep. SetState(double * q, double * qvel=NULL): virtual int q: double * - Position buffer. qvel: double * - Optional velocity buffer (default NULL). Description: Sets the position (and optionally the velocity) buffer, and calculates the acceleration buffer accordingly using implicit Newmark, assuming no external force. Returns 0 if successful, 1 otherwise. DoTimestep(): virtual int Description: Runs a timestep of implicit Newmark, updating the internal position, velocity, and acceleration buffers accordingly. Returns 0 if and only if the timestep is completed successfully. SetNewmarkBeta(double NewmarkBeta): void NewmarkBeta: double - The value for the Newmark Beta parameter. Description: Set the value of the beta parameter for Newmark integrators. No checking is performed to see if these values are in the appropriate range. SetNewmarkGamma(double NewmarkGamma): void NewmarkGamma: double - The value for the Newmark Gamma parameter. Description: Set the value of the gamma parameter for Newmark integrators. No checking is performed to see if these values are in the appropriate range. UseStaticSolver(bool useStaticSolver): void useStaticSolver: bool - True to use a static solver, false for dynamic. Description: Sets whether to use a static solver. The class defaults to dynamic. ``` -------------------------------- ### Run Vega Interactive Deformable Simulator Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Explains how to run the `interactiveDeformableSimulator` executable with a configuration file. It highlights the importance of running it from the directory containing the .config file and mentions useful in-simulator keybindings. ```Shell interactiveDeformableSimulator ``` -------------------------------- ### API Documentation for ImplicitBackwardEulerSparse Class Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Documents the `ImplicitBackwardEulerSparse` class, which implements implicit backward Euler integration. It inherits from `ImplicitNewmarkSparse` and overrides methods for state setting and timestepping specific to Euler integration. ```APIDOC class ImplicitBackwardEulerSparse : public ImplicitNewmarkSparse Description: Implements implicit backward Euler integration [BW98]. Constructor: ImplicitBackwardEulerSparse(int r, double timestep, SparseMatrix * massMatrix, ForceModel * forceModel, int numConstrainedDOFs=0, int * constrainedDOFs=NULL, double dampingMassCoef=0.0, double dampingStiffnessCoef=0.0, int maxIterations = 1, double epsilon = 1E-6, int numSolverThreads=0) r: int - Inherited from ImplicitNewmarkSparse. timestep: double - Inherited from ImplicitNewmarkSparse. massMatrix: SparseMatrix * - Inherited from ImplicitNewmarkSparse. forceModel: ForceModel * - Inherited from ImplicitNewmarkSparse. numConstrainedDOFs: int - Inherited from ImplicitNewmarkSparse. constrainedDOFs: int * - Inherited from ImplicitNewmarkSparse. dampingMassCoef: double - Inherited from ImplicitNewmarkSparse. dampingStiffnessCoef: double - Inherited from ImplicitNewmarkSparse. maxIterations: int - Inherited from ImplicitNewmarkSparse. epsilon: double - Inherited from ImplicitNewmarkSparse. numSolverThreads: int - Inherited from ImplicitNewmarkSparse. Description: Initializes the integrator. Methods: SetState(double * q, double * qvel=NULL): virtual int q: double * - Position buffer. qvel: double * - Optional velocity buffer (default NULL). Description: Sets the position (and optionally the velocity) buffer based on the parameters, and calculates the appropriate acceleration buffer values using implicit Euler, assuming no external forces. Returns 0 if successful, 1 otherwise. DoTimestep(): virtual int Description: Runs a timestep of implicit Euler, and updates the internal position, velocity, and acceleration buffers accordingly. Returns 0 if successful, 1 otherwise. ``` -------------------------------- ### Define 1-Indexed Tetrahedral Elements in Vega File Format Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This example illustrates the definition of tetrahedral elements using the "*ELEMENTS" keyword. It specifies 'TETS' as the element type, followed by the number of elements and vertices per element (4 for tets). Each line defines an element by its index (starting from 1) and the indices of its four constituent vertices. Correct vertex ordering is crucial for positive orientation. ```Vega File Format *ELEMENTS TETS 2 4 0 1 2 3 4 1 2 5 3 4 1 ``` -------------------------------- ### Define Material Regions for Elements (*REGION) Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This snippet illustrates how to define a region, associating a material with a group of elements. The first example assigns 'material1' to elements specified in 'set1'. The second example shows how to assign 'material1' to all mesh elements using the built-in 'allElements' set. ```Vega Configuration *REGION set1, material1 ``` ```Vega Configuration *REGION allElements, material1 ``` -------------------------------- ### ObjMesh: Get OBJ Filename Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Retrieves the name of the .obj file used to initialize the ObjMesh object. Returns an empty string if the object was not constructed from a file. ```APIDOC std::string getObjFilename() ``` -------------------------------- ### Build and Link VegaFEM Core Graphics Utilities with CMake Source: https://github.com/eddiejohnston/vegafem/blob/main/utilities/CMakeLists.txt This CMake snippet configures the build process for a set of core VegaFEM graphics utilities such as `clothBW-rt` and `displayObj`. It finds required packages like X11 and GLUI, defines executables from their source files, links them with OpenGL, GLUT, and conditional libraries, and includes logic for copying runtime DLLs on Windows and installing the binaries. ```CMake find_package(X11 REQUIRED) # freeglut on Linux find_package(glui CONFIG REQUIRED) # clothBW-rt displayObj editShapeARAP interactiveDeformableSimulator reducedDynamicSolver #=========================================================================== set(VegaFEM_utilities clothBW-rt displayObj editShapeARAP interactiveDeformableSimulator # largeModalDeformationFactory reducedDynamicSolver-rt ) foreach(target_name ${VegaFEM_utilities}) file(GLOB_RECURSE sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS "${target_name}/*.c" "${target_name}/*.cpp") add_executable(${target_name} ${sources}) target_link_libraries(${target_name} PRIVATE ${PROJECT_NAME} OpenGL::GL GLUT::GLUT $,glui::glui,glui::glui_static> #reducedDynamicSolver-rt interactiveDeformableSimulator editShapeARAP displayObj clothBW-rt $<$:X11::X11> ) # DLL copy to install folder must be wrapped with condition because generator expression # TARGET_RUNTIME_DLLS ""On non-DLL platforms, this expression always evaluates to an empty string"" # which fails on non-DLL platforms because the custom command becomes invalid by lack of argument # See https://stackoverflow.com/a/73550650/4709428 if(CMAKE_IMPORT_LIBRARY_SUFFIX) # Only on DLL platform https://cmake.org/cmake/help/latest/variable/CMAKE_IMPORT_LIBRARY_SUFFIX.html add_custom_command(TARGET ${target_name} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS ) install(TARGETS ${target_name} RUNTIME_DEPENDENCIES PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" DIRECTORIES "$" ) endif() install(TARGETS ${target_name} RUNTIME DESTINATION bin CONFIGURATIONS Release) endforeach() target_link_libraries(displayObj PRIVATE GLEW::GLEW) ``` -------------------------------- ### Build Vega Model Reduction Libraries and Drivers Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Describes the final step to compile all model reduction libraries and demonstration drivers after satisfying dependencies. It involves running the dedicated build script from the main Vega folder. ```Shell # From the main Vega folder ./buildModelReduction ``` -------------------------------- ### Get Stiffness Matrix Topology Function Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This function allocates a new SparseMatrix and populates it with the non-zero entry pattern of the stiffness matrix. It is used to determine the sparsity structure of the stiffness matrix. ```C++ void GetStiffnessMatrixTopology(SparseMatrix ** stiffnessMatrixTopology) ``` -------------------------------- ### IntegratorBaseDense Setter Methods Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Provides methods to dynamically update components of the IntegratorBaseDense. `SetReducedForceModel` allows changing the force model at runtime, and `SetMassMatrix` enables runtime modification of the reduced mass matrix. ```APIDOC void SetReducedForceModel(ReducedForceModel * reducedForceModel) virtual void SetMassMatrix(double * massMatrix) ``` -------------------------------- ### ObjMesh: Get Material Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Returns a reference or a pointer to the material at the specified index within the global array of materials. The reference version provides read-only access, while the pointer allows modification. ```APIDOC const Material & getMaterial(unsigned int index) Material * getMaterialHandle(unsigned int index) ``` -------------------------------- ### API Documentation for IntegratorBaseSparse Class Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Documents the `IntegratorBaseSparse` class, a foundational component for integrators dealing with large sparse matrices in VegaFEM. It details its constructor and core methods for managing forces, damping, and performance metrics. ```APIDOC class IntegratorBaseSparse : public IntegratorBase Description: A base class for integrators for dynamical systems characterized by (large) sparse matrices, such as geometrically complex 3D elasticity. This is the main integrator type in Vega. These integrators use a ForceModel class to obtain the internal forces and stiffness matrices. Stiffness matrices are sparse and stored using the SparseMatrix class. IntegratorBaseSparse stores two sparse matrices: the mass matrix and the damping matrix to be applied in addition to mass- and stiffness-based damping specified in IntegratorBase. Constructor: IntegratorBaseSparse(int r, double timestep, SparseMatrix * massMatrix, ForceModel * forceModel, int numConstrainedDOFs=0, int * constrainedDOFs=NULL, double dampingMassCoef=0.0, double dampingStiffnessCoef=0.0) r: int - The number of degrees of freedom. timestep: double - The simulation timestep. massMatrix: SparseMatrix * - Pointer to the mass matrix. forceModel: ForceModel * - Pointer to the force model. numConstrainedDOFs: int - Number of constrained degrees of freedom (default 0). constrainedDOFs: int * - Array of constrained degrees of freedom (default NULL). dampingMassCoef: double - Coefficient for mass-based damping (default 0.0). dampingStiffnessCoef: double - Coefficient for stiffness-based damping (default 0.0). Description: Initializes the number of degrees of freedom r, the timestep, the mass matrix, which degrees of freedom are constrained, and the ForceModel. The internal damping SparseMatrix is set to zero. Methods: SetForceModel(ForceModel * forceModel): virtual void forceModel: ForceModel * - The ForceModel object to set. Description: Sets the ForceModel object to forceModel. This makes it possible to change the force model at runtime. SetDampingMatrix(SparseMatrix * dampingMatrix): virtual void dampingMatrix: SparseMatrix * - The damping matrix D to set. Description: Sets the damping matrix D to dampingMatrix. This matrix will be added to the matrix produced according to the mass and stiffness damping coefficients to get the total damping matrix for the simulation. GetForceAssemblyTime(): virtual double Description: Return the time taken in DoTimestep to generate the force/stiffness values. GetSystemSolveTime(): virtual double Description: Return the time taken in DoTimestep to solve the linear system while timestepping. GetKineticEnergy(): virtual double Description: Calculates and returns the kinetic energy of the simulation, based upon the mass matrix and the velocity buffer of the class. GetTotalMass(): virtual double Description: Calculates and returns the total mass of the simulation, based upon the mass matrix and the velocity buffer of the class. ``` -------------------------------- ### PerformanceCounter Class API Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Documents the PerformanceCounter class, designed to measure the execution time of code blocks with microsecond accuracy. It allows starting, stopping, and retrieving elapsed time for performance profiling. ```APIDOC class PerformanceCounter PerformanceCounter() Starts the counter at the current system time. The start time can be explicitly reset later. void StartCounter() Restarts the counter at the current system time. void StopCounter() Stops the counter at the current system time. double GetElapsedTime() Returns the elapsed time between the last start and stop events. Note that a single timer cannot measure total running time of two separate blocks by starting and stopping it twice. ``` -------------------------------- ### ObjMesh: Get Vertex Data by Index Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Retrieves the vertex position, texture coordinate, or normal vector from the global arrays using their respective indices. These functions provide direct access to the raw data. ```APIDOC Vec3d getPosition(int vertexIndex) Vec3d getTextureCoordinate(int textureCoordinateIndex) Vec3d getNormal(int normalIndex) ``` -------------------------------- ### ObjMesh: Get Vertex Data by Vertex Object Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Retrieves the vertex position, texture coordinate, or normal vector associated with a given `Vertex` object. This provides a convenient way to access data linked to a specific vertex. ```APIDOC Vec3d getPosition(Vertex & vertex) Vec3d getTextureCoordinate(Vertex & vertex) Vec3d getNormal(Vertex & vertex) ``` -------------------------------- ### Initialize and Control Mesh Textures (C++) Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html These methods manage texture mapping for the mesh. `SetUpTextures` is mandatory for enabling textures and configures blend mode and mip-mapping. `hasTextures`, `EnableTextures`, and `DisableTextures` provide runtime control and status. ```APIDOC ObjMeshRender::SetUpTextures(LightingModulationType lightingModulation, MipmapType mipmap) Description: Initializes any textures specified by the .obj file, and enables texture rendering. Calling this function is mandatory for texture mapping to work. Must be called after OpenGL has been initialized. The lightingModulation parameter selects either MODULATE or REPLACE for the texture blend mode, and the mipmap parameter selects either USEMIPMAP or NOMIPMAP for whether to use mip-mapping. Returns 0 iff successful. Parameters: lightingModulation (LightingModulationType): Selects MODULATE or REPLACE for texture blend mode. mipmap (MipmapType): Selects USEMIPMAP or NOMIPMAP for mip-mapping. Return: int (0 if successful, non-zero otherwise) ObjMeshRender::hasTextures() Description: After SetUpTextures has been called, returns whether the model has textures. Return: bool (True if textures are present and set up, false otherwise) ObjMeshRender::EnableTextures() Description: Enables textures for rendering. Does not check whether textures have been set up. Return: void ObjMeshRender::DisableTextures() Description: Disables textures for rendering. Does not check whether textures have been set up. Return: void ``` -------------------------------- ### Define VegaFEM Core Libraries and Source Management Source: https://github.com/eddiejohnston/vegafem/blob/main/CMakeLists.txt This section defines a comprehensive list of core VegaFEM libraries and then iterates through them to configure include directories and collect all associated header and source files. It uses `target_include_directories` for both build and install interfaces, and `file(GLOB_RECURSE)` to dynamically find source and header files within each library's directory. ```CMake set(VegaFEM_core_libs animationHelper basicAlgorithms camera clothBW configFile constrainedDOFs corotationalLinearFEM distanceField elasticForceModel forceModel getopts glslPhong graph hashTable imageIO include integrator integratorDense integratorSparse interpolationCoordinates isotropicHyperelasticFEM laplacianMatrix lighting listIO macros massSpringSystem matrix matrixIO mesh mesher minivector modalMatrix objMesh objMeshGPUDeformer openGLHelper performanceCounter polarDecomposition quaternion reducedElasticForceModel reducedForceModel reducedStvk renderVolumetricMesh rigidBodyDynamics sceneObject sceneObjectReduced shapeEdit sparseMatrix sparseSolver stencilForceModel stvk volumetricMesh windingNumber ) set(all_headers) set(all_sources) foreach(lib ${VegaFEM_core_libs}) target_include_directories(${PROJECT_NAME} PRIVATE $ INTERFACE $ $ ) file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}/*.hpp") list(APPEND all_headers ${headers}) file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}/*.cpp") list(APPEND all_sources ${sources}) endforeach() ``` -------------------------------- ### Integrate PARDISO Solver into VegaFEM Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Steps to enable the PARDISO solver from Intel MKL for use with VegaFEM. This involves setting library paths in the Makefile-header and defining specific macros in C/C++ header files to notify Vega of PARDISO's availability and switch the default integrator library. ```Makefile PARDISO DIR= PARDISO INCLUDE= PARDISO LIB= ``` ```C++ #define PARDISO_SOLVER_IS_AVAILABLE // in libraries/sparseSolver/sparseSolverAvailability.h ``` ```C++ #define PARDISO // in libraries/integrator/integratorSolverSelection.h ``` -------------------------------- ### ObjMesh: Get Bounding Box Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Returns an axis-aligned bounding box for the mesh. The tightest fitting box is scaled by `expansionRatio`. For `expansionRatio=1`, the tight-fitting bounding box is obtained. The minimum and maximum corners of the box are returned via `bmin` and `bmax` pointers. ```APIDOC void getBoundingBox(double expansionRatio, Vec3d * bmin, Vec3d * bmax) ``` -------------------------------- ### Get Counts of Various Mesh Objects (VolumetricMesh) Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html These methods provide the total count for different types of objects within the mesh, including vertices, elements, materials, sets, and regions. They are essential for iterating through or sizing data structures related to the mesh components. ```APIDOC int getNumVertices() int getNumElements() int getNumMaterials() int getNumSets() int getNumRegions() ``` -------------------------------- ### IntegratorBaseSparse Common Methods Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Provides common methods for IntegratorBaseSparse. `SetState` allows updating position and velocity buffers, while `DoTimestep` executes a single timestep of explicit central differences, updating internal simulation buffers. ```APIDOC virtual int SetState(double * q, double * qvel=NULL) virtual int DoTimestep() ``` -------------------------------- ### API Documentation for ConfigFile Class Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Documents the `ConfigFile` class, which parses values from user-defined text configuration files. It supports reading various data types and provides methods for adding mandatory or optional configuration options and parsing the file. ```APIDOC class ConfigFile Parses values from a text configuration file. The syntax of the configuration file is user-defined. Options can be read as int, bool, float, double, Vec3d, char * (C-string), std::string and std::vector types. int addOption(const char * optionName, T * destLocation) Defined for T as int, bool, float, double, char, std::string, std::vector. Adds a mandatory option with name optionName. When the config file is later parsed, any value found for this option is written to the variable pointed to by destLocation. If no value for this option is found, the parse is considered to have failed. Returns a non-zero value if the option has already been defined. int addOptionOptional(const char * optionName, T * destLocation, T defaultvalue) int addOptionOptional(const char * optionName, char * destLocation, const char * defaultvalue) Adds an optional option with name optionName. When the config file is later parsed, the variable pointed to by destLocation is set to the value found in the file, or to defaultValue if no value is set. Returns a non-zero value if the option has already been defined. int parseOptions(const char * filename) Parses the options in file filename, writing the option values it reads to the appropriate variables. A non-zero value is returned if any mandatory options are not specified. ``` -------------------------------- ### VolumetricMesh::ENuMaterial Class and Properties Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This class stores material properties parameterized by Young’s modulus (E) and Poisson’s ratio (ν), common for many materials in VegaFEM. It provides methods to get and set these properties, including Lamé coefficients, and the material's name. ```APIDOC class VolumetricMesh::ENuMaterial { // Constructor: Constructed by VolumetricMesh constructor. double getE(); // Returns Young's modulus E. double getNu(); // Returns Poisson's ratio nu. double getDensity(); // Returns density. double getLambda(); // Returns Lamé coefficient lambda (computed from E, nu). double getMu(); // Returns Lamé coefficient mu (computed from E, nu). std::string getName(); // Returns the name string of the material. void setE(double E); // Sets Young's modulus E. void setNu(double nu); // Sets Poisson's ratio nu. void setDensity(double density); // Sets density. void setName(char * name); // Sets the name of the material. } ``` -------------------------------- ### Get Number of Vertices Per Mesh Element (VolumetricMesh) Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html Retrieves the count of vertices that constitute each individual mesh element within the VolumetricMesh. This is useful for understanding the mesh's fundamental structure, e.g., whether it's composed of triangles (3 vertices) or tetrahedra (4 vertices). ```APIDOC int getNumElementVertices() ``` -------------------------------- ### Define 1-Indexed Vertices in Vega File Format Source: https://github.com/eddiejohnston/vegafem/blob/main/VegaUsersManual.html This snippet demonstrates how to define vertices using the "*VERTICES" keyword. It specifies the total number of vertices, followed by '3' for three-dimensional simulation. Each subsequent line lists a vertex index (starting from 1), and its X, Y, Z coordinates in meters. ```Vega File Format *VERTICES 5 3 0 0 1 0.5 0.5 0.5 2 1.0 -0.5 0.5 3 -1.0 0.0 1.0 4 0.25 -0.25 0.5 5 0.6 0.2 0.3 ```