Export.h 8.58 KB
Newer Older
Gilles MARCKMANN's avatar
Gilles MARCKMANN committed
1
/*
2 3
    This source code is subject to non-permissive licence,
    see the DamageBandDyn/LICENSE file for conditions.
Gilles MARCKMANN's avatar
Gilles MARCKMANN committed
4
*/
5 6
#ifndef _Export_h
#define _Export_h
7 8 9 10 11 12 13
// DamageBandDyn
#include "tools.h"
// Xfem
#include "xEntityToEntity.h"
#include "xAlgorithm.h"
// boost
#include <boost/iterator/filter_iterator.hpp>
14

15 16 17 18 19 20 21 22 23 24 25
namespace xfem
{
class xExport;
class xExportManager;
class xExportSensors;
class xLevelSet;
class xIntegrationRule;
class xMesh;
template <typename T>
class xEval;
}
26

27 28 29 30
class PostProcessing
{
public:
  PostProcessing(xfem::xExportManager& export_manager_, xfem::xExportSensors& sensor_manager_, xfem::xExport& pexport_, const int frequency_);
31

32 33 34
  void reinit(xfem::xMesh* mesh);

  void exportOnSpace(const std::string export_name, const int step, const xfem::xLevelSet& ls);
35 36 37
  void exportOnSpace(const std::string export_name, const int step, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                     xfem::xIter begin,
                     xfem::xIter end);
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
  void exportOnSpace(const std::string export_name, const int step, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                     boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin,
                     boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end);
  void exportOnSpace(const std::string export_name, const int step, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                     std::set<AOMD::mEntity*>::const_iterator begin,
                     std::set<AOMD::mEntity*>::const_iterator end);
  void exportOnSpace(const std::string export_name, const int step, const xfem::xEval<xfem::xVector>& eval, const xfem::xIntegrationRule& integration_rule,
                     boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin,
                     boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end);
  void exportOnSpace(const std::string export_name, const int step, const xfem::xEval<xfem::xTensor2>& eval, const xfem::xIntegrationRule& integration_rule,
                     boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin,
                     boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end);
  void exportOnSpace(const std::string export_name, const int step, const xfem::xEval<xfem::xTensor2Sym>& eval, const xfem::xIntegrationRule& integration_rule,
                     boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin,
                     boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end);

  void exportOnTime(const std::string name, const int step, const double time, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                    boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin,
                    boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end,
                    xfem::xEntityToEntity entity_to_entity=xfem::xIdentity<AOMD::mEntity*>());
  void exportOnTime(const std::string name, const int step, const double time, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                    boost::filter_iterator<xfem::xEntityFilter, xfem::xClassIter> begin,
                    boost::filter_iterator<xfem::xEntityFilter, xfem::xClassIter> end,
                    xfem::xEntityToEntity entity_to_entity=xfem::xIdentity<AOMD::mEntity*>());
  void exportOnTime(const std::string name, const double time, const double val);
  void exportOnTime(const std::string name, const double time, const xfem::xEval<double>& eval);
  void exportOnTime(const std::string name, const double time, const xfem::xEval<xfem::xVector>& eval);
  void exportOnTime(const std::string name, const double time, const xfem::xEval<xfem::xTensor2>& eval);
  void exportOnTime(const std::string name, const double time, const xfem::xEval<xfem::xTensor2Sym>& eval);

  void exportPowerOnTime(const std::string name, const int step, const double time, const double time_step, double& cumulate, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                          boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin,
                          boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end,
                          xfem::xEntityToEntity entity_to_entity=xfem::xIdentity<AOMD::mEntity*>());
  void exportPowerOnTime(const std::string name, const int step, const double time, const double time_step, double& cumulate, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                          boost::filter_iterator<xfem::xEntityFilter, xfem::xClassIter> begin,
                          boost::filter_iterator<xfem::xEntityFilter, xfem::xClassIter> end,
                          xfem::xEntityToEntity entity_to_entity=xfem::xIdentity<AOMD::mEntity*>());
  void exportPowerOnTime(const std::string name, const int step, const double time, const double cumulate);

  void exportEnergyOnTime(const std::string name, const int step, const double time, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                          boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin,
                          boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end,
                          xfem::xEntityToEntity entity_to_entity=xfem::xIdentity<AOMD::mEntity*>());
  void exportEnergyOnTime(const std::string name, const int step, const double time, const xfem::xEval<double>& eval, const xfem::xIntegrationRule& integration_rule,
                          boost::filter_iterator<xfem::xEntityFilter, xfem::xClassIter> begin,
                          boost::filter_iterator<xfem::xEntityFilter, xfem::xClassIter> end,
                          xfem::xEntityToEntity entity_to_entity=xfem::xIdentity<AOMD::mEntity*>());

  void exportTotalEnergyOnTime(const int step, const double time);

  template <typename SPACE, typename ITER>
  void exportShapeFunctions(const SPACE& space, const xfem::xIntegrationRule& integration_rule, ITER begin, ITER end, const std::vector<int>& dofs)
  {
    ExportShapeFunctions(pexport, space, integration_rule, begin, end, dofs);
  }

  void storeLevelSet(std::string name, const int step, const xfem::xLevelSet& ls);
  void storeMesh(std::string name, const xfem::xMesh& mesh);
  void storeInternalVariable(std::string name, const int step, const xfem::xEval<double>& eval,
                             boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin, 
                             boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end);
  void storeInternalVariable(std::string name, const int step, const xfem::xEval<xfem::xTensor2>& eval,
                             boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> begin, 
                             boost::filter_iterator<xfem::xEntityFilter, xfem::xIter> end);
  void storeValue(std::string name, const int step, const double val);
  void storeValue(std::string name, const int step, const int val);
  void storeValue(std::string name, const int step, const bool val);
  void storeCSRVector(std::string name, const int step, const lalg::xCSRVector& vec);
  void archiveRestoreFiles(const int step);

private:
  xfem::xExport& pexport;
  xfem::xExportSensors& sensor_manager;
  xfem::xExportManager& export_manager;
113
  eXlibris_types::hash_map<std::string, double> current_map;
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
  int frequency;
};

template <typename SPACE, typename ITER>
void ExportShapeFunctions(xfem::xExport& pexport, const SPACE& space, const xfem::xIntegrationRule& integration_rule, ITER begin, ITER end, const std::vector<int>& dofs)
{
  xfem::xDoubleManager double_manager;
  xfem::xField field(&double_manager, space);
  xfem::xValueCreator<xfem::xValueDouble> value_creator;
  xfem::DeclareValueField(field, value_creator, begin, end);
  xfem::xStateDofCreator<> state_dof_creator(double_manager, "dofs_exp");
  xfem::DeclareState(field, state_dof_creator, begin, end);
  const int nb_dofs = double_manager.size("dofs_exp");
  double_manager.PrintForDebug("shape_function.txt");

  xfem::xEvalField<xfem::xIdentity<double> > eval_field(field);

  for (std::vector<int>::const_iterator it=dofs.begin(); it!=dofs.end(); ++it)
  {
    int i = *it;
    std::cout << "nb_dofs: " << nb_dofs << " i: " << i << std::endl;
    std::vector<double> R(nb_dofs, 0.);
    R[i-1] = 1.;
    xfem::Visit(xfem::xWriteSolutionVisitor<std::vector<double> >(R.begin()), double_manager.begin("dofs_exp"), double_manager.end("dofs_exp"));
    const std::string filename = "shape_function_"+toString(i);
    xfem::Export(eval_field, pexport, filename, integration_rule, begin, end);
  }
}
142 143

#endif