Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Özgür Ozan Sen
ogs
Commits
fa640fde
Commit
fa640fde
authored
1 year ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[ParameterLib] Impl RasterParameter
parent
e850ec25
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ParameterLib/RasterParameter.cpp
+37
-0
37 additions, 0 deletions
ParameterLib/RasterParameter.cpp
ParameterLib/RasterParameter.h
+72
-0
72 additions, 0 deletions
ParameterLib/RasterParameter.h
with
109 additions
and
0 deletions
ParameterLib/RasterParameter.cpp
0 → 100644
+
37
−
0
View file @
fa640fde
/**
* \file
* \copyright
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include
"RasterParameter.h"
#include
"BaseLib/ConfigTree.h"
#include
"BaseLib/Error.h"
#include
"BaseLib/Logging.h"
namespace
ParameterLib
{
std
::
unique_ptr
<
ParameterBase
>
createRasterParameter
(
std
::
string
const
&
name
,
BaseLib
::
ConfigTree
const
&
config
,
std
::
vector
<
GeoLib
::
NamedRaster
>
const
&
named_rasters
)
{
//! \ogs_file_param{prj__parameters__parameter__type}
config
.
checkConfigParameter
(
"type"
,
"Raster"
);
auto
const
&
named_raster
=
BaseLib
::
getIfOrError
(
named_rasters
,
[
&
name
](
auto
const
&
named_raster
)
{
return
name
==
named_raster
.
raster_name
;
},
"Could not find raster '"
+
name
);
DBUG
(
"Using the raster '{}' for the raster parameter."
,
name
);
return
std
::
make_unique
<
RasterParameter
>
(
name
,
named_raster
);
}
}
// namespace ParameterLib
This diff is collapsed.
Click to expand it.
ParameterLib/RasterParameter.h
0 → 100644
+
72
−
0
View file @
fa640fde
/**
* \file
* \copyright
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include
"GeoLib/Raster.h"
#include
"Parameter.h"
namespace
ParameterLib
{
struct
RasterParameter
final
:
public
Parameter
<
double
>
{
explicit
RasterParameter
(
std
::
string
const
&
name_
,
GeoLib
::
NamedRaster
const
&
named_raster
)
:
Parameter
<
double
>
(
name_
),
_named_raster
(
named_raster
)
{
}
bool
isTimeDependent
()
const
override
{
return
false
;
}
int
getNumberOfGlobalComponents
()
const
override
{
return
1
;
}
std
::
vector
<
double
>
operator
()(
double
const
/*t*/
,
SpatialPosition
const
&
pos
)
const
override
{
auto
const
&
coordinates
=
pos
.
getCoordinates
();
if
(
!
coordinates
)
{
OGS_FATAL
(
"RasterParameter::operator(): couldn't get coordinates."
);
}
auto
const
value
=
_named_raster
.
raster
.
getValueAtPoint
(
*
coordinates
);
return
{
value
};
}
Eigen
::
Matrix
<
double
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
getNodalValuesOnElement
(
MeshLib
::
Element
const
&
element
,
double
const
t
)
const
override
{
auto
const
n_nodes
=
element
.
getNumberOfNodes
();
Eigen
::
Matrix
<
double
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
result
(
n_nodes
,
getNumberOfGlobalComponents
());
SpatialPosition
position
;
auto
const
nodes
=
element
.
getNodes
();
for
(
unsigned
i
=
0
;
i
<
n_nodes
;
++
i
)
{
position
.
setCoordinates
(
*
(
nodes
[
i
]));
auto
const
&
values
=
this
->
operator
()(
t
,
position
);
result
.
row
(
i
)
=
Eigen
::
Map
<
Eigen
::
Matrix
<
double
,
Eigen
::
Dynamic
,
1
>
const
>
(
values
.
data
(),
values
.
size
());
}
return
result
;
}
private
:
GeoLib
::
NamedRaster
const
&
_named_raster
;
};
std
::
unique_ptr
<
ParameterBase
>
createRasterParameter
(
std
::
string
const
&
name
,
BaseLib
::
ConfigTree
const
&
config
,
std
::
vector
<
GeoLib
::
NamedRaster
>
const
&
named_rasters
);
}
// namespace ParameterLib
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