www.cemf.ir
ProcessField.hpp
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 #ifndef __ProcessField_hpp__
22 #define __ProcessField_hpp__
23 
24 
25 #include "processField.hpp"
26 #include "rectMeshFields.hpp"
27 #include "twoPartEntry.hpp"
28 #include "fieldOperations.hpp"
29 #include "rectMeshFieldToVTK.hpp"
30 
31 namespace pFlow
32 {
33 
34 
35 template<typename T>
37 :
38  public processField
39 {
40 
41 protected:
42 
44 
45 
47 
48 public:
49 
50  TypeInfoTemplate11("ProcessField", T);
51 
53  const dictionary& dict,
54  pointRectCell& pToCell,
55  repository& rep)
56  :
57  processField(dict, pToCell, rep),
58  field_(
59  this->isUniform()?
60  timeFolder().createUniformPointField_H(this->fieldName(), getUniformValue(), false ):
61  timeFolder().readPointField_H<T>(this->fieldName())
62  ),
64  (
65  mesh(),
67  T{}
68  )
69  {
70 
71  }
72 
73  add_vCtor(
76  dictionary);
77 
78 
79  T getUniformValue()const
80  {
81  const dataEntry& entry = dict().dataEntryRef("field");
82  twoPartEntry tpEntry(entry);
83  return tpEntry.secondPartVal<T>();
84  }
85 
86  virtual bool process() override
87  {
88 
89  const includeMask& incMask = includeMask_();
90 
91  auto numeratorPtr = sumMaksOp( field_() , this->pointToCell(), incMask);
92  uniquePtr<rectMeshField_H<real>> denomeratorPtr;
93 
94  if(operation() == "sum")
95  {
96  denomeratorPtr = makeUnique<rectMeshField_H<real>>(this->mesh(), static_cast<real>(1.0));
97 
98  }else if(operation() == "average")
99  {
100 
101  pointField_H<real> oneFld(
102  objectFile
103  (
104  "oneField",
105  "",
108  ),
109  const_cast<pointStructure&>(field_().pStruct()),
110  static_cast<real>(1.0),
111  static_cast<real>(1.0)
112  );
113 
114  denomeratorPtr = sumOp(oneFld, this->pointToCell());
115 
116  }else if(operation() == "averageMask")
117  {
118  //pointField_H<real> oneFld(field_().pStruct(), static_cast<real>(1.0), static_cast<real>(1.0));
119  pointField_H<real> oneFld(
120  objectFile
121  (
122  "oneField",
123  "",
126  ),
127  const_cast<pointStructure&>(field_().pStruct()),
128  static_cast<real>(1.0),
129  static_cast<real>(1.0)
130  );
131 
132  denomeratorPtr = sumMaksOp(oneFld, this->pointToCell(), incMask);
133 
134  }
135  else
136  {
137  fatalErrorInFunction<<"operation is not known: "<< operation()<<endl;
138  fatalExit;
139  }
140 
141  auto& numerator = numeratorPtr();
142  auto& denomerator = denomeratorPtr();
143 
144  for(int32 i=0; i<this->mesh().nx(); i++ )
145  {
146  for(int32 j=0; j<this->mesh().ny(); j++ )
147  {
148  for(int32 k=0; k<this->mesh().nz(); k++ )
149  {
150  if( pointToCell().nPointInCell(i,j,k)>= threshold() )
151  {
152  processedField_(i,j,k) = numerator(i,j,k)/denomerator(i,j,k);
153  }
154  else
155  {
156  processedField_(i,j,k) = T{};
157  }
158  }
159  }
160  }
161 
162 
163  return true;
164  }
165 
166 
167  bool writeToVTK(iOstream& os)const override
168  {
170  }
171 
172 };
173 
174 
175 } // pFlow
176 
177 
178 
179 #endif //__ProcessField_hpp__
twoPartEntry.hpp
pFlow::ProcessField::field_
uniquePtr< pointField_H< T > > field_
Definition: ProcessField.hpp:43
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::rectMeshField
Definition: rectMeshField.hpp:31
pFlow::twoPartEntry
Definition: twoPartEntry.hpp:36
pFlow::sumMaksOp
uniquePtr< rectMeshField_H< T > > sumMaksOp(pointField_H< T > &field, pointRectCell &pointToCell, const incMask &mask)
Definition: fieldOperations.hpp:66
pFlow::processField::isUniform
bool isUniform() const
Definition: processField.hpp:134
pFlow::processField::processedFieldName
const word & processedFieldName() const
Definition: processField.hpp:159
fieldOperations.hpp
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::includeMask
Definition: includeMask.hpp:33
pFlow::processField::operation
const word & operation() const
Definition: processField.hpp:139
pFlow::processField::includeMask_
uniquePtr< includeMask > includeMask_
Definition: processField.hpp:59
pFlow::ProcessField::processedField_
rectMeshField_H< T > processedField_
Definition: ProcessField.hpp:46
pFlow
Definition: demGeometry.hpp:27
pFlow::ProcessField::add_vCtor
add_vCtor(processField, ProcessField, dictionary)
pFlow::objectFile::WRITE_NEVER
@ WRITE_NEVER
Definition: objectFile.hpp:44
pFlow::pointField
Definition: pointField.hpp:33
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::ProcessField::writeToVTK
bool writeToVTK(iOstream &os) const override
Definition: ProcessField.hpp:167
pFlow::dataEntry
Data entry to be used in dictionries.
Definition: dataEntry.hpp:48
processField.hpp
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::pointRectCell
Definition: pointRectCell.hpp:32
pFlow::convertRectMeshField
bool convertRectMeshField(iOstream &os, const rectMeshField_H< T > &field)
Definition: rectMeshFieldToVTK.hpp:29
pFlow::processField::processField
processField(const dictionary &dict, pointRectCell &pToCell, repository &rep)
Definition: processField.cpp:27
rectMeshFields.hpp
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::processField
Definition: processField.hpp:37
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::ProcessField::ProcessField
ProcessField(const dictionary &dict, pointRectCell &pToCell, repository &rep)
Definition: ProcessField.hpp:52
pFlow::ProcessField::process
virtual bool process() override
Definition: ProcessField.hpp:86
pFlow::objectFile::READ_NEVER
@ READ_NEVER
Definition: objectFile.hpp:37
pFlow::ProcessField::getUniformValue
T getUniformValue() const
Definition: ProcessField.hpp:79
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::processField::threshold
auto threshold() const
Definition: processField.hpp:154
pFlow::processField::fieldName
const word & fieldName() const
Definition: processField.hpp:129
pFlow::repository
Definition: repository.hpp:34
pFlow::sumOp
uniquePtr< rectMeshField_H< T > > sumOp(pointField_H< T > &field, pointRectCell &pointToCell)
Definition: fieldOperations.hpp:34
pFlow::processField::mesh
const auto & mesh() const
Definition: processField.hpp:84
rectMeshFieldToVTK.hpp
pFlow::ProcessField::TypeInfoTemplate11
TypeInfoTemplate11("ProcessField", T)
pFlow::processField::dict
auto & dict()
Definition: processField.hpp:104
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
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::ProcessField
Definition: ProcessField.hpp:36
pFlow::twoPartEntry::secondPartVal
T secondPartVal() const
Definition: twoPartEntry.hpp:62
pFlow::processField::pointToCell
const auto & pointToCell() const
Definition: processField.hpp:94
pFlow::timeFolder
Definition: timeFolder.hpp:32