Skip to content

Commit

Permalink
added Velocity3dProfile
Browse files Browse the repository at this point in the history
git-svn-id: https://scm.projects.hlrs.de/svn/ls1/MarDyn/trunk@6469 a63bd714-7e14-4b5e-94e7-302c8c8ff188
  • Loading branch information
kruegener committed Aug 27, 2018
1 parent 166d24a commit bea7801
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 13 deletions.
16 changes: 10 additions & 6 deletions src/plugins/KartesianProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,21 @@ void KartesianProfile::readXML(XMLfileUnits &xmlconfig) {
_ALL = true;
}
// ADDING PROFILES
if(_DENSITY || _ALL){
ProfileBase* profile = new DensityProfile();
profile->init(this);
_profiles.push_back(profile);
_comms += profile->comms();
// Need DensityProfile for Velocity3dProfile
if(_DENSITY || _VELOCITY || _ALL){
_densProfile = new DensityProfile();
_densProfile->init(this);
_profiles.push_back(_densProfile);
_comms += _densProfile->comms();
}
if(_TEMPERATURE || _ALL){
// TODO
}
if(_VELOCITY || _ALL){
// TODO
ProfileBase* profile = new Velocity3dProfile();
profile->init(this);
_profiles.push_back(profile);
_comms += profile->comms();
}

xmlconfig.getNodeValue("timesteps/init", _initStatistics);
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/KartesianProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "PluginBase.h"
#include "Domain.h"
#include "profiles/DensityProfile.h"
#include "plugins/profiles/Velocity3dProfile.h"

#include "parallel/DomainDecompBase.h"
#include "particleContainer/ParticleContainer.h"

Expand Down Expand Up @@ -46,6 +48,7 @@ class KartesianProfile : public PluginBase{
double globalLength[3];
double segmentVolume;
Domain* dom;
ProfileBase* _densProfile;

private:
unsigned long _writeFrequency; // File Output / Reset frequency
Expand All @@ -58,7 +61,6 @@ class KartesianProfile : public PluginBase{

vector<ProfileBase*> _profiles;
int _comms = 0;
//DensityProfile _densProfile;

bool _ALL = false;
bool _DENSITY = false;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/profiles/DensityProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
void DensityProfile::output(string prefix) {
global_log->info() << "[DensityProfile] output" << std::endl;
_profilePrefix = prefix;
_profilePrefix += "_kartesian.ndpr";
_profilePrefix += "_kartesian.NDpr";
ofstream outfile(_profilePrefix.c_str());
outfile.precision(6);
// TODO: FIX ACCESS TO ELEMENTS / _yOff ???
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/profiles/DensityProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include "ProfileBase.h"
#include "../KartesianProfile.h"


class DensityProfile : public ProfileBase {
public:
~DensityProfile(){};
~DensityProfile() final {};
void record(ParticleIterator *mol, unsigned long uID) final {
_localProfile[uID] += 1;
}
Expand All @@ -22,13 +23,13 @@ class DensityProfile : public ProfileBase {
_globalProfile[uID] = domainDecomp->collCommGetLongDouble();
//global_log->info() << "[DensityProfile] globalProfile " << uID << ": " << _globalProfile[uID] << "\n";
}
void output(string prefix) override;
void output(string prefix) final;
void reset(unsigned long uID) final {
_localProfile[uID] = 0.0;
_globalProfile[uID] = 0.0;
}
// set correct number of communications needed for this profile
int comms() override {return 1;}
int comms() final {return 1;}
};


Expand Down
8 changes: 6 additions & 2 deletions src/plugins/profiles/ProfileBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "../../Domain.h"
#include "../../parallel/DomainDecompBase.h"

class KartesianProfile;

class ProfileBase {
Expand All @@ -22,16 +23,19 @@ class ProfileBase {
// number of needed communications
virtual int comms() = 0;

std::map<unsigned, long double> getProfile(){return _globalProfile;};
std::map<unsigned, long double>* get3dProfile(){return _global3dProfile;};

protected:
// TODO: Add necessary maps for profiles
// Local 1D Profile
std::map<unsigned, long double> _localProfile;
// Global 1D Profile
std::map<unsigned, long double> _globalProfile;
// Local 3D Profile
std::map<unsigned, long double> _local3dProfile;
std::map<unsigned, long double> _local3dProfile[3];
// Global 3D Profile
std::map<unsigned, long double> _global3dProfile;
std::map<unsigned, long double> _global3dProfile[3];

// output file prefix
string _profilePrefix;
Expand Down
53 changes: 53 additions & 0 deletions src/plugins/profiles/Velocity3dProfile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Created by Kruegener on 8/27/2018.
//

#include "Velocity3dProfile.h"

void Velocity3dProfile::output(string prefix) {
global_log->info() << "[Velocity3dProfile] output" << std::endl;
_profilePrefix = prefix;
_profilePrefix += "_kartesian.V3Dpr";

std::map<unsigned, long double> dens = _kartProf->_densProfile->getProfile();

ofstream outfile(_profilePrefix.c_str());
outfile.precision(6);

outfile << "//Segment volume: " << _kartProf->segmentVolume << "\n//Accumulated data sets: " << _kartProf->accumulatedDatasets << "\n//Local profile of X-Y-Z components of velocity. Output file generated by the \"Velocity3dProfile\" method, plugins/profiles. \n";
outfile << "//local velocity profile: Y - Z || X-projection\n";
// TODO: more info
outfile << "// \t dX \t dY \t dZ \n";
outfile << "\t" << 1/_kartProf->universalInvProfileUnit[0] << "\t" << 1/_kartProf->universalInvProfileUnit[1] << "\t" << 1/_kartProf->universalInvProfileUnit[2]<< "\n";
outfile << "0 \t";

for(unsigned z = 0; z < _kartProf->universalProfileUnit[2]; z++){
outfile << (z+0.5) / _kartProf->universalInvProfileUnit[2] <<" \t\t\t"; // Eintragen der z Koordinaten in Header
}
outfile << "\n";
long double vd;
// Y - axis label
for(unsigned y = 0; y < _kartProf->universalProfileUnit[1]; y++){
double hval = (y + 0.5) / _kartProf->universalInvProfileUnit[1];
outfile << hval << "\t";
// number density values
for(unsigned z = 0; z < _kartProf->universalProfileUnit[2]; z++){
for(unsigned x = 0; x < _kartProf->universalProfileUnit[0]; x++){
long unID = (long) (x * _kartProf->universalProfileUnit[0] * _kartProf->universalProfileUnit[2] + y * _kartProf->universalProfileUnit[1] + z);
// X - Y - Z output
for(unsigned d = 0; d < 3; d++){
if(dens[unID] != 0){
vd = _global3dProfile[d][unID] / dens[unID];
}
else{
vd = 0;
}
outfile << vd << "\t";
}
}
}
outfile << "\n";
}
outfile.close();

}
42 changes: 42 additions & 0 deletions src/plugins/profiles/Velocity3dProfile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// Created by Kruegener on 8/27/2018.
//

#ifndef MARDYN_TRUNK_VELOCITYPROFILE_H
#define MARDYN_TRUNK_VELOCITYPROFILE_H

#include "ProfileBase.h"
#include "../KartesianProfile.h"


class Velocity3dProfile : public ProfileBase {
public:
~Velocity3dProfile() final = default;
void record(ParticleIterator *mol, unsigned long uID) final {
for(unsigned short d = 0; d < 3; d++){
_local3dProfile[d][uID] += (*mol)->v(d);
}
}
void collectAppend(DomainDecompBase *domainDecomp, unsigned long uID) final {
for(unsigned short d = 0; d < 3; d++){
domainDecomp->collCommAppendLongDouble(_local3dProfile[d][uID]);
}
}
void collectRetrieve(DomainDecompBase *domainDecomp, unsigned long uID) final {
for(unsigned short d = 0; d < 3; d++){
_global3dProfile[d][uID] = domainDecomp->collCommGetLongDouble();
}
}
void output(string prefix) final;
void reset(unsigned long uID) final {
for(unsigned d = 0; d < 3; d++){
_local3dProfile[d][uID] = 0.0;
_global3dProfile[d][uID] = 0.0;
}
}
// set correct number of communications needed for this profile
int comms() final {return 3;}
};


#endif //MARDYN_TRUNK_VELOCITYPROFILE_H

0 comments on commit bea7801

Please sign in to comment.