Loading [MathJax]/extensions/tex2jax.js
OGS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
IntegrationPointWriter.h
Go to the documentation of this file.
1
10#include <algorithm>
11#include <functional>
12#include <iterator>
13#include <memory>
14#include <optional>
15#include <string>
16#include <vector>
17
19
20#pragma once
21
22namespace MeshLib
23{
24class Mesh;
25class Properties;
26
28{
33 template <typename LocalAssemblerInterface, typename... Args>
35 std::string const& name,
36 int const n_components,
37 int const integration_order,
38 std::vector<std::unique_ptr<LocalAssemblerInterface>> const&
39 local_assemblers,
40 std::vector<double> (LocalAssemblerInterface::*getIpData)(Args...)
41 const,
42 Args&&... args)
43 : _name(name),
44 _n_components(n_components),
45 _integration_order(integration_order)
46 {
47 _callback = [&local_assemblers,
48 getIpData,
49 ... f_args = std::forward<Args>(args)]
50 {
51 // Result containing integration point data for each local
52 // assembler.
53 std::vector<std::vector<double>> result;
54 result.reserve(local_assemblers.size());
55
56 std::transform(begin(local_assemblers), end(local_assemblers),
57 std::back_inserter(result),
58 [&](auto const& la)
59 { return (*la.*getIpData)(f_args...); });
60
61 return result;
62 };
63 }
64
70 template <typename LocalAssemblerInterface, typename Accessor>
72 std::string const& name,
73 int const n_components,
74 int const integration_order,
75 std::vector<std::unique_ptr<LocalAssemblerInterface>> const&
76 local_assemblers,
77 Accessor accessor)
78 : _name(name),
79 _n_components(n_components),
80 _integration_order(integration_order)
81 {
82 _callback = [&local_assemblers, accessor]
83 {
84 // Result containing integration point data for each local
85 // assembler.
86 std::vector<std::vector<double>> result;
87 result.reserve(local_assemblers.size());
88
89 std::transform(begin(local_assemblers), end(local_assemblers),
90 std::back_inserter(result),
91 [&accessor](auto const& la)
92 { return accessor(*la); });
93
94 return result;
95 };
96 }
97
98 int numberOfComponents() const { return _n_components; }
99 int integrationOrder() const { return _integration_order; }
100 std::string name() const { return _name; }
101 std::vector<std::vector<double>> values() const { return _callback(); }
102
103private:
104 std::string const _name;
105 int const _n_components;
107 std::function<std::vector<std::vector<double>>()> _callback;
108};
109
118 MeshLib::Mesh& mesh,
119 std::vector<std::unique_ptr<IntegrationPointWriter>> const&
120 integration_point_writer);
121
125std::optional<IntegrationPointMetaData> getIntegrationPointMetaData(
126 MeshLib::Properties const& properties);
127} // namespace MeshLib
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
Definition Properties.h:33
std::optional< IntegrationPointMetaData > getIntegrationPointMetaData(MeshLib::Properties const &properties)
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)