23 #ifndef _GEO_FILES_WRITER_HH_
24 #define _GEO_FILES_WRITER_HH_
53 inputData_ = inputData;
60 std :: string fileName = inputData_->outputPath() +
"geo/" + name +
".geo";
61 #if VERBOSE_LEVEL >= 2
62 std :: cout <<
"fileName = " << fileName <<
"\n";
64 outputFile_.open(fileName.c_str(), std :: ios :: out);
66 std :: cerr <<
"Can't open output file" << fileName << std :: endl;
70 outputFile_ <<
"/////////////////////////////////////////////////\n";
71 outputFile_ <<
"// This file was generated by msbGrid software //\n";
72 outputFile_ <<
"/////////////////////////////////////////////////\n\n";
76 outputFile_ <<
"// primary input data : //\n";
78 outputFile_ <<
"// xMin = " << inputData_->xMin() <<
"\n";
79 outputFile_ <<
"// xMax = " << inputData_->xMax() <<
"\n";
81 outputFile_ <<
"// blockNumberCoeffx = " << inputData_->blockNumberController() [ 0 ]
82 <<
" , blockNumberCoeffy = " << inputData_->blockNumberController() [ 1 ] <<
"\n\n";
84 outputFile_ <<
"// dr = " << inputData_->dr() <<
"\n";
85 outputFile_ <<
"// rafCoeff = " << inputData_->rafCoeff() <<
" , note : this value is used only for the fully unstructured geometry file (it is not used in msbGrid geometry files).\n\n";
87 outputFile_ <<
"// secondary input data : //\n";
88 outputFile_ <<
"// blockCenterDistribution = " << inputData_->blockCenterDistribution()
89 <<
" , blockAngleDistribution = " << inputData_->blockAngleDistribution()
92 outputFile_ <<
"// blockCenterRandSeqId = " << inputData_->blockCenterRandSeqId()
93 <<
" , blockAngleRandSeqId = " << inputData_->blockAngleRandSeqId()
95 outputFile_ <<
"// blockCenterPertCoeff = " << inputData_->blockCenterPertCoeff() <<
" , note : random distribution with pertCoeff null (blockCenterPertCoeff = 0) is equivalent to a periodic distribution\n\n";
97 outputFile_ <<
"// dist2BoundCoeff = " << inputData_->dist2BoundCoeff()
98 <<
" , interBlockDistCoeff = " << inputData_->interBlockDistCoeff()
101 outputFile_ <<
"// some statistics : //\n";
102 for (
int ib = 0; ib < inputData_->blockNumber(); ++ib ) {
103 outputFile_ <<
"// block " << ib
104 <<
" , origine : x = " << inputData_->blockCenter() [ ib ].first <<
" , y = " << inputData_->blockCenter() [ ib ].second
105 <<
" , inclinaison : beta = " << inputData_->blockAngle() [ ib ] <<
" [deg]\n";
113 outputFile_ <<
"// command line options : ";
114 outputFile_ <<
" --outputPath=\"" << inputData_->outputPath() <<
"\""
115 <<
" --outputDirName=\"" << inputData_->outputDirName() <<
"\""
116 <<
" --xMin=\"" << inputData_->xMin() <<
"\""
117 <<
" --xMax=\"" << inputData_->xMax() <<
"\""
118 <<
" --bnCx=\"" << inputData_->blockNumberController() [ 0 ] <<
"\""
119 <<
" --bnCy=\"" << inputData_->blockNumberController() [ 1 ] <<
"\""
120 <<
" --dr=\"" << inputData_->dr() <<
"\""
121 <<
" --rafC=\"" << inputData_->rafCoeff() <<
"\""
122 <<
" --bCId=\"" << inputData_->blockCenterRandSeqId() <<
"\""
123 <<
" --bAId=\"" << inputData_->blockAngleRandSeqId() <<
"\""
124 <<
" --bCPC=\"" << inputData_->blockCenterPertCoeff() <<
"\""
125 <<
" --d2bC=\"" << inputData_->dist2BoundCoeff() <<
"\""
126 <<
" --intbC=\"" << inputData_->interBlockDistCoeff() <<
"\""
130 const std :: string
geoFile(
const std :: string &name =
"newFile",
const bool &fromBuildDirectory =
false)
132 if ( fromBuildDirectory ) {
133 return ( inputData_->outputPath() +
"/gmsh/" + name +
".geo" );
136 return ( name +
".geo" );
146 void write(
const std :: string &texte)
147 { outputFile_ << texte; }
150 void write(
const Point &pt0,
const std :: string &clName0 =
"")
156 outputFile_ << std :: setw(1) << std :: fixed
157 <<
"Point(" << pt0.
Id() <<
") = {"
158 << pt0.
x() [ 0 ] <<
", "
159 << pt0.
x() [ 1 ] <<
", "
162 if ( clName0 !=
"" ) {
163 outputFile_ << clName0;
165 outputFile_ << pt0.
cl();
168 outputFile_ <<
"};\n";
178 outputFile_ << std :: setw(1) << std :: fixed
179 <<
"Line(" << ed0.
Id() <<
") = {"
180 << ed0.
vPt() [ 0 ]->Id() <<
", "
181 << ed0.
vPt() [ 1 ]->Id() <<
"};\n";
186 if ( bl0.
size() == 0 ) {
190 for (
int iEnt = 0; iEnt < bl0.
size(); ++iEnt ) {
196 void writeLineLoop(
const std :: vector< Edge * > &vEd0,
const int &lineLoopNumber)
198 std :: vector< Edge * > vEd1;
200 vEd1.push_back(vEd0 [ 0 ]);
201 int headPointIndex = 0;
203 outputFile_ << std :: setw(1) << std :: fixed <<
"Line Loop(" << lineLoopNumber <<
") = {";
204 outputFile_ << ( headPointIndex == 0 ?
"+" :
"-" ) << vEd1.front()->Id() <<
", ";
206 for (
int ie0 = 0; ie0 < vEd0.size() - 2; ++ie0 ) {
207 addLeftSideNeighbor(vEd0, vEd1, headPointIndex);
208 const std :: string sign = ( headPointIndex == 0 ?
"+" :
"-" );
209 outputFile_ << ( headPointIndex == 0 ?
"+" :
"-" ) << vEd1.front()->Id() <<
", ";
212 addLeftSideNeighbor(vEd0, vEd1, headPointIndex);
213 outputFile_ << ( headPointIndex == 0 ?
"+" :
"-" ) << vEd1.front()->Id() <<
"};\n";
223 template<
int locEdNumber >
230 const int locPtNumber = locEdNumber;
231 const int lastEdIndex = locEdNumber - 1;
232 const int lastPtIndex = locPtNumber - 1;
234 outputFile_ << std :: setw(1) << std :: fixed;
237 outputFile_ <<
"Line Loop(" << pl0.
Id() <<
") = {";
238 for (
int iEd1 = 0; iEd1 < lastEdIndex; ++iEd1 ) {
239 outputFile_ << ( ( pl0.
vEd() [ iEd1 ]->vPt() [ 0 ]->Id() == pl0.
vPt() [ iEd1 ]->Id() ) ?
"+" :
"-" )
240 << pl0.
vEd() [ iEd1 ]->Id() <<
", ";
243 outputFile_ << ( ( pl0.
vEd() [ lastEdIndex ]->vPt() [ 0 ]->Id() == pl0.
vPt() [ lastEdIndex ]->Id() ) ?
"+" :
"-" )
244 << pl0.
vEd() [ lastEdIndex ]->Id() <<
"};\n";
247 outputFile_ <<
"Plane Surface(" << pl0.
Id() <<
") = {" << pl0.
Id() <<
"};\n";
250 outputFile_ <<
"Transfinite Line{";
251 for (
int iEd1 = 0; iEd1 < lastEdIndex; ++iEd1 ) {
252 outputFile_ << pl0.
vEd() [ iEd1 ]->Id() <<
", ";
255 outputFile_ << pl0.
vEd() [ lastEdIndex ]->Id() <<
"} = 2 Using Progression 1;\n";
258 outputFile_ <<
"Transfinite Surface{" << pl0.
Id() <<
"} = {";
259 for (
int iPt1 = 0; iPt1 < lastPtIndex; ++iPt1 ) {
260 outputFile_ << pl0.
vPt() [ iPt1 ]->Id() <<
", ";
263 outputFile_ << pl0.
vPt() [ lastPtIndex ]->Id() <<
"};\n";
267 template<
typename EntityT >
270 if ( bl0.
size() == 0 ) {
274 outputFile_ <<
"\n/// Block " << bl0.
Id() <<
"\n";
275 for (
int iEnt = 0; iEnt < bl0.
size(); ++iEnt ) {
280 outputFile_ <<
"Physical Surface(" << bl0.
Id() <<
") = {" << bl0.
vEnt().front().Id() <<
":" << bl0.
vEnt().back().Id() <<
"};\n";