www.cemf.ir
setFieldEntryTemplates.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 
22 template <typename Type>
24 {
25  word typeName( entry_.firstPart() );
26  return getTypeName<Type>() == typeName;
27 };
28 
29 template <typename Type>
31 {
32  if( !checkForType<Type>() ) return false;
33 
34  Type defValue = entry_.secondPartVal<Type>();
35  CONSUME_PARAM(defValue);
36  return true;
37 }
38 
39 template <typename Type>
42 (
44  bool verbose
45 )
46 {
47 
48  if( !checkForType<Type>() ) return nullptr;
49 
50  Type defValue = entry_.secondPartVal<Type>();
51 
52  if(verbose)
53  REPORT(2)<<"Creating pointField " << Green_Text(fieldName())<< " with default value " << Cyan_Text(defValue)<<
54  " in repository "<< pStruct.owner()->name() <<END_REPORT;
55 
56  auto Ptr = makeUnique<pointField_H<Type>>(
58  (
59  fieldName(),
60  "",
63  ),
64  pStruct,
65  defValue,
66  defValue
67  );
68 
69  return Ptr;
70 }
71 
72 
73 
74 template <typename Type>
76 (
77  repository& owner,
78  uint32IndexContainer& selected,
79  bool verbose
80 )
81 {
82  if( !checkForType<Type>() ) return false;
83 
84 
85  auto fName = fieldName();
86 
87  if( !owner.lookupObjectName(fName) )
88  {
90  "Cannot find "<< fName << " in repository " << owner.name() << ". \n";
91  return false;
92  }
93 
94  Type value = entry_.secondPartVal<Type>();
95 
96  if(verbose)
97  REPORT(2)<< "Setting selected points of " << Green_Text(fName)
98  << " to value " << Cyan_Text(value) <<END_REPORT;
99 
100 
101  auto fieldTypeName = owner.lookupObjectTypeName(fName);
102 
103  if( getTypeName<pointField_H<Type>>() == fieldTypeName )
104  {
105 
106  auto& field = owner.lookupObject<pointField_H<Type>>(fName);
107  if(field.insertSetElement(selected, value))
108  return true;
109  else
110  return false;
111  }
112 
114  fieldTypeName<< " is not a supported field type for setFieldEntry.\n";
115  return false;
116 }
117 
Green_Text
#define Green_Text(text)
Definition: iOstream.hpp:42
Cyan_Text
#define Cyan_Text(text)
Definition: iOstream.hpp:44
REPORT
#define REPORT(n)
Definition: streams.hpp:39
pFlow::repository::lookupObject
T & lookupObject(const word &name)
return a ref to the underlaying data in the object
Definition: repositoryTemplates.cpp:40
pFlow::repository::lookupObjectName
bool lookupObjectName(const word &nm) const
Definition: repository.cpp:157
pFlow::setFieldEntry::setPointFieldDefaultValueNew
uniquePtr< pointField_H< Type > > setPointFieldDefaultValueNew(pointStructure &pStruct, bool verbose=false)
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::objectFile::WRITE_ALWAYS
@ WRITE_ALWAYS
Definition: objectFile.hpp:43
pFlow::repository::lookupObjectTypeName
word lookupObjectTypeName(const word &nm) const
Definition: repository.cpp:163
pFlow::setFieldEntry::setPointFieldSelected
bool setPointFieldSelected(repository &owner, uint32IndexContainer &selected, bool verbose=false)
Definition: setFieldEntryTemplates.cpp:76
pFlow::repository::name
word name() const
Definition: repository.cpp:60
pFlow::pointField
Definition: pointField.hpp:33
pFlow::pointStructure
Definition: pointStructure.hpp:34
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::setFieldEntry::checkForType
bool checkForType() const
Definition: setFieldEntryTemplates.cpp:23
END_REPORT
#define END_REPORT
Definition: streams.hpp:40
pFlow::objectFile
Definition: objectFile.hpp:30
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::setFieldEntry::checkForTypeAndValue
bool checkForTypeAndValue() const
Definition: setFieldEntryTemplates.cpp:30
pFlow::objectFile::READ_NEVER
@ READ_NEVER
Definition: objectFile.hpp:37
pFlow::getTypeName
word getTypeName()
Definition: typeInfo.hpp:122
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::setFieldEntry::entry_
twoPartEntry entry_
Definition: setFieldEntry.hpp:37
CONSUME_PARAM
#define CONSUME_PARAM(x)
Definition: pFlowMacros.hpp:38
pFlow::repository
Definition: repository.hpp:34
pFlow::twoPartEntry::firstPart
const word & firstPart() const
Definition: twoPartEntry.hpp:51
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39