Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-xt
Commits
87b65d89
Commit
87b65d89
authored
12 years ago
by
Dr. Felix Tobias Schindler
Browse files
Options
Downloads
Patches
Plain Diff
[function.spe10] added min/max value and linear rescaling
parent
81b76368
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/stuff/function/spe10.hh
+28
-16
28 additions, 16 deletions
dune/stuff/function/spe10.hh
with
28 additions
and
16 deletions
dune/stuff/function/spe10.hh
+
28
−
16
View file @
87b65d89
...
...
@@ -8,6 +8,7 @@
#include
<dune/stuff/common/parameter/tree.hh>
#include
<dune/stuff/common/color.hh>
#include
<dune/stuff/common/string.hh>
#include
"interface.hh"
...
...
@@ -46,17 +47,20 @@ private:
static
const
size_t
numXelements
=
100
;
static
const
size_t
numYelements
=
1
;
static
const
size_t
numZelements
=
20
;
static
const
double
minValue
=
0.001
;
static
const
double
maxValue
=
998.915
;
public
:
Spe10Model1
(
const
std
::
string
filename
,
const
DomainType
&
_lowerLeft
,
const
DomainType
&
_upperRight
,
// const std::vector< size_t >& _numElements,
const
std
::
string
_name
=
id
(),
const
int
_order
=
0
,
const
double
_regularization
=
0.0
)
const
std
::
string
_name
=
id
(),
const
int
_order
=
0
,
const
double
_minValue
=
minValue
,
const
double
_maxValue
=
maxValue
)
:
lowerLeft_
(
_lowerLeft
)
,
upperRight_
(
_upperRight
)
// , numElements_(_numElements)
,
name_
(
_name
)
,
order_
(
_order
)
,
regularization_
(
_regularization
)
,
minValue_
(
_minValue
)
{
// sanity checks
std
::
stringstream
msg
;
...
...
@@ -83,11 +87,13 @@ public:
// msg << "\n" << Dune::Stuff::Common::colorStringRed("ERROR:")
// << " numElements[1] has to be smaller than " << numZelements << " (is " << numElements_[1] << ")!";
// }
if
(
regularization_
<
0.0
)
{
if
(
!
(
_maxValue
>
minValue_
)
)
{
++
throw_up
;
msg
<<
"
\n
"
<<
Dune
::
Stuff
::
Common
::
colorStringRed
(
"ERROR:"
)
<<
"
regularization must not be negative (is "
<<
regularization_
<<
")!"
;
msg
<<
"
\n
"
<<
Dune
::
Stuff
::
Common
::
colorStringRed
(
"ERROR:"
)
<<
"
maxValue_ (is "
<<
_maxValue
<<
") has to be larger than minValue_ (is "
<<
_minValue
<<
")!"
;
}
scale_
=
(
_maxValue
-
minValue_
)
/
(
maxValue
-
minValue
);
shift_
=
minValue_
-
scale_
*
minValue
;
// read all the data from the file
std
::
ifstream
datafile
(
filename
);
if
(
datafile
.
is_open
())
{
...
...
@@ -129,10 +135,11 @@ public:
static
Dune
::
ParameterTree
createSampleDescription
(
const
std
::
string
subName
=
""
)
{
Dune
::
ParameterTree
description
;
description
[
"filename"
]
=
"perm_case1.dat"
;
description
[
"lowerLeft"
]
=
"[0.0; 0.0]"
;
description
[
"upperRight"
]
=
"[762.0; 15.24]"
;
description
[
"regularization"
]
=
"0.0"
;
description
[
"filename"
]
=
"perm_case1.dat"
;
description
[
"lowerLeft"
]
=
"[0.0; 0.0]"
;
description
[
"upperRight"
]
=
"[762.0; 15.24]"
;
description
[
"minValue"
]
=
Dune
::
Stuff
::
Common
::
toString
(
minValue
);
description
[
"maxValue"
]
=
Dune
::
Stuff
::
Common
::
toString
(
maxValue
);
// description["numElements"] = "[100; 20]";
description
[
"name"
]
=
id
();
description
[
"order"
]
=
"0"
;
...
...
@@ -153,9 +160,12 @@ public:
const
std
::
vector
<
DomainFieldType
>
upperRightIn
=
description
.
getVector
<
DomainFieldType
>
(
"upperRight"
,
dimDomain
);
// const std::vector< size_t > numElements = description.getVector< size_t >( "numElements",
// dimDomain);
double
regularizationIn
=
0.0
;
if
(
description
.
hasKey
(
"regularization"
))
regularizationIn
=
description
.
get
<
double
>
(
"regularization"
);
double
minValueIn
=
minValue
;
if
(
description
.
hasKey
(
"minValue"
))
minValueIn
=
description
.
get
<
double
>
(
"minValue"
);
double
maxValueIn
=
maxValue
;
if
(
description
.
hasKey
(
"maxValue"
))
maxValueIn
=
description
.
get
<
double
>
(
"maxValue"
);
const
std
::
string
nameIn
=
description
.
get
<
std
::
string
>
(
"name"
,
id
());
const
int
orderIn
=
description
.
get
<
int
>
(
"order"
,
0
);
// convert and leave the checks to the constructor
...
...
@@ -166,7 +176,7 @@ public:
upperRight
[
dd
]
=
upperRightIn
[
dd
];
}
// create and return
return
new
ThisType
(
filenameIn
,
lowerLeft
,
upperRight
,
/*numElements,*/
nameIn
,
orderIn
,
regularization
In
);
return
new
ThisType
(
filenameIn
,
lowerLeft
,
upperRight
,
/*numElements,*/
nameIn
,
orderIn
,
minValueIn
,
maxValue
In
);
}
// static ThisType createFromParamTree(const Dune::ParameterTree paramTree)
const
DomainType
&
lowerLeft
()
const
...
...
@@ -206,10 +216,10 @@ public:
// }
// if (interval[0] >= numElements_[0] || interval[1] >= numElements_[1]) {
if
(
interval
[
0
]
>=
numXelements
||
interval
[
1
]
>=
numZelements
)
{
ret
[
0
]
=
0
;
ret
[
0
]
=
minValue_
;
}
else
{
const
size_t
index
=
interval
[
0
]
+
numXelements
*
0
+
numXelements
*
numYelements
*
interval
[
1
];
ret
[
0
]
=
data_
[
index
]
+
regularization
_
;
ret
[
0
]
=
(
scale_
*
data_
[
index
]
)
+
shift
_
;
}
}
// virtual void evaluate(const DomainType& x, RangeType& ret) const
...
...
@@ -220,8 +230,10 @@ private:
// const std::vector< size_t > numElements_;
const
std
::
string
name_
;
const
int
order_
;
const
double
regularization
_
;
const
double
minValue
_
;
double
*
data_
;
double
scale_
;
double
shift_
;
};
// class Spe10Model1< DomainFieldImp, 2, RangeFieldImp, 1 >
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment