PlasCom2  1.0
XPACC Multi-physics simluation application
PCPPUtil.H
Go to the documentation of this file.
1 #ifndef __PCPP_UTIL_H__
2 #define __PCPP_UTIL_H__
3 #include <iostream>
4 #include <sstream>
5 #include <string>
6 
7 #include "PCPPTypes.H"
8 #include "PCPPFieldData.H"
9 #include "PCPPIO.H"
10 
11 namespace pcpp {
12 
13  namespace util {
14 
15  int RecursiveReadConfiguration(const std::string &currentPath,
16  std::istream &inStream,pcpp::ConfigType &plascomConfig,
17  std::ostream &messageStream,const std::string="");
18 
19  int ProcessConfigurationFile(const std::string &configFileName,
20  pcpp::ConfigType &plascomConfig,
21  pcpp::CommunicatorType &globalCommunicator,
22  std::ostream &messageStream);
23 
24  int ProcessConfigurationRestart(const std::string &restartFileName,
25  pcpp::ConfigType &inConfig,
26  pcpp::CommunicatorType &configCommunicator,
27  std::ostream &messageStream);
28 
29  std::string ConfigKey(const std::string &configName,const std::string &keyName);
30 
31  pcpp::ConfigType GetSubConfig(const std::string &configName,const pcpp::ConfigType &plascomConfig);
32 
34  const std::string &dictName,
35  pcpp::field::metadataset &dataDictionary,
36  std::ostream &messageStream);
37 
39  const char loc);
40 
42  const std::string &configName);
43 
44 
45 
46  template<typename GridType>
47  int ConfigureGrid(pcpp::ConfigType &inConfig,const std::string &gridKey,
48  pcpp::CommunicatorType &inCommunicator,GridType &inGrid,
49  std::ostream &messageStream)
50  {
51  return(0);
52  }
53 
54  template<typename BufferDataType>
55  void ReportBufferStats(std::ostream &outStream,size_t numValues,const BufferDataType *dataBuffer)
56  {
57 
58  if(numValues == 0)
59  return;
60 
61  size_t minLocation = 0;
62  size_t maxLocation = 0;
63  double bufferMean = 0;
64  double bufferDev = 0;
65 
66  BufferDataType minValue = std::numeric_limits<BufferDataType>::max();
67  BufferDataType maxValue = -std::numeric_limits<BufferDataType>::max();
68 
69  for(size_t iValue = 0;iValue < numValues;iValue++){
70  if(dataBuffer[iValue] < minValue){
71  minValue = dataBuffer[iValue];
72  minLocation = iValue;
73  }
74  if(dataBuffer[iValue] > maxValue){
75  maxValue = dataBuffer[iValue];
76  maxLocation = iValue;
77  }
78  bufferMean += dataBuffer[iValue];
79  bufferDev += dataBuffer[iValue]*dataBuffer[iValue];
80  }
81 
82  bufferMean /= numValues;
83  bufferDev /= numValues;
84  bufferDev -= (bufferMean*bufferMean);
85  bufferDev = std::sqrt(std::abs(bufferDev));
86 
87  outStream << "Min: " << minValue << " @ " << minLocation << std::endl
88  << "Max: " << maxValue << " @ " << maxLocation << std::endl
89  << "Mean: " << bufferMean << " +/- " << bufferDev << std::endl;
90  return;
91  }
92 
93 
94  int ErrorMetrics(int numDim,size_t numPoints,double *dataBuffer,
95  double *normData,size_t &maxErrLocation);
96  }
97 }
98 #endif
void const size_t * numPoints
Definition: EulerKernels.H:10
int ProcessConfigurationFile(const std::string &configFileName, pcpp::ConfigType &plascomConfig, pcpp::CommunicatorType &globalCommunicator, std::ostream &messageStream)
Populate a configuration object from file in parallel.
Definition: PCPPUtil.C:326
pcpp::field::metadataset ExtractDictionary(const pcpp::field::metadataset &dataDictionary, const char loc)
Definition: PCPPUtil.C:9
int ProcessConfigurationRestart(const std::string &restartFileName, pcpp::ConfigType &inConfig, pcpp::CommunicatorType &configCommunicator, std::ostream &messageStream)
Populate a configuration object from an HDF5 restart file.
Definition: PCPPUtil.C:396
int ErrorMetrics(int numDim, size_t numPoints, double *dataBuffer, double *normData, size_t &maxErrLocation)
Definition: PCPPUtil.C:23
pcpp::ConfigType ExtractConfigParams(const fixtures::ConfigurationType &inConfig, const std::string &configName)
Definition: PCPPUtil.C:70
Main encapsulation of MPI.
Definition: COMM.H:62
std::string ConfigKey(const std::string &configName, const std::string &keyName)
Definition: PCPPUtil.C:191
int ConfigureGrid(pcpp::ConfigType &inConfig, const std::string &gridKey, pcpp::CommunicatorType &inCommunicator, GridType &inGrid, std::ostream &messageStream)
Definition: PCPPUtil.H:47
int RecursiveReadConfiguration(const std::string &currentPath, std::istream &inStream, pcpp::ConfigType &plascomConfig, std::ostream &messageStream, const std::string="")
Definition: PCPPUtil.C:203
pcpp::ConfigType GetSubConfig(const std::string &configName, const pcpp::ConfigType &plascomConfig)
Definition: PCPPUtil.C:90
void ReportBufferStats(std::ostream &outStream, size_t numValues, const BufferDataType *dataBuffer)
Definition: PCPPUtil.H:55
int ConfigureDataDictionary(pcpp::ConfigType &inConfig, const std::string &dictName, pcpp::field::metadataset &dataDictionary, std::ostream &messageStream)
Definition: PCPPUtil.C:129