Skip to content

Commit a02cad1

Browse files
committed
Added an offline mode option to batch.py
* Added a decription of offline IPC mode to the README * Fixed IPC_bin's log when OpenGL is disabled and not offline mode
1 parent c2206ea commit a02cad1

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ This is the opensource reference implementation of the SIGGRAPH 2020 paper [Incr
2222

2323
## Build
2424

25-
* `python build.py`
25+
You can either use `python build.py` or
26+
```
27+
mkdir build
28+
cd build
29+
cmake -DCMAKE_BUILD_TYPE=Release ..
30+
make -j4
31+
```
2632

2733
### Dependancies
2834

@@ -40,6 +46,10 @@ installed at a system level
4046
* IPC also supports using [Eigen](http://eigen.tuxfamily.org/) or [AMGCL](https://github.com/ddemidov/amgcl) as linear solver, which can be set via `IPC_LINSYSSOLVER` in `CMakeLists.txt`. To use custom linear solvers, you can implement a new interface (subclass) to our `LinSysSolver` class.
4147
* [libigl](https://libigl.github.io/), [OSQP](https://osqp.org/), [AMGCL](https://github.com/ddemidov/amgcl), and [TBB](https://software.intel.com/content/www/us/en/develop/tools/threading-building-blocks.html): downloaded and built through CMake
4248

49+
### Without OpenGL
50+
51+
If your system does not have the required OpenGL libraries, you can disable the viewer using the CMake argument `-DIPC_WITH_OPENGL=OFF`. It is important to then run IPC in offline mode (see below).
52+
4353
### 2D?
4454

4555
IPC is only implemented for 3D simulation.
@@ -71,6 +81,12 @@ of the sub-project (e.g. `DIAGNOSTIC`, `MESH_PROCESSING`). You can also set thes
7181

7282
Please see our [quick start guide](https://github.com/ipc-sim/IPC/wiki) for a `hello world` example with various settings. The output of each script will be saved into a separate folder in `output/`.
7383

84+
### Offline Mode
85+
86+
It is possible to run IPC with and without the viewer. By default, the `batch.py` script runs IPC with the viewer. If you provide the argument `--offline` to `batch.py` then it will run IPC in offline mode (i.e. without the viewer).
87+
88+
If you are running the `IPC_bin` executable directly then the first argument controls the mode. Mode `10` runs IPC with the viewer and is the default in the `batch.py`. Mode `100` runs IPC in offline mode (without the viewer). See `IPC_bin --help` for more detail.
89+
7490
### HPC
7591

7692
From the IPC root directory use `sbatch run.sh` to processes all the input

batch.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
from os import listdir
55
from os.path import isfile, join
66

7+
import argparse
8+
9+
parser = argparse.ArgumentParser(description='Batch proccess IPC sims.')
10+
parser.add_argument(
11+
"--offline", help="run IPC without the viewer", action='store_true')
12+
args = parser.parse_args()
13+
714
inputFolderPath = os.path.realpath('.') + '/input/'
815
# on Mac:
916
# progPath = os.path.realpath('.') + '/build/Release/IPC_bin'
@@ -14,19 +21,26 @@
1421
# progPath = os.path.realpath('.') + '/src/Projects/DistortionMin/DistortionMin'
1522

1623
# envSetStr = 'export LD_LIBRARY_PATH=/usr/local/lib\n'
17-
NTSetStr0 = 'export MKL_NUM_THREADS=' # for Ubuntu or Mac when CHOLMOD is compiled with MKL LAPACK and BLAS
18-
NTSetStr1 = 'export OMP_NUM_THREADS=' # for Ubuntu when CHOLMOD is compiled with libopenblas
19-
NTSetStr2 = 'export VECLIB_MAXIMUM_THREADS=' # for Mac when CHOLMOD is compiled with default LAPACK and BLAS
24+
# for Ubuntu or Mac when CHOLMOD is compiled with MKL LAPACK and BLAS
25+
NTSetStr0 = 'export MKL_NUM_THREADS='
26+
# for Ubuntu when CHOLMOD is compiled with libopenblas
27+
NTSetStr1 = 'export OMP_NUM_THREADS='
28+
# for Mac when CHOLMOD is compiled with default LAPACK and BLAS
29+
NTSetStr2 = 'export VECLIB_MAXIMUM_THREADS='
2030

2131
for numOfThreads in ['1', '8', '12']:
2232
inputFolderPath = os.path.realpath('.') + '/input/' + numOfThreads + '/'
33+
if(not os.path.isdir(inputFolderPath)):
34+
continue
2335
onlyfiles = [
2436
f for f in listdir(inputFolderPath) if isfile(join(inputFolderPath, f))
2537
]
2638
for inputModelNameI in onlyfiles:
2739
runCommand = NTSetStr0 + numOfThreads + '\n'
2840
runCommand += NTSetStr1 + numOfThreads + '\n'
2941
runCommand += NTSetStr2 + numOfThreads + '\n'
30-
runCommand += progPath + ' 10 ' + inputFolderPath + inputModelNameI + ' t' + numOfThreads
42+
runCommand += "{} {} {} t{}".format(
43+
progPath, '100' if args.offline else '10',
44+
inputFolderPath + inputModelNameI, numOfThreads)
3145
if subprocess.call([runCommand], shell=True):
3246
continue

src/main.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,9 @@ bool preDrawFunc()
607607
}
608608

609609
struct CLIArgs {
610-
int progMode = 0;
611-
std::string meshFileName = "cone2.0.obj";
612-
double lambda = 0.0;
613-
double delta = 4.0;
614-
std::string folderTail = "";
610+
int progMode;
611+
std::string inputFileName;
612+
std::string folderTail;
615613
int logLevel = 0; // trace (all logs)
616614
};
617615

@@ -621,7 +619,7 @@ void init_cli_app(CLI::App& app, CLIArgs& args)
621619
"program mode 0=optimization, 10=auto-switch, "
622620
"11=auto-switch (save png), 100=offline",
623621
true);
624-
app.add_option("meshFileName", args.meshFileName, "input file name", true);
622+
app.add_option("inputFileName", args.inputFileName, "input file name", true);
625623
app.add_option(
626624
"folderTail", args.folderTail, "output folder name tail/suffix", true);
627625
app.add_set("--logLevel,--log", args.logLevel, { 0, 1, 2, 3, 4, 5, 6 },
@@ -686,15 +684,15 @@ int main(int argc, char* argv[])
686684

687685
// Optimization mode
688686
std::string meshFilePath;
689-
if (args.meshFileName.at(0) == '/') {
687+
if (args.inputFileName.at(0) == '/') {
690688
spdlog::info("The input script file name is gloabl mesh file path.");
691-
meshFilePath = args.meshFileName;
692-
args.meshFileName = args.meshFileName.substr(args.meshFileName.find_last_of('/') + 1);
689+
meshFilePath = args.inputFileName;
690+
args.inputFileName = args.inputFileName.substr(args.inputFileName.find_last_of('/') + 1);
693691
}
694692
else {
695-
meshFilePath = args.meshFileName;
693+
meshFilePath = args.inputFileName;
696694
}
697-
std::string meshName = args.meshFileName.substr(0, args.meshFileName.find_last_of('.'));
695+
std::string meshName = args.inputFileName.substr(0, args.inputFileName.find_last_of('.'));
698696
// Load mesh
699697
Eigen::MatrixXd V, UV, N;
700698
Eigen::MatrixXi F, FUV, FN, E;
@@ -1222,7 +1220,7 @@ int main(int argc, char* argv[])
12221220
#endif
12231221
viewer.launch();
12241222
#else
1225-
spdlog::critical("Not offiline mode supported only with opengl");
1223+
spdlog::critical("Only offline mode is supported when OpenGL is disabled. See --help for more details.");
12261224
#endif
12271225
}
12281226

0 commit comments

Comments
 (0)