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 "vocabs.hpp"
25 #include "vtkFile.hpp"
26 
28 :
29  control_(control),
30  dict_(postprocessFile__, control_.settings().path()+postprocessFile__)
31 {
32  REPORT(1)<<"Reading numberBased dictionary ..."<<endREPORT;
33  auto nbDict = dict_.subDictOrCreate("numberBased");
34 
36  if(!numberBasedDictNames_.empty())
37  {
38  REPORT(1)<< "numberBased dictionary contains " << yellowText(numberBasedDictNames_)<<endREPORT<<endl;
39  }
40 
41 
43  if(!weightBasedDictNames_.empty())
44  {
45  REPORT(1)<< "numberBased dictionary contains " << yellowText(weightBasedDictNames_)<<endREPORT<<endl;
46  }
47 
48 
49 }
50 
51 
52 
53 bool pFlow::postprocess::processTimeFolder(real time, const word& tName, const fileSystem& localFolder)
54 {
55 
56  time_ = time;
57 
58  REPORT(0)<<"Working on time folder "<< cyanText(time)<<endREPORT;
59  timeFolderReposiory_ =
60  makeUnique<repository>
61  (
62  "timeFolder-"+tName,
63  localFolder,
64  &control_
65  );
66 
67  REPORT(1)<<"Reading pointStructure"<<endREPORT;
68  timeFolderReposiory().emplaceObject<pointStructure>(
70  (
72  "",
75  ));
76 
77 
78  REPORT(1)<<"Creating mesh and point to cell mapper"<<endREPORT;
79  pointToCell_ = makeUnique<pointRectCell>(
80  dict_.subDict("rectMesh"),
81  timeFolderReposiory().lookupObject<pointStructure>(pointStructureFile__),
82  timeFolderReposiory());
83 
84  // first numberbased dict
85  processedFields_.clear();
86  for(word& dictName:numberBasedDictNames_)
87  {
88 
89 
90  auto fieldDict = dict_.subDict("numberBased").subDict(dictName);
91  auto ppFieldPtr = processField::create(
92  fieldDict,
93  pointToCell_(),
94  timeFolderReposiory());
95 
96  if(!ppFieldPtr->process())
97  {
98  fatalExit;
99  }
100 
101  processedFields_.push_back( ppFieldPtr.release() );
102 
103  output<<endl;
104 
105  }
106 
107 
108 
109  return true;
110 }
111 
112 
114 {
115  return processTimeFolder(
116  tFolder.time(),
117  tFolder.timeName(),
118  tFolder.localFolder() );
119 }
120 
121 
123 {
124  vtkFile vtk(destPath, bName, time_);
125 
126  if(!vtk) return false;
127 
128  REPORT(1)<<"Writing processed fields to vtk file..."<<endREPORT;
129  // mesh
130  pointToCell_->mesh().writeToVtk(vtk());
131 
132  ForAll( i, processedFields_)
133  {
134 
135  if( !processedFields_[i].writeToVTK(vtk()))
136  {
137 
138  fatalErrorInFunction<<"error in writing "<< processedFields_[i].processedFieldName()<<
139  "to vtk file\n";
140  return false;
141  }
142  }
143 
144  return true;
145 }
pFlow::timeFolder::time
real time() const
Definition: timeFolder.hpp:57
pFlow::postprocess::writeToVTK
bool writeToVTK(fileSystem path, word bName) const
Definition: postprocess.cpp:122
pFlow::vtkFile
Definition: vtkFile.hpp:33
pFlow::pointStructureFile__
const char * pointStructureFile__
Definition: vocabs.hpp:42
endREPORT
#define endREPORT
Definition: streams.hpp:41
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
REPORT
#define REPORT(n)
Definition: streams.hpp:40
pFlow::postprocess::processTimeFolder
bool processTimeFolder(real time, const word &tName, const fileSystem &localFolder)
Definition: postprocess.cpp:53
cyanText
#define cyanText(text)
Definition: streams.hpp:34
pFlow::processField::create
static uniquePtr< processField > create(const dictionary &dict, pointRectCell &pToCell, repository &rep)
Definition: processField.cpp:96
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::systemControl
Definition: systemControl.hpp:41
pFlow::dictionary::subDictOrCreate
dictionary & subDictOrCreate(const word &keyword)
Definition: dictionary.cpp:634
pFlow::timeFolder::timeName
word timeName() const
Definition: timeFolder.hpp:67
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:320
pFlow::objectFile::WRITE_NEVER
@ WRITE_NEVER
Definition: objectFile.hpp:47
pFlow::dictionary::dictionaryKeywords
wordList dictionaryKeywords() const
Definition: dictionary.cpp:721
pFlow::fileSystem
Definition: fileSystem.hpp:63
pFlow::pointStructure
Definition: pointStructure.hpp:44
pFlow::timeFolder::localFolder
fileSystem localFolder() const
Definition: timeFolder.hpp:73
pFlow::postprocessFile__
const char * postprocessFile__
Definition: vocabs.hpp:49
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::output
Ostream output
pFlow::objectFile::READ_ALWAYS
@ READ_ALWAYS
Definition: objectFile.hpp:39
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:71
pFlow::postprocess::numberBasedDictNames_
wordList numberBasedDictNames_
Definition: postprocess.hpp:45
pFlow::objectFile
Definition: objectFile.hpp:33
pFlow::postprocess::weightBasedDictNames_
wordList weightBasedDictNames_
Definition: postprocess.hpp:47
pFlow::postprocess::postprocess
postprocess(systemControl &control)
Definition: postprocess.cpp:27
postprocess.hpp
vocabs.hpp
pFlow::postprocess::dict_
dictionary dict_
Definition: postprocess.hpp:43
yellowText
#define yellowText(text)
Definition: streams.hpp:30
pointStructure.hpp
vtkFile.hpp
timeFolder.hpp
pFlow::timeFolder
Definition: timeFolder.hpp:32