MFEM
v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
miniapps
spde
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
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
(
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
50
private
:
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.
56
class
OffsetTransformer
:
public
GFTransformer
57
{
58
public
:
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
65
private
:
66
real_t
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
(
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
79
private
:
80
real_t
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
(
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
93
private
:
94
real_t
threshold_ = 0.0;
95
};
96
97
}
// namespace spde
98
}
// namespace mfem
99
100
#endif
// TRANSFORMATION_HPP
mfem::ParGridFunction
Class for parallel grid function.
Definition
pgridfunc.hpp:33
mfem::spde::GFTransformer
Base class to transform a grid function.
Definition
transformation.hpp:24
mfem::spde::GFTransformer::Transform
virtual void Transform(ParGridFunction &x) const =0
mfem::spde::GFTransformer::~GFTransformer
virtual ~GFTransformer()=default
mfem::spde::GFTransformer::GFTransformer
GFTransformer()=default
mfem::spde::LevelSetTransformer
Level Set Transformer, 1 for u(x) >= threshold, 0 otherwise.
Definition
transformation.hpp:85
mfem::spde::LevelSetTransformer::Transform
void Transform(ParGridFunction &x) const override
Applies a level set to the GridFunction.
Definition
transformation.cpp:58
mfem::spde::LevelSetTransformer::~LevelSetTransformer
~LevelSetTransformer() override=default
mfem::spde::LevelSetTransformer::LevelSetTransformer
LevelSetTransformer(real_t threshold)
Definition
transformation.hpp:88
mfem::spde::LevelSetTransformer::LevelSetTransformer
LevelSetTransformer()=default
mfem::spde::OffsetTransformer
Adds an constant offset to a grid function, i.e. u(x) = u(x) + offset.
Definition
transformation.hpp:57
mfem::spde::OffsetTransformer::OffsetTransformer
OffsetTransformer()=default
mfem::spde::OffsetTransformer::OffsetTransformer
OffsetTransformer(real_t offset)
Definition
transformation.hpp:60
mfem::spde::OffsetTransformer::~OffsetTransformer
~OffsetTransformer() override=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::ScaleTransformer
Transforms a grid function by scaling it by a constant factor.
Definition
transformation.hpp:71
mfem::spde::ScaleTransformer::Transform
void Transform(ParGridFunction &x) const override
Scales a grid function by an constant factor.
Definition
transformation.cpp:56
mfem::spde::ScaleTransformer::ScaleTransformer
ScaleTransformer()=default
mfem::spde::ScaleTransformer::~ScaleTransformer
~ScaleTransformer() override=default
mfem::spde::ScaleTransformer::ScaleTransformer
ScaleTransformer(real_t scale)
Definition
transformation.hpp:74
mfem::spde::UniformGRFTransformer
Definition
transformation.hpp:41
mfem::spde::UniformGRFTransformer::UniformGRFTransformer
UniformGRFTransformer(real_t min, real_t max)
Definition
transformation.hpp:44
mfem::spde::UniformGRFTransformer::~UniformGRFTransformer
~UniformGRFTransformer() override=default
mfem::spde::UniformGRFTransformer::UniformGRFTransformer
UniformGRFTransformer()=default
mfem::spde::UniformGRFTransformer::Transform
void Transform(ParGridFunction &x) const override
Definition
transformation.cpp:35
mfem.hpp
mfem
Definition
CodeDocumentation.dox:1
mfem::real_t
float real_t
Definition
config.hpp:43
1.11.0