Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
3766c8ba
Commit
3766c8ba
authored
Feb 11, 2021
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Improve DiscreteFunctionInterpoler
It can now handle functions with values in B, N, Z, R, R^d and R^dxd
parent
01a77a08
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!75
Feature/language discretization
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/scheme/DiscreteFunctionInterpoler.cpp
+82
-10
82 additions, 10 deletions
src/scheme/DiscreteFunctionInterpoler.cpp
src/scheme/DiscreteFunctionInterpoler.hpp
+3
-0
3 additions, 0 deletions
src/scheme/DiscreteFunctionInterpoler.hpp
with
85 additions
and
10 deletions
src/scheme/DiscreteFunctionInterpoler.cpp
+
82
−
10
View file @
3766c8ba
...
...
@@ -3,29 +3,101 @@
#include
<scheme/DiscreteFunctionP0.hpp>
#include
<utils/Exceptions.hpp>
template
<
size_t
Dimension
,
typename
DataType
>
std
::
shared_ptr
<
IDiscreteFunction
>
DiscreteFunctionInterpoler
::
_interpolate
()
const
{
std
::
shared_ptr
mesh
=
std
::
dynamic_pointer_cast
<
const
Mesh
<
Connectivity
<
Dimension
>>>
(
m_mesh
);
return
std
::
make_shared
<
DiscreteFunctionP0
<
Dimension
,
DataType
>>
(
mesh
,
m_function_id
);
}
template
<
size_t
Dimension
>
std
::
shared_ptr
<
IDiscreteFunction
>
DiscreteFunctionInterpoler
::
_interpolate
()
const
{
const
auto
&
function_descriptor
=
m_function_id
.
descriptor
();
Assert
(
function_descriptor
.
domainMappingNode
().
children
[
1
]
->
m_data_type
==
ASTNodeDataType
::
typename_t
);
const
ASTNodeDataType
&
data_type
=
function_descriptor
.
domainMappingNode
().
children
[
1
]
->
m_data_type
.
contentType
();
switch
(
data_type
)
{
case
ASTNodeDataType
::
bool_t
:
{
return
this
->
_interpolate
<
Dimension
,
bool
>
();
}
case
ASTNodeDataType
::
unsigned_int_t
:
{
return
this
->
_interpolate
<
Dimension
,
uint64_t
>
();
}
case
ASTNodeDataType
::
int_t
:
{
return
this
->
_interpolate
<
Dimension
,
int64_t
>
();
}
case
ASTNodeDataType
::
double_t
:
{
return
this
->
_interpolate
<
Dimension
,
double
>
();
}
case
ASTNodeDataType
::
vector_t
:
{
switch
(
data_type
.
dimension
())
{
case
1
:
{
return
this
->
_interpolate
<
Dimension
,
TinyVector
<
1
>>
();
}
case
2
:
{
return
this
->
_interpolate
<
Dimension
,
TinyVector
<
2
>>
();
}
case
3
:
{
return
this
->
_interpolate
<
Dimension
,
TinyVector
<
3
>>
();
}
default
:
{
std
::
ostringstream
os
;
os
<<
"invalid vector dimension "
<<
rang
::
fgB
::
red
<<
data_type
.
dimension
()
<<
rang
::
style
::
reset
;
throw
UnexpectedError
(
os
.
str
());
}
}
}
case
ASTNodeDataType
::
matrix_t
:
{
Assert
(
data_type
.
nbColumns
()
==
data_type
.
nbRows
(),
"undefined matrix type"
);
switch
(
data_type
.
nbColumns
())
{
case
1
:
{
return
this
->
_interpolate
<
Dimension
,
TinyMatrix
<
1
>>
();
}
case
2
:
{
return
this
->
_interpolate
<
Dimension
,
TinyMatrix
<
2
>>
();
}
case
3
:
{
return
this
->
_interpolate
<
Dimension
,
TinyMatrix
<
3
>>
();
}
default
:
{
std
::
ostringstream
os
;
os
<<
"invalid vector dimension "
<<
rang
::
fgB
::
red
<<
data_type
.
dimension
()
<<
rang
::
style
::
reset
;
throw
UnexpectedError
(
os
.
str
());
}
}
}
default
:
{
std
::
ostringstream
os
;
os
<<
"invalid interpolation value type: "
<<
rang
::
fgB
::
red
<<
dataTypeName
(
data_type
)
<<
rang
::
style
::
reset
;
throw
UnexpectedError
(
os
.
str
());
}
}
}
std
::
shared_ptr
<
IDiscreteFunction
>
DiscreteFunctionInterpoler
::
interpolate
()
const
{
std
::
shared_ptr
<
IDiscreteFunction
>
discrete_function
;
switch
(
m_mesh
->
dimension
())
{
case
1
:
{
std
::
shared_ptr
mesh
=
std
::
dynamic_pointer_cast
<
const
Mesh
<
Connectivity
<
1
>>>
(
m_mesh
);
discrete_function
=
std
::
make_shared
<
DiscreteFunctionP0
<
1
,
double
>>
(
mesh
,
m_function_id
);
break
;
return
this
->
_interpolate
<
1
>
();
}
case
2
:
{
std
::
shared_ptr
mesh
=
std
::
dynamic_pointer_cast
<
const
Mesh
<
Connectivity
<
2
>>>
(
m_mesh
);
discrete_function
=
std
::
make_shared
<
DiscreteFunctionP0
<
2
,
double
>>
(
mesh
,
m_function_id
);
break
;
return
this
->
_interpolate
<
2
>
();
}
case
3
:
{
std
::
shared_ptr
mesh
=
std
::
dynamic_pointer_cast
<
const
Mesh
<
Connectivity
<
3
>>>
(
m_mesh
);
discrete_function
=
std
::
make_shared
<
DiscreteFunctionP0
<
3
,
double
>>
(
mesh
,
m_function_id
);
break
;
return
this
->
_interpolate
<
3
>
();
}
default
:
{
throw
UnexpectedError
(
"invalid dimension"
);
}
}
return
discrete_function
;
return
nullptr
;
}
This diff is collapsed.
Click to expand it.
src/scheme/DiscreteFunctionInterpoler.hpp
+
3
−
0
View file @
3766c8ba
...
...
@@ -15,6 +15,9 @@ class DiscreteFunctionInterpoler
std
::
shared_ptr
<
const
IDiscreteFunctionDescriptor
>
m_discrete_function_descriptor
;
const
FunctionSymbolId
m_function_id
;
template
<
size_t
Dimension
,
typename
DataType
>
std
::
shared_ptr
<
IDiscreteFunction
>
_interpolate
()
const
;
template
<
size_t
Dimension
>
std
::
shared_ptr
<
IDiscreteFunction
>
_interpolate
()
const
;
...
...
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