From 0bdc29fd577a7a7b65f600f1c11954c67fc479eb Mon Sep 17 00:00:00 2001 From: Bojan Nikolic Date: Fri, 6 Feb 2009 11:51:54 +0000 Subject: [PATCH] Add a simple C++ program illustrating generation 3d turbulent volumes --- .bzrignore | 4 +- bnlib/test/Makefile.am | 8 ++++ bnlib/test/kvolume.cpp | 99 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 bnlib/test/Makefile.am create mode 100644 bnlib/test/kvolume.cpp diff --git a/.bzrignore b/.bzrignore index 2a0d762..d7fa9d1 100644 --- a/.bzrignore +++ b/.bzrignore @@ -192,4 +192,6 @@ CVS ./oof/test/Makefile ./bnmin1/test/t_utils ./bnmin1/test/t_utils - +./bnlib/test/kvolume +./bnlib/test/Makefile +*.tar.bz2 diff --git a/bnlib/test/Makefile.am b/bnlib/test/Makefile.am new file mode 100644 index 0000000..f9239e0 --- /dev/null +++ b/bnlib/test/Makefile.am @@ -0,0 +1,8 @@ +bin_PROGRAMS = kvolume + +kvolume_SOURCES = kvolume.cpp + +LDADD=../src/libbnlib.la -lboost_program_options + +INCLUDES=-I../src + diff --git a/bnlib/test/kvolume.cpp b/bnlib/test/kvolume.cpp new file mode 100644 index 0000000..ff94833 --- /dev/null +++ b/bnlib/test/kvolume.cpp @@ -0,0 +1,99 @@ +// Copyright (2009) Bojan Nikolic +// +// This file is part of BNLib +// BNLIB is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// BNLIB is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with BNLIB. If not, see . +// +// Comments regarding this example welcome at: +// Bojan Nikolic + +#include +#include + +#include "../src/kolmog/kolmogorov_3d.hxx" +#include "../src/bnrandom.hxx" + +int main(int argc, char* argv[]) +{ + using namespace boost::program_options; + + options_description desc("Allowed options"); + desc.add_options() + ("nx", value(), + "Number of pixels in the X direction") + ("ny", value(), + "Number of pixels in the Y direction") + ("nz", value(), + "Number of pixels in the Z direction") + ("help", "Produce this help message"); + + positional_options_description p; + p.add("nx", 1); + p.add("ny", 1); + p.add("nz", 1); + + variables_map vm; + store(command_line_parser(argc, argv). + options(desc).positional(p).run(), + vm); + notify(vm); + + if (vm.count("help")) + { + std::cout<<"Generate a Kolmogorov phase volume and write it out standard output" + <= ny >= nz"< phasevolume.dat"<(); + const size_t ny = vm["ny"].as(); + const size_t nz = vm["nz"].as(); + + const size_t totalsize=nx*ny*nz; + + double * cube = new double[totalsize]; + BNLib::NormDistZM dist(1.0); + + Kolmogorov3D(cube, + nx, + ny, + nz, + dist, + KInitialEFB & KBalancedIters & KEdgeBalanced); + + std::cout.write((char *)cube, + sizeof(double)*totalsize); + + delete[] cube; + } +} + + +