Memosa-FVM  0.2
FluentDataExporter< T > Class Template Reference

#include <FluentDataExporter.h>

Collaboration diagram for FluentDataExporter< T >:

Public Types

typedef Array< T > TArray
 

Public Member Functions

 FluentDataExporter (FluentReader &reader, const string fileName, const bool binary, const int atypeComponent)
 
void init ()
 
void closeSection ()
 
void writeScalarField (const Field &field, const int fluentFieldId)
 
void writeVectorField (const Field &field, const int fluentFieldId)
 
void finish ()
 

Private Attributes

FluentReader_reader
 
FILE * _fp
 
const bool _binary
 
const int _atypeComponent
 
const int _sectionID
 

Detailed Description

template<class T>
class FluentDataExporter< T >

Definition at line 14 of file FluentDataExporter.h.

Member Typedef Documentation

template<class T >
typedef Array<T> FluentDataExporter< T >::TArray

Definition at line 17 of file FluentDataExporter.h.

Constructor & Destructor Documentation

template<class T >
FluentDataExporter< T >::FluentDataExporter ( FluentReader reader,
const string  fileName,
const bool  binary,
const int  atypeComponent 
)
inline

Definition at line 19 of file FluentDataExporter.h.

References FluentDataExporter< T >::_fp.

22  :
23  _reader(reader),
24  _fp(fopen(fileName.c_str(),"wb")),
25  _binary(binary),
26  _atypeComponent(atypeComponent),
27  _sectionID(_binary ? 3300 : 300)
28  {
29  if (!_fp)
30  throw CException("FluentDataExporter: cannot open file " + fileName +
31  "for writing");
32  }
FluentReader & _reader

Member Function Documentation

template<class T >
void FluentDataExporter< T >::closeSection ( )
inline

Definition at line 39 of file FluentDataExporter.h.

References FluentDataExporter< T >::_binary, and FluentDataExporter< T >::_fp.

Referenced by FluentDataExporter< T >::writeScalarField(), and FluentDataExporter< T >::writeVectorField().

40  {
41  if (_binary)
42  fprintf(_fp,"\nEnd of Binary Section 3300");
43  fprintf(_fp,"))\n");
44  }
template<class T >
void FluentDataExporter< T >::finish ( )
inline

Definition at line 177 of file FluentDataExporter.h.

References FluentDataExporter< T >::_fp.

178  {
179  fclose(_fp);
180  }
template<class T >
void FluentDataExporter< T >::init ( )
inline

Definition at line 34 of file FluentDataExporter.h.

References FluentDataExporter< T >::_fp.

35  {
36  fprintf(_fp,"(4 (60 0 0 1 2 4 4 4 8 8 4))\n");
37  }
template<class T >
void FluentDataExporter< T >::writeScalarField ( const Field field,
const int  fluentFieldId 
)
inline

Definition at line 46 of file FluentDataExporter.h.

References FluentDataExporter< T >::_atypeComponent, FluentDataExporter< T >::_binary, FluentDataExporter< T >::_fp, FluentDataExporter< T >::_reader, FluentDataExporter< T >::_sectionID, FluentDataExporter< T >::closeSection(), Mesh::getBoundaryFaceGroups(), Mesh::getCells(), FluentReader::getCellZones(), Mesh::getFaceCells(), Mesh::getFaces(), FluentReader::getFaceZones(), StorageSite::getOffset(), StorageSite::getSelfCount(), Field::hasArray(), FluentZone::iBeg, FluentZone::ID, FaceGroup::id, FluentZone::iEnd, FluentCellZone::interiorZoneIds, FluentCellZone::mesh, FaceGroup::site, and ScalarArrayWriter< T >::write().

48  {
49  FaceZonesMap& faceZones = _reader.getFaceZones();
50  CellZonesMap& cellZones = _reader.getCellZones();
51 
53 
54  foreach(const CellZonesMap::value_type& pos, cellZones)
55  {
56  const FluentCellZone& cz = *pos.second;
57  const Mesh& mesh = *cz.mesh;
58 
59  const StorageSite& cells = mesh.getCells();
60  const StorageSite& faces = mesh.getFaces();
61 
62  if (field.hasArray(cells))
63  {
64  const TArray& aCell = dynamic_cast<const TArray&>(field[cells]);
65  fprintf(_fp,"(%d (%d %d 1 0 1 %d %d)\n(",
66  _sectionID, fluentFieldId, cz.ID,
67  cz.iBeg+1,cz.iEnd+1);
68  writer.write(_fp,aCell,0,cells.getSelfCount());
69  closeSection();
70 
71  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
72  {
73  const FaceGroup& fg = *fgPtr;
74  const StorageSite& faces = fg.site;
75 
76  const FluentFaceZone& fz = *faceZones[fg.id];
77  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
78 
79  fprintf(_fp,"(%d (%d %d 1 0 1 %d %d)\n(",
80  _sectionID, fluentFieldId, fz.ID,
81  fz.iBeg+1,fz.iEnd+1);
82 
83  int cbeg = faceCells(0,1);
84 
85  writer.write(_fp,aCell,cbeg,faces.getSelfCount());
86  closeSection();
87  }
88  }
89  if (field.hasArray(faces))
90  {
91  const TArray& aFaces = dynamic_cast<const TArray&>(field[faces]);
92 
93  int faceOffset =0;
94  foreach(int fzId, cz.interiorZoneIds)
95  {
96  const FluentFaceZone& fz = *faceZones[fzId];
97  const int count = fz.iEnd-fz.iBeg+1;
98  fprintf(_fp,"(%d (%d %d 1 0 1 %d %d)\n(",
99  _sectionID, fluentFieldId, fz.ID,
100  fz.iBeg+1,fz.iEnd+1);
101  writer.write(_fp,aFaces,faceOffset,count);
102  closeSection();
103  faceOffset += count;
104  }
105 
106  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
107  {
108  const FaceGroup& fg = *fgPtr;
109  const StorageSite& faces = fg.site;
110 
111  const FluentFaceZone& fz = *faceZones[fg.id];
112 
113  fprintf(_fp,"(%d (%d %d 1 0 1 %d %d)\n(",
114  _sectionID, fluentFieldId, fz.ID,
115  fz.iBeg+1,fz.iEnd+1);
116 
117  writer.write(_fp,aFaces,faces.getOffset(),faces.getSelfCount());
118  closeSection();
119  }
120  }
121 
122  }
123  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
int getSelfCount() const
Definition: StorageSite.h:40
bool hasArray(const StorageSite &s) const
Definition: Field.cpp:37
Definition: Mesh.h:28
map< int, FluentFaceZone * > FaceZonesMap
Definition: FluentReader.h:70
Definition: Mesh.h:49
FaceZonesMap & getFaceZones()
Definition: FluentReader.h:95
const int id
Definition: Mesh.h:41
map< int, FluentCellZone * > CellZonesMap
Definition: FluentReader.h:71
CellZonesMap & getCellZones()
Definition: FluentReader.h:96
const StorageSite & getFaces() const
Definition: Mesh.h:108
const StorageSite & getCells() const
Definition: Mesh.h:109
FluentReader & _reader
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
int getOffset() const
Definition: StorageSite.h:87
vector< int > interiorZoneIds
Definition: FluentReader.h:41
StorageSite site
Definition: Mesh.h:40
template<class T >
void FluentDataExporter< T >::writeVectorField ( const Field field,
const int  fluentFieldId 
)
inline

Definition at line 125 of file FluentDataExporter.h.

References FluentDataExporter< T >::_atypeComponent, FluentDataExporter< T >::_binary, FluentDataExporter< T >::_fp, FluentDataExporter< T >::_reader, FluentDataExporter< T >::_sectionID, FluentDataExporter< T >::closeSection(), Mesh::getBoundaryFaceGroups(), Mesh::getCells(), FluentReader::getCellZones(), Mesh::getFaceCells(), FluentReader::getFaceZones(), StorageSite::getSelfCount(), Field::hasArray(), FluentZone::iBeg, FluentZone::ID, FaceGroup::id, FluentZone::iEnd, FluentCellZone::mesh, FaceGroup::site, and VectorArrayWriter< T, N >::write().

126  {
127 
129 
130  FaceZonesMap& faceZones = _reader.getFaceZones();
131  CellZonesMap& cellZones = _reader.getCellZones();
132 
133  for(int nd=0; nd<3; nd++)
134  {
136 
137  foreach(const CellZonesMap::value_type& pos, cellZones)
138  {
139  const FluentCellZone& cz = *pos.second;
140  const Mesh& mesh = *cz.mesh;
141 
142  const StorageSite& cells = mesh.getCells();
143 
144  if (field.hasArray(cells))
145  {
146  const VectorT3Array& aCell = dynamic_cast<const VectorT3Array&>(field[cells]);
147 
148  fprintf(_fp,"(%d (%d %d 1 0 1 %d %d)\n(",
149  _sectionID, fluentFieldId+nd, cz.ID,
150  cz.iBeg+1,cz.iEnd+1);
151  writer.write(_fp,aCell,0,cells.getSelfCount());
152  closeSection();
153 
154  foreach(const FaceGroupPtr fgPtr, mesh.getBoundaryFaceGroups())
155  {
156  const FaceGroup& fg = *fgPtr;
157  const StorageSite& faces = fg.site;
158 
159  const FluentFaceZone& fz = *faceZones[fg.id];
160  const CRConnectivity& faceCells = mesh.getFaceCells(faces);
161 
162  fprintf(_fp,"(%d (%d %d 1 0 1 %d %d)\n(",
163  _sectionID, fluentFieldId+nd, fz.ID,
164  fz.iBeg+1,fz.iEnd+1);
165 
166  int cbeg = faceCells(0,1);
167 
168  writer.write(_fp,aCell,cbeg,faces.getSelfCount());
169  closeSection();
170  }
171  }
172  }
173  }
174 
175  }
const FaceGroupList & getBoundaryFaceGroups() const
Definition: Mesh.h:187
shared_ptr< FaceGroup > FaceGroupPtr
Definition: Mesh.h:46
int getSelfCount() const
Definition: StorageSite.h:40
bool hasArray(const StorageSite &s) const
Definition: Field.cpp:37
Definition: Mesh.h:28
map< int, FluentFaceZone * > FaceZonesMap
Definition: FluentReader.h:70
Definition: Mesh.h:49
Array< Vector< double, 3 > > VectorT3Array
Definition: CellMark.cpp:7
FaceZonesMap & getFaceZones()
Definition: FluentReader.h:95
const int id
Definition: Mesh.h:41
map< int, FluentCellZone * > CellZonesMap
Definition: FluentReader.h:71
CellZonesMap & getCellZones()
Definition: FluentReader.h:96
const StorageSite & getCells() const
Definition: Mesh.h:109
FluentReader & _reader
const CRConnectivity & getFaceCells(const StorageSite &site) const
Definition: Mesh.cpp:388
Definition: Array.h:14
StorageSite site
Definition: Mesh.h:40

Member Data Documentation

template<class T >
const int FluentDataExporter< T >::_atypeComponent
private
template<class T >
FluentReader& FluentDataExporter< T >::_reader
private
template<class T >
const int FluentDataExporter< T >::_sectionID
private

The documentation for this class was generated from the following file: