MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
transformation.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
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
17namespace mfem
18{
19namespace spde
20{
21
22/// Base class to transform a grid function.
24{
25public:
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{
42public:
44 UniformGRFTransformer(real_t min, real_t 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
50private:
51 real_t min_ = 0.0;
52 real_t max_ = 1.0;
53};
54
55/// Adds an constant offset to a grid function, i.e. u(x) = u(x) + offset.
57{
58public:
59 OffsetTransformer() = default;
60 explicit OffsetTransformer(real_t offset) : offset_(offset) {}
61 ~OffsetTransformer() override = default;
62 /// Offsets a grid function by an constant offset.
63 void Transform(ParGridFunction &x) const override;
64
65private:
66 real_t offset_ = 0.0;
67};
68
69/// Transforms a grid function by scaling it by a constant factor.
71{
72public:
73 ScaleTransformer() = default;
74 explicit ScaleTransformer(real_t scale) : scale_(scale) {}
75 ~ScaleTransformer() override = default;
76 /// Scales a grid function by an constant factor.
77 void Transform(ParGridFunction &x) const override;
78
79private:
80 real_t scale_ = 1.0;
81};
82
83/// Level Set Transformer, 1 for u(x) >= threshold, 0 otherwise.
85{
86public:
88 explicit LevelSetTransformer(real_t threshold) : threshold_(threshold) {}
89 ~LevelSetTransformer() override = default;
90 /// Applies a level set to the GridFunction.
91 void Transform(ParGridFunction &x) const override;
92
93private:
94 real_t threshold_ = 0.0;
95};
96
97} // namespace spde
98} // namespace mfem
99
100#endif // TRANSFORMATION_HPP
Class for parallel grid function.
Definition pgridfunc.hpp:33
Base class to transform a grid function.
virtual void Transform(ParGridFunction &x) const =0
virtual ~GFTransformer()=default
Level Set Transformer, 1 for u(x) >= threshold, 0 otherwise.
void Transform(ParGridFunction &x) const override
Applies a level set to the GridFunction.
~LevelSetTransformer() override=default
Adds an constant offset to a grid function, i.e. u(x) = u(x) + offset.
~OffsetTransformer() override=default
void Transform(ParGridFunction &x) const override
Offsets a grid function by an constant offset.
Transforms a grid function by scaling it by a constant factor.
void Transform(ParGridFunction &x) const override
Scales a grid function by an constant factor.
~ScaleTransformer() override=default
UniformGRFTransformer(real_t min, real_t max)
~UniformGRFTransformer() override=default
void Transform(ParGridFunction &x) const override
float real_t
Definition config.hpp:43