OGS
IntegrationPointWriter.h
Go to the documentation of this file.
1 
10 #include <functional>
11 #include <memory>
12 #include <nlohmann/json_fwd.hpp>
13 #include <vector>
14 
15 #pragma once
16 
17 namespace MeshLib
18 {
19 class Mesh;
20 }
21 
22 namespace ProcessLib
23 {
25 {
26  template <typename LocalAssemblerInterface, typename... Args>
28  std::string const& name,
29  int const n_components,
30  int const integration_order,
31  std::vector<std::unique_ptr<LocalAssemblerInterface>> const&
32  local_assemblers,
33  std::vector<double> (LocalAssemblerInterface::*getIpData)(Args...)
34  const,
35  Args&&... args)
36  : _name(name),
37  _n_components(n_components),
38  _integration_order(integration_order)
39  {
40  _callback = [&local_assemblers,
41  getIpData,
42  ... f_args = std::forward<Args>(args)]
43  {
44  // Result containing integration point data for each local
45  // assembler.
46  std::vector<std::vector<double>> result;
47  result.reserve(local_assemblers.size());
48 
49  std::transform(begin(local_assemblers), end(local_assemblers),
50  std::back_inserter(result),
51  [&](auto const& la)
52  { return (*la.*getIpData)(f_args...); });
53 
54  return result;
55  };
56  }
57  int numberOfComponents() const { return _n_components; }
58  int integrationOrder() const { return _integration_order; }
59  std::string name() const { return _name; }
60  std::vector<std::vector<double>> values() const { return _callback(); }
61 
62 private:
63  std::string const _name;
64  int const _n_components;
65  int const _integration_order;
66  std::function<std::vector<std::vector<double>>()> _callback;
67 };
68 
77  MeshLib::Mesh& mesh,
78  std::vector<std::unique_ptr<IntegrationPointWriter>> const&
79  integration_point_writer);
80 
84 {
85  std::string const name;
86  int const n_components;
87  int const integration_order;
88 };
89 
94  std::string const& name);
95 } // namespace ProcessLib
IntegrationPointMetaData getIntegrationPointMetaData(MeshLib::Mesh const &mesh, std::string const &name)
void addIntegrationPointWriter(MeshLib::Mesh &mesh, std::vector< std::unique_ptr< IntegrationPointWriter >> const &integration_point_writer)
std::function< std::vector< std::vector< double > >)> _callback
IntegrationPointWriter(std::string const &name, int const n_components, int const integration_order, std::vector< std::unique_ptr< LocalAssemblerInterface >> const &local_assemblers, std::vector< double >(LocalAssemblerInterface::*getIpData)(Args...) const, Args &&... args)
std::vector< std::vector< double > > values() const