[Bf-blender-cvs] [fc557cdd138] fluid-mantaflow: Mantaflow: Fixed issues raised in part 1 of the review (D3850)

Sebastián Barschkis noreply at git.blender.org
Tue Dec 10 15:39:11 CET 2019


Commit: fc557cdd138cbfb678eba1d21691af8659a9ceaf
Author: Sebastián Barschkis
Date:   Tue Dec 10 15:35:30 2019 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rBfc557cdd138cbfb678eba1d21691af8659a9ceaf

Mantaflow: Fixed issues raised in part 1 of the review (D3850)

===================================================================

M	extern/mantaflow/CMakeLists.txt
M	extern/mantaflow/UPDATE.sh
D	extern/mantaflow/dependencies/cnpy/example1.cpp
M	extern/mantaflow/helper/pwrapper/numpyWrap.h
D	extern/mantaflow/helper/pwrapper/pymain.cpp
D	extern/mantaflow/preprocessed/commonkernels.h.reg
D	extern/mantaflow/preprocessed/conjugategrad.h.reg
D	extern/mantaflow/preprocessed/edgecollapse.h.reg
D	extern/mantaflow/preprocessed/fastmarch.h.reg
D	extern/mantaflow/preprocessed/fileio/mantaio.h.reg
D	extern/mantaflow/preprocessed/fluidsolver.h.reg
D	extern/mantaflow/preprocessed/general.h.reg
D	extern/mantaflow/preprocessed/grid.h.reg
D	extern/mantaflow/preprocessed/grid4d.h.reg
D	extern/mantaflow/preprocessed/kernel.h.reg
D	extern/mantaflow/preprocessed/levelset.h.reg
D	extern/mantaflow/preprocessed/mesh.h.reg
D	extern/mantaflow/preprocessed/movingobs.h.reg
D	extern/mantaflow/preprocessed/multigrid.h.reg
D	extern/mantaflow/preprocessed/noisefield.h.reg
D	extern/mantaflow/preprocessed/particle.h.reg
M	extern/mantaflow/preprocessed/plugin/extforces.cpp
D	extern/mantaflow/preprocessed/python/defines.py.reg
D	extern/mantaflow/preprocessed/shapes.h.reg
D	extern/mantaflow/preprocessed/timing.h.reg
D	extern/mantaflow/preprocessed/turbulencepart.h.reg
D	extern/mantaflow/preprocessed/vortexpart.h.reg
D	extern/mantaflow/preprocessed/vortexsheet.h.reg

===================================================================

diff --git a/extern/mantaflow/CMakeLists.txt b/extern/mantaflow/CMakeLists.txt
index ce92c4042fd..a667eb114fc 100644
--- a/extern/mantaflow/CMakeLists.txt
+++ b/extern/mantaflow/CMakeLists.txt
@@ -79,70 +79,54 @@ set(SRC
   ${MANTA_DEP}/cnpy/cnpy.h
 
   ${MANTA_PP}/commonkernels.h
-  ${MANTA_PP}/commonkernels.h.reg
   ${MANTA_PP}/commonkernels.h.reg.cpp
   ${MANTA_PP}/conjugategrad.cpp
   ${MANTA_PP}/conjugategrad.h
-  ${MANTA_PP}/conjugategrad.h.reg
   ${MANTA_PP}/conjugategrad.h.reg.cpp
   ${MANTA_PP}/edgecollapse.cpp
   ${MANTA_PP}/edgecollapse.h
-  ${MANTA_PP}/edgecollapse.h.reg
   ${MANTA_PP}/edgecollapse.h.reg.cpp
   ${MANTA_PP}/fastmarch.cpp
   ${MANTA_PP}/fastmarch.h
-  ${MANTA_PP}/fastmarch.h.reg
   ${MANTA_PP}/fastmarch.h.reg.cpp
   ${MANTA_PP}/fileio/iogrids.cpp
   ${MANTA_PP}/fileio/iomeshes.cpp
   ${MANTA_PP}/fileio/ioparticles.cpp
   ${MANTA_PP}/fileio/mantaio.h
-  ${MANTA_PP}/fileio/mantaio.h.reg
   ${MANTA_PP}/fileio/mantaio.h.reg.cpp
   ${MANTA_PP}/fluidsolver.cpp
   ${MANTA_PP}/fluidsolver.h
-  ${MANTA_PP}/fluidsolver.h.reg
   ${MANTA_PP}/fluidsolver.h.reg.cpp
   ${MANTA_PP}/general.cpp
   ${MANTA_PP}/general.h
-  ${MANTA_PP}/general.h.reg
   ${MANTA_PP}/general.h.reg.cpp
   ${MANTA_PP}/gitinfo.h
   ${MANTA_PP}/grid.cpp
   ${MANTA_PP}/grid.h
-  ${MANTA_PP}/grid.h.reg
   ${MANTA_PP}/grid.h.reg.cpp
   ${MANTA_PP}/grid4d.cpp
   ${MANTA_PP}/grid4d.h
-  ${MANTA_PP}/grid4d.h.reg
   ${MANTA_PP}/grid4d.h.reg.cpp
   ${MANTA_PP}/kernel.cpp
   ${MANTA_PP}/kernel.h
-  ${MANTA_PP}/kernel.h.reg
   ${MANTA_PP}/kernel.h.reg.cpp
   ${MANTA_PP}/levelset.cpp
   ${MANTA_PP}/levelset.h
-  ${MANTA_PP}/levelset.h.reg
   ${MANTA_PP}/levelset.h.reg.cpp
   ${MANTA_PP}/mesh.cpp
   ${MANTA_PP}/mesh.h
-  ${MANTA_PP}/mesh.h.reg
   ${MANTA_PP}/mesh.h.reg.cpp
   ${MANTA_PP}/movingobs.cpp
   ${MANTA_PP}/movingobs.h
-  ${MANTA_PP}/movingobs.h.reg
   ${MANTA_PP}/movingobs.h.reg.cpp
   ${MANTA_PP}/multigrid.cpp
   ${MANTA_PP}/multigrid.h
-  ${MANTA_PP}/multigrid.h.reg
   ${MANTA_PP}/multigrid.h.reg.cpp
   ${MANTA_PP}/noisefield.cpp
   ${MANTA_PP}/noisefield.h
-  ${MANTA_PP}/noisefield.h.reg
   ${MANTA_PP}/noisefield.h.reg.cpp
   ${MANTA_PP}/particle.cpp
   ${MANTA_PP}/particle.h
-  ${MANTA_PP}/particle.h.reg
   ${MANTA_PP}/particle.h.reg.cpp
   ${MANTA_PP}/plugin/advection.cpp
   ${MANTA_PP}/plugin/apic.cpp
@@ -165,29 +149,23 @@ set(SRC
   ${MANTA_PP}/plugin/waveletturbulence.cpp
   ${MANTA_PP}/plugin/waves.cpp
   ${MANTA_PP}/python/defines.py
-  ${MANTA_PP}/python/defines.py.reg
   ${MANTA_PP}/python/defines.py.reg.cpp
   ${MANTA_PP}/registration.cpp
   ${MANTA_PP}/shapes.cpp
   ${MANTA_PP}/shapes.h
-  ${MANTA_PP}/shapes.h.reg
   ${MANTA_PP}/shapes.h.reg.cpp
   ${MANTA_PP}/test.cpp
   ${MANTA_PP}/timing.cpp
   ${MANTA_PP}/timing.h
-  ${MANTA_PP}/timing.h.reg
   ${MANTA_PP}/timing.h.reg.cpp
   ${MANTA_PP}/turbulencepart.cpp
   ${MANTA_PP}/turbulencepart.h
-  ${MANTA_PP}/turbulencepart.h.reg
   ${MANTA_PP}/turbulencepart.h.reg.cpp
   ${MANTA_PP}/vortexpart.cpp
   ${MANTA_PP}/vortexpart.h
-  ${MANTA_PP}/vortexpart.h.reg
   ${MANTA_PP}/vortexpart.h.reg.cpp
   ${MANTA_PP}/vortexsheet.cpp
   ${MANTA_PP}/vortexsheet.h
-  ${MANTA_PP}/vortexsheet.h.reg
   ${MANTA_PP}/vortexsheet.h.reg.cpp
 
   ${MANTA_HLP}/pwrapper/manta.h
diff --git a/extern/mantaflow/UPDATE.sh b/extern/mantaflow/UPDATE.sh
index 49177081cb9..bd8ba26609d 100644
--- a/extern/mantaflow/UPDATE.sh
+++ b/extern/mantaflow/UPDATE.sh
@@ -60,12 +60,20 @@ mkdir -p $BLENDER_INSTALLATION/blender/tmp/helper/ && cp -Rf $MANTA_INSTALLATION
 mkdir -p $BLENDER_INSTALLATION/blender/tmp/helper/ && cp -Rf $MANTA_INSTALLATION/mantaflowgit/source/pwrapper "$_"
 mkdir -p $BLENDER_INSTALLATION/blender/tmp/preprocessed/ && cp -Rf $MANTA_INSTALLATION/mantaflowgit/build_blender/pp/source/. "$_"
 
+# Remove some files that are not need in Blender
+rm $BLENDER_INSTALLATION/blender/tmp/dependencies/cnpy/example1.cpp
+rm $BLENDER_INSTALLATION/blender/tmp/helper/pwrapper/pymain.cpp
+rm $BLENDER_INSTALLATION/blender/tmp/preprocessed/*.reg
+rm $BLENDER_INSTALLATION/blender/tmp/preprocessed/python/*.reg
+rm $BLENDER_INSTALLATION/blender/tmp/preprocessed/fileio/*.reg
+
 # ==================== 4) CLANG-FORMAT ===================================================
 
 cd $BLENDER_INSTALLATION/blender/tmp/
 
 echo "Applying clang format to Mantaflow source files"
-find . -iname *.h -o -iname *.cpp -o -iname *.reg | xargs clang-format --verbose -i -style=file
+find . -iname *.h -o -iname *.cpp | xargs clang-format --verbose -i -style=file
+find . -iname *.h -o -iname *.cpp | xargs dos2unix --verbose
 
 # ==================== 5) MOVE MANTAFLOW FILES TO EXTERN/ ================================
 
diff --git a/extern/mantaflow/dependencies/cnpy/example1.cpp b/extern/mantaflow/dependencies/cnpy/example1.cpp
deleted file mode 100644
index 8f463d10174..00000000000
--- a/extern/mantaflow/dependencies/cnpy/example1.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "cnpy.h"
-#include <complex>
-#include <cstdlib>
-#include <iostream>
-#include <map>
-#include <string>
-
-const int Nx = 128;
-const int Ny = 64;
-const int Nz = 32;
-
-int main()
-{
-  // set random seed so that result is reproducible (for testing)
-  srand(0);
-  // create random data
-  std::vector<std::complex<double>> data(Nx * Ny * Nz);
-  for (int i = 0; i < Nx * Ny * Nz; i++)
-    data[i] = std::complex<double>(rand(), rand());
-
-  // save it to file
-  cnpy::npy_save("arr1.npy", &data[0], {Nz, Ny, Nx}, "w");
-
-  // load it into a new array
-  cnpy::NpyArray arr = cnpy::npy_load("arr1.npy");
-  std::complex<double> *loaded_data = arr.data<std::complex<double>>();
-
-  // make sure the loaded data matches the saved data
-  assert(arr.word_size == sizeof(std::complex<double>));
-  assert(arr.shape.size() == 3 && arr.shape[0] == Nz && arr.shape[1] == Ny && arr.shape[2] == Nx);
-  for (int i = 0; i < Nx * Ny * Nz; i++)
-    assert(data[i] == loaded_data[i]);
-
-  // append the same data to file
-  // npy array on file now has shape (Nz+Nz,Ny,Nx)
-  cnpy::npy_save("arr1.npy", &data[0], {Nz, Ny, Nx}, "a");
-
-  // now write to an npz file
-  // non-array variables are treated as 1D arrays with 1 element
-  double myVar1 = 1.2;
-  char myVar2 = 'a';
-  cnpy::npz_save("out.npz", "myVar1", &myVar1, {1}, "w");  //"w" overwrites any existing file
-  cnpy::npz_save(
-      "out.npz", "myVar2", &myVar2, {1}, "a");  //"a" appends to the file we created above
-  cnpy::npz_save(
-      "out.npz", "arr1", &data[0], {Nz, Ny, Nx}, "a");  //"a" appends to the file we created above
-
-  // load a single var from the npz file
-  cnpy::NpyArray arr2 = cnpy::npz_load("out.npz", "arr1");
-
-  // load the entire npz file
-  cnpy::npz_t my_npz = cnpy::npz_load("out.npz");
-
-  // check that the loaded myVar1 matches myVar1
-  cnpy::NpyArray arr_mv1 = my_npz["myVar1"];
-  double *mv1 = arr_mv1.data<double>();
-  assert(arr_mv1.shape.size() == 1 && arr_mv1.shape[0] == 1);
-  assert(mv1[0] == myVar1);
-
-  // std::cout << "Loading test.npz" << std::endl;
-  // cnpy::NpyArray test_npz_a = cnpy::npz_load("test.npz","a");
-  // cnpy::NpyArray test_npz_b = cnpy::npz_load("test.npz","b");
-
-  // std::cout << "test_npz_a: " << test_npz_a.word_size << std::endl;
-  // std::cout << "test_npz_b: " << test_npz_b.word_size << std::endl;
-
-  // auto b = test_npz_b.as_vec<float>();
-  // for ( auto b_entry : b)
-  // {
-  //     std::cout << b_entry << " ";
-  // }
-  // std::cout << std::endl;
-  // cnpy::npz_save("test_a.npz", "a", test_npz_a.data<float>(), test_npz_a.shape, "w"); //"w"
-  // overwrites any existing file cnpy::npz_save("test_a.npz", "b", test_npz_b.data<float>(),
-  // test_npz_b.shape, "a"); //"a" appends to the file we created above
-}
diff --git a/extern/mantaflow/helper/pwrapper/numpyWrap.h b/extern/mantaflow/helper/pwrapper/numpyWrap.h
index 67e7e2851d2..c92a2eaaa97 100644
--- a/extern/mantaflow/helper/pwrapper/numpyWrap.h
+++ b/extern/mantaflow/helper/pwrapper/numpyWrap.h
@@ -1,86 +1,86 @@
-/******************************************************************************
- *
- * MantaFlow fluid solver framework
- * Copyright 2017 Steffen Wiewel, Moritz Baecher, Rachel Chu
- *
- * This program is free software, distributed under the terms of the
- * Apache License, Version 2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Convert mantaflow grids to/from numpy arrays
- *
- ******************************************************************************/
-
-#ifdef _PCONVERT_H
-#  ifndef _NUMPYCONVERT_H
-#    define _NUMPYCONVERT_H
-
-enum NumpyTypes {
-  N_BOOL = 0,
-  N_BYTE,
-  N_UBYTE,
-  N_SHORT,
-  N_USHORT,
-  N_INT,
-  N_UINT,
-  N_LONG,
-  N_ULONG,
-  N_LONGLONG,
-  N_ULONGLONG,
-  N_FLOAT,
-  N_DOUBLE,
-  N_LONGDOUBLE,
-  N_CFLOAT,
-  N_CDOUBLE,
-  N_CLONGDOUBLE,
-  N_OBJECT = 17,
-  N_STRING,
-  N_UNICODE,
-  N_VOID,
-  /*
-   * New 1.6 types appended, may be integrated
-   * into the above in 2.0.
-   */
-  N_DATETIME,
-  N_TIMEDELTA,
-  N_HALF,
-
-  N_NTYPES,
-  N_NOTYPE,
-  N_CHAR,          /* special flag */
-  N_USERDEF = 256, /* leave room for characters */
-
-  /* The number of types not including the new 1.6 types */
-  N_NTYPES_ABI_COMPATIBLE = 21
-};
-
-namespace Manta {
-class PyArrayContainer {
- public:
-  /// Constructors
-  PyArrayContainer(void *_pParentPyArray);
-  PyArrayContainer(const PyArrayContainer &_Other);
-  ~PyArrayContainer();
-  /// Operators
-  PyArrayContainer &operator=(const PyArrayContainer &_Other);
-
- private:
-  void ExtractData(void *_pParentPyArray);
-
- public:
-  void *pData;
-  NumpyTypes DataType;
-  unsigned int TotalSize;
-  std::vector<long> Dims;
-
- private:
-  void *pParentPyArray;
-};
-
-// template<> PyArrayContainer* fromPyPtr<PyArrayContainer>(PyObject* obj, std::vector<void*>*
-// tmp);
-template<> PyArrayContainer fromPy<PyArrayContainer>(PyObject *obj);
-}  // namespace Manta
-
-#  endif
-#endif
+/******************************************************************************
+ *
+ * MantaFlow fluid solver framework
+ * Copyright 2017 Steffen Wiewel, Moritz Baecher, Rachel Chu
+ *
+ * This program is free software, distributed under the terms of the
+ * Apache License, Version 2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Co

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list