LifeV
Exporter.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5 Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6 Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8 This file is part of LifeV.
9 
10 LifeV is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14 
15 LifeV is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 /*!
27  @file
28  @brief exporter and ExporterData classes provide interfaces for post-processing
29 
30  @date 11-11-2008
31  @author Simone Deparis <simone.deparis.epfl.ch>
32 
33  @maintainer Radu Popescu <radu.popescu@epfl.ch>
34  @contributor Tiziano Passerini <tiziano@mathcs.emory.edu>
35 
36  Usage: two steps
37  <ol>
38  <li> first: add the variables using addVariable
39  <li> second: call postProcess( time );
40  </ol>
41 */
42 
43 #ifndef EXPORTER_H
44 #define EXPORTER_H 1
45 
46 #include <fstream>
47 #include <sstream>
48 
49 #include <lifev/core/LifeV.hpp>
50 
51 #include <lifev/core/array/VectorEpetra.hpp>
52 #include <lifev/core/filter/GetPot.hpp>
53 #include <lifev/core/util/LifeChrono.hpp>
54 #include <lifev/core/fem/FESpace.hpp>
55 #include <lifev/core/mesh/MarkerDefinitions.hpp>
56 
57 namespace LifeV
58 {
59 
60 //! ExporterData - Holds the data structure of the array to import/export
61 /*!
62  @author Simone Deparis <simone.deparis@epfl.ch>
63  @date 11-11-2008
64 
65  This class holds the data structure of one datum
66  to help the importer/exporter
67  e.g. variable name, shared pointer to data, size, and few others.
68  */
69 template< typename MeshType >
70 class ExporterData
71 {
72 public:
73 
74  //! @name Public Types
75  //@{
76 
77  typedef MeshType mesh_Type;
78  typedef VectorEpetra vector_Type;
79  typedef std::shared_ptr<vector_Type> vectorPtr_Type;
80  typedef FESpace< mesh_Type, MapEpetra > feSpace_Type;
81  typedef std::shared_ptr<feSpace_Type> feSpacePtr_Type;
82 
83  //! FieldTypeEnum of data stored.
84  enum FieldTypeEnum
85  {
86  ScalarField, /*!< ScalarField stands for scalar field */
87  VectorField /*!< VectorField stands for vector field */
88  };
89 
90  //! Where is data centered? /
91  enum WhereEnum
92  {
93  Node, /*!< Node centered */
94  Cell /*!< Cell centered */
95  };
96 
97  //! Time regime of the field /
98  enum FieldRegimeEnum
99  {
100  UnsteadyRegime, /*!< The field is in unsteady regime */
101  SteadyRegime, /*!< The field is in steady regime */
102  NullRegime /*!< DEPRECATED */
103  };
104 
105  //@}
106 
107  //! @name Constructor & Destructor
108  //@{
109 
110  //! Constructor with all the data to be stored
111  /*!
112  Constructor with all the data to be stored
113  @param fieldType - scalar or vector field
114  @param variableName - name assigned to this variable in output file
115  @param feSpacePtr - shared pointer to variable FESpace
116  @param vectorPtr - shared pointer to variable array
117  @param start - address of first datum in the array to be stored.
118  Useful in case you want to define a subrange of the vector *vec
119  @param regime - if UnsteadyRegime, then the file name for postprocessing has to include time dependency
120  @param where - where is variable located (Node or Cell)
121  */
122  ExporterData (const FieldTypeEnum& fieldType,
123  const std::string& variableName,
124  const feSpacePtr_Type& feSpacePtr,
125  const vectorPtr_Type& vectorPtr,
126  const UInt& start,
127  const FieldRegimeEnum& regime,
128  const WhereEnum& where = Node);
129 
130  //@}
131 
132  //! @name Operators
133  //@{
134 
135  //! Accessor to component (const)
136  /*!
137  @param i which component to access
138  */
139  Real operator() (const UInt i) const;
140 
141  //! Accessor to component (reference)
142  /*!
143  @param i which component to access
144  */
145  Real& operator() (const UInt i);
146 
147  //@}
148 
149  //! @name Set Methods
150  //@{
151 
152  //! set the time regime of the field
153  void setRegime (FieldRegimeEnum regime)
154  {
155  M_regime = regime;
156  }
157 
158  //! set where is the variable located (Node or Cell)
159  void setWhere ( WhereEnum where )
160  {
161  M_where = where;
162  }
163  //@}
164 
165 
166  //! @name Get Methods
167  //@{
168 
169  //! name assigned to this variable in output file
170  const std::string& variableName() const
171  {
172  return M_variableName;
173  }
174 
175  //! number of (scalar) DOFs of the variable
176 
177  const UInt& numDOF() const
178  {
179  return M_numDOF;
180  }
181 
182  //! address of first datum in the array
183  const UInt& start() const
184  {
185  return M_start;
186  }
187 
188  //! scalar or vector field
189  const FieldTypeEnum& fieldType() const
190  {
191  return M_fieldType;
192  }
193 
194  //! shared pointer to array
195  const vectorPtr_Type storedArrayPtr() const
196  {
197  return M_storedArrayPtr;
198  }
199 
200  //! returns UnsteadyRegime (=0) if file name for postprocessing has to include time dependency
201  FieldRegimeEnum regime() const
202  {
203  return M_regime;
204  }
205 
206  //! returns Scalar or Vector strings
207  std::string typeName() const;
208 
209  //! returns 1 (if Scalar) or 3 (if Vector)
210  UInt fieldDim() const;
211 
212  //! Node or Cell centered ?
213  const WhereEnum& where() const
214  {
215  return M_where;
216  }
217 
218  //! returns Node or Cell centered string
219  std::string whereName() const;
220 
221  const feSpacePtr_Type& feSpacePtr() const
222  {
223  return M_feSpacePtr;
224  };
225  //@}
226 
227 private:
228  //! @name Private data members
229  //@{
230  //! name assigned to this variable in output file
231  std::string M_variableName;
232 
233  //! pointer to the FESpace of the variable
234  feSpacePtr_Type M_feSpacePtr;
235 
236  //! pointer to storedArray
237  vectorPtr_Type M_storedArrayPtr;
238 
239  //! number of (scalar) DOFs of the variable
240  UInt M_numDOF;
241 
242  //! address of first datum in the array
243  UInt M_start;
244 
245  //! scalar or vector field
246  FieldTypeEnum M_fieldType;
247 
248  //! equal to UnsteadyRegime if file name for postprocessing has to include time dependency
249  FieldRegimeEnum M_regime;
250 
251  //! Node or Cell centered
252  WhereEnum M_where;
253  //@}
254 };
255 
256 
257 //! Exporter - Pure virtual class that describes a generic exporter
258 /*!
259  @author Simone Deparis <simone.deparis@epfl.ch>
260  @date 11-11-2008
261 
262  This class is pure virtual and describes a generic exporter that can
263  also do import
264  */
265 template<typename MeshType>
266 class Exporter
267 {
268 
269 public:
270  //! @name Public typedefs
271  //@{
272  typedef MeshType mesh_Type;
273  typedef std::shared_ptr<MeshType> meshPtr_Type;
274  typedef Epetra_Comm comm_Type;
275  typedef std::shared_ptr<comm_Type> commPtr_Type;
276  typedef ExporterData<mesh_Type> exporterData_Type;
277  typedef typename exporterData_Type::vector_Type vector_Type;
278  typedef typename exporterData_Type::vectorPtr_Type vectorPtr_Type;
279  typedef typename exporterData_Type::feSpace_Type feSpace_Type;
280  typedef typename exporterData_Type::feSpacePtr_Type feSpacePtr_Type;
281  typedef typename exporterData_Type::WhereEnum WhereEnum;
282  typedef typename exporterData_Type::FieldTypeEnum FieldTypeEnum;
283  typedef typename exporterData_Type::FieldRegimeEnum FieldRegimeEnum;
284  typedef typename std::vector<exporterData_Type > dataVector_Type;
285  typedef typename dataVector_Type::iterator dataVectorIterator_Type;
286  typedef typename std::multimap<WhereEnum, UInt > whereToDataIdMap_Type;
287  typedef typename std::multimap<FE_TYPE, UInt > feTypeToDataIdMap_Type;
288  //@}
289 
290  //! @name Constructor & Destructor
291  //@{
292 
293  //! Empty constructor for Exporter
294  Exporter();
295 
296  //! Constructor for Exporter without prefix and procID
297  /*!
298  In this case prefix and procID should be set separately
299  @param dfile the GetPot data file where you must provide an [exporter] section with:
300  "start" (start index for filenames 0 for 000, 1 for 001 etc.),
301  "save" (how many time steps between snapshots)
302  "multimesh" ( = true if the mesh has to be saved at each post-processing step)
303  @param the prefix for the case file (ex. "test" for test.case)
304  */
305  Exporter (const GetPot& dfile, const std::string& prefix);
306 
307  //! Destructor
308  virtual ~Exporter() {};
309  //@}
310 
311 
312  //! @name Methods
313  //@{
314 
315  //! Adds a new variable to be post-processed
316  /*!
317  @param type the type of the variable exporterData_Type::FieldTypeEnum
318  @param variableName the name of the variable (to be used in file prefix)
319  @param feSpacePtr a pointer to the FESpace of the variable
320  @param vectorPtr a pointer to the vector containing the values of the variable
321  @param start location in the vector where the storing of the variable starts
322  @param regime if UnsteadyRegime the filename should change at each time step
323  @param where choose whether the variable is defined on Nodes of Elements
324  */
325  void addVariable (const FieldTypeEnum& type,
326  const std::string& variableName,
327  const feSpacePtr_Type& feSpacePtr,
328  const vectorPtr_Type& vectorPtr,
329  const UInt& start,
330  const FieldRegimeEnum& regime = exporterData_Type::UnsteadyRegime,
331  const WhereEnum& where = exporterData_Type::Node );
332 
333  //! Post-process the variables added to the list
334  /*!
335  @param time the solver time
336  */
337  virtual void postProcess (const Real& time) = 0;
338 
339  //! Import data from previous simulations at a certain time
340  /*!
341  @param Time the time of the data to be imported
342  */
343  virtual UInt importFromTime ( const Real& Time ) = 0;
344 
345  //! Import data from previous simulations
346  /*!
347  @param time the solver time
348  @param dt time step used to rebuild the history up to now
349  */
350  virtual void import (const Real& startTime, const Real& dt) = 0;
351 
352  //! Read only last timestep
353  virtual void import (const Real& startTime) = 0;
354 
355  virtual void readVariable (exporterData_Type& dvar);
356 
357  //! Export the Processor ID as P0 variable
358  virtual void exportPID ( meshPtr_Type& mesh, commPtr_Type& comm, const bool binaryFormat = false );
359 
360  //! Export the region marker ID as P0 variable
361  void exportRegionMarkerID ( std::shared_ptr<MeshType> mesh, std::shared_ptr<Epetra_Comm> comm );
362 
363  //! Export entity flags
364  virtual void exportFlags ( std::shared_ptr<MeshType> mesh, std::shared_ptr<Epetra_Comm> comm, flag_Type const& flag = EntityFlags::ALL );
365 
366  //@}
367 
368  //! @name Set Methods
369  //@{
370 
371  //! Set data from file.
372  /*!
373  * @param dataFile data file.
374  * @param section section in the data file.
375  */
376  virtual void setDataFromGetPot ( const GetPot& dataFile, const std::string& section = "exporter" );
377 
378  //! Set prefix.
379  /*!
380  * @param prefix prefix.
381  */
382  void setPrefix ( const std::string& prefix )
383  {
384  M_prefix = prefix;
385  }
386 
387  //! Set the folder for pre/postprocessing
388  /*!
389  * @param Directory output folder
390  */
391  void setPostDir ( const std::string& Directory )
392  {
393  M_postDir = Directory;
394  }
395 
396  //! Set the current time index
397  /*!
398  * @param timeIndex index of the current time frame
399  */
400  void setTimeIndex ( const UInt& timeIndex )
401  {
402  M_timeIndex = timeIndex;
403  }
404 
405  //! Set the time index of the first file
406  /*!
407  * @param timeIndexStart index of the first time frame
408  */
409  void setTimeIndexStart ( const UInt& timeIndexStart )
410  {
411  M_timeIndexStart = timeIndexStart;
412  }
413 
414  //! Set how many time step between two snapshots
415  /*!
416  * @param save steps
417  */
418  void setSave ( const UInt& save )
419  {
420  M_save = save;
421  }
422 
423  //! Set if to save the mesh at each time step.
424  /*!
425  * @param multimesh multimesh
426  */
427  void setMultimesh ( const bool& multimesh )
428  {
429  M_multimesh = multimesh;
430  }
431 
432  virtual void setMeshProcId ( const meshPtr_Type mesh, const int& procId );
433 
434  //! Close the output file
435  /*!
436  This method is only used by some of the exporter which derive from this class.
437  */
438  virtual void closeFile() {}
439  //@}
440 
441  //! @name Get Methods
442  //@{
443  //! returns how many time steps between two snapshots
444  const UInt& save() const
445  {
446  return M_save;
447  }
448 
449  //! returns the time index of the first snapshot
450  const UInt& timeIndexStart() const
451  {
452  return M_timeIndexStart;
453  }
454 
455  //! returns the time index of the current snapshot
456  const UInt& timeIndex() const
457  {
458  return M_timeIndex;
459  }
460 
461  //! returns the type of the map to use for the VectorEpetra
462  virtual MapEpetraType mapType() const = 0;
463  //@}
464 
465 protected:
466 
467  //! @name Protected methods
468  //@{
469  //! compute postfix
470  void computePostfix();
471 
472  //! A method to read a scalar field (to be implemented in derived classes)
473  /*!
474  @param dvar the ExporterData object
475  */
476  virtual void readScalar ( exporterData_Type& dvar ) = 0;
477  //! A method to read a vector field (to be implemented in derived classes)
478  /*!
479  @param dvar the ExporterData object
480  */
481  virtual void readVector ( exporterData_Type& dvar ) = 0;
482 
483  //@}
484 
485  //! @name Protected data members
486  //@{
487  //! the file prefix
488  std::string M_prefix;
489  //! the name of the folder where to read or write files
490  std::string M_postDir;
491  //! the time index of the first snapshot
492  UInt M_timeIndexStart;
493  //! the time index of the current snapshot
494  UInt M_timeIndex;
495  //! how many time steps between subsequent snapshots
496  UInt M_save;
497  //! do we want to save the mesh with each snapshot?
498  bool M_multimesh;
499  //! how many digits (in the file suffix) for the time index
500  UInt M_timeIndexWidth;
501  //! a pointer to the mesh
502  meshPtr_Type M_mesh;
503  //! the ID of the process
504  Int M_procId;
505  //! the file suffix
506  std::string M_postfix;
507  //! how many processes produced the data that we want to import
508  UInt M_numImportProc;
509  //! a map to retrieve all data located in the same geo entities (node or element)
510  whereToDataIdMap_Type M_whereToDataIdMap;
511  //! a map to retrieve all data defined in the same FE space
512  feTypeToDataIdMap_Type M_feTypeToDataIdMap;
513  //! the vector of ExporterData objects
514  dataVector_Type M_dataVector;
515  //! the list of time steps (for use in import procedures)
516  std::list<Real> M_timeSteps;
517  //@}
518 };
519 
520 // ==================================================
521 // EXPORTERDATA: IMPLEMENTATION
522 // ==================================================
523 
524 // =================
525 // Constructor
526 // =================
527 
528 template< typename MeshType >
529 ExporterData<MeshType>::ExporterData ( const FieldTypeEnum& type,
530  const std::string& variableName,
531  const feSpacePtr_Type& feSpacePtr,
532  const vectorPtr_Type& vectorPtr,
533  const UInt& start,
534  const FieldRegimeEnum& regime,
535  const WhereEnum& where ) :
536  M_variableName ( variableName ),
537  M_feSpacePtr ( feSpacePtr ),
538  M_storedArrayPtr ( vectorPtr ),
539  M_numDOF ( feSpacePtr->dim() ),
540  M_start ( start ),
541  M_fieldType ( type ),
542  M_regime ( regime ),
543  M_where ( where )
544 {}
545 
546 // ==============
547 // Operators
548 // ==============
549 
550 template< typename MeshType >
551 Real ExporterData<MeshType>::operator() ( const UInt i ) const
552 {
553  return (*M_storedArrayPtr) [i];
554 }
555 
556 template< typename MeshType >
557 Real& ExporterData<MeshType>::operator() ( const UInt i )
558 {
559  return (*M_storedArrayPtr) [i];
560 }
561 
562 template< typename MeshType >
563 std::string ExporterData<MeshType>::typeName() const
564 {
565  switch (M_fieldType)
566  {
567  case ScalarField:
568  return "Scalar";
569  case VectorField:
570  return "Vector";
571  }
572 
573  ERROR_MSG ( "Unknown field type" );
574  return std::string();
575 }
576 
577 template< typename MeshType >
578 UInt ExporterData<MeshType>::fieldDim() const
579 {
580  return M_feSpacePtr->fieldDim();
581 }
582 
583 template< typename MeshType >
584 std::string ExporterData<MeshType>::whereName() const
585 {
586  switch (M_where)
587  {
588  case Node:
589  return "Node";
590  case Cell:
591  return "Cell";
592  }
593 
594  ERROR_MSG ( "Unknown location of data" );
595  return std::string();
596 }
597 
598 // ==================================================
599 // EXPORTER: IMPLEMENTATION
600 // ==================================================
601 
602 // ===================================================
603 // Constructors
604 // ===================================================
605 template<typename MeshType>
606 Exporter<MeshType>::Exporter() :
607  M_prefix ( "output"),
608  M_postDir ( "./" ),
609  M_timeIndexStart ( 0 ),
610  M_timeIndex ( M_timeIndexStart ),
611  M_save ( 1 ),
612  M_multimesh ( true ),
613  M_timeIndexWidth ( 5 ),
614  M_numImportProc ( 0 )
615 {}
616 
617 template<typename MeshType>
618 Exporter<MeshType>::Exporter ( const GetPot& dfile, const std::string& prefix ) :
619  M_prefix ( prefix )
620 {
621  setDataFromGetPot (dfile);
622 }
623 
624 // ===================================================
625 // Methods
626 // ===================================================
627 template<typename MeshType>
628 void Exporter<MeshType>::addVariable (const FieldTypeEnum& type,
629  const std::string& variableName,
630  const feSpacePtr_Type& feSpacePtr,
631  const vectorPtr_Type& vectorPtr,
632  const UInt& start,
633  const FieldRegimeEnum& regime,
634  const WhereEnum& where )
635 {
636  M_dataVector.push_back ( exporterData_Type (type, variableName, feSpacePtr, vectorPtr, start, regime, where) );
637  M_whereToDataIdMap.insert ( std::pair<WhereEnum, UInt > (where, M_dataVector.size() - 1 ) );
638  M_feTypeToDataIdMap.insert ( std::pair<FE_TYPE, UInt > (feSpacePtr->fe().refFE().type(), M_dataVector.size() - 1 ) );
639 }
640 
641 template <typename MeshType>
642 void Exporter<MeshType>::readVariable (exporterData_Type& dvar)
643 {
644  switch ( dvar.fieldType() )
645  {
646  case exporterData_Type::ScalarField:
647  readScalar (dvar);
648  break;
649  case exporterData_Type::VectorField:
650  readVector (dvar);
651  break;
652  }
653 }
654 
655 template <typename MeshType>
656 void Exporter<MeshType>::exportFlags ( std::shared_ptr<MeshType> mesh, std::shared_ptr<Epetra_Comm> comm, flag_Type const& compareFlag )
657 {
658  // @todo this is only for point flags, extension to other entity flags is trivial
659 
660  // @todo switch loops for efficiency!
661 
662  // @todo use FESpace M_spacemap for generality
663  const ReferenceFE& refFE = feTetraP1;
664  const QuadratureRule& qR = quadRuleTetra15pt;
665  const QuadratureRule& bdQr = quadRuleTria4pt;
666 
667  feSpacePtr_Type FlagFESpacePtr ( new feSpace_Type ( mesh, refFE, qR, bdQr, 1, comm ) );
668 
669  std::vector< vectorPtr_Type > FlagData ( EntityFlags::number );
670 
671  for ( flag_Type kFlag ( 1 ), flagCount ( 0 ); kFlag < EntityFlags::ALL; kFlag *= 2, flagCount++ )
672  {
673  if ( kFlag & compareFlag )
674  {
675  FlagData[ flagCount ].reset ( new vector_Type ( FlagFESpacePtr->map() ) );
676 
677  for ( UInt iPoint ( 0 ); iPoint < FlagFESpacePtr->mesh()->numPoints(); ++iPoint )
678  {
679  typename MeshType::point_Type const& point = FlagFESpacePtr->mesh()->pointList[ iPoint ];
680  FlagData[ flagCount ]->setCoefficient ( point.id() , Flag::testOneSet ( point.flag(), kFlag ) );
681  }
682 
683  addVariable ( exporterData_Type::ScalarField,
684  "Flag " + EntityFlags::name ( kFlag ),
685  FlagFESpacePtr,
686  FlagData[ flagCount ],
687  0,
688  exporterData_Type::SteadyRegime,
689  exporterData_Type::Node );
690  }
691  }
692 }
693 
694 template <typename MeshType>
695 void Exporter<MeshType>::exportPID ( meshPtr_Type& mesh, commPtr_Type& comm, bool const binaryFormat )
696 {
697  // TODO: use FESpace M_spacemap for generality
698  const ReferenceFE* refFEPtr;
699 
700  // Need a factory!!!!
701  // @todo Need a factory!
702  switch ( MeshType::S_geoDimensions )
703  {
704  case 3:
705  refFEPtr = &feTetraP0;
706  break;
707  case 2:
708  refFEPtr = &feTriaP0;
709  break;
710  case 1:
711  refFEPtr = &feSegP0;
712  break;
713  default:
714  ERROR_MSG ( "Dimension not supported " );
715  }
716 
717  // Useless quadrature rule
718  const QuadratureRule& dummyQR = quadRuleDummy;
719 
720  feSpacePtr_Type PID_FESpacePtr ( new feSpace_Type ( mesh, *refFEPtr, dummyQR, dummyQR, 1, comm ) );
721 
722  vectorPtr_Type PIDData ( new vector_Type ( PID_FESpacePtr->map() ) );
723  *PIDData = 0.;
724 
725  std::string name;
726 
727  if ( binaryFormat )
728  {
729  name = "PIDbinary";
730  for ( UInt iElem ( 0 ); iElem < mesh->numElements(); ++iElem )
731  {
732  const ID globalElem = mesh->element (iElem).id();
733  Int PIDValue = 1;
734  PIDValue <<= comm->MyPID();
735  PIDData->sumIntoGlobalValues ( globalElem, PIDValue );
736  }
737  PIDData->globalAssemble();
738  }
739  else
740  {
741  name = "PID";
742  for ( UInt iElem ( 0 ); iElem < mesh->numElements(); ++iElem )
743  {
744  const ID globalElem = mesh->element (iElem).id();
745  (*PIDData) [ globalElem ] = comm->MyPID();
746  }
747  }
748 
749  addVariable ( exporterData_Type::ScalarField,
750  name,
751  PID_FESpacePtr,
752  PIDData,
753  0,
754  exporterData_Type::SteadyRegime,
755  exporterData_Type::Cell );
756 }
757 
758 // Export the region marker ID as P0 variable
759 template <typename MeshType>
760 void Exporter<MeshType>::exportRegionMarkerID ( std::shared_ptr<MeshType> mesh, std::shared_ptr<Epetra_Comm> comm )
761 {
762  // TODO: use FESpace M_spacemap for generality
763  const ReferenceFE* refFEPtr;
764 
765  // Need a factory!!!!
766  // @todo Need a factory!
767  switch ( MeshType::S_geoDimensions )
768  {
769  case 3:
770  refFEPtr = &feTetraP0;
771  break;
772  case 2:
773  refFEPtr = &feTriaP0;
774  break;
775  case 1:
776  refFEPtr = &feSegP0;
777  break;
778  default:
779  ERROR_MSG ( "Dimension not supported " );
780  }
781 
782  // Useless quadrature rule
783  const QuadratureRule& dummyQR = quadRuleDummy;
784 
785  const feSpacePtr_Type regionMarkerID_FESpacePtr ( new feSpace_Type ( mesh, *refFEPtr,
786  dummyQR, dummyQR,
787  1, comm ) );
788 
789  vectorPtr_Type regionMarkerIDData ( new vector_Type ( regionMarkerID_FESpacePtr->map() ) );
790 
791  for ( UInt iElem ( 0 ); iElem < mesh->numElements(); ++iElem )
792  {
793  const ID globalElem = mesh->element (iElem).id();
794  (*regionMarkerIDData) [ globalElem ] = mesh->element (iElem).markerID();
795  }
796 
797  addVariable ( exporterData_Type::ScalarField,
798  "regionMarkerID",
799  regionMarkerID_FESpacePtr,
800  regionMarkerIDData,
801  0,
802  exporterData_Type::SteadyRegime,
803  exporterData_Type::Cell );
804 
805 } // exportRegionMarkerID
806 
807 template <typename MeshType>
808 void Exporter<MeshType>::computePostfix()
809 {
810  std::ostringstream index;
811  index.fill ( '0' );
812 
813  if (M_timeIndex % M_save == 0)
814  {
815  index << std::setw (M_timeIndexWidth) << ( M_timeIndex / M_save );
816 
817  M_postfix = "." + index.str();
818  }
819  else
820  {
821  // M_postfix = "*****";
822  std::string stars ("");
823  for (UInt cc (0); cc < M_timeIndexWidth; ++cc)
824  {
825  stars += "*";
826  }
827  M_postfix = stars;
828  }
829 
830  ++M_timeIndex;
831 }
832 
833 // ===================================================
834 // Set Methods
835 // ===================================================
836 template<typename MeshType>
837 void Exporter<MeshType>::setDataFromGetPot ( const GetPot& dataFile, const std::string& section )
838 {
839  M_postDir = dataFile ( ( section + "/post_dir" ).data(), "./" );
840  M_timeIndexStart = dataFile ( ( section + "/start" ).data(), 0 );
841  M_timeIndex = M_timeIndexStart;
842  M_save = dataFile ( ( section + "/save" ).data(), 1 );
843  M_multimesh = dataFile ( ( section + "/multimesh" ).data(), true );
844  M_timeIndexWidth = dataFile ( ( section + "/time_id_width" ).data(), 5);
845  M_numImportProc = dataFile ( ( section + "/numImportProc" ).data(), 1);
846 }
847 
848 template<typename MeshType>
849 void Exporter<MeshType>::setMeshProcId ( const meshPtr_Type mesh , const int& procId )
850 {
851  M_mesh = mesh;
852  M_procId = procId;
853 }
854 
855 } // Namespace LifeV
856 
857 #endif // EXPORTER_H
const QuadratureRule quadRuleDummy(pt_node_0pt, QUAD_RULE_DUMMY, "Dummy quadrature rule", NONE, 0, 0)
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
FESpace - Short description here please!
Definition: FESpace.hpp:78
const flag_Type ALL(0x7F)
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
double Real
Generic real data.
Definition: LifeV.hpp:175
The class for a reference Lagrangian finite element.
available bit-flags for different geometric properties
Definition: MeshEntity.hpp:48
QuadratureRule - The basis class for storing and accessing quadrature rules.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191