MFEM
v4.6.0
Finite element discretization library
miniapps
spde
transformation.hpp
Go to the documentation of this file.
1
// Copyright (c) 2010-2023, 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
17
namespace
mfem
18
{
19
namespace
spde
20
{
21
22
/// Base class to transform a grid function.
23
class
GFTransformer
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).
40
class
UniformGRFTransformer
:
public
GFTransformer
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.
56
class
OffsetTransformer
:
public
GFTransformer
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.
70
class
ScaleTransformer
:
public
GFTransformer
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.
84
class
LevelSetTransformer
:
public
GFTransformer
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
mfem::spde::UniformGRFTransformer
Definition:
transformation.hpp:40
mfem::spde::LevelSetTransformer
Level Set Transformer, 1 for u(x) >= threshold, 0 otherwise.
Definition:
transformation.hpp:84
mfem::spde::ScaleTransformer
Transforms a grid function by scaling it by a constant factor.
Definition:
transformation.hpp:70
mfem::spde::GFTransformer::GFTransformer
GFTransformer()=default
mfem::spde::OffsetTransformer::Transform
void Transform(ParGridFunction &x) const override
Offsets a grid function by an constant offset.
Definition:
transformation.cpp:48
mfem::spde::UniformGRFTransformer::Transform
void Transform(ParGridFunction &x) const override
Definition:
transformation.cpp:35
mfem
Definition:
CodeDocumentation.dox:1
mfem::spde::ScaleTransformer::ScaleTransformer
ScaleTransformer(double scale)
Definition:
transformation.hpp:74
mfem::spde::UniformGRFTransformer::~UniformGRFTransformer
~UniformGRFTransformer() override=default
mfem::spde::OffsetTransformer
Adds an constant offset to a grid function, i.e. u(x) = u(x) + offset.
Definition:
transformation.hpp:56
mfem::spde::OffsetTransformer::OffsetTransformer
OffsetTransformer(double offset)
Definition:
transformation.hpp:60
mfem::spde::LevelSetTransformer::~LevelSetTransformer
~LevelSetTransformer() override=default
mfem::spde::OffsetTransformer::~OffsetTransformer
~OffsetTransformer() override=default
mfem::spde::UniformGRFTransformer::UniformGRFTransformer
UniformGRFTransformer(double min, double max)
Definition:
transformation.hpp:44
mfem.hpp
mfem::spde::GFTransformer::~GFTransformer
virtual ~GFTransformer()=default
mfem::spde::GFTransformer
Base class to transform a grid function.
Definition:
transformation.hpp:23
mfem::spde::GFTransformer::Transform
virtual void Transform(ParGridFunction &x) const =0
mfem::spde::UniformGRFTransformer::UniformGRFTransformer
UniformGRFTransformer()=default
mfem::spde::LevelSetTransformer::LevelSetTransformer
LevelSetTransformer(double threshold)
Definition:
transformation.hpp:88
mfem::spde::LevelSetTransformer::LevelSetTransformer
LevelSetTransformer()=default
mfem::spde::ScaleTransformer::Transform
void Transform(ParGridFunction &x) const override
Scales a grid function by an constant factor.
Definition:
transformation.cpp:56
mfem::ParGridFunction
Class for parallel grid function.
Definition:
pgridfunc.hpp:32
mfem::spde::ScaleTransformer::ScaleTransformer
ScaleTransformer()=default
mfem::spde::OffsetTransformer::OffsetTransformer
OffsetTransformer()=default
mfem::spde::ScaleTransformer::~ScaleTransformer
~ScaleTransformer() override=default
mfem::spde::LevelSetTransformer::Transform
void Transform(ParGridFunction &x) const override
Applies a level set to the GridFunction.
Definition:
transformation.cpp:58
Generated on Wed Sep 27 2023 14:52:34 for MFEM by
1.8.14