/* The MIT License (MIT) Copyright (c) 2015 Tony Saad Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include #include #ifndef M_PI #define M_PI 3.14159265358979323846 #endif double karman_spec(const double k) { // INPUTS const double ke_ = 40.0; // ke - peak wave number const double nu = 1.0e-5; const double urms = 0.25; // computed from inputs to satisfy isotropic turbulence properties const double ke = sqrt(5.0/12)*ke_; const double L = 0.746834/ke; //integral length scale - sqrt(Pi)*Gamma(5/6)/Gamma(1/3)*1/ke const double alpha = 1.452762113; // 55/(9 Sqrt[Pi]) Gamma[5/6]/Gamma[1/3] const double epsilone = urms*urms*urms/L; const double keta = pow(epsilone, 0.25)*pow(nu,-3.0/4.0); const double r1 = k/ke; const double r2 = k/keta; const double tke = alpha*(urms*urms/ke)*(r1*r1*r1*r1 / pow(1.0 + r1*r1, 17.0/6.0))*exp(-2.0*r2*r2); return tke; } void help() { printf("Usage: TurboGen -n number_of_points -m number_of_modes -l domain_length -o \n"); } int main(int argc, char ** argv) { //__________________________________ // Parse arguments int N = 32; int nModes = 5000; double L = 9.0*2.0*M_PI/100; bool enableIO = false; for (int i=0; i 1.0e-10) { count++; } } } } printf("cells with divergence = %i\n", count); #endif // DEBUG // cleanup free(phi); free(nu); free(theta); free(psi); free(km); free(kx); free(ky); free(kz); free(ktx); free(kty); free(ktz); free(sxm); free(sym); free(szm); free(xc); free(yc); free(zc); free(u); free(v); free(w); return 0; }