www.cemf.ir
postprocess.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include "postprocess.hpp"
22 #include "timeFolder.hpp"
23 #include "pointStructure.hpp"
24 #include "countFields.hpp"
25 #include "vocabs.hpp"
26 #include "vtkFile.hpp"
27 
29 :
30  control_(control),
31  dict_(postprocessFile__, control_.settings().path()+postprocessFile__)
32 {
33  REPORT(1)<<"Reading numberBased dictionary ..."<<END_REPORT;
34  auto nbDict = dict_.subDictOrCreate("numberBased");
35 
37  if(!numberBasedDictNames_.empty())
38  {
39  REPORT(1)<< "numberBased dictionary contains " << Yellow_Text(numberBasedDictNames_)<<END_REPORT<<endl;
40  }
41 
43  if(!weightBasedDictNames_.empty())
44  {
45  REPORT(1)<< "numberBased dictionary contains " << Yellow_Text(weightBasedDictNames_)<<END_REPORT<<endl;
46  }
47 
49  if(!countDictNames_.empty())
50  {
51  REPORT(1)<< "counting dictionary contains " << Yellow_Text(countDictNames_)<<END_REPORT<<endl;
52  }
53 
54 }
55 
56 
57 
58 bool pFlow::postprocess::processTimeFolder(real time, const word& tName, const fileSystem& localFolder)
59 {
60 
61  time_ = time;
62 
63  REPORT(0)<<"Working on time folder "<< Cyan_Text(time)<<END_REPORT;
64 
65  control_.time().setTime(time);
66 
67  REPORT(1)<<"Reading pointStructure"<<END_REPORT;
68  pointStructure pStruct(control_);
69 
70  // first delete the object to remove fields from repository
71  pointToCell_.reset(nullptr);
72 
73  REPORT(1)<<"Creating mesh and point to cell mapper"<<END_REPORT;
74  pointToCell_ = makeUnique<pointRectCell>(
75  dict_.subDict("rectMesh"),
76  pStruct,
77  control_.time());
78 
79  // first numberbased dict
80 
81  processedFields_.clear();
82  for(word& dictName:numberBasedDictNames_)
83  {
84  auto fieldDict = dict_.subDict("numberBased").subDict(dictName);
85  auto ppFieldPtr = processField::create(
86  fieldDict,
87  pointToCell_(),
88  control_.time());
89 
90  if(!ppFieldPtr->process())
91  {
92  fatalExit;
93  }
94 
95  processedFields_.push_back( ppFieldPtr.release() );
96  output<<endl;
97  }
98 
99  countedVariableNamesList_.clear();
100  countedVairablesLists_.clear();
101 
102  for(const auto& countDictName:countDictNames_)
103  {
104  REPORT(1)<<"Processing "<< Yellow_Text("counting."<<countDictName)<<END_REPORT;
105  const dictionary& countDict = dict_.subDict("counting").subDict(countDictName);
106 
107  countFields cFields(countDict);
108 
109  cFields.process(timeFolderReposiory());
110 
111  countedVariableNamesList_.push_back(
112  cFields.variableNames());
113 
114  countedVairablesLists_.push_back(cFields.countedValues());
115 
116  }
117  output<<"\n";
118 
119 
120  return true;
121 }
122 
123 
125 {
126  return processTimeFolder(
127  tFolder.time(),
128  tFolder.timeName(),
129  tFolder.localFolder() );
130 }
131 
132 
134 {
135  vtkFile vtk(destPath, bName, time_, false);
136 
137  if(!vtk) return false;
138 
139  REPORT(1)<<"Writing processed fields to vtk file..."<<END_REPORT;
140  // mesh
141  pointToCell_->mesh().writeToVtk(vtk());
142 
143  ForAll( i, processedFields_)
144  {
145 
146  if( !processedFields_[i].writeToVTK(vtk()))
147  {
148 
149  fatalErrorInFunction<<"error in writing "<< processedFields_[i].processedFieldName()<<
150  "to vtk file\n";
151  return false;
152  }
153  }
154 
155  return true;
156 }
pFlow::timeFolder::time
real time() const
Definition: timeFolder.hpp:57
pFlow::postprocess::writeToVTK
bool writeToVTK(fileSystem path, word bName) const
Definition: postprocess.cpp:133
pFlow::vtkFile
Definition: vtkFile.hpp:33
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
Cyan_Text
#define Cyan_Text(text)
Definition: iOstream.hpp:44
REPORT
#define REPORT(n)
Definition: streams.hpp:39
pFlow::postprocess::processTimeFolder
bool processTimeFolder(real time, const word &tName, const fileSystem &localFolder)
Definition: postprocess.cpp:58
pFlow::processField::create
static uniquePtr< processField > create(const dictionary &dict, pointRectCell &pToCell, repository &rep)
Definition: processField.cpp:95
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::systemControl
Definition: systemControl.hpp:41
pFlow::dictionary::subDictOrCreate
dictionary & subDictOrCreate(const word &keyword)
search for a sub-dict with keyword create a new sub-dict if not found and return a ref to it fatalExi...
Definition: dictionary.cpp:647
pFlow::timeFolder::timeName
word timeName() const
Definition: timeFolder.hpp:67
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::countFields::process
bool process(repository &rep)
Definition: countFields.cpp:37
Yellow_Text
#define Yellow_Text(text)
Definition: iOstream.hpp:40
pFlow::dictionary::dictionaryKeywords
wordList dictionaryKeywords() const
return a list of all dictionary (non-null) keywords
Definition: dictionary.cpp:734
pFlow::fileSystem
Manages file pathes, manupulate and combines them.
Definition: fileSystem.hpp:71
pFlow::countFields::countedValues
const uint32List & countedValues() const
Definition: countFields.hpp:63
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::timeFolder::localFolder
fileSystem localFolder() const
Definition: timeFolder.hpp:73
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::countFields::variableNames
const wordList & variableNames() const
Definition: countFields.hpp:59
pFlow::output
Ostream output
pFlow::postprocess::countDictNames_
wordList countDictNames_
Definition: postprocess.hpp:49
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:75
pFlow::postprocess::numberBasedDictNames_
wordList numberBasedDictNames_
Definition: postprocess.hpp:45
END_REPORT
#define END_REPORT
Definition: streams.hpp:40
pFlow::countFields
Definition: countFields.hpp:33
pFlow::dictionary::subDict
dictionary & subDict(const word &keyword)
ref to a subdictioanry fatalExit if not found
Definition: dictionary.cpp:560
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::postprocess::weightBasedDictNames_
wordList weightBasedDictNames_
Definition: postprocess.hpp:47
pFlow::postprocess::postprocess
postprocess(systemControl &control)
Definition: postprocess.cpp:28
postprocess.hpp
vocabs.hpp
pFlow::postprocess::dict_
dictionary dict_
Definition: postprocess.hpp:43
pointStructure.hpp
countFields.hpp
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67
pFlow::postprocessFile__
const char *const postprocessFile__
Definition: vocabs.hpp:49
vtkFile.hpp
timeFolder.hpp
pFlow::timeFolder
Definition: timeFolder.hpp:32