bubble-dynamics

Spherical bubble dynamics simulator
git clone https://git.0xfab.ch/bubble-dynamics.git
Log | Files | Refs | README | LICENSE

commit f041c6d2e0a54f4ffcd9f2d26d1d48c959de403d
parent e1a4f02bfedf3f5ab57e06318a789d03546937ca
Author: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Date:   Sat, 19 Dec 2020 18:12:21 +0100

Fix warnings

Diffstat:
Msrc/BubbleBase.h | 15++++++++-------
Msrc/bubbleDynamics.cpp | 14++++++++------
Msrc/kernels.h | 16++++++++--------
Msrc/kernels/Dahlquist.h | 7++++---
Msrc/kernels/KMClusterPositions_D.h | 38++++++++++++++++----------------------
Msrc/kernels/KMCluster_FC.h | 35+++++++++++++++--------------------
Msrc/kernels/KMCluster_TY.h | 36+++++++++++++++---------------------
Msrc/kernels/KellerMiksis.h | 8++++----
Msrc/kernels/RPCluster.h | 35+++++++++++++++--------------------
Msrc/kernels/RPClusterPositions_D.h | 37++++++++++++++++---------------------
Msrc/kernels/RayleighPlesset.h | 8++++----
Msrc/kernels/RayleighPlesset_HBGL.h | 8++++----
12 files changed, 117 insertions(+), 140 deletions(-)

diff --git a/src/BubbleBase.h b/src/BubbleBase.h @@ -6,12 +6,13 @@ #ifndef BUBBLEBASE_H_ZVSZD3E8 #define BUBBLEBASE_H_ZVSZD3E8 -#include <vector> -#include <string> +#include <ArgumentParser.h> + #include <cmath> #include <cstdio> #include <functional> -#include "ArgumentParser.h" +#include <string> +#include <vector> struct Bubble { @@ -64,7 +65,7 @@ struct BubbleData // drivers if (p("-pext").asString("const") == "const") - pext = [this] (const Real t) { return (this->pamp * this->p0); }; + pext = [this](const Real) { return (this->pamp * this->p0); }; else if (p("-pext").asString("const") == "sin") pext = [this] (const Real t) { return (this->p0*this->pamp*std::sin(this->omega * t)); }; else if (p("-pext").asString("const") == "coshbgl") @@ -87,7 +88,7 @@ struct BubbleData }; // pressure derivative - dpext = [this] (const Real t) { return 0.0; }; + dpext = [this](const Real) { return 0.0; }; // other filename = p("-bubbleFile").asString("none"); @@ -144,10 +145,10 @@ struct BubbleData void print() const { printf("Bubble Data:\n"); - printf("\tNbubbles = %d\n", Nbubbles); + printf("\tNbubbles = %zu\n", Nbubbles); printf("\tBubbles:\n"); for (size_t i = 0; i < Nbubbles; ++i) - printf("\t\tBubble %d: R0 = %e, Rdot0 = %e\n", i, R0[i], Rdot0[i]); + printf("\t\tBubble %zu: R0 = %e, Rdot0 = %e\n", i, R0[i], Rdot0[i]); printf("\tgamma = %e\n", gamma); printf("\trho = %e\n", rhoL); printf("\tnu = %e\n", nuL); diff --git a/src/bubbleDynamics.cpp b/src/bubbleDynamics.cpp @@ -3,6 +3,11 @@ /* Author: Fabian Wermelinger */ /* Tag: Solve 1D bubble dynamics */ /* Copyright 2016 ETH Zurich. All Rights Reserved. */ +#include <GnuplotDump.h> +#include <TimeStepper/TimeStepper.h> +#include <common.h> +#include <kernels.h> + #include <cassert> #include <cstdio> #include <iostream> @@ -11,11 +16,6 @@ #include <cmath> #include <ctime> -#include "common.h" -#include "kernels.h" -#include "GnuplotDump.h" -#include "TimeStepper.h" - using namespace std; @@ -184,7 +184,9 @@ int main(int argc, const char** argv) stepper->write(step, t, dt, U, &simConfig); } - printf("\nFinal Time = %e;\nFinal Step = %d\n", stepperData.t, stepperData.step); + printf("\nFinal Time = %e;\nFinal Step = %zu\n", + stepperData.t, + stepperData.step); stepper->dispose(); delete stepper; diff --git a/src/kernels.h b/src/kernels.h @@ -6,16 +6,16 @@ #ifndef KERNELS_H_KY4W86QV #define KERNELS_H_KY4W86QV -#include "kernels/RayleighPlesset.h" -#include "kernels/RayleighPlesset_HBGL.h" -#include "kernels/KellerMiksis.h" +#include <kernels/KellerMiksis.h> +#include <kernels/RayleighPlesset.h> +#include <kernels/RayleighPlesset_HBGL.h> #ifdef _USE_EIGEN_ -#include "kernels/RPCluster.h" -#include "kernels/KMCluster_TY.h" -#include "kernels/KMCluster_FC.h" +#include <kernels/KMCluster_FC.h> +#include <kernels/KMCluster_TY.h> +#include <kernels/RPCluster.h> #ifdef _POS_STATE_ -#include "kernels/RPClusterPositions_D.h" -#include "kernels/KMClusterPositions_D.h" +#include <kernels/KMClusterPositions_D.h> +#include <kernels/RPClusterPositions_D.h> #endif #endif diff --git a/src/kernels/Dahlquist.h b/src/kernels/Dahlquist.h @@ -6,10 +6,11 @@ #ifndef DAHLQUIST_H_SQ60WZPY #define DAHLQUIST_H_SQ60WZPY +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> +#include <common.h> + #include <cassert> -#include "common.h" -#include "KernelBase.h" -#include "GnuplotDump.h" template <typename Tinput, typename Trhs=Tinput> class Dahlquist : public KernelBase<Tinput,Trhs> diff --git a/src/kernels/KMClusterPositions_D.h b/src/kernels/KMClusterPositions_D.h @@ -7,6 +7,13 @@ #ifndef BUBBLECLUSTERPOS_D_H_GHBNU569 #define BUBBLECLUSTERPOS_D_H_GHBNU569 +#include <BubbleBase.h> +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> + +#include <Eigen/Core> +#include <Eigen/Dense> + #include <cassert> #include <cstdlib> #include <iostream> @@ -14,16 +21,6 @@ #include <cmath> #include <vector> -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Core" -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Dense" -#include <Eigen/Core> -#include <Eigen/Dense> - -#include "KernelBase.h" -#include "BubbleBase.h" -#include "GnuplotDump.h" - - template <typename Tinput, typename Trhs=Tinput> class KMClusterPositions_D : public KernelBase<Tinput,Trhs> { @@ -77,11 +74,9 @@ public: } } - for (int i = 0; i < N; ++i) - { + for (size_t i = 0; i < N; ++i) { const Bubble& bi = data.coords[i]; - for (int j = 0; j < N; ++j) - { + for (size_t j = 0; j < N; ++j) { const Bubble& bj = data.coords[j]; data.Dij[j + i*N] = bi.distance(bj); } @@ -303,10 +298,9 @@ public: const BubbleData& bd = *(BubbleData const* const)data; const size_t N = 5*_N+2; - double out[N]; + std::vector<double> out(N); double Vg = 0.0; - for (int i = 0; i < _N; ++i) - { + for (size_t i = 0; i < _N; ++i) { const double r = U[i][0]; out[i] = r; out[i+_N] = bd.pBubble(U, i); @@ -318,7 +312,7 @@ public: out[5*_N] = bd.pext(t); out[5*_N+1] = Vg; - m_dumper->write(step, t, dt, &out[0], N); + m_dumper->write(step, t, dt, out.data(), N); if (bd.bVTK) { @@ -334,27 +328,27 @@ public: vtk << "DATASET UNSTRUCTURED_GRID\n"; vtk << "POINTS " << bd.Nbubbles << " double" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][2] << " " << U[i][4] << " " << U[i][6] << std::endl; vtk << std::endl; vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS radius double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][0] << std::endl; vtk << std::endl; // vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS velocity double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][1] << std::endl; vtk << std::endl; vtk << "VECTORS transvel double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][3] << " " << U[i][5] << " " << U[i][7] << std::endl; vtk << std::endl; } diff --git a/src/kernels/KMCluster_FC.h b/src/kernels/KMCluster_FC.h @@ -6,21 +6,19 @@ #ifndef BUBBLECLUSTER_FC_H_UJH09T7V #define BUBBLECLUSTER_FC_H_UJH09T7V +#include <BubbleBase.h> +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> + +#include <Eigen/Core> +#include <Eigen/Dense> + #include <cassert> #include <cstdlib> #include <fstream> #include <cmath> #include <vector> -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Core" -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Dense" -#include <Eigen/Core> -#include <Eigen/Dense> - -#include "KernelBase.h" -#include "BubbleBase.h" -#include "GnuplotDump.h" - template <typename Tinput, typename Trhs=Tinput> class KMCluster_FC : public KernelBase<Tinput,Trhs> @@ -69,11 +67,9 @@ public: } } - for (int i = 0; i < N; ++i) - { + for (size_t i = 0; i < N; ++i) { const Bubble& bi = data.coords[i]; - for (int j = 0; j < N; ++j) - { + for (size_t j = 0; j < N; ++j) { const Bubble& bj = data.coords[j]; data.Dij[j + i*N] = bi.distance(bj); } @@ -164,10 +160,9 @@ public: // const Real odat[7] = {U[0][0], U[7][0], U[1][0], pb[0], pb[1], pb[2], bd.pext(t)}; const size_t N = 2*_N+2; - double out[N]; + std::vector<double> out(N); double Vg = 0.0; - for (int i = 0; i < _N; ++i) - { + for (size_t i = 0; i < _N; ++i) { const double r = U[i][0]; out[i] = r; out[i+_N] = bd.pBubble(U, i); @@ -176,7 +171,7 @@ public: out[2*_N] = bd.pext(t); out[2*_N+1] = Vg; - m_dumper->write(step, t, dt, &out[0], N); + m_dumper->write(step, t, dt, out.data(), N); if (bd.bVTK) { @@ -192,21 +187,21 @@ public: vtk << "DATASET UNSTRUCTURED_GRID\n"; vtk << "POINTS " << bd.Nbubbles << " double" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << bd.coords[i].pos[0] << " " << bd.coords[i].pos[1] << " " << bd.coords[i].pos[2] << std::endl; vtk << std::endl; vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS radius double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][0] << std::endl; vtk << std::endl; // vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS velocity double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][1] << std::endl; vtk << std::endl; } diff --git a/src/kernels/KMCluster_TY.h b/src/kernels/KMCluster_TY.h @@ -6,22 +6,19 @@ #ifndef BUBBLECLUSTER_TY_H_ECCX59FB #define BUBBLECLUSTER_TY_H_ECCX59FB +#include <BubbleBase.h> +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> + +#include <Eigen/Core> +#include <Eigen/Dense> + #include <cassert> #include <cstdlib> #include <fstream> #include <cmath> #include <vector> -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Core" -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Dense" -#include <Eigen/Core> -#include <Eigen/Dense> - -#include "KernelBase.h" -#include "BubbleBase.h" -#include "GnuplotDump.h" - - template <typename Tinput, typename Trhs=Tinput> class KMCluster_TY : public KernelBase<Tinput,Trhs> { @@ -69,11 +66,9 @@ public: } } - for (int i = 0; i < N; ++i) - { + for (size_t i = 0; i < N; ++i) { const Bubble& bi = data.coords[i]; - for (int j = 0; j < N; ++j) - { + for (size_t j = 0; j < N; ++j) { const Bubble& bj = data.coords[j]; data.Dij[j + i*N] = bi.distance(bj); } @@ -160,10 +155,9 @@ public: // const Real odat[7] = {U[0][0], U[7][0], U[1][0], pb[0], pb[1], pb[2], bd.pext(t)}; const size_t N = 2*_N+2; - double out[N]; + std::vector<double> out(N); double Vg = 0.0; - for (int i = 0; i < _N; ++i) - { + for (size_t i = 0; i < _N; ++i) { const double r = U[i][0]; out[i] = r; out[i+_N] = bd.pBubble(U, i); @@ -172,7 +166,7 @@ public: out[2*_N] = bd.pext(t); out[2*_N+1] = Vg; - m_dumper->write(step, t, dt, &out[0], N); + m_dumper->write(step, t, dt, out.data(), N); if (bd.bVTK) { @@ -188,21 +182,21 @@ public: vtk << "DATASET UNSTRUCTURED_GRID\n"; vtk << "POINTS " << bd.Nbubbles << " double" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << bd.coords[i].pos[0] << " " << bd.coords[i].pos[1] << " " << bd.coords[i].pos[2] << std::endl; vtk << std::endl; vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS radius double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][0] << std::endl; vtk << std::endl; // vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS velocity double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][1] << std::endl; vtk << std::endl; } diff --git a/src/kernels/KellerMiksis.h b/src/kernels/KellerMiksis.h @@ -6,13 +6,13 @@ #ifndef KELLERMIKSIS_H_BMJWDX72 #define KELLERMIKSIS_H_BMJWDX72 +#include <BubbleBase.h> +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> + #include <cassert> #include <cmath> -#include "KernelBase.h" -#include "BubbleBase.h" -#include "GnuplotDump.h" - template <typename Tinput, typename Trhs=Tinput> class KellerMiksis : public KernelBase<Tinput,Trhs> { diff --git a/src/kernels/RPCluster.h b/src/kernels/RPCluster.h @@ -6,21 +6,19 @@ #ifndef RPCLUSTER_H_67YUOP08 #define RPCLUSTER_H_67YUOP08 +#include <BubbleBase.h> +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> + +#include <Eigen/Core> +#include <Eigen/Dense> + #include <cassert> #include <cstdlib> #include <fstream> #include <cmath> #include <vector> -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Core" -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Dense" -#include <Eigen/Core> -#include <Eigen/Dense> - -#include "KernelBase.h" -#include "BubbleBase.h" -#include "GnuplotDump.h" - template <typename Tinput, typename Trhs=Tinput> class RPCluster : public KernelBase<Tinput,Trhs> @@ -69,11 +67,9 @@ public: } } - for (int i = 0; i < N; ++i) - { + for (size_t i = 0; i < N; ++i) { const Bubble& bi = data.coords[i]; - for (int j = 0; j < N; ++j) - { + for (size_t j = 0; j < N; ++j) { const Bubble& bj = data.coords[j]; data.Dij[j + i*N] = bi.distance(bj); } @@ -154,10 +150,9 @@ public: // const Real odat[7] = {U[0][0], U[7][0], U[1][0], pb[0], pb[1], pb[2], bd.pext(t)}; const size_t N = 2*_N+2; - double out[N]; + std::vector<double> out(N); double Vg = 0.0; - for (int i = 0; i < _N; ++i) - { + for (size_t i = 0; i < _N; ++i) { const double r = U[i][0]; out[i] = r; out[i+_N] = bd.pBubble(U, i); @@ -166,7 +161,7 @@ public: out[2*_N] = bd.pext(t); out[2*_N+1] = Vg; - m_dumper->write(step, t, dt, &out[0], N); + m_dumper->write(step, t, dt, out.data(), N); if (bd.bVTK) { @@ -182,21 +177,21 @@ public: vtk << "DATASET UNSTRUCTURED_GRID\n"; vtk << "POINTS " << bd.Nbubbles << " double" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << bd.coords[i].pos[0] << " " << bd.coords[i].pos[1] << " " << bd.coords[i].pos[2] << std::endl; vtk << std::endl; vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS radius double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][0] << std::endl; vtk << std::endl; // vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS velocity double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][1] << std::endl; vtk << std::endl; } diff --git a/src/kernels/RPClusterPositions_D.h b/src/kernels/RPClusterPositions_D.h @@ -7,21 +7,19 @@ #ifndef RPCLUSTERPOS_D_H_UIJM88YU #define RPCLUSTERPOS_D_H_UIJM88YU +#include <BubbleBase.h> +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> + +#include <Eigen/Core> +#include <Eigen/Dense> + #include <cassert> #include <cstdlib> #include <fstream> #include <cmath> #include <vector> -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Core" -//#include "/cluster/home/ursular/research/codes/eigen/Eigen/Dense" -#include <Eigen/Core> -#include <Eigen/Dense> - -#include "KernelBase.h" -#include "BubbleBase.h" -#include "GnuplotDump.h" - template <typename Tinput, typename Trhs=Tinput> class RPClusterPositions_D : public KernelBase<Tinput,Trhs> @@ -76,11 +74,9 @@ public: } } - for (int i = 0; i < N; ++i) - { + for (size_t i = 0; i < N; ++i) { const Bubble& bi = data.coords[i]; - for (int j = 0; j < N; ++j) - { + for (size_t j = 0; j < N; ++j) { const Bubble& bj = data.coords[j]; data.Dij[j + i*N] = bi.distance(bj); } @@ -283,10 +279,9 @@ public: const BubbleData& bd = *(BubbleData const* const)data; const size_t N = 5*_N+2; - double out[N]; + std::vector<double> out(N); double Vg = 0.0; - for (int i = 0; i < _N; ++i) - { + for (size_t i = 0; i < _N; ++i) { const double r = U[i][0]; out[i] = r; out[i+_N] = bd.pBubble(U, i); @@ -298,7 +293,7 @@ public: out[5*_N] = bd.pext(t); out[5*_N+1] = Vg; - m_dumper->write(step, t, dt, &out[0], N); + m_dumper->write(step, t, dt, out.data(), N); if (bd.bVTK) { @@ -314,27 +309,27 @@ public: vtk << "DATASET UNSTRUCTURED_GRID\n"; vtk << "POINTS " << bd.Nbubbles << " double" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][2] << " " << U[i][4] << " " << U[i][6] << std::endl; vtk << std::endl; vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS radius double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][0] << std::endl; vtk << std::endl; // vtk << "POINT_DATA " << bd.Nbubbles << std::endl; vtk << "SCALARS velocity double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][1] << std::endl; vtk << std::endl; vtk << "VECTORS transvel double\n"; vtk << "LOOKUP_TABLE default" << std::endl; - for (int i = 0; i < bd.Nbubbles; ++i) + for (size_t i = 0; i < bd.Nbubbles; ++i) vtk << U[i][3] << " " << U[i][5] << " " << U[i][7] << std::endl; vtk << std::endl; } diff --git a/src/kernels/RayleighPlesset.h b/src/kernels/RayleighPlesset.h @@ -6,13 +6,13 @@ #ifndef RAYLEIGHPLESSET_H_DLCI4XQ3 #define RAYLEIGHPLESSET_H_DLCI4XQ3 +#include <BubbleBase.h> +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> + #include <cassert> #include <cmath> -#include "KernelBase.h" -#include "BubbleBase.h" -#include "GnuplotDump.h" - template <typename Tinput, typename Trhs=Tinput> class RayleighPlesset : public KernelBase<Tinput,Trhs> { diff --git a/src/kernels/RayleighPlesset_HBGL.h b/src/kernels/RayleighPlesset_HBGL.h @@ -6,13 +6,13 @@ #ifndef RAYLEIGHPLESSET_HBGL_H_EVWDWXSM #define RAYLEIGHPLESSET_HBGL_H_EVWDWXSM +#include <BubbleBase.h> +#include <GnuplotDump.h> +#include <TimeStepper/KernelBase.h> + #include <cassert> #include <cmath> -#include "KernelBase.h" -#include "BubbleBase.h" -#include "GnuplotDump.h" - template <typename Tinput, typename Trhs=Tinput> class RayleighPlesset_HBGL : public KernelBase<Tinput,Trhs> {