Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (c) 2005-2012, University of Oxford. 00004 All rights reserved. 00005 00006 University of Oxford means the Chancellor, Masters and Scholars of the 00007 University of Oxford, having an administrative office at Wellington 00008 Square, Oxford OX1 2JD, UK. 00009 00010 This file is part of Chaste. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright notice, 00017 this list of conditions and the following disclaimer in the documentation 00018 and/or other materials provided with the distribution. 00019 * Neither the name of the University of Oxford nor the names of its 00020 contributors may be used to endorse or promote products derived from this 00021 software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 */ 00035 00036 #ifndef CMGUIWRITER_HPP_ 00037 #define CMGUIWRITER_HPP_ 00038 00039 #include "AbstractTetrahedralMeshWriter.hpp" 00040 #include "OutputFileHandler.hpp" 00041 00045 static const char CmguiNodeFileHeader3D[] = " #Fields=1\n\ 00046 1) coordinates, coordinate, rectangular cartesian, #Components=3\n\ 00047 x. Value index= 1, #Derivatives= 0\n\ 00048 y. Value index= 2, #Derivatives= 0\n\ 00049 z. Value index= 3, #Derivatives= 0\n"; 00050 00054 static const char CmguiNodeFileHeader2D[] = " #Fields=1\n\ 00055 1) coordinates, coordinate, rectangular cartesian, #Components=2\n\ 00056 x. Value index= 1, #Derivatives= 0\n\ 00057 y. Value index= 2, #Derivatives= 0\n"; 00058 00059 00063 static const char CmguiNodeFileHeader1D[] = " #Fields=1\n\ 00064 1) coordinates, coordinate, rectangular cartesian, #Components=1\n\ 00065 x. Value index= 1, #Derivatives= 0\n"; 00066 00070 static const char CmguiElementFileHeader3D[] = "Shape. Dimension=3, simplex(2;3)*simplex*simplex\n\ 00071 #Scale factor sets= 0\n\ 00072 #Nodes= 4\n"; 00073 00077 static const char CmguiElementFileHeader3DQuadratic[] = "Shape. Dimension=3, simplex(2;3)*simplex*simplex\n\ 00078 #Scale factor sets= 0\n\ 00079 #Nodes= 10\n"; 00080 00081 00085 static const char CmguiElementFileHeader2D[] = "Shape. Dimension=2, simplex(2)*simplex\n\ 00086 #Scale factor sets= 0\n\ 00087 #Nodes= 3\n"; 00088 00092 static const char CmguiElementFileHeader2DQuadratic[] = "Shape. Dimension=2, simplex(2)*simplex\n\ 00093 #Scale factor sets= 0\n\ 00094 #Nodes= 6\n"; 00095 00099 static const char CmguiElementFileHeader1D[] = "Shape. Dimension=1, line\n\ 00100 #Scale factor sets= 0\n\ 00101 #Nodes= 2\n"; 00102 00106 static const char CmguiElementFileHeader1DQuadratic[] = "Shape. Dimension=1, line\n\ 00107 #Scale factor sets= 0\n\ 00108 #Nodes= 3\n"; 00109 00110 00114 static const char CmguiCoordinatesFileHeader3D[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=3\n\ 00115 x. l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\ 00116 #Nodes= 4\n\ 00117 1. #Values=1\n\ 00118 Value indices: 1\n\ 00119 Scale factor indices: 1\n\ 00120 2. #Values=1\n\ 00121 Value indices: 1\n\ 00122 Scale factor indices: 2\n\ 00123 3. #Values=1\n\ 00124 Value indices: 1\n\ 00125 Scale factor indices: 3\n\ 00126 4. #Values=1\n\ 00127 Value indices: 1\n\ 00128 Scale factor indices: 4\n\ 00129 y. l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\ 00130 #Nodes= 4\n\ 00131 1. #Values=1\n\ 00132 Value indices: 1\n\ 00133 Scale factor indices: 1\n\ 00134 2. #Values=1\n\ 00135 Value indices: 1\n\ 00136 Scale factor indices: 2\n\ 00137 3. #Values=1\n\ 00138 Value indices: 1\n\ 00139 Scale factor indices: 3\n\ 00140 4. #Values=1\n\ 00141 Value indices: 1\n\ 00142 Scale factor indices: 4\n\ 00143 z. l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\ 00144 #Nodes= 4\n\ 00145 1. #Values=1\n\ 00146 Value indices: 1\n\ 00147 Scale factor indices: 1\n\ 00148 2. #Values=1\n\ 00149 Value indices: 1\n\ 00150 Scale factor indices: 2\n\ 00151 3. #Values=1\n\ 00152 Value indices: 1\n\ 00153 Scale factor indices: 3\n\ 00154 4. #Values=1\n\ 00155 Value indices: 1\n\ 00156 Scale factor indices: 4\n"; 00157 00158 00162 static const char CmguiCoordinatesFileHeader3DQuadratic[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=3\n\ 00163 x. q.simplex(2;3)*q.simplex*q.simplex, no modify, standard node based.\n\ 00164 #Nodes= 10\n\ 00165 1. #Values=1\n\ 00166 Value indices: 1\n\ 00167 Scale factor indices: 1\n\ 00168 2. #Values=1\n\ 00169 Value indices: 1\n\ 00170 Scale factor indices: 2\n\ 00171 3. #Values=1\n\ 00172 Value indices: 1\n\ 00173 Scale factor indices: 3\n\ 00174 4. #Values=1\n\ 00175 Value indices: 1\n\ 00176 Scale factor indices: 4\n\ 00177 5. #Values=1\n\ 00178 Value indices: 1\n\ 00179 Scale factor indices: 5\n\ 00180 6. #Values=1\n\ 00181 Value indices: 1\n\ 00182 Scale factor indices: 6\n\ 00183 7. #Values=1\n\ 00184 Value indices: 1\n\ 00185 Scale factor indices: 7\n\ 00186 8. #Values=1\n\ 00187 Value indices: 1\n\ 00188 Scale factor indices: 8\n\ 00189 9. #Values=1\n\ 00190 Value indices: 1\n\ 00191 Scale factor indices: 9\n\ 00192 10. #Values=1\n\ 00193 Value indices: 1\n\ 00194 Scale factor indices: 10\n\ 00195 y. q.simplex(2;3)*q.simplex*q.simplex, no modify, standard node based.\n\ 00196 #Nodes= 10\n\ 00197 1. #Values=1\n\ 00198 Value indices: 1\n\ 00199 Scale factor indices: 1\n\ 00200 2. #Values=1\n\ 00201 Value indices: 1\n\ 00202 Scale factor indices: 2\n\ 00203 3. #Values=1\n\ 00204 Value indices: 1\n\ 00205 Scale factor indices: 3\n\ 00206 4. #Values=1\n\ 00207 Value indices: 1\n\ 00208 Scale factor indices: 4\n\ 00209 5. #Values=1\n\ 00210 Value indices: 1\n\ 00211 Scale factor indices: 5\n\ 00212 6. #Values=1\n\ 00213 Value indices: 1\n\ 00214 Scale factor indices: 6\n\ 00215 7. #Values=1\n\ 00216 Value indices: 1\n\ 00217 Scale factor indices: 7\n\ 00218 8. #Values=1\n\ 00219 Value indices: 1\n\ 00220 Scale factor indices: 8\n\ 00221 9. #Values=1\n\ 00222 Value indices: 1\n\ 00223 Scale factor indices: 9\n\ 00224 10. #Values=1\n\ 00225 Value indices: 1\n\ 00226 Scale factor indices: 10\n\ 00227 z. q.simplex(2;3)*q.simplex*q.simplex, no modify, standard node based.\n\ 00228 #Nodes= 10\n\ 00229 1. #Values=1\n\ 00230 Value indices: 1\n\ 00231 Scale factor indices: 1\n\ 00232 2. #Values=1\n\ 00233 Value indices: 1\n\ 00234 Scale factor indices: 2\n\ 00235 3. #Values=1\n\ 00236 Value indices: 1\n\ 00237 Scale factor indices: 3\n\ 00238 4. #Values=1\n\ 00239 Value indices: 1\n\ 00240 Scale factor indices: 4\n\ 00241 5. #Values=1\n\ 00242 Value indices: 1\n\ 00243 Scale factor indices: 5\n\ 00244 6. #Values=1\n\ 00245 Value indices: 1\n\ 00246 Scale factor indices: 6\n\ 00247 7. #Values=1\n\ 00248 Value indices: 1\n\ 00249 Scale factor indices: 7\n\ 00250 8. #Values=1\n\ 00251 Value indices: 1\n\ 00252 Scale factor indices: 8\n\ 00253 9. #Values=1\n\ 00254 Value indices: 1\n\ 00255 Scale factor indices: 9\n\ 00256 10. #Values=1\n\ 00257 Value indices: 1\n\ 00258 Scale factor indices: 10\n"; 00259 00260 00264 static const char CmguiCoordinatesFileHeader2D[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=2\n\ 00265 x. l.simplex(2)*l.simplex, no modify, standard node based.\n\ 00266 #Nodes= 3\n\ 00267 1. #Values=1\n\ 00268 Value indices: 1\n\ 00269 Scale factor indices: 1\n\ 00270 2. #Values=1\n\ 00271 Value indices: 1\n\ 00272 Scale factor indices: 2\n\ 00273 3. #Values=1\n\ 00274 Value indices: 1\n\ 00275 Scale factor indices: 3\n\ 00276 y. l.simplex(2)*l.simplex, no modify, standard node based.\n\ 00277 #Nodes= 3\n\ 00278 1. #Values=1\n\ 00279 Value indices: 1\n\ 00280 Scale factor indices: 1\n\ 00281 2. #Values=1\n\ 00282 Value indices: 1\n\ 00283 Scale factor indices: 2\n\ 00284 3. #Values=1\n\ 00285 Value indices: 1\n\ 00286 Scale factor indices: 3\n"; 00287 00288 00293 static const char CmguiCoordinatesFileHeader2DQuadratic[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=2\n\ 00294 x. q.simplex(2)*q.simplex, no modify, standard node based.\n\ 00295 #Nodes= 6\n\ 00296 1. #Values=1\n\ 00297 Value indices: 1\n\ 00298 Scale factor indices: 1\n\ 00299 2. #Values=1\n\ 00300 Value indices: 1\n\ 00301 Scale factor indices: 2\n\ 00302 3. #Values=1\n\ 00303 Value indices: 1\n\ 00304 Scale factor indices: 3\n\ 00305 4. #Values=1\n\ 00306 Value indices: 1\n\ 00307 Scale factor indices: 4\n\ 00308 5. #Values=1\n\ 00309 Value indices: 1\n\ 00310 Scale factor indices: 5\n\ 00311 6. #Values=1\n\ 00312 Value indices: 1\n\ 00313 Scale factor indices: 6\n\ 00314 y. q.simplex(2)*q.simplex, no modify, standard node based.\n\ 00315 #Nodes= 6\n\ 00316 1. #Values=1\n\ 00317 Value indices: 1\n\ 00318 Scale factor indices: 1\n\ 00319 2. #Values=1\n\ 00320 Value indices: 1\n\ 00321 Scale factor indices: 2\n\ 00322 3. #Values=1\n\ 00323 Value indices: 1\n\ 00324 Scale factor indices: 3\n\ 00325 4. #Values=1\n\ 00326 Value indices: 1\n\ 00327 Scale factor indices: 4\n\ 00328 5. #Values=1\n\ 00329 Value indices: 1\n\ 00330 Scale factor indices: 5\n\ 00331 6. #Values=1\n\ 00332 Value indices: 1\n\ 00333 Scale factor indices: 6\n"; 00334 00335 00336 00341 static const char CmguiCoordinatesFileHeader1D[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=1\n\ 00342 x. l.Lagrange, no modify, standard node based.\n\ 00343 #Nodes= 2\n\ 00344 1. #Values=1\n\ 00345 Value indices: 1\n\ 00346 Scale factor indices: 1\n\ 00347 2. #Values=1\n\ 00348 Value indices: 1\n\ 00349 Scale factor indices: 2\n"; 00350 00351 00356 static const char CmguiCoordinatesFileHeader1DQuadratic[] = " 1) coordinates, coordinate, rectangular cartesian, #Components=1\n\ 00357 x. q.Lagrange, no modify, standard node based.\n\ 00358 #Nodes= 3\n\ 00359 1. #Values=1\n\ 00360 Value indices: 1\n\ 00361 Scale factor indices: 1\n\ 00362 2. #Values=1\n\ 00363 Value indices: 1\n\ 00364 Scale factor indices: 2\n\ 00365 3. #Values=1\n\ 00366 Value indices: 1\n\ 00367 Scale factor indices: 3\n"; 00368 00373 static const char CmguiAdditionalFieldHeader3D[] = " field, rectangular cartesian, #Components=1\n\ 00374 x. l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\ 00375 #Nodes= 4\n\ 00376 1. #Values=1\n\ 00377 Value indices: 1\n\ 00378 Scale factor indices: 1\n\ 00379 2. #Values=1\n\ 00380 Value indices: 1\n\ 00381 Scale factor indices: 2\n\ 00382 3. #Values=1\n\ 00383 Value indices: 1\n\ 00384 Scale factor indices: 3\n\ 00385 4. #Values=1\n\ 00386 Value indices: 1\n\ 00387 Scale factor indices: 4\n"; 00388 00389 00395 static const char CmguiAdditionalFieldHeader3DQuadratic[] = " field, rectangular cartesian, #Components=1\n\ 00396 x. q.simplex(2;3)*q.simplex*q.simplex, no modify, standard node based.\n\ 00397 #Nodes= 10\n\ 00398 1. #Values=1\n\ 00399 Value indices: 1\n\ 00400 Scale factor indices: 1\n\ 00401 2. #Values=1\n\ 00402 Value indices: 1\n\ 00403 Scale factor indices: 2\n\ 00404 3. #Values=1\n\ 00405 Value indices: 1\n\ 00406 Scale factor indices: 3\n\ 00407 4. #Values=1\n\ 00408 Value indices: 1\n\ 00409 Scale factor indices: 4\n\ 00410 5. #Values=1\n\ 00411 Value indices: 1\n\ 00412 Scale factor indices: 5\n\ 00413 6. #Values=1\n\ 00414 Value indices: 1\n\ 00415 Scale factor indices: 6\n\ 00416 7. #Values=1\n\ 00417 Value indices: 1\n\ 00418 Scale factor indices: 7\n\ 00419 8. #Values=1\n\ 00420 Value indices: 1\n\ 00421 Scale factor indices: 8\n\ 00422 9. #Values=1\n\ 00423 Value indices: 1\n\ 00424 Scale factor indices: 9\n\ 00425 10. #Values=1\n\ 00426 Value indices: 1\n\ 00427 Scale factor indices: 10\n"; 00428 00433 static const char CmguiAdditionalFieldHeader2D[] = " field, rectangular cartesian, #Components=1\n\ 00434 x. l.simplex(2)*l.simplex, no modify, standard node based.\n\ 00435 #Nodes= 3\n\ 00436 1. #Values=1\n\ 00437 Value indices: 1\n\ 00438 Scale factor indices: 1\n\ 00439 2. #Values=1\n\ 00440 Value indices: 1\n\ 00441 Scale factor indices: 2\n\ 00442 3. #Values=1\n\ 00443 Value indices: 1\n\ 00444 Scale factor indices: 3\n"; 00445 00450 static const char CmguiAdditionalFieldHeader2DQuadratic[] = " field, rectangular cartesian, #Components=1\n\ 00451 x. q.simplex(2)*q.simplex, no modify, standard node based.\n\ 00452 #Nodes= 6\n\ 00453 1. #Values=1\n\ 00454 Value indices: 1\n\ 00455 Scale factor indices: 1\n\ 00456 2. #Values=1\n\ 00457 Value indices: 1\n\ 00458 Scale factor indices: 2\n\ 00459 3. #Values=1\n\ 00460 Value indices: 1\n\ 00461 Scale factor indices: 3\n\ 00462 4. #Values=1\n\ 00463 Value indices: 1\n\ 00464 Scale factor indices: 4\n\ 00465 5. #Values=1\n\ 00466 Value indices: 1\n\ 00467 Scale factor indices: 5\n\ 00468 6. #Values=1\n\ 00469 Value indices: 1\n\ 00470 Scale factor indices: 6\n"; 00471 00472 00477 static const char CmguiAdditionalFieldHeader1D[] = " field, rectangular cartesian, #Components=1\n\ 00478 x. l.Lagrange, no modify, standard node based.\n\ 00479 #Nodes= 2\n\ 00480 1. #Values=1\n\ 00481 Value indices: 1\n\ 00482 Scale factor indices: 1\n\ 00483 2. #Values=1\n\ 00484 Value indices: 1\n\ 00485 Scale factor indices: 2\n"; 00486 00491 static const char CmguiAdditionalFieldHeader1DQuadratic[] = " field, rectangular cartesian, #Components=1\n\ 00492 x. q.Lagrange, no modify, standard node based.\n\ 00493 #Nodes= 2\n\ 00494 1. #Values=1\n\ 00495 Value indices: 1\n\ 00496 Scale factor indices: 1\n\ 00497 2. #Values=1\n\ 00498 Value indices: 1\n\ 00499 Scale factor indices: 2\n\ 00500 3. #Values=1\n\ 00501 Value indices: 1\n\ 00502 Scale factor indices: 3\n"; 00503 00504 00516 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM> 00517 class CmguiMeshWriter : public AbstractTetrahedralMeshWriter<ELEMENT_DIM,SPACE_DIM> 00518 { 00519 protected: 00520 00524 std::vector<std::string> mAdditionalFieldNames; 00525 00526 00531 std::vector<std::string> mRegionNames;// {tissue, bath, whatever} 00532 00539 std::string mGroupName; 00540 00545 std::string mElementFileHeader; 00546 00552 std::string mCoordinatesFileHeader; 00553 00558 std::string mAdditionalFieldHeader; 00559 00564 unsigned mNumNodesPerElement; 00565 00569 std::vector<unsigned> mReordering; 00570 00576 std::ios_base::openmode GetOpenMode(bool append); 00577 00583 out_stream OpenNodeFile(bool append = false); 00584 00590 std::vector<boost::shared_ptr<std::ofstream> > OpenElementFiles(bool append = false); 00591 00598 void WriteNodeFileHeader(out_stream& rpNodeFile); 00599 00605 void WriteElementsFileHeader(std::vector<boost::shared_ptr<std::ofstream> >& rElemFiles); 00606 00607 00611 void CreateFilesWithHeaders(); 00612 00616 void AppendLocalDataToFiles(); 00617 00621 void WriteFilesFooter(); 00622 00623 public: 00624 00632 CmguiMeshWriter(const std::string& rDirectory, 00633 const std::string& rBaseName, 00634 bool cleanDirectory=true); 00635 00639 void WriteFiles(); 00640 00646 void SetAdditionalFieldNames(std::vector<std::string>& rFieldNames); 00647 00653 void SetRegionNames(std::vector<std::string>& rRegionNames); 00654 00658 virtual ~CmguiMeshWriter() 00659 {} 00660 00661 00662 // A method called CompareCmguiFiles() has been removed, please use FileComparison class instead. 00663 00664 }; 00665 00666 #endif /*CMGUIWRITER_HPP_*/