www.cemf.ir
multiTriSurface.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 #include "multiTriSurface.hpp"
23 
25 (
26  const objectFile &obj,
27  repository *owner
28 )
29 :
30  triSurface(obj, owner),
31  subscriber("multiTriSurface")
32 {
33  if( !IOobject::readObject() )
34  {
36  "Error in reading from file "<<IOobject::path()<<endl;
37  fatalExit;
38  }
39 }
40 
42 (
43  const objectFile &objf,
44  repository *owner,
45  const multiTriSurface &surf
46 )
47 :
48  triSurface(objf, owner, surf),
49  subscriber("multiTriSurface"),
50  subSurfaces_(surf.subSurfaces_)
51 {
52 
53 }
54 
56 (
57  const word &name,
58  const realx3x3Vector &triangles
59 )
60 {
61  uint32 start = size();
62  uint32 pointStart = numPoints();
63 
64  if(!triSurface::append(triangles))
65  {
67  return false;
68  }
69  uint32 end = size();
70  uint32 pointEnd = numPoints();
71  subSurfaces_.emplace_back(name, start, end, pointStart, pointEnd);
72 
73  return true;
74 }
75 
77 {
78  subSurfaces_.clear();
79 
80  if( !is.findKeywordAndVal("subSurfaces", subSurfaces_ ) )
81  {
83  "Error in reading subSurfaces from stream "<< is.name()<<endl;
84  return false;
85  }
86 
87  return triSurface::read(is, iop);
88 }
89 
91 (
92  iOstream &os,
93  const IOPattern &iop
94 ) const
95 {
96 
97 
98  if( iop.thisProcWriteData() )
99  {
100  os.writeWordEntry("subSurfaces", subSurfaces_);
101  if(!os.check(FUNCTION_NAME))return false;
102  }
103 
104  return triSurface::write(os,iop);
105 }
pFlow::multiTriSurface::appendSurface
bool appendSurface(const word &name, const realx3x3Vector &vertices)
Definition: multiTriSurface.cpp:56
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::multiTriSurface::multiTriSurface
multiTriSurface(const objectFile &obj, repository *owner)
Construct from objectFile and owner repository.
Definition: multiTriSurface.cpp:25
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::multiTriSurface::write
bool write(iOstream &os, const IOPattern &iop) const override
Definition: multiTriSurface.cpp:91
pFlow::triSurface::write
bool write(iOstream &os, const IOPattern &iop) const override
Definition: triSurface.cpp:282
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::iIstream::findKeywordAndVal
bool findKeywordAndVal(const word &keyword, T &val, bool checkEndStatement=true)
find a pair of keyword and data terminated by ; keyword data; return false if keyword does not exist ...
Definition: iIstreamI.hpp:24
pFlow::subscriber
Definition: subscriber.hpp:37
pFlow::multiTriSurface
Definition: multiTriSurface.hpp:32
pFlow::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.cpp:42
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
multiTriSurface.hpp
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::multiTriSurface::subSurfaces_
subSurfaceList subSurfaces_
Definition: multiTriSurface.hpp:39
pFlow::multiTriSurface::read
bool read(iIstream &is, const IOPattern &iop) override
Definition: multiTriSurface.cpp:76
pFlow::IOPattern::thisProcWriteData
bool thisProcWriteData() const
Definition: IOPattern.hpp:146
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::triSurface::read
bool read(iIstream &is, const IOPattern &iop) override
Definition: triSurface.cpp:257
pFlow::repository
Definition: repository.hpp:34
pFlow::triSurface
Definition: triSurface.hpp:103
pFlow::Vector
Definition: Vector.hpp:48
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Write a keyword/value entry.
Definition: iOstream.hpp:239