OGS
IntegrationPointWriter.h
Go to the documentation of this file.
1 
10 #include <algorithm>
11 #include <functional>
12 #include <iterator>
13 #include <memory>
14 #include <nlohmann/json_fwd.hpp>
15 #include <vector>
16 
17 #pragma once
18 
19 namespace MeshLib
20 {
21 class Mesh;
22 class Properties;
23 }
24 
25 namespace ProcessLib
26 {
28 {
29  template <typename LocalAssemblerInterface, typename... Args>
31  std::string const& name,
32  int const n_components,
33  int const integration_order,
34  std::vector<std::unique_ptr<LocalAssemblerInterface>> const&
35  local_assemblers,
36  std::vector<double> (LocalAssemblerInterface::*getIpData)(Args...)
37  const,
38  Args&&... args)
39  : _name(name),
40  _n_components(n_components),
41  _integration_order(integration_order)
42  {
43  _callback = [&local_assemblers,
44  getIpData,
45  ... f_args = std::forward<Args>(args)]
46  {
47  // Result containing integration point data for each local
48  // assembler.
49  std::vector<std::vector<double>> result;
50  result.reserve(local_assemblers.size());
51 
52  std::transform(begin(local_assemblers), end(local_assemblers),
53  std::back_inserter(result),
54  [&](auto const& la)
55  { return (*la.*getIpData)(f_args...); });
56 
57  return result;
58  };
59  }
60  int numberOfComponents() const { return _n_components; }
61  int integrationOrder() const { return _integration_order; }
62  std::string name() const { return _name; }
63  std::vector<std::vector<double>> values() const { return _callback(); }
64 
65 private:
66  std::string const _name;
67  int const _n_components;
68  int const _integration_order;
69  std::function<std::vector<std::vector<double>>()> _callback;
70 };
71 
80  MeshLib::Mesh& mesh,
81  std::vector<std::unique_ptr<IntegrationPointWriter>> const&
82  integration_point_writer);
83 
87 {
88  std::string const name;
89  int const n_components;
90  int const integration_order;
91 };
92 
97  MeshLib::Properties const& properties, std::string const& name);
98 } // namespace ProcessLib
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
Definition: Properties.h:36
IntegrationPointMetaData getIntegrationPointMetaData(MeshLib::Properties const &properties, std::string const &name)
void addIntegrationPointDataToMesh(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