VTK
vtkLSDynaReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLSDynaReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*----------------------------------------------------------------------------
16  Copyright (c) Sandia Corporation
17  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18 ----------------------------------------------------------------------------*/
19 
153 #ifndef __vtkLSDynaReader_h
154 #define __vtkLSDynaReader_h
155 
157 
158 class LSDynaMetaData;
160 class vtkPoints;
161 class vtkDataArray;
163 class vtkUnstructuredGrid;
164 
166 {
167 public:
169  virtual void PrintSelf(ostream &os, vtkIndent indent);
170  static vtkLSDynaReader *New();
171 
174  void Dump( ostream &os );
175 
178  void DebugDump();
179 
181  virtual int CanReadFile( const char* fname );
182 
184 
186  virtual void SetDatabaseDirectory( const char* );
187  const char* GetDatabaseDirectory();
188  int IsDatabaseValid();
190 
192 
196  virtual void SetFileName( const char* );
197  const char* GetFileName();
199 
204  char* GetTitle();
205 
209  int GetDimensionality();
210 
214  vtkIdType GetNumberOfNodes();
215 
220  vtkIdType GetNumberOfCells();
221 
228  vtkIdType GetNumberOfContinuumCells();
229 
233  vtkIdType GetNumberOfSolidCells();
234 
238  vtkIdType GetNumberOfThickShellCells();
239 
243  vtkIdType GetNumberOfShellCells();
244 
248  vtkIdType GetNumberOfRigidBodyCells();
249 
253  vtkIdType GetNumberOfRoadSurfaceCells();
254 
258  vtkIdType GetNumberOfBeamCells();
259 
263  vtkIdType GetNumberOfParticleCells();
264 
266 
269  vtkIdType GetNumberOfTimeSteps();
270  virtual void SetTimeStep( vtkIdType );
271  vtkIdType GetTimeStep();
272  double GetTimeValue( vtkIdType );
273  vtkGetVector2Macro(TimeStepRange,int);
274  vtkSetVector2Macro(TimeStepRange,int);
276 
278 
280  int GetNumberOfPointArrays();
281  const char* GetPointArrayName(int);
282  virtual void SetPointArrayStatus( int arr, int status );
283  virtual void SetPointArrayStatus( const char* arrName, int status );
284  int GetPointArrayStatus( int arr );
285  int GetPointArrayStatus( const char* arrName );
286  int GetNumberOfComponentsInPointArray( int arr );
287  int GetNumberOfComponentsInPointArray( const char* arrName );
289 
291 
295  int GetNumberOfCellArrays( int cellType );
296  const char* GetCellArrayName( int cellType, int arr );
297  virtual void SetCellArrayStatus( int cellType, int arr, int status );
298  virtual void SetCellArrayStatus( int cellType, const char* arrName, int status );
299  int GetCellArrayStatus( int cellType, int arr );
300  int GetCellArrayStatus( int cellType, const char* arrName );
301  int GetNumberOfComponentsInCellArray( int cellType, int arr );
302  int GetNumberOfComponentsInCellArray( int cellType, const char* arrName );
304 
306 
308  int GetNumberOfSolidArrays();
309  const char* GetSolidArrayName(int);
310  virtual void SetSolidArrayStatus( int arr, int status );
311  virtual void SetSolidArrayStatus( const char* arrName, int status );
312  int GetSolidArrayStatus( int arr );
313  int GetSolidArrayStatus( const char* arrName );
315 
316  int GetNumberOfComponentsInSolidArray( int a );
317  int GetNumberOfComponentsInSolidArray( const char* arrName );
318 
320 
322  int GetNumberOfThickShellArrays();
323  const char* GetThickShellArrayName(int);
324  virtual void SetThickShellArrayStatus( int arr, int status );
325  virtual void SetThickShellArrayStatus( const char* arrName, int status );
326  int GetThickShellArrayStatus( int arr );
327  int GetThickShellArrayStatus( const char* arrName );
329 
330  int GetNumberOfComponentsInThickShellArray( int a );
331  int GetNumberOfComponentsInThickShellArray( const char* arrName );
332 
334 
336  int GetNumberOfShellArrays();
337  const char* GetShellArrayName(int);
338  virtual void SetShellArrayStatus( int arr, int status );
339  virtual void SetShellArrayStatus( const char* arrName, int status );
340  int GetShellArrayStatus( int arr );
341  int GetShellArrayStatus( const char* arrName );
343 
344  int GetNumberOfComponentsInShellArray( int a );
345  int GetNumberOfComponentsInShellArray( const char* arrName );
346 
348 
350  int GetNumberOfRigidBodyArrays();
351  const char* GetRigidBodyArrayName(int);
352  virtual void SetRigidBodyArrayStatus( int arr, int status );
353  virtual void SetRigidBodyArrayStatus( const char* arrName, int status );
354  int GetRigidBodyArrayStatus( int arr );
355  int GetRigidBodyArrayStatus( const char* arrName );
357 
358  int GetNumberOfComponentsInRigidBodyArray( int a );
359  int GetNumberOfComponentsInRigidBodyArray( const char* arrName );
360 
362 
364  int GetNumberOfRoadSurfaceArrays();
365  const char* GetRoadSurfaceArrayName(int);
366  virtual void SetRoadSurfaceArrayStatus( int arr, int status );
367  virtual void SetRoadSurfaceArrayStatus( const char* arrName, int status );
368  int GetRoadSurfaceArrayStatus( int arr );
369  int GetRoadSurfaceArrayStatus( const char* arrName );
371 
372  int GetNumberOfComponentsInRoadSurfaceArray( int a );
373  int GetNumberOfComponentsInRoadSurfaceArray( const char* arrName );
374 
376 
378  int GetNumberOfBeamArrays();
379  const char* GetBeamArrayName(int);
380  virtual void SetBeamArrayStatus( int arr, int status );
381  virtual void SetBeamArrayStatus( const char* arrName, int status );
382  int GetBeamArrayStatus( int arr );
383  int GetBeamArrayStatus( const char* arrName );
385 
386  int GetNumberOfComponentsInBeamArray( int a );
387  int GetNumberOfComponentsInBeamArray( const char* arrName );
388 
390 
392  int GetNumberOfParticleArrays();
393  const char* GetParticleArrayName(int);
394  virtual void SetParticleArrayStatus( int arr, int status );
395  virtual void SetParticleArrayStatus( const char* arrName, int status );
396  int GetParticleArrayStatus( int arr );
397  int GetParticleArrayStatus( const char* arrName );
399 
400  int GetNumberOfComponentsInParticleArray( int a );
401  int GetNumberOfComponentsInParticleArray( const char* arrName );
402 
404 
407  void SetDeformedMesh(int);
408  vtkGetMacro(DeformedMesh,int);
409  vtkBooleanMacro(DeformedMesh,int);
411 
413 
421  vtkSetMacro(RemoveDeletedCells,int);
422  vtkGetMacro(RemoveDeletedCells,int);
423  vtkBooleanMacro(RemoveDeletedCells,int);
425 
427 
429  vtkSetMacro(DeletedCellsAsGhostArray,int);
430  vtkGetMacro(DeletedCellsAsGhostArray,int);
431  vtkBooleanMacro(DeletedCellsAsGhostArray,int);
433 
435 
444  vtkSetStringMacro(InputDeck);
445  vtkGetStringMacro(InputDeck);
447 
449 
457  int GetNumberOfPartArrays();
458  const char* GetPartArrayName(int);
459  virtual void SetPartArrayStatus( int arr, int status );
460  virtual void SetPartArrayStatus( const char* partName, int status );
461  int GetPartArrayStatus( int arr );
462  int GetPartArrayStatus( const char* partName );
464 
465 protected:
466  //holds all the parts and all the properties for each part
468 
472 
474 
479 
482  int TimeStepRange[2];
483 
485  char* InputDeck;
486 
487  vtkLSDynaReader();
488  virtual ~vtkLSDynaReader();
489 
496  int ReadHeaderInformation( int currentAdaptLevel );
497 
505  int ScanDatabaseTimeSteps();
506 
509 
511 
517  virtual int ReadTopology();
518  virtual int ReadNodes();
519  virtual int ReadPartSizes();
520  virtual int ReadConnectivityAndMaterial();
521  virtual int ReadUserIds();
522  virtual int ReadState( vtkIdType );
523  virtual int ReadNodeStateInfo( vtkIdType );
524  virtual int ReadCellStateInfo( vtkIdType );
525  virtual int ReadDeletion();
526  virtual int ReadSPHState( vtkIdType );
528 
530  virtual void ResetPartInfo();
531 
534  virtual int ReadInputDeck();
535 
538  virtual int ReadPartTitlesFromRootFile();
539 
543  virtual int ReadUserMaterialIds();
544 
546 
548  int ReadInputDeckXML( ifstream& deck );
549  int ReadInputDeckKeywords( ifstream& deck );
551 
554  int WriteInputDeckSummary( const char* fname );
555 
563  virtual void ReadDeletionArray(vtkUnsignedCharArray* arr, const int& pos, const int& size);
564 
566  virtual void ReadCellProperties(const int& type,const int& numTuples);
567 
568  LSDynaMetaData* P;
569 
570  void ResetPartsCache();
571 private:
572 
573  //Helper templated methods to optimze reading. We cast the entire buffer
574  //to a given type instead of casting each element to improve performance
575  template<typename T>
576  void FillDeletionArray(T* buffer, vtkUnsignedCharArray* arr, const vtkIdType& start, const vtkIdType& numCells,
577  const int& deathPos, const int& cellSize);
578 
579  template<int wordSize, typename T>
580  int FillTopology(T* buffer);
581 
582  template<typename T, int blockType, vtkIdType numWordsPerCell, vtkIdType cellLength>
583  void ReadBlockCellSizes();
584 
585  template<typename T>
586  int FillPartSizes();
587 
588  vtkLSDynaReader( const vtkLSDynaReader& ); // Not implemented.
589  void operator = ( const vtkLSDynaReader& ); // Not implemented.
590 };
591 
592 inline void vtkLSDynaReader::SetPointArrayStatus( const char* arrName, int status )
593 {
594  for ( int a=0; a<this->GetNumberOfPointArrays(); ++a )
595  {
596  if ( strcmp( arrName, this->GetPointArrayName(a) ) == 0 )
597  {
598  this->SetPointArrayStatus( a, status );
599  return;
600  }
601  }
602  vtkWarningMacro( "Point array \"" << arrName << "\" does not exist" );
603 }
604 
605 inline int vtkLSDynaReader::GetPointArrayStatus( const char* arrName )
606 {
607  for ( int a=0; a<this->GetNumberOfPointArrays(); ++a )
608  {
609  if ( strcmp( arrName, this->GetPointArrayName(a) ) == 0 )
610  {
611  return this->GetPointArrayStatus( a );
612  }
613  }
614  //vtkWarningMacro( "Point array \"" << arrName << "\" does not exist" );
615  return 0;
616 }
617 
618 inline int vtkLSDynaReader::GetNumberOfComponentsInPointArray( const char* arrName )
619 {
620  for ( int a=0; a<this->GetNumberOfPointArrays(); ++a )
621  {
622  if ( strcmp( arrName, this->GetPointArrayName( a ) ) == 0 )
623  {
624  return this->GetNumberOfComponentsInPointArray( a );
625  }
626  }
627  //vtkWarningMacro( "Point array \"" << arrName << "\" does not exist" );
628  return 0;
629 }
630 
631 inline void vtkLSDynaReader::SetCellArrayStatus( int cellType, const char* arrName, int status )
632 {
633  for ( int a=0; a<this->GetNumberOfCellArrays( cellType ); ++a )
634  {
635  if ( strcmp( arrName, this->GetCellArrayName( cellType, a ) ) == 0 )
636  {
637  this->SetCellArrayStatus( cellType, a, status );
638  return;
639  }
640  }
641  vtkWarningMacro( "Cell array \"" << arrName << "\" (type " << cellType << ") does not exist" );
642 }
643 
644 inline int vtkLSDynaReader::GetCellArrayStatus( int cellType, const char* arrName )
645 {
646  for ( int a=0; a<this->GetNumberOfCellArrays( cellType ); ++a )
647  {
648  if ( strcmp( arrName, this->GetCellArrayName( cellType, a ) ) == 0 )
649  {
650  return this->GetCellArrayStatus( cellType, a );
651  }
652  }
653  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
654  return 0;
655 }
656 
657 inline int vtkLSDynaReader::GetNumberOfComponentsInCellArray( int cellType, const char* arrName )
658 {
659  for ( int a=0; a<this->GetNumberOfCellArrays( cellType ); ++a )
660  {
661  if ( strcmp( arrName, this->GetCellArrayName( cellType, a ) ) == 0 )
662  {
663  return this->GetNumberOfComponentsInCellArray( cellType, a );
664  }
665  }
666  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
667  return 0;
668 }
669 
670 inline void vtkLSDynaReader::SetSolidArrayStatus( const char* arrName, int status )
671 {
672  for ( int a=0; a<this->GetNumberOfSolidArrays(); ++a )
673  {
674  if ( strcmp( arrName, this->GetSolidArrayName(a) ) == 0 )
675  {
676  this->SetSolidArrayStatus( a, status );
677  return;
678  }
679  }
680  vtkWarningMacro( "Solid array \"" << arrName << "\" does not exist" );
681 }
682 
683 inline int vtkLSDynaReader::GetSolidArrayStatus( const char* arrName )
684 {
685  for ( int a=0; a<this->GetNumberOfSolidArrays(); ++a )
686  {
687  if ( strcmp( arrName, this->GetSolidArrayName(a) ) == 0 )
688  {
689  return this->GetSolidArrayStatus( a );
690  }
691  }
692  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
693  return 0;
694 }
695 
696 inline int vtkLSDynaReader::GetNumberOfComponentsInSolidArray( const char* arrName )
697 {
698  for ( int a=0; a<this->GetNumberOfSolidArrays(); ++a )
699  {
700  if ( strcmp( arrName, this->GetSolidArrayName(a) ) == 0 )
701  {
702  return this->GetNumberOfComponentsInSolidArray( a );
703  }
704  }
705  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
706  return 0;
707 }
708 
709 inline void vtkLSDynaReader::SetThickShellArrayStatus( const char* arrName, int status )
710 {
711  for ( int a=0; a<this->GetNumberOfThickShellArrays(); ++a )
712  {
713  if ( strcmp( arrName, this->GetThickShellArrayName(a) ) == 0 )
714  {
715  this->SetThickShellArrayStatus( a, status );
716  return;
717  }
718  }
719  vtkWarningMacro( "Thick shell array \"" << arrName << "\" does not exist" );
720 }
721 
722 inline int vtkLSDynaReader::GetThickShellArrayStatus( const char* arrName )
723 {
724  for ( int a=0; a<this->GetNumberOfThickShellArrays(); ++a )
725  {
726  if ( strcmp( arrName, this->GetThickShellArrayName(a) ) == 0 )
727  {
728  return this->GetThickShellArrayStatus( a );
729  }
730  }
731  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
732  return 0;
733 }
734 
736 {
737  for ( int a=0; a<this->GetNumberOfThickShellArrays(); ++a )
738  {
739  if ( strcmp( arrName, this->GetThickShellArrayName(a) ) == 0 )
740  {
741  return this->GetNumberOfComponentsInThickShellArray( a );
742  }
743  }
744  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
745  return 0;
746 }
747 
748 inline void vtkLSDynaReader::SetShellArrayStatus( const char* arrName, int status )
749 {
750  for ( int a=0; a<this->GetNumberOfShellArrays(); ++a )
751  {
752  if ( strcmp( arrName, this->GetShellArrayName(a) ) == 0 )
753  {
754  this->SetShellArrayStatus( a, status );
755  return;
756  }
757  }
758  vtkWarningMacro( "Shell array \"" << arrName << "\" does not exist" );
759 }
760 
761 inline int vtkLSDynaReader::GetShellArrayStatus( const char* arrName )
762 {
763  for ( int a=0; a<this->GetNumberOfShellArrays(); ++a )
764  {
765  if ( strcmp( arrName, this->GetShellArrayName(a) ) == 0 )
766  {
767  return this->GetShellArrayStatus( a );
768  }
769  }
770  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
771  return 0;
772 }
773 
774 inline int vtkLSDynaReader::GetNumberOfComponentsInShellArray( const char* arrName )
775 {
776  for ( int a=0; a<this->GetNumberOfShellArrays(); ++a )
777  {
778  if ( strcmp( arrName, this->GetShellArrayName(a) ) == 0 )
779  {
780  return this->GetNumberOfComponentsInShellArray( a );
781  }
782  }
783  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
784  return 0;
785 }
786 
787 inline void vtkLSDynaReader::SetBeamArrayStatus( const char* arrName, int status )
788 {
789  for ( int a=0; a<this->GetNumberOfBeamArrays(); ++a )
790  {
791  if ( strcmp( arrName, this->GetBeamArrayName(a) ) == 0 )
792  {
793  this->SetBeamArrayStatus( a, status );
794  return;
795  }
796  }
797  vtkWarningMacro( "Beam array \"" << arrName << "\" does not exist" );
798 }
799 
800 inline int vtkLSDynaReader::GetBeamArrayStatus( const char* arrName )
801 {
802  for ( int a=0; a<this->GetNumberOfBeamArrays(); ++a )
803  {
804  if ( strcmp( arrName, this->GetBeamArrayName(a) ) == 0 )
805  {
806  return this->GetBeamArrayStatus( a );
807  }
808  }
809  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
810  return 0;
811 }
812 
813 inline int vtkLSDynaReader::GetNumberOfComponentsInBeamArray( const char* arrName )
814 {
815  for ( int a=0; a<this->GetNumberOfBeamArrays(); ++a )
816  {
817  if ( strcmp( arrName, this->GetBeamArrayName(a) ) == 0 )
818  {
819  return this->GetNumberOfComponentsInBeamArray( a );
820  }
821  }
822  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
823  return 0;
824 }
825 
826 inline void vtkLSDynaReader::SetParticleArrayStatus( const char* arrName, int status )
827 {
828  for ( int a=0; a<this->GetNumberOfParticleArrays(); ++a )
829  {
830  if ( strcmp( arrName, this->GetParticleArrayName(a) ) == 0 )
831  {
832  this->SetParticleArrayStatus( a, status );
833  return;
834  }
835  }
836  vtkWarningMacro( "Particle array \"" << arrName << "\" does not exist" );
837 }
838 
839 inline int vtkLSDynaReader::GetParticleArrayStatus( const char* arrName )
840 {
841  for ( int a=0; a<this->GetNumberOfParticleArrays(); ++a )
842  {
843  if ( strcmp( arrName, this->GetParticleArrayName(a) ) == 0 )
844  {
845  return this->GetParticleArrayStatus( a );
846  }
847  }
848  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
849  return 0;
850 }
851 
853 {
854  for ( int a=0; a<this->GetNumberOfParticleArrays(); ++a )
855  {
856  if ( strcmp( arrName, this->GetParticleArrayName(a) ) == 0 )
857  {
858  return this->GetNumberOfComponentsInParticleArray( a );
859  }
860  }
861  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
862  return 0;
863 }
864 
865 inline void vtkLSDynaReader::SetRigidBodyArrayStatus( const char* arrName, int status )
866 {
867  for ( int a=0; a<this->GetNumberOfRigidBodyArrays(); ++a )
868  {
869  if ( strcmp( arrName, this->GetRigidBodyArrayName(a) ) == 0 )
870  {
871  this->SetRigidBodyArrayStatus( a, status );
872  return;
873  }
874  }
875  vtkWarningMacro( "Rigid body array \"" << arrName << "\" does not exist" );
876 }
877 
878 inline int vtkLSDynaReader::GetRigidBodyArrayStatus( const char* arrName )
879 {
880  for ( int a=0; a<this->GetNumberOfRigidBodyArrays(); ++a )
881  {
882  if ( strcmp( arrName, this->GetRigidBodyArrayName(a) ) == 0 )
883  {
884  return this->GetRigidBodyArrayStatus( a );
885  }
886  }
887  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
888  return 0;
889 }
890 
892 {
893  for ( int a=0; a<this->GetNumberOfRigidBodyArrays(); ++a )
894  {
895  if ( strcmp( arrName, this->GetRigidBodyArrayName(a) ) == 0 )
896  {
897  return this->GetNumberOfComponentsInRigidBodyArray( a );
898  }
899  }
900  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
901  return 0;
902 }
903 
904 inline void vtkLSDynaReader::SetRoadSurfaceArrayStatus( const char* arrName, int status )
905 {
906  for ( int a=0; a<this->GetNumberOfRoadSurfaceArrays(); ++a )
907  {
908  if ( strcmp( arrName, this->GetRoadSurfaceArrayName(a) ) == 0 )
909  {
910  this->SetRoadSurfaceArrayStatus( a, status );
911  return;
912  }
913  }
914  vtkWarningMacro( "Road surface array \"" << arrName << "\" does not exist" );
915 }
916 
917 inline int vtkLSDynaReader::GetRoadSurfaceArrayStatus( const char* arrName )
918 {
919  for ( int a=0; a<this->GetNumberOfRoadSurfaceArrays(); ++a )
920  {
921  if ( strcmp( arrName, this->GetRoadSurfaceArrayName(a) ) == 0 )
922  {
923  return this->GetRoadSurfaceArrayStatus( a );
924  }
925  }
926  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
927  return 0;
928 }
929 
931 {
932  for ( int a=0; a<this->GetNumberOfRoadSurfaceArrays(); ++a )
933  {
934  if ( strcmp( arrName, this->GetRoadSurfaceArrayName(a) ) == 0 )
935  {
936  return this->GetNumberOfComponentsInRoadSurfaceArray( a );
937  }
938  }
939  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
940  return 0;
941 }
942 
943 inline void vtkLSDynaReader::SetPartArrayStatus( const char* arrName, int status )
944 {
945  for ( int a=0; a<this->GetNumberOfPartArrays(); ++a )
946  {
947  if ( strcmp( arrName, this->GetPartArrayName(a) ) == 0 )
948  {
949  this->SetPartArrayStatus( a, status );
950  return;
951  }
952  }
953  vtkWarningMacro( "Part \"" << arrName << "\" does not exist" );
954 }
955 
956 inline int vtkLSDynaReader::GetPartArrayStatus( const char* partName )
957 {
958  for ( int a=0; a<this->GetNumberOfPartArrays(); ++a )
959  {
960  if ( strcmp( partName, this->GetPartArrayName(a) ) == 0 )
961  {
962  return this->GetPartArrayStatus( a );
963  }
964  }
965  //vtkWarningMacro( "PartArray \"" << partName << "\" does not exist" );
966  return 0;
967 }
968 
969 #endif // __vtkLSDynaReader_h