Skip to content

Commit

Permalink
Fix mesh mutation frequency (#74)
Browse files Browse the repository at this point in the history
* build: Update geometry central version
* build: do not search for netcdf

* fix: do not split or collapse around notable vertices
* fix: respect initial timestep for mesh update frequencies

Due to variable time stepping algorithms the time step can vary with system configuration. The modified time step was used for updating mutation/prescription counters leading to difficult to predict behavior.

* fix: Adding an aggressive exclusion criteria for split/collapse processing when fixed boundary conditions are used

!Modifies split/collapse behavior for fixed boundary simulations

* refactor!: change mesh update periods to be double
* refactor: update python type hints

* feat: geodesic distance calculations relative to user defined vertices
* feat: add Gaussian force to visualization
* feat: add function to remove low valency vertices and add to split-collapse

---------

Signed-off-by: Christopher T. Lee <ctlee@ucsd.edu>
Co-authored-by: Xiaoyi Wu <xiw135@ucsd.edu>
  • Loading branch information
ctlee and suikarum1 authored Feb 5, 2025
1 parent fedb38e commit faadb77
Show file tree
Hide file tree
Showing 19 changed files with 1,254 additions and 234 deletions.
72 changes: 36 additions & 36 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,46 +59,46 @@ jobs:
cmake --build . --config Release -j 4
ctest -C Release -V -j 4
# build_macos:
# name: Build-Test macOS
# strategy:
# fail-fast: false
# matrix:
# os: [macos-15]
# runs-on: ${{ matrix.os }}
# defaults:
# run:
# shell: bash
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# submodules: recursive
build_macos:
name: Build-Test macOS
strategy:
fail-fast: false
matrix:
os: [macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive

# - uses: actions/setup-python@v5
# id: pyexe
# with:
# python-version: '3.10'
- uses: actions/setup-python@v5
id: pyexe
with:
python-version: '3.10'

# # - name: Setup python libs
# # id: pyexe
# # run: |
# # python3 --version
# # # python3 -m pip install pytest
# # py_exe_path=$(which python3)
# # echo ::set-output name=path::$py_exe_path
# - name: Setup python libs
# id: pyexe
# run: |
# python3 --version
# # python3 -m pip install pytest
# py_exe_path=$(which python3)
# echo ::set-output name=path::$py_exe_path

# - name: Resolve dependencies
# run: brew install netcdf eigen pybind11 netcdf-cxx
- name: Resolve dependencies
run: brew install netcdf eigen pybind11 netcdf-cxx

# - name: Build
# run: |
# mkdir -p build && cd build;
# cmake -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_PYMEM3DG=ON -DSUITESPARSE=OFF -DWITH_NETCDF=ON -DPython_EXECUTABLE:FILEPATH=${{ steps.pyexe.outputs.python-path }} --log-level=DEBUG ..
# cmake --build . --config Release -j 4
- name: Build
run: |
mkdir -p build && cd build;
cmake -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_PYMEM3DG=ON -DSUITESPARSE=OFF -DWITH_NETCDF=ON -DPython_EXECUTABLE:FILEPATH=${{ steps.pyexe.outputs.python-path }} --log-level=DEBUG ..
cmake --build . --config Release -j 4
# - name: Test
# run: ctest -C Release -V -j 4
- name: Test
run: ctest -C Release -V -j 4


# build_windows:
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:
name: Deploy to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [build_linux]
needs: [build_linux, build_macos]
defaults:
run:
shell: bash
Expand Down
5 changes: 4 additions & 1 deletion include/mem3dg/solver/integrator/integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class DLL_PUBLIC Integrator {
// key parameters (read/write)
/// characteristic time step
double characteristicTimeStep;
// Original time step at construction
double baseTimeStep;
// total simulation time
double totalTime = std::numeric_limits<double>::max();
/// period of saving output data
Expand Down Expand Up @@ -132,7 +134,8 @@ class DLL_PUBLIC Integrator {
Integrator(System &system_, double characteristicTimeStep_, double tolerance_,
std::string outputDirectory_)
: timeStep(characteristicTimeStep_), system(system_),
characteristicTimeStep(characteristicTimeStep_), tolerance(tolerance_),
characteristicTimeStep(characteristicTimeStep_),
baseTimeStep(characteristicTimeStep_), tolerance(tolerance_),
outputDirectory(outputDirectory_) {
ifDisableIntegrate = true;
ifPrintToConsole = true;
Expand Down
2 changes: 1 addition & 1 deletion include/mem3dg/solver/mesh_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct MeshProcessor {
*/
struct MeshMutator {
/// period of mesh mutation
std::size_t mutateMeshPeriod = std::numeric_limits<std::size_t>::max();
double mutateMeshPeriod = std::numeric_limits<double>::max();

/// Whether edge flip
bool isFlipEdge = false;
Expand Down
14 changes: 7 additions & 7 deletions include/mem3dg/solver/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct Parameters {
/// domain of shape variation
double geodesicMask = -1;
/// period of updating mask
std::size_t updateMaskPeriod = std::numeric_limits<std::size_t>::max();
double updateMaskPeriod = std::numeric_limits<double>::max();

/**
* @brief check parameter conflicts
Expand All @@ -175,22 +175,22 @@ struct Parameters {
std::function<Eigen::Matrix<bool, Eigen::Dynamic, 1>(const Geometry &)>
prescribeNotableVertex = NULL;
/// period of updating geodesic distance from notableVertex calculation
std::size_t updateGeodesicsPeriod = std::numeric_limits<std::size_t>::max();
double updateGeodesicsPeriod = std::numeric_limits<double>::max();
/// period of updating notable vertex based functional
/// prescribeNotableVertex
std::size_t updateNotableVertexPeriod =
std::numeric_limits<std::size_t>::max();
double updateNotableVertexPeriod = std::numeric_limits<double>::max();
};

struct Protein {
/// interior point parameter for protein density
double proteinInteriorPenalty = 0; // 1e-6
/// prescription of protein density
std::function<EigenVectorX1d(double, EigenVectorX1d, EigenVectorX1d)>
std::function<EigenVectorX1d(const Geometry &, double, EigenVectorX1d,
EigenVectorX1d)>
prescribeProteinDensityDistribution = NULL;
/// period of updating protein density distribution
std::size_t updateProteinDensityDistributionPeriod =
std::numeric_limits<std::size_t>::max();
double updateProteinDensityDistributionPeriod =
std::numeric_limits<double>::max();
};

struct Spring {
Expand Down
2 changes: 2 additions & 0 deletions include/mem3dg/solver/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ class DLL_PUBLIC System {
*/
bool processSplitCollapseQueued();

bool removeLowValencyVertices(std::size_t degree = 4);

/**
* @brief global smoothing after mutation of the mesh
* @param initStep initial guess of time step
Expand Down
4 changes: 4 additions & 0 deletions include/mem3dg/type_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ inline auto toMatrix(gcs::VertexData<gc::Vector3> &vector) {
return gc::EigenMap<double, 3>(vector);
}

inline const auto toMatrix(const gcs::VertexData<gc::Vector3> &vector) {
return gc::EigenMap<double, 3>(vector);
}

} // namespace mem3dg

namespace std {
Expand Down
Loading

0 comments on commit faadb77

Please sign in to comment.