MFEM  v4.6.0 Finite element discretization library
transformation.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details
11
12 #ifndef TRANSFORMATION_HPP
13 #define TRANSFORMATION_HPP
14
15 #include "mfem.hpp"
16
17 namespace mfem
18 {
19 namespace spde
20 {
21
22 /// Base class to transform a grid function.
24 {
25 public:
26  GFTransformer() = default;
27  virtual ~GFTransformer() = default;
28  virtual void Transform(ParGridFunction &x) const = 0;
29 };
30
31 /// This transformations is a pointwise transformation to
32 /// transform a Gaussian random field to a random field following a uniform
33 /// distributions. Specifically, we implement the transformations as described
34 /// in the following paper:
35 /// Lazarov, B.S., Schevenels, M. & Sigmund, O. Topology optimization
36 /// considering material and geometric uncertainties using stochastic
37 /// collocation methods. Struct Multidisc Optim 46, 597–612 (2012).
38 /// https://doi.org/10.1007/s00158-012-0791-7
39 /// Equation (19).
41 {
42 public:
43  UniformGRFTransformer() = default;
44  UniformGRFTransformer(double min, double max) : min_(min), max_(max) {}
45  ~UniformGRFTransformer() override = default;
46  /// Transforms a GridFunction representing a Gaussian random field to a
47  /// uniform random field between a and b.
48  void Transform(ParGridFunction &x) const override;
49
50 private:
51  double min_ = 0.0;
52  double max_ = 1.0;
53 };
54
55 /// Adds an constant offset to a grid function, i.e. u(x) = u(x) + offset.
57 {
58 public:
59  OffsetTransformer() = default;
60  explicit OffsetTransformer(double offset) : offset_(offset) {}
61  ~OffsetTransformer() override = default;
62  /// Offsets a grid function by an constant offset.
63  void Transform(ParGridFunction &x) const override;
64
65 private:
66  double offset_ = 0.0;
67 };
68
69 /// Transforms a grid function by scaling it by a constant factor.
71 {
72 public:
73  ScaleTransformer() = default;
74  explicit ScaleTransformer(double scale) : scale_(scale) {}
75  ~ScaleTransformer() override = default;
76  /// Scales a grid function by an constant factor.
77  void Transform(ParGridFunction &x) const override;
78
79 private:
80  double scale_ = 1.0;
81 };
82
83 /// Level Set Transformer, 1 for u(x) >= threshold, 0 otherwise.
85 {
86 public:
87  LevelSetTransformer() = default;
88  explicit LevelSetTransformer(double threshold) : threshold_(threshold) {}
89  ~LevelSetTransformer() override = default;
90  /// Applies a level set to the GridFunction.
91  void Transform(ParGridFunction &x) const override;
92
93 private:
94  double threshold_ = 0.0;
95 };
96
97 } // namespace spde
98 } // namespace mfem
99
100 #endif // TRANSFORMATION_HPP
Level Set Transformer, 1 for u(x) >= threshold, 0 otherwise.
Transforms a grid function by scaling it by a constant factor.
void Transform(ParGridFunction &x) const override
Offsets a grid function by an constant offset.
void Transform(ParGridFunction &x) const override
~UniformGRFTransformer() override=default
Adds an constant offset to a grid function, i.e. u(x) = u(x) + offset.
~LevelSetTransformer() override=default
~OffsetTransformer() override=default
UniformGRFTransformer(double min, double max)
virtual ~GFTransformer()=default
Base class to transform a grid function.
virtual void Transform(ParGridFunction &x) const =0
LevelSetTransformer(double threshold)
void Transform(ParGridFunction &x) const override
Scales a grid function by an constant factor.
Class for parallel grid function.
Definition: pgridfunc.hpp:32
~ScaleTransformer() override=default
void Transform(ParGridFunction &x) const override
Applies a level set to the GridFunction.