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 <string>
15#include <vector>
16
17#pragma once
18
19namespace MeshLib
20{
21class Mesh;
22class Properties;
23
25{
30 template <typename LocalAssemblerInterface, typename... Args>
32 std::string const& name,
33 int const n_components,
34 int const integration_order,
35 std::vector<std::unique_ptr<LocalAssemblerInterface>> const&
36 local_assemblers,
37 std::vector<double> (LocalAssemblerInterface::*getIpData)(Args...)
38 const,
39 Args&&... args)
40 : _name(name),
41 _n_components(n_components),
42 _integration_order(integration_order)
43 {
44 _callback = [&local_assemblers,
45 getIpData,
46 ... f_args = std::forward<Args>(args)]
47 {
48 // Result containing integration point data for each local
49 // assembler.
50 std::vector<std::vector<double>> result;
51 result.reserve(local_assemblers.size());
52
53 std::transform(begin(local_assemblers), end(local_assemblers),
54 std::back_inserter(result),
55 [&](auto const& la)
56 { return (*la.*getIpData)(f_args...); });
57
58 return result;
59 };
60 }
61
67 template <typename LocalAssemblerInterface, typename Accessor>
69 std::string const& name,
70 int const n_components,
71 int const integration_order,
72 std::vector<std::unique_ptr<LocalAssemblerInterface>> const&
73 local_assemblers,
74 Accessor accessor)
75 : _name(name),
76 _n_components(n_components),
77 _integration_order(integration_order)
78 {
79 _callback = [&local_assemblers, accessor]
80 {
81 // Result containing integration point data for each local
82 // assembler.
83 std::vector<std::vector<double>> result;
84 result.reserve(local_assemblers.size());
85
86 std::transform(begin(local_assemblers), end(local_assemblers),
87 std::back_inserter(result),
88 [&accessor](auto const& la)
89 { return accessor(*la); });
90
91 return result;
92 };
93 }
94
95 int numberOfComponents() const { return _n_components; }
96 int integrationOrder() const { return _integration_order; }
97 std::string name() const { return _name; }
98 std::vector<std::vector<double>> values() const { return _callback(); }
99
100private:
101 std::string const _name;
102 int const _n_components;
104 std::function<std::vector<std::vector<double>>()> _callback;
105};
106
115 MeshLib::Mesh& mesh,
116 std::vector<std::unique_ptr<IntegrationPointWriter>> const&
117 integration_point_writer);
118
122{
123 std::string const name;
124 int const n_components;
126};
127
132 MeshLib::Properties const& properties, std::string const& name);
133} // namespace MeshLib
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::vector< std::vector< double > > values() const
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, Accessor accessor)
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)