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 
150 #ifndef __vtkLSDynaReader_h
151 #define __vtkLSDynaReader_h
152 
154 
155 class vtkLSDynaReaderPrivate;
156 class vtkPoints;
157 class vtkDataArray;
158 class vtkUnstructuredGrid;
159 
161 {
162 public:
164  virtual void PrintSelf(ostream &os, vtkIndent indent);
165  static vtkLSDynaReader *New();
166 
167  //BTX
175  enum {
176  PARTICLE = 0,
177  BEAM = 1,
178  SHELL = 2,
179  THICK_SHELL = 3,
180  SOLID = 4,
181  RIGID_BODY = 5,
182  ROAD_SURFACE = 6,
183  NUM_CELL_TYPES
184  };
185  //ETX
186 
189  void Dump( ostream &os );
190 
193  void DebugDump();
194 
196  int CanReadFile( const char* fname );
197 
199 
201  virtual void SetDatabaseDirectory( const char* );
202  const char* GetDatabaseDirectory();
203  int IsDatabaseValid();
205 
207 
211  virtual void SetFileName( const char* );
212  const char* GetFileName();
214 
219  char* GetTitle();
220 
224  int GetDimensionality();
225 
229  vtkIdType GetNumberOfNodes();
230 
235  vtkIdType GetNumberOfCells();
236 
243  vtkIdType GetNumberOfContinuumCells();
244 
248  vtkIdType GetNumberOfSolidCells();
249 
253  vtkIdType GetNumberOfThickShellCells();
254 
258  vtkIdType GetNumberOfShellCells();
259 
263  vtkIdType GetNumberOfRigidBodyCells();
264 
268  vtkIdType GetNumberOfRoadSurfaceCells();
269 
273  vtkIdType GetNumberOfBeamCells();
274 
278  vtkIdType GetNumberOfParticleCells();
279 
281 
284  vtkIdType GetNumberOfTimeSteps();
285  virtual void SetTimeStep( vtkIdType );
286  vtkIdType GetTimeStep();
287  double GetTimeValue( vtkIdType );
288  vtkGetVector2Macro(TimeStepRange,int);
289  vtkSetVector2Macro(TimeStepRange,int);
291 
293 
295  int GetNumberOfPointArrays();
296  const char* GetPointArrayName(int);
297  virtual void SetPointArrayStatus( int arr, int status );
298  virtual void SetPointArrayStatus( const char* arrName, int status );
299  int GetPointArrayStatus( int arr );
300  int GetPointArrayStatus( const char* arrName );
301  int GetNumberOfComponentsInPointArray( int arr );
302  int GetNumberOfComponentsInPointArray( const char* arrName );
304 
306 
310  int GetNumberOfCellArrays( int cellType );
311  const char* GetCellArrayName( int cellType, int arr );
312  virtual void SetCellArrayStatus( int cellType, int arr, int status );
313  virtual void SetCellArrayStatus( int cellType, const char* arrName, int status );
314  int GetCellArrayStatus( int cellType, int arr );
315  int GetCellArrayStatus( int cellType, const char* arrName );
316  int GetNumberOfComponentsInCellArray( int cellType, int arr );
317  int GetNumberOfComponentsInCellArray( int cellType, const char* arrName );
319 
321 
323  int GetNumberOfSolidArrays();
324  const char* GetSolidArrayName(int);
325  virtual void SetSolidArrayStatus( int arr, int status );
326  virtual void SetSolidArrayStatus( const char* arrName, int status );
327  int GetSolidArrayStatus( int arr );
328  int GetSolidArrayStatus( const char* arrName );
330 
331  int GetNumberOfComponentsInSolidArray( int a );
332  int GetNumberOfComponentsInSolidArray( const char* arrName );
333 
335 
337  int GetNumberOfThickShellArrays();
338  const char* GetThickShellArrayName(int);
339  virtual void SetThickShellArrayStatus( int arr, int status );
340  virtual void SetThickShellArrayStatus( const char* arrName, int status );
341  int GetThickShellArrayStatus( int arr );
342  int GetThickShellArrayStatus( const char* arrName );
344 
345  int GetNumberOfComponentsInThickShellArray( int a );
346  int GetNumberOfComponentsInThickShellArray( const char* arrName );
347 
349 
351  int GetNumberOfShellArrays();
352  const char* GetShellArrayName(int);
353  virtual void SetShellArrayStatus( int arr, int status );
354  virtual void SetShellArrayStatus( const char* arrName, int status );
355  int GetShellArrayStatus( int arr );
356  int GetShellArrayStatus( const char* arrName );
358 
359  int GetNumberOfComponentsInShellArray( int a );
360  int GetNumberOfComponentsInShellArray( const char* arrName );
361 
363 
365  int GetNumberOfRigidBodyArrays();
366  const char* GetRigidBodyArrayName(int);
367  virtual void SetRigidBodyArrayStatus( int arr, int status );
368  virtual void SetRigidBodyArrayStatus( const char* arrName, int status );
369  int GetRigidBodyArrayStatus( int arr );
370  int GetRigidBodyArrayStatus( const char* arrName );
372 
373  int GetNumberOfComponentsInRigidBodyArray( int a );
374  int GetNumberOfComponentsInRigidBodyArray( const char* arrName );
375 
377 
379  int GetNumberOfRoadSurfaceArrays();
380  const char* GetRoadSurfaceArrayName(int);
381  virtual void SetRoadSurfaceArrayStatus( int arr, int status );
382  virtual void SetRoadSurfaceArrayStatus( const char* arrName, int status );
383  int GetRoadSurfaceArrayStatus( int arr );
384  int GetRoadSurfaceArrayStatus( const char* arrName );
386 
387  int GetNumberOfComponentsInRoadSurfaceArray( int a );
388  int GetNumberOfComponentsInRoadSurfaceArray( const char* arrName );
389 
391 
393  int GetNumberOfBeamArrays();
394  const char* GetBeamArrayName(int);
395  virtual void SetBeamArrayStatus( int arr, int status );
396  virtual void SetBeamArrayStatus( const char* arrName, int status );
397  int GetBeamArrayStatus( int arr );
398  int GetBeamArrayStatus( const char* arrName );
400 
401  int GetNumberOfComponentsInBeamArray( int a );
402  int GetNumberOfComponentsInBeamArray( const char* arrName );
403 
405 
407  int GetNumberOfParticleArrays();
408  const char* GetParticleArrayName(int);
409  virtual void SetParticleArrayStatus( int arr, int status );
410  virtual void SetParticleArrayStatus( const char* arrName, int status );
411  int GetParticleArrayStatus( int arr );
412  int GetParticleArrayStatus( const char* arrName );
414 
415  int GetNumberOfComponentsInParticleArray( int a );
416  int GetNumberOfComponentsInParticleArray( const char* arrName );
417 
419 
422  vtkSetMacro(DeformedMesh,int);
423  vtkGetMacro(DeformedMesh,int);
424  vtkBooleanMacro(DeformedMesh,int);
426 
428 
436  vtkSetMacro(RemoveDeletedCells,int);
437  vtkGetMacro(RemoveDeletedCells,int);
438  vtkBooleanMacro(RemoveDeletedCells,int);
440 
442 
445  vtkSetMacro(SplitByMaterialId,int);
446  vtkGetMacro(SplitByMaterialId,int);
447  vtkBooleanMacro(SplitByMaterialId,int);
449 
451 
460  vtkSetStringMacro(InputDeck);
461  vtkGetStringMacro(InputDeck);
463 
465 
473  int GetNumberOfPartArrays();
474  const char* GetPartArrayName(int);
475  virtual void SetPartArrayStatus( int arr, int status );
476  virtual void SetPartArrayStatus( const char* partName, int status );
477  int GetPartArrayStatus( int arr );
478  int GetPartArrayStatus( const char* partName );
480 
481 protected:
482  // All the output grids (one for each possible combination of cell attributes)
483  vtkUnstructuredGrid* OutputParticles; // have radius of influence
484  vtkUnstructuredGrid* OutputBeams; // have TNB frame
485  vtkUnstructuredGrid* OutputShell; // integration points are different than 3D
486  vtkUnstructuredGrid* OutputThickShell; // integration points are different than planar 2D
487  vtkUnstructuredGrid* OutputSolid; // integration points are different than 2D
488  vtkUnstructuredGrid* OutputRigidBody; // can't have deflection, only velocity, accel, ...
489  vtkUnstructuredGrid* OutputRoadSurface; // can't have deflection, only velocity, accel, ...
490 
494 
498 
501 
504  int TimeStepRange[2];
505 
507  char* InputDeck;
508 
509  vtkLSDynaReader();
510  virtual ~vtkLSDynaReader();
511 
518  int ReadHeaderInformation( int currentAdaptLevel );
519 
527  int ScanDatabaseTimeSteps();
528 
531 
533 
539  virtual int ReadNodes();
540  virtual int ReadConnectivityAndMaterial();
541  virtual int ReadUserIds();
542  virtual int ReadState( vtkIdType );
543  virtual int ReadDeletion();
544  virtual int ReadSPHState( vtkIdType );
546 
549  virtual int ReadInputDeck();
550 
554  virtual int ReadUserMaterialIds();
555 
557 
559  int ReadInputDeckXML( ifstream& deck );
560  int ReadInputDeckKeywords( ifstream& deck );
562 
565  int WriteInputDeckSummary( const char* fname );
566 
567  void PartFilter( vtkMultiBlockDataSet* mbds, int celltype );
575  virtual int ReadDeletionArray( vtkDataArray* arr, int& anyDeleted );
576 
577 private:
578  vtkLSDynaReader( const vtkLSDynaReader& ); // Not implemented.
579  void operator = ( const vtkLSDynaReader& ); // Not implemented.
580 
581  vtkLSDynaReaderPrivate* P;
582 };
583 
584 inline void vtkLSDynaReader::SetPointArrayStatus( const char* arrName, int status )
585 {
586  for ( int a=0; a<this->GetNumberOfPointArrays(); ++a )
587  {
588  if ( strcmp( arrName, this->GetPointArrayName(a) ) == 0 )
589  {
590  this->SetPointArrayStatus( a, status );
591  return;
592  }
593  }
594  vtkWarningMacro( "Point array \"" << arrName << "\" does not exist" );
595 }
596 
597 inline int vtkLSDynaReader::GetPointArrayStatus( const char* arrName )
598 {
599  for ( int a=0; a<this->GetNumberOfPointArrays(); ++a )
600  {
601  if ( strcmp( arrName, this->GetPointArrayName(a) ) == 0 )
602  {
603  return this->GetPointArrayStatus( a );
604  }
605  }
606  //vtkWarningMacro( "Point array \"" << arrName << "\" does not exist" );
607  return 0;
608 }
609 
610 inline int vtkLSDynaReader::GetNumberOfComponentsInPointArray( const char* arrName )
611 {
612  for ( int a=0; a<this->GetNumberOfPointArrays(); ++a )
613  {
614  if ( strcmp( arrName, this->GetPointArrayName( a ) ) == 0 )
615  {
616  return this->GetNumberOfComponentsInPointArray( a );
617  }
618  }
619  //vtkWarningMacro( "Point array \"" << arrName << "\" does not exist" );
620  return 0;
621 }
622 
623 inline void vtkLSDynaReader::SetCellArrayStatus( int cellType, const char* arrName, int status )
624 {
625  for ( int a=0; a<this->GetNumberOfCellArrays( cellType ); ++a )
626  {
627  if ( strcmp( arrName, this->GetCellArrayName( cellType, a ) ) == 0 )
628  {
629  this->SetCellArrayStatus( cellType, a, status );
630  return;
631  }
632  }
633  vtkWarningMacro( "Cell array \"" << arrName << "\" (type " << cellType << ") does not exist" );
634 }
635 
636 inline int vtkLSDynaReader::GetCellArrayStatus( int cellType, const char* arrName )
637 {
638  for ( int a=0; a<this->GetNumberOfCellArrays( cellType ); ++a )
639  {
640  if ( strcmp( arrName, this->GetCellArrayName( cellType, a ) ) == 0 )
641  {
642  return this->GetCellArrayStatus( cellType, a );
643  }
644  }
645  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
646  return 0;
647 }
648 
649 inline int vtkLSDynaReader::GetNumberOfComponentsInCellArray( int cellType, const char* arrName )
650 {
651  for ( int a=0; a<this->GetNumberOfCellArrays( cellType ); ++a )
652  {
653  if ( strcmp( arrName, this->GetCellArrayName( cellType, a ) ) == 0 )
654  {
655  return this->GetNumberOfComponentsInCellArray( cellType, a );
656  }
657  }
658  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
659  return 0;
660 }
661 
662 inline void vtkLSDynaReader::SetSolidArrayStatus( const char* arrName, int status )
663 {
664  for ( int a=0; a<this->GetNumberOfSolidArrays(); ++a )
665  {
666  if ( strcmp( arrName, this->GetSolidArrayName(a) ) == 0 )
667  {
668  this->SetSolidArrayStatus( a, status );
669  return;
670  }
671  }
672  vtkWarningMacro( "Solid array \"" << arrName << "\" does not exist" );
673 }
674 
675 inline int vtkLSDynaReader::GetSolidArrayStatus( const char* arrName )
676 {
677  for ( int a=0; a<this->GetNumberOfSolidArrays(); ++a )
678  {
679  if ( strcmp( arrName, this->GetSolidArrayName(a) ) == 0 )
680  {
681  return this->GetSolidArrayStatus( a );
682  }
683  }
684  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
685  return 0;
686 }
687 
688 inline int vtkLSDynaReader::GetNumberOfComponentsInSolidArray( const char* arrName )
689 {
690  for ( int a=0; a<this->GetNumberOfSolidArrays(); ++a )
691  {
692  if ( strcmp( arrName, this->GetSolidArrayName(a) ) == 0 )
693  {
694  return this->GetNumberOfComponentsInSolidArray( a );
695  }
696  }
697  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
698  return 0;
699 }
700 
701 inline void vtkLSDynaReader::SetThickShellArrayStatus( const char* arrName, int status )
702 {
703  for ( int a=0; a<this->GetNumberOfThickShellArrays(); ++a )
704  {
705  if ( strcmp( arrName, this->GetThickShellArrayName(a) ) == 0 )
706  {
707  this->SetThickShellArrayStatus( a, status );
708  return;
709  }
710  }
711  vtkWarningMacro( "Thick shell array \"" << arrName << "\" does not exist" );
712 }
713 
714 inline int vtkLSDynaReader::GetThickShellArrayStatus( const char* arrName )
715 {
716  for ( int a=0; a<this->GetNumberOfThickShellArrays(); ++a )
717  {
718  if ( strcmp( arrName, this->GetThickShellArrayName(a) ) == 0 )
719  {
720  return this->GetThickShellArrayStatus( a );
721  }
722  }
723  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
724  return 0;
725 }
726 
728 {
729  for ( int a=0; a<this->GetNumberOfThickShellArrays(); ++a )
730  {
731  if ( strcmp( arrName, this->GetThickShellArrayName(a) ) == 0 )
732  {
733  return this->GetNumberOfComponentsInThickShellArray( a );
734  }
735  }
736  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
737  return 0;
738 }
739 
740 inline void vtkLSDynaReader::SetShellArrayStatus( const char* arrName, int status )
741 {
742  for ( int a=0; a<this->GetNumberOfShellArrays(); ++a )
743  {
744  if ( strcmp( arrName, this->GetShellArrayName(a) ) == 0 )
745  {
746  this->SetShellArrayStatus( a, status );
747  return;
748  }
749  }
750  vtkWarningMacro( "Shell array \"" << arrName << "\" does not exist" );
751 }
752 
753 inline int vtkLSDynaReader::GetShellArrayStatus( const char* arrName )
754 {
755  for ( int a=0; a<this->GetNumberOfShellArrays(); ++a )
756  {
757  if ( strcmp( arrName, this->GetShellArrayName(a) ) == 0 )
758  {
759  return this->GetShellArrayStatus( a );
760  }
761  }
762  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
763  return 0;
764 }
765 
766 inline int vtkLSDynaReader::GetNumberOfComponentsInShellArray( const char* arrName )
767 {
768  for ( int a=0; a<this->GetNumberOfShellArrays(); ++a )
769  {
770  if ( strcmp( arrName, this->GetShellArrayName(a) ) == 0 )
771  {
772  return this->GetNumberOfComponentsInShellArray( a );
773  }
774  }
775  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
776  return 0;
777 }
778 
779 inline void vtkLSDynaReader::SetBeamArrayStatus( const char* arrName, int status )
780 {
781  for ( int a=0; a<this->GetNumberOfBeamArrays(); ++a )
782  {
783  if ( strcmp( arrName, this->GetBeamArrayName(a) ) == 0 )
784  {
785  this->SetBeamArrayStatus( a, status );
786  return;
787  }
788  }
789  vtkWarningMacro( "Beam array \"" << arrName << "\" does not exist" );
790 }
791 
792 inline int vtkLSDynaReader::GetBeamArrayStatus( const char* arrName )
793 {
794  for ( int a=0; a<this->GetNumberOfBeamArrays(); ++a )
795  {
796  if ( strcmp( arrName, this->GetBeamArrayName(a) ) == 0 )
797  {
798  return this->GetBeamArrayStatus( a );
799  }
800  }
801  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
802  return 0;
803 }
804 
805 inline int vtkLSDynaReader::GetNumberOfComponentsInBeamArray( const char* arrName )
806 {
807  for ( int a=0; a<this->GetNumberOfBeamArrays(); ++a )
808  {
809  if ( strcmp( arrName, this->GetBeamArrayName(a) ) == 0 )
810  {
811  return this->GetNumberOfComponentsInBeamArray( a );
812  }
813  }
814  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
815  return 0;
816 }
817 
818 inline void vtkLSDynaReader::SetParticleArrayStatus( const char* arrName, int status )
819 {
820  for ( int a=0; a<this->GetNumberOfParticleArrays(); ++a )
821  {
822  if ( strcmp( arrName, this->GetParticleArrayName(a) ) == 0 )
823  {
824  this->SetParticleArrayStatus( a, status );
825  return;
826  }
827  }
828  vtkWarningMacro( "Particle array \"" << arrName << "\" does not exist" );
829 }
830 
831 inline int vtkLSDynaReader::GetParticleArrayStatus( const char* arrName )
832 {
833  for ( int a=0; a<this->GetNumberOfParticleArrays(); ++a )
834  {
835  if ( strcmp( arrName, this->GetParticleArrayName(a) ) == 0 )
836  {
837  return this->GetParticleArrayStatus( a );
838  }
839  }
840  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
841  return 0;
842 }
843 
845 {
846  for ( int a=0; a<this->GetNumberOfParticleArrays(); ++a )
847  {
848  if ( strcmp( arrName, this->GetParticleArrayName(a) ) == 0 )
849  {
850  return this->GetNumberOfComponentsInParticleArray( a );
851  }
852  }
853  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
854  return 0;
855 }
856 
857 inline void vtkLSDynaReader::SetRigidBodyArrayStatus( const char* arrName, int status )
858 {
859  for ( int a=0; a<this->GetNumberOfRigidBodyArrays(); ++a )
860  {
861  if ( strcmp( arrName, this->GetRigidBodyArrayName(a) ) == 0 )
862  {
863  this->SetRigidBodyArrayStatus( a, status );
864  return;
865  }
866  }
867  vtkWarningMacro( "Rigid body array \"" << arrName << "\" does not exist" );
868 }
869 
870 inline int vtkLSDynaReader::GetRigidBodyArrayStatus( const char* arrName )
871 {
872  for ( int a=0; a<this->GetNumberOfRigidBodyArrays(); ++a )
873  {
874  if ( strcmp( arrName, this->GetRigidBodyArrayName(a) ) == 0 )
875  {
876  return this->GetRigidBodyArrayStatus( a );
877  }
878  }
879  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
880  return 0;
881 }
882 
884 {
885  for ( int a=0; a<this->GetNumberOfRigidBodyArrays(); ++a )
886  {
887  if ( strcmp( arrName, this->GetRigidBodyArrayName(a) ) == 0 )
888  {
889  return this->GetNumberOfComponentsInRigidBodyArray( a );
890  }
891  }
892  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
893  return 0;
894 }
895 
896 inline void vtkLSDynaReader::SetRoadSurfaceArrayStatus( const char* arrName, int status )
897 {
898  for ( int a=0; a<this->GetNumberOfRoadSurfaceArrays(); ++a )
899  {
900  if ( strcmp( arrName, this->GetRoadSurfaceArrayName(a) ) == 0 )
901  {
902  this->SetRoadSurfaceArrayStatus( a, status );
903  return;
904  }
905  }
906  vtkWarningMacro( "Road surface array \"" << arrName << "\" does not exist" );
907 }
908 
909 inline int vtkLSDynaReader::GetRoadSurfaceArrayStatus( const char* arrName )
910 {
911  for ( int a=0; a<this->GetNumberOfRoadSurfaceArrays(); ++a )
912  {
913  if ( strcmp( arrName, this->GetRoadSurfaceArrayName(a) ) == 0 )
914  {
915  return this->GetRoadSurfaceArrayStatus( a );
916  }
917  }
918  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
919  return 0;
920 }
921 
923 {
924  for ( int a=0; a<this->GetNumberOfRoadSurfaceArrays(); ++a )
925  {
926  if ( strcmp( arrName, this->GetRoadSurfaceArrayName(a) ) == 0 )
927  {
928  return this->GetNumberOfComponentsInRoadSurfaceArray( a );
929  }
930  }
931  //vtkWarningMacro( "Cell array \"" << arrName << "\" does not exist" );
932  return 0;
933 }
934 
935 inline void vtkLSDynaReader::SetPartArrayStatus( const char* arrName, int status )
936 {
937  for ( int a=0; a<this->GetNumberOfPartArrays(); ++a )
938  {
939  if ( strcmp( arrName, this->GetPartArrayName(a) ) == 0 )
940  {
941  this->SetPartArrayStatus( a, status );
942  return;
943  }
944  }
945  vtkWarningMacro( "Part \"" << arrName << "\" does not exist" );
946 }
947 
948 inline int vtkLSDynaReader::GetPartArrayStatus( const char* partName )
949 {
950  for ( int a=0; a<this->GetNumberOfPartArrays(); ++a )
951  {
952  if ( strcmp( partName, this->GetPartArrayName(a) ) == 0 )
953  {
954  return this->GetPartArrayStatus( a );
955  }
956  }
957  //vtkWarningMacro( "PartArray \"" << partName << "\" does not exist" );
958  return 0;
959 }
960 
961 #endif // __vtkLSDynaReader_h