diff --git a/source/Applications/bChannelVA/Averaging.cpp b/source/Applications/bChannelVA/Averaging.cpp index 92c34aad4f7149ec27d4a1bdd4e670edfe90fab9..2c8b98536d1b408bdc8d81b936fcd433f46f5c53 100644 --- a/source/Applications/bChannelVA/Averaging.cpp +++ b/source/Applications/bChannelVA/Averaging.cpp @@ -456,7 +456,7 @@ void Averaging::volumeAveragingWithMPI(double l_real) if (yy < 0) yy = dimensions[1] + yy; if (yy >= dimensions[1]) yy = yy - dimensions[1]; - if (zz < 0) zz = dimensions[2] + zz; + if (zz < 0) zz = 0; if (zz >= dimensions[2]) zz = dimensions[2] - 1; double mm = (G((double)x, l)*G((double)y, l)*G((double)z, l)) / lNorm; @@ -966,7 +966,7 @@ void Averaging::meanOfStresses(int numberOfTimeSteps) } } -void Averaging::planarAveragingMQ(std::array<int, 3> dimensions) +void Averaging::planarAveragingMQ() { double numberof_XY_points = (double)dimensions[0] * (double)dimensions[1]; @@ -1047,12 +1047,3 @@ void Averaging::readVolumeAveragingValuesFromBinaryFiles(std::string fname, int readMatrixFromBinaryFiles<double>(fname + "Vz" + UbSystem::toString(timeStep) + ".bin", vaVzMatrix); readMatrixFromBinaryFiles<double>(fname + "Pr" + UbSystem::toString(timeStep) + ".bin", vaPrMatrix); } -////////////////////////////////////////////////////////////////////////// -double Averaging::G(double x, double l) -{ - if (fabs(x) <= l) - return l - fabs(x); - else - return 0.0; -} -////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/source/Applications/bChannelVA/Averaging.h b/source/Applications/bChannelVA/Averaging.h index c8b8d692263b9d4e6931510d44fdbc2e6c3eb368..c5e5c1df8006c3129aa0d102f9f6643f2820a853 100644 --- a/source/Applications/bChannelVA/Averaging.h +++ b/source/Applications/bChannelVA/Averaging.h @@ -43,7 +43,7 @@ public: void meanOfFluctuations(int numberOfTimeSteps); void sumOfStresses(); void meanOfStresses(int numberOfTimeSteps); - void planarAveragingMQ(std::array<int, 3> dimensions); + void planarAveragingMQ(); void writeToCSV(std::string path, double origin, double deltax); void readVolumeAveragingValuesFromBinaryFiles(std::string fname, int timeStep); @@ -216,4 +216,12 @@ template<class T> void Averaging::readMatrixFromBinaryFiles(std::string fname, C timer_write->StopTimer(); UBLOG(logINFO,"read matrix time: " + UbSystem::toString(timer_write->GetElapsedTime()) + " s"); } +////////////////////////////////////////////////////////////////////////// +inline double Averaging::G(double x, double l) +{ + if (fabs(x) <= l) + return l - fabs(x); + else + return 0.0; +} ////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/source/Applications/bChannelVA/bChannelVA.cpp b/source/Applications/bChannelVA/bChannelVA.cpp index 60be26dec239d621b30d0bb24d2f3d2b7eb17e4f..0fcef46f21343e9e8385fb9970331565efb1f053 100644 --- a/source/Applications/bChannelVA/bChannelVA.cpp +++ b/source/Applications/bChannelVA/bChannelVA.cpp @@ -1,125 +1,138 @@ -#include <iostream> -#include <string> -#include "VirtualFluids.h" - -#include "Averaging.h" - -using namespace std; - - -////////////////////////////////////////////////////////////////////////// -int main(int argc, char* argv[]) -{ - try - { - SPtr<Communicator> comm = MPICommunicator::getInstance(); - int myid = comm->getProcessID(); - - //Pheonix //double deltaX = 1; //double halfDeltaX = deltaX / 2.0; //std::array<int, 3> dimensions = { 600 / (int)deltaX, 400 / (int)deltaX, 400 / (int)deltaX }; //std::array<double, 3> geo_origin = { halfDeltaX, halfDeltaX, halfDeltaX }; //std::array<double, 3> geo_spacing = { 1,1,1 }; //std::array<int, 6> geo_extent = { 0, dimensions[0] - 1, 0, dimensions[1] - 1, 0, dimensions[2] - 1 }; //double real_l = 40; //double l = 40; - //int startTimeStep = 600000; //int timeStep = 10000; //int numberOfTimeSteps = 610000; //1200000; //int numberOfSamples = numberOfTimeSteps / startTimeStep; //int numberOfGridPoints = dimensions[0] * dimensions[1] * dimensions[2]; - - - //Bombadil - string pathIn = "d:/temp/BreugemChannelAnisotrop2"; - string pathOut = "d:/temp/BreugemChannelAnisotrop2"; - - double deltaX = 10; - double halfDeltaX = deltaX / 2.0; - std::array<int, 3> dimensions = { 600/(int)deltaX, 400/(int)deltaX, 400/(int)deltaX }; - std::array<double, 3> geo_origin = { halfDeltaX, halfDeltaX, halfDeltaX }; - std::array<double, 3> geo_spacing = { 10,10,10 }; - std::array<int, 6> geo_extent = { 0, dimensions[0] - 1, 0, dimensions[1] - 1, 0, dimensions[2] - 1 }; - double real_l = 40; - double l = 40; - - int startTimeStep = 60000; - int timeStep = 1000; - int numberOfTimeSteps = 61000; - int numberOfSamples = (numberOfTimeSteps - startTimeStep)/timeStep + 1; - int numberOfGridPoints = dimensions[0] * dimensions[1] * dimensions[2]; - - Averaging av; - av.setDimensions(dimensions); - av.setExtent(geo_extent); - av.setOrigin(geo_origin); - av.setSpacing(geo_spacing); - av.setDeltaX(deltaX); - - //av.createGeoMatrix(pathIn + "/bc/bc0.pvtu"); - //if (myid == 0) av.writeGeoMatrixToBinaryFiles(pathOut + "/va/geomatrix.bin"); - av.readGeoMatrixFromBinaryFiles(pathOut + "/va/geomatrix.bin"); - av.initVolumeAveragingValues(); - - for (int t = startTimeStep; t <= numberOfTimeSteps; t += timeStep) - { - av.createMQMatrix(pathIn + "/mq/mq" + UbSystem::toString(t) + ".pvtu"); - if (myid == 0) av.writeMqMatrixToBinaryFiles(pathOut + "/va/mq/mq" + UbSystem::toString(t) + "/mq", t); - //av.volumeAveragingWithMPI(real_l); - //if (myid == 0) - //{ - // //av.sumOfVolumeAveragingValues(); - // av.writeVolumeAveragingValuesToBinaryFiles(pathOut + "/va/vav/vav", t); - //} - } - - //av.writeMqMatrixToImageFile(pathOut + "/va/vav/mq"); - //if (myid == 0) av.readVolumeAveragingValuesFromBinaryFiles(pathOut + "/va/vav/vav", 60000); - //if (myid == 0) av.writeVaMatrixToImageFile(pathOut + "/va/vav/vav"); - - //if (myid == 0) - //{ - // av.initMeanVolumeAveragingValues(); - // av.meanOfVolumeAveragingValues(numberOfSamples); - // av.writeMeanVolumeAveragingValuesToBinaryFiles(pathOut + "/va/mean/mean"); - // av.writeMeanMatrixToImageFile(pathOut + "/va/vav/vavMean"); - //} - - //for (int t = startTimeStep; t <= numberOfTimeSteps; t += timeStep) - //{ - // av.readVolumeAveragingValuesFromBinaryFiles(pathOut + "/va/vav/vav", t); - // av.sumOfVolumeAveragingValues(); - //} - - //av.initMeanVolumeAveragingValues(); - //av.meanOfVolumeAveragingValues(numberOfSamples); - //av.writeMeanVolumeAveragingValuesToBinaryFiles(pathOut + "/va/mean/mean"); - //av.writeMeanMatrixToImageFile(pathOut + "/va/vav/vavMean"); - - //av.initFluctuationsofVolumeAveragingValues(); - //av.initSumOfFluctuations(); - //av.initMeanOfFluctuations(); - //av.initStresses(); - //av.initSumOfStresses(); - //av.initMeanOfStresses(); - //av.initPlanarAveragingMQ(); - - - //for (int t = startTimeStep; t <= numberOfTimeSteps; t += timeStep) - //{ - // av.readVolumeAveragingValuesFromBinaryFiles(pathOut + "/va/vav/vav", t); - // av.fluctuationsOfVolumeAveragingValue(); - // av.writeFluctuationsToBinaryFiles(pathOut + "/va/av/Fluc", t); - // av.writeStressesToBinaryFiles(pathOut + "/va/av/Stresses", t); - // av.sumOfFluctuations(); - // av.sumOfStresses(); - //} - - //av.meanOfFluctuations(numberOfSamples); - //av.meanOfStresses(numberOfSamples); - //av.planarAveragingMQ(dimensions); - //av.writeToCSV(pathOut + "/va/av", geo_origin[2], deltaX); - } - catch (const std::exception& e) - { - cerr << e.what() << endl << flush; - } - catch (std::string& s) - { - cerr << s << endl; - } - catch (...) - { - cerr << "unknown exception" << endl; - } - +#include <iostream> +#include <string> +#include "VirtualFluids.h" + +#include "Averaging.h" + +using namespace std; + + +////////////////////////////////////////////////////////////////////////// +int main(int argc, char* argv[]) +{ + try + { + SPtr<Communicator> comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + //Pheonix + //double deltaX = 1; + //double halfDeltaX = deltaX / 2.0; + //std::array<int, 3> dimensions = { 600 / (int)deltaX, 400 / (int)deltaX, 400 / (int)deltaX }; + //std::array<double, 3> geo_origin = { halfDeltaX, halfDeltaX, halfDeltaX }; + //std::array<double, 3> geo_spacing = { 1,1,1 }; + //std::array<int, 6> geo_extent = { 0, dimensions[0] - 1, 0, dimensions[1] - 1, 0, dimensions[2] - 1 }; + //double real_l = 40; + //double l = 40; + + //int startTimeStep = 600000; + //int timeStep = 10000; + //int numberOfTimeSteps = 610000; //1200000; + //int numberOfSamples = numberOfTimeSteps / startTimeStep; + //int numberOfGridPoints = dimensions[0] * dimensions[1] * dimensions[2]; + + + //Bombadil + string pathIn = "d:/temp/BreugemChannelAnisotrop2"; + string pathOut = "d:/temp/BreugemChannelAnisotrop2"; + + double deltaX = 10; + double halfDeltaX = deltaX / 2.0; + std::array<int, 3> dimensions = { 600/(int)deltaX, 400/(int)deltaX, 400/(int)deltaX }; + std::array<double, 3> geo_origin = { halfDeltaX, halfDeltaX, halfDeltaX }; + std::array<double, 3> geo_spacing = { 10,10,10 }; + std::array<int, 6> geo_extent = { 0, dimensions[0] - 1, 0, dimensions[1] - 1, 0, dimensions[2] - 1 }; + double real_l = 40; + double l = 40; + + int startTimeStep = 60000; + int timeStep = 1000; + int numberOfTimeSteps = 61000; + int numberOfSamples = (numberOfTimeSteps - startTimeStep)/timeStep + 1; + int numberOfGridPoints = dimensions[0] * dimensions[1] * dimensions[2]; + + Averaging av; + av.setDimensions(dimensions); + av.setExtent(geo_extent); + av.setOrigin(geo_origin); + av.setSpacing(geo_spacing); + av.setDeltaX(deltaX); + + //av.createGeoMatrix(pathIn + "/bc/bc0.pvtu"); + //if (myid == 0) av.writeGeoMatrixToBinaryFiles(pathOut + "/va/geomatrix.bin"); + av.readGeoMatrixFromBinaryFiles(pathOut + "/va/geomatrix.bin"); + av.initVolumeAveragingValues(); + + for (int t = startTimeStep; t <= numberOfTimeSteps; t += timeStep) + { + av.createMQMatrix(pathIn + "/mq/mq" + UbSystem::toString(t) + ".pvtu"); + if (myid == 0) av.writeMqMatrixToBinaryFiles(pathOut + "/va/mq/mq" + UbSystem::toString(t) + "/mq", t); + //av.volumeAveragingWithMPI(real_l); + //if (myid == 0) + //{ + // //av.sumOfVolumeAveragingValues(); + // av.writeVolumeAveragingValuesToBinaryFiles(pathOut + "/va/vav/vav", t); + //} + } + + //av.writeMqMatrixToImageFile(pathOut + "/va/vav/mq"); + //if (myid == 0) av.readVolumeAveragingValuesFromBinaryFiles(pathOut + "/va/vav/vav", 60000); + //if (myid == 0) av.writeVaMatrixToImageFile(pathOut + "/va/vav/vav"); + + //if (myid == 0) + //{ + // av.initMeanVolumeAveragingValues(); + // av.meanOfVolumeAveragingValues(numberOfSamples); + // av.writeMeanVolumeAveragingValuesToBinaryFiles(pathOut + "/va/mean/mean"); + // av.writeMeanMatrixToImageFile(pathOut + "/va/vav/vavMean"); + //} + + //for (int t = startTimeStep; t <= numberOfTimeSteps; t += timeStep) + //{ + // av.readVolumeAveragingValuesFromBinaryFiles(pathOut + "/va/vav/vav", t); + // av.sumOfVolumeAveragingValues(); + //} + + //av.initMeanVolumeAveragingValues(); + //av.meanOfVolumeAveragingValues(numberOfSamples); + //av.writeMeanVolumeAveragingValuesToBinaryFiles(pathOut + "/va/mean/mean"); + //av.writeMeanMatrixToImageFile(pathOut + "/va/vav/vavMean"); + + //av.initFluctuationsofVolumeAveragingValues(); + //av.initSumOfFluctuations(); + //av.initMeanOfFluctuations(); + //av.initStresses(); + //av.initSumOfStresses(); + //av.initMeanOfStresses(); + //av.initPlanarAveragingMQ(); + + + //for (int t = startTimeStep; t <= numberOfTimeSteps; t += timeStep) + //{ + // av.readVolumeAveragingValuesFromBinaryFiles(pathOut + "/va/vav/vav", t); + // av.fluctuationsOfVolumeAveragingValue(); + // av.writeFluctuationsToBinaryFiles(pathOut + "/va/av/Fluc", t); + // av.writeStressesToBinaryFiles(pathOut + "/va/av/Stresses", t); + // av.sumOfFluctuations(); + // av.sumOfStresses(); + //} + + //av.meanOfFluctuations(numberOfSamples); + //av.meanOfStresses(numberOfSamples); + //av.planarAveragingMQ(dimensions); + //av.writeToCSV(pathOut + "/va/av", geo_origin[2], deltaX); + } + catch (const std::exception& e) + { + cerr << e.what() << endl << flush; + } + catch (std::string& s) + { + cerr << s << endl; + } + catch (...) + { + cerr << "unknown exception" << endl; + } + } \ No newline at end of file