Skip to content

Commit 544cec1

Browse files
committed
add nestedFormatString
1 parent 8bcecc7 commit 544cec1

File tree

13 files changed

+823
-124
lines changed

13 files changed

+823
-124
lines changed

codes/cgns/src/CgnsCoor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ void CgnsCoor::SetDimensionStr()
345345
irmax[ 2 ] = isize[ j ++ ];
346346
}
347347
// cell size
348-
cellSize[ 0 ] = isize[ j ++ ];
349-
cellSize[ 1 ] = isize[ j ++ ];
348+
this->cellSize[ 0 ] = isize[ j ++ ];
349+
this->cellSize[ 1 ] = isize[ j ++ ];
350350
if ( this->cgnsZone->cgnsBase->celldim == THREE_D )
351351
{
352352
cellSize[ 2 ] = isize[ j ++ ];

tools/codes/cgns/CgnsBase.cpp

Lines changed: 102 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ void BBase::ReadFile(const std::string &fileName)
7777
{
7878
//namespace fs = std::filesystem;
7979
//std::cout << "Current path is " << fs::current_path() << '\n';
80-
8180
int openStatus = cg_open( fileName.c_str(), CG_MODE_READ, & this->fileId );
8281
std::string stars( "**************************************************************" );
8382
std::cout << stars << "\n";
@@ -157,9 +156,12 @@ void Base::ReadBaseUnits( int fileId, int baseId )
157156
{
158157
DataClass_t dclass;
159158
cg_goto(fileId, 1, "end");
160-
cg_dataclass_read(&dclass);
159+
int ierr = cg_dataclass_read(&dclass);
161160

162-
std::cout << "dclass = " << dclass << " dclass name = " << DataClassName[dclass] << "\n";
161+
if ( ierr == CG_OK )
162+
{
163+
std::cout << "dclass = " << dclass << " dclass name = " << DataClassName[ dclass ] << "\n";
164+
}
163165

164166
CGNS_ENUMT(MassUnits_t) mass;
165167
CGNS_ENUMT(LengthUnits_t) length;
@@ -176,30 +178,41 @@ void Base::ReadBaseUnits( int fileId, int baseId )
176178
CGNS_ENUMT(TemperatureUnits_t) ix;
177179
CGNS_ENUMT(AngleUnits_t) ia;
178180

179-
cg_units_read(&im,&il,&it,&ix,&ia);
181+
ierr = cg_units_read(&im,&il,&it,&ix,&ia);
180182

181-
std::printf("\nUnits=\n %s\n %s\n %s\n %s\n %s\n",
182-
MassUnitsName[im],LengthUnitsName[il],TimeUnitsName[it],
183-
TemperatureUnitsName[ix],AngleUnitsName[ia]);
183+
if ( ierr == CG_OK )
184+
{
185+
std::printf( "\nUnits=\n %s\n %s\n %s\n %s\n %s\n",
186+
MassUnitsName[ im ], LengthUnitsName[ il ], TimeUnitsName[ it ],
187+
TemperatureUnitsName[ ix ], AngleUnitsName[ ia ] );
188+
}
184189

185190
int nunits = -1;
186-
cg_nunits(&nunits);
187-
188-
std::cout << " CGNS nunits = " << nunits << "\n";
191+
ierr = cg_nunits(&nunits);
192+
if ( ierr == CG_OK )
193+
{
194+
std::cout << " CGNS nunits = " << nunits << "\n";
195+
}
189196

190-
cg_unitsfull_read(&mass, &length, &time, &temp, &angle, &current, &amount, &intensity);
191-
std::cout << "mass = " << mass << " MassUnitsName[mass] = " << MassUnitsName[mass]<<"\n";
192-
std::cout << "length = " << length << " LengthUnitsName[length] = " << LengthUnitsName[length]<<"\n";
193-
std::cout << "time = " << time << " TimeUnitsName[time] = " << TimeUnitsName[time]<<"\n";
194-
std::cout << "temp = " << temp << " TemperatureUnitsName[temp] = " << TemperatureUnitsName[temp]<<"\n";
195-
std::cout << "angle = " << angle<< " AngleUnitsName[angle] = " << AngleUnitsName[angle]<<"\n";
196-
std::cout << "current = " << current<< " ElectricCurrentUnitsName[current] = " << ElectricCurrentUnitsName[current]<<"\n";
197-
std::cout << "amount = " << amount<< " SubstanceAmountUnitsName[amount] = " << SubstanceAmountUnitsName[amount]<<"\n";
198-
std::cout << "intensity = " << intensity << " LuminousIntensityUnitsName[intensity] = " << LuminousIntensityUnitsName[intensity]<<"\n";
197+
ierr = cg_unitsfull_read(&mass, &length, &time, &temp, &angle, &current, &amount, &intensity);
198+
if ( ierr == CG_OK )
199+
{
200+
std::cout << "mass = " << mass << " MassUnitsName[mass] = " << MassUnitsName[ mass ] << "\n";
201+
std::cout << "length = " << length << " LengthUnitsName[length] = " << LengthUnitsName[ length ] << "\n";
202+
std::cout << "time = " << time << " TimeUnitsName[time] = " << TimeUnitsName[ time ] << "\n";
203+
std::cout << "temp = " << temp << " TemperatureUnitsName[temp] = " << TemperatureUnitsName[ temp ] << "\n";
204+
std::cout << "angle = " << angle << " AngleUnitsName[angle] = " << AngleUnitsName[ angle ] << "\n";
205+
std::cout << "current = " << current << " ElectricCurrentUnitsName[current] = " << ElectricCurrentUnitsName[ current ] << "\n";
206+
std::cout << "amount = " << amount << " SubstanceAmountUnitsName[amount] = " << SubstanceAmountUnitsName[ amount ] << "\n";
207+
std::cout << "intensity = " << intensity << " LuminousIntensityUnitsName[intensity] = " << LuminousIntensityUnitsName[ intensity ] << "\n";
208+
}
199209

200210
int nexps = -1;
201-
cg_nexponents (&nexps);
202-
std::cout << "nexps = " << nexps << "\n";
211+
ierr = cg_nexponents (&nexps);
212+
if ( ierr == CG_OK )
213+
{
214+
std::cout << "nexps = " << nexps << "\n";
215+
}
203216
}
204217

205218
void Base::ReadBase( int fileId, int baseId )
@@ -323,7 +336,7 @@ void Zone::DumpZone()
323336
}
324337
std::cout << "total faces of zone : " << this->nFaces << "\n";
325338
std::cout << "total number face nodes of zone : " << this->totalNumFaceNodes << "\n";
326-
this->DrawZone();
339+
//this->DrawZone();
327340
}
328341

329342
void Zone::DrawZone()
@@ -497,6 +510,47 @@ void Zone::SetDimensions()
497510
this->nNodes = this->irmax[ 0 ];
498511
this->nCells = this->cellSize[ 0 ];
499512
}
513+
else
514+
{
515+
// lower range index
516+
this->irmin[ 0 ] = 1;
517+
this->irmin[ 1 ] = 1;
518+
this->irmin[ 2 ] = 1;
519+
520+
// upper range index of vertices
521+
this->irmax[ 0 ] = 1;
522+
this->irmax[ 1 ] = 1;
523+
this->irmax[ 2 ] = 1;
524+
525+
this->cellSize[ 0 ] = 1;
526+
this->cellSize[ 1 ] = 1;
527+
this->cellSize[ 2 ] = 1;
528+
529+
// upper range index of vertices
530+
// vertex size
531+
int j = 0;
532+
this->irmax[ 0 ] = this->isize[ j ++ ];
533+
this->irmax[ 1 ] = this->isize[ j ++ ];
534+
535+
int celldim = THREE_D;
536+
if ( celldim == THREE_D )
537+
{
538+
this->irmax[ 2 ] = this->isize[ j ++ ];
539+
}
540+
// cell size
541+
this->cellSize[ 0 ] = this->isize[ j ++ ];
542+
this->cellSize[ 1 ] = this->isize[ j ++ ];
543+
if ( celldim == THREE_D )
544+
{
545+
cellSize[ 2 ] = this->isize[ j ++ ];
546+
}
547+
std::cout << " The Dimension Of Grid is : \n";
548+
std::cout << " I Direction " << std::setw( 10 ) << irmin[ 0 ] << std::setw( 10 ) << irmax[ 0 ] << "\n";
549+
std::cout << " J Direction " << std::setw( 10 ) << irmin[ 1 ] << std::setw( 10 ) << irmax[ 1 ] << "\n";
550+
std::cout << " K Direction " << std::setw( 10 ) << irmin[ 2 ] << std::setw( 10 ) << irmax[ 2 ] << "\n";
551+
this->nNodes = irmax[ 0 ] * irmax[ 1 ] * irmax[ 2 ];
552+
this->nCells = cellSize[ 0 ] * cellSize[ 1 ] * cellSize[ 2 ];
553+
}
500554
std::cout << " numberOfNodes = " << this->nNodes << " numberOfCells = " << this->nCells << "\n";
501555
}
502556

@@ -651,12 +705,12 @@ void Coor::DumpCoor()
651705

652706
Field::Field()
653707
{
654-
this->data = 0;
708+
//this->data = 0;
655709
}
656710

657711
Field::~Field()
658712
{
659-
this->DeAllocateData();
713+
//this->DeAllocateData();
660714
}
661715

662716
void Field::ReadField( int fileId, int baseId, int zoneId, int solutionId, int fieldId, Zone * zone )
@@ -679,7 +733,7 @@ void Field::ReadField( int fileId, int baseId, int zoneId, int solutionId, int f
679733
this->AllocateData( zone->nNodes );
680734

681735
std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
682-
int ierr = cg_field_read( fileId, baseId, zoneId, solutionId, this->fieldName, this->dataType, zone->irmin, zone->irmax, this->data);
736+
int ierr = cg_field_read( fileId, baseId, zoneId, solutionId, this->fieldName, this->dataType, zone->irmin, zone->irmax, this->data.data());
683737
if ( ierr == CG_OK )
684738
{
685739
std::cout << "cg_field_read ierr = " << ierr << "\n";
@@ -737,28 +791,38 @@ void Field::AllocateData( int nNodes )
737791
this->nNodes = nNodes;
738792
if ( this->dataType == RealSingle )
739793
{
740-
this->data = new float [ nNodes ];
794+
//this->data = new float [ nNodes ];
795+
this->data.resize(nNodes * sizeof(float) );
741796
}
742-
else
797+
else if ( this->dataType == RealDouble )
743798
{
744-
this->data = new double [ nNodes ];
799+
//this->data = new double [ nNodes ];
800+
this->data.resize(nNodes * sizeof(double) );
745801
}
746-
}
747-
748-
void Field::DeAllocateData()
749-
{
750-
if ( this->dataType == RealSingle )
802+
else if ( this->dataType == ComplexSingle )
751803
{
752-
float * f_data = static_cast< float * >( this->data );
753-
delete [] f_data;
804+
this->data.resize(nNodes * 2 * sizeof(float) );
754805
}
755-
else
806+
else if ( this->dataType == ComplexDouble )
756807
{
757-
double * d_data = static_cast< double * >( this->data );
758-
delete [] d_data;
808+
this->data.resize(nNodes * 2 * sizeof(double) );
759809
}
760810
}
761811

812+
void Field::DeAllocateData()
813+
{
814+
//if ( this->dataType == RealSingle )
815+
//{
816+
// float * f_data = static_cast< float * >( this->data );
817+
// delete [] f_data;
818+
//}
819+
//else
820+
//{
821+
// double * d_data = static_cast< double * >( this->data );
822+
// delete [] d_data;
823+
//}
824+
}
825+
762826
Solution::Solution()
763827
{
764828
;

tools/codes/cgns/CgnsBase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class Field
139139
char33 fieldName;
140140
int fieldId = -1;
141141
double doubleFieldId = -1;
142-
void * data;
142+
//void * data;
143+
std::vector<char> data;
143144
cgsize_t nNodes;
144145
DataClass_t dataclass;
145146
int dimflag=-1; //0: nondimensional 1: dimensional

tools/codes/cgnspanel.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "cgnspanel.h"
2+
#include "cgnsview.h"
23
#include <QGroupBox>
34
#include <QGridLayout>
45
#include <QResizeEvent>
@@ -110,3 +111,23 @@ void CgnsPanel::resizeEvent(QResizeEvent *event)
110111

111112
this->nodeDataGroupBox->resize(event->size().width(),event->size().height()-this->h1-this->h2-this->h3);
112113
}
114+
115+
void CgnsPanel::Display(const QString &text)
116+
{
117+
this->nodeDataTextEdit->setPlainText(text);
118+
}
119+
120+
void CgnsPanel::DisplayNode(CgnsNode *node)
121+
{
122+
this->parentNodeLineEdit->setText(QString::fromStdString(node->parent_name));
123+
this->nodeNameLineEdit->setText(QString::fromStdString(node->name));
124+
this->nodeLabelLineEdit->setText(QString::fromStdString(node->label));
125+
this->dataTypeLineEdit->setText(QString::fromStdString(node->data_type));
126+
this->dimLineEdit->setText(QString::fromStdString(node->dimstr));
127+
this->bytesLineEdit->setText(QString::number(node->data_size));
128+
this->nodeDataTextEdit->setPlainText(QString::fromStdString(node->valuestr));
129+
130+
this->linkFileLineEdit->setText(QString::fromStdString(node->link_file));
131+
this->linkNodeLineEdit->setText(QString::fromStdString(node->link_node));
132+
133+
}

tools/codes/cgnspanel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class QGridLayout;
88
class QLabel;
99
class QLineEdit;
1010

11+
class CgnsNode;
12+
1113
class CgnsPanel : public QWidget
1214
{
1315
Q_OBJECT
@@ -17,6 +19,9 @@ class CgnsPanel : public QWidget
1719
void resizeEvent(QResizeEvent *event) override;
1820

1921
signals:
22+
public:
23+
void Display(const QString &text);
24+
void DisplayNode(CgnsNode *node);
2025
private:
2126
QGroupBox *nodeDescGroupBox;
2227
QGroupBox *linkDescGroupBox;

0 commit comments

Comments
 (0)