Skip to content

Commit

Permalink
cubic is almost ready!
Browse files Browse the repository at this point in the history
  • Loading branch information
yangbai90 committed Nov 3, 2019
1 parent 13bf4fe commit 26c5918
Show file tree
Hide file tree
Showing 11 changed files with 20,105 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ set(INC ${INC} include/GeoReader.h)
set(SRC ${SRC} src/GeoReader/GeoReader.cpp src/GeoReader/GeoReaderRun.cpp)
set(SRC ${SRC} src/GeoReader/PrintHelper.cpp src/GeoReader/PrintInfo.cpp)

set(SRC ${SRC} src/GeoReader/RunJobForCircle.cpp)
set(SRC ${SRC} src/GeoReader/ReadGeoFile.cpp)
set(SRC ${SRC} src/GeoReader/RunJobForCircle.cpp)
set(SRC ${SRC} src/GeoReader/RunJobForRect.cpp)
set(SRC ${SRC} src/GeoReader/RunJobForCubic.cpp)
set(SRC ${SRC} src/GeoReader/JudgeFuns.cpp)



add_executable(np2m-dev ${SRC} ${INC})
Expand Down
46 changes: 45 additions & 1 deletion include/GeoReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class GeoReader
void RunJobForCubic();
void RunJobForCylinder();

//********************************
//*** Judge fun
private:
bool IsIthPointOnEdge(const int &i,const int &component,const double &coord) const;
bool IsIthLineOnEdge(const int &i,const int &component,const double &coord) const;
bool IsIthSurfaceOnEdge(const int &i,const int &component,const double &coord) const;

private:
void SetTol(double tol){_tolerance=tol;}
void SetSize(double size){_Size=size;}
private:
inline int GetPointsNum() const {return _nNodes;}
inline int GetLinesNum() const {return _nLines;}
Expand All @@ -41,11 +51,36 @@ class GeoReader
inline int GetMinDim() const {return _nDimMin;}
inline int GetMaxDim() const {return _nDimMax;}

private:
inline double GetIthNodeJthCoord(const int &i,const int &j)const{
return _NodeCoords[(i-1)*3+j-1];
}
//**********************************
inline int GetIthLineJthNodeID(const int &i,const int &j)const{
return _Line[(i-1)*2+j-1];
}
//**********************************
inline int GetIthLineLoopLength(const int &i)const{
return (int)_LineLoop[i-1].size();
}
inline int GetIthLineLoopJthLineID(const int &i,const int &j)const{
return _LineLoop[i-1][j-1];
}
//***********************************
inline int GetIthSurfaceLoopLength(const int &i)const{
return (int)_SurfaceLoop[i-1].size();
}
inline int GetIthSurfaceLoopJthSurfaceID(const int &i,const int &j)const{
return _SurfaceLoop[i-1][j-1];
}

private:
// information for geometric
double _Xmin,_Xmax,_Ymin,_Ymax,_Zmin,_Zmax;
int _nDim,_nDimMax,_nDimMin;
int _nNodes,_nLines,_nLineLoops,_nSurfaces,_nVolumes;
double _tolerance=5.0e-2;
double _Size=1.0;
int _nNodes,_nLines,_nLineLoops,_nSurfaces,_nSurfaceLoops,_nVolumes;

vector<double> _NodeCoords;
vector<int> _Line;
Expand All @@ -66,6 +101,15 @@ class GeoReader
};
JobType _JobType;
string _Domain;
private:
// array for split information
vector<int> _LeftLineIDSet,_RightLineIDSet;
vector<int> _BottomLineIDSet,_TopLineIDSet;

vector<int> _LeftSurfaceIDSet,_RightSurfaceIDSet;
vector<int> _BottomSurfaceIDSet,_TopSurfaceIDSet;
vector<int> _BackSurfaceIDSet,_FrontSurfaceIDSet;


};

Expand Down
65 changes: 64 additions & 1 deletion src/GeoReader/GeoReaderRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ void GeoReader::Run(int args,char *argv[]){
bool HasPrint=true;
bool HasDomain=false;
bool HasGeoFile=false;
vector<double> numbers;
if(args==1){
cout<<"******************************************************************"<<endl;
cout<<"*** Error: no geo file name is given !!! ***"<<endl;
Expand Down Expand Up @@ -49,6 +50,7 @@ void GeoReader::Run(int args,char *argv[]){
if(substr.compare(substr.length()-4,4,".geo")==0){
if(substr.length()>4){
_GeoFileName=substr;
_NewGeoFileName="new"+_GeoFileName;
HasGeoFile=true;
}
else{
Expand Down Expand Up @@ -127,6 +129,66 @@ void GeoReader::Run(int args,char *argv[]){
}
}
}
else if(str.compare("-tol")==0){
if(i==args-1){
cout<<"*** Error: no number found after -tol !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
cout<<"*** np2m exit due to some errors !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
abort();
}
else{
substr=string(argv[i+1]);
numbers=SplitNumVecFromString(substr);
if(numbers.size()<1){
cout<<"*** Error: no number found after -tol !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
cout<<"*** np2m exit due to some errors !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
abort();
}
else{
if(numbers[0]<1.0e-13){
cout<<"*** Error: invalid value for -tol option !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
cout<<"*** np2m exit due to some errors !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
abort();
}
SetTol(numbers[0]);
}
}
}
else if(str.compare("-size")==0){
if(i==args-1){
cout<<"*** Error: no number found after -size !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
cout<<"*** np2m exit due to some errors !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
abort();
}
else{
substr=string(argv[i+1]);
numbers=SplitNumVecFromString(substr);
if(numbers.size()<1){
cout<<"*** Error: no number found after -size !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
cout<<"*** np2m exit due to some errors !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
abort();
}
else{
if(numbers[0]<1.0e-13){
cout<<"*** Error: invalid value for -size option !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
cout<<"*** np2m exit due to some errors !!! ***"<<endl;
cout<<"******************************************************************"<<endl;
abort();
}
SetSize(numbers[0]);
}
}
}
}
}

Expand Down Expand Up @@ -164,9 +226,10 @@ void GeoReader::Run(int args,char *argv[]){
RunJobForCircle();
break;
case JobType::RECTANGLE:
// RunJobForRect();
RunJobForRect();
break;
case JobType::CUBIC:
RunJobForCubic();
break;
default:
cout<<"******************************************************************"<<endl;
Expand Down
34 changes: 34 additions & 0 deletions src/GeoReader/JudgeFuns.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "GeoReader.h"

bool GeoReader::IsIthPointOnEdge(const int &i,const int &component,const double &coord) const{
if(abs(GetIthNodeJthCoord(i,component)-coord)<_tolerance){
return true;
}
return false;
}
//*************************************
bool GeoReader::IsIthLineOnEdge(const int &i,const int &component,const double &coord) const{
int id1=GetIthLineJthNodeID(i,1);
int id2=GetIthLineJthNodeID(i,2);
if(IsIthPointOnEdge(id1,component,coord)&&IsIthPointOnEdge(id2,component,coord)){
return true;
}
return false;
}
//**************************************
bool GeoReader::IsIthSurfaceOnEdge(const int &i,const int &component,const double &coord) const{
bool IsOnEdge=true;
int j,lineid;
for(j=1;j<=GetIthLineLoopLength(i);++j){
lineid=GetIthLineLoopJthLineID(i,j);
if(lineid<0) lineid=-lineid;
if(IsIthLineOnEdge(lineid,component,coord)){
IsOnEdge=true;
}
else{
IsOnEdge=false;
return false;
}
}
return IsOnEdge;
}
4 changes: 3 additions & 1 deletion src/GeoReader/PrintInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ void GeoReader::PrintInfo()
printf("*** Physical dim max=%4d, dim min=%4d ***\n",GetMaxDim(),GetMinDim());

printf("*** Domain=%10s ***\n",_Domain.c_str());

printf("*** tolerance=%14.6e, size=%14.6e ***\n",_tolerance,_Size);
printf("*** Input geo file= %-40s ***\n",_GeoFileName.c_str());
printf("*** Output geo file= %-40s***\n",_NewGeoFileName.c_str());
cout<<"******************************************************************"<<endl;
}
18 changes: 16 additions & 2 deletions src/GeoReader/ReadGeoFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ void GeoReader::ReadGeoFile(){
_NodeCoords.clear();_nNodes=0;
_Line.clear();_nLines=0;
_LineLoop.clear();_nLineLoops=0;
_nSurfaces=0;
_nSurfaceLoops=0;_nVolumes=0;
while(!in.eof()){
getline(in,line);
if(line.find("Point (")!=string::npos){
Expand Down Expand Up @@ -126,10 +128,22 @@ void GeoReader::ReadGeoFile(){
surfaceid.clear();
for(unsigned int i=1;i<numbers.size();i++){
surfaceid.push_back(int(numbers[i]));
cout<<int(numbers[i])<<" ";
// cout<<int(numbers[i])<<" ";
}
cout<<endl;
// cout<<endl;
_SurfaceLoop.push_back(surfaceid);
_nSurfaceLoops+=1;
}
}
else if(line.find("Volume (")!=string::npos){
// Read Plane surface information
strvec=SplitStringVecBySymbol(line,';');
numbers=SplitNumVecFromString(strvec[0]);
if(numbers.size()<2){
cout<<"**** Error: Volume () must have 2 numbers!!!"<<endl;
abort();
}
else{
_nVolumes+=1;
}
}
Expand Down
Loading

0 comments on commit 26c5918

Please sign in to comment.