Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sdpm
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
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
Aerospace and Mechanical Engineering
sdpm
Commits
23090ab7
Commit
23090ab7
authored
11 months ago
by
Adrien Crovato
Browse files
Options
Downloads
Patches
Plain Diff
Add interface for sdpmDouble
parent
a8636c4d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Version 1.1
Pipeline
#23660
passed
11 months ago
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sdpm/_src/sdpmw.i
+32
-7
32 additions, 7 deletions
sdpm/_src/sdpmw.i
sdpm/api/om.py
+2
-2
2 additions, 2 deletions
sdpm/api/om.py
sdpm/src/sdpm.h
+2
-0
2 additions, 0 deletions
sdpm/src/sdpm.h
with
36 additions
and
9 deletions
sdpm/_src/sdpmw.i
+
32
−
7
View file @
23090ab7
...
...
@@ -90,6 +90,9 @@ threads="1"
// SDPM typemaps
%
include
"
sdpm_def.h
"
// needed to access USE_CODI in SWIG interface
#
ifndef
USE_CODI
typedef
double
sdpmDouble
;
// needed so that SWIG does not convert sdpmDouble to double
#
endif
%
typemap
(
out
)
sdpmDouble
{
#ifndef USE_CODI
$result = PyFloat_FromDouble($1);
...
...
@@ -106,6 +109,14 @@ threads="1"
%
template
(
std_vector_Elementp
)
std
::
vector
<
sdpm
::
Element
*>
;
%
template
(
std_vector_Tagp
)
std
::
vector
<
sdpm
::
Tag
*>
;
%
template
(
std_map_string_Tagp
)
std
::
map
<
std
::
string
,
sdpm
::
Tag
*>
;
%
template
(
std_vector_vector3d
)
std
::
vector
<
sdpmVector3d
>
;
#
ifndef
USE_CODI
%
rename
(
std_vector_double
)
std
::
vector
<
sdpmDouble
>
;
%
rename
(
std_vector_vector_double
)
std
::
vector
<
std
::
vector
<
sdpmDouble
>>
;
#
else
%
template
(
std_vector_sdpmdouble
)
std
::
vector
<
sdpmDouble
>
;
%
template
(
std_vector_vector_sdpmdouble
)
std
::
vector
<
std
::
vector
<
sdpmDouble
>>
;
#
endif
// SDPM
%
include
"
sdpm.h
"
...
...
@@ -134,26 +145,40 @@ threads="1"
// Interface to SDPM types
class
sdpmVector3d
{}
;
%
extend
sdpmVector3d
{
double getitem(int i)
double
__
getitem
__
(int i)
{
if (i > 2)
throw std::runtime_error("sdpmVector3d: index out of range (size 3)!\n");
#ifndef USE_CODI
return (*self)(i);
#else
return (*self)(i).getValue();
#endif
}
std::string __str__()
// use repr instead of str so that iterables also print nicely
std::string __repr__()
{
std::ostringstream out; out << *self; return out.str();
std::ostringstream out; out << *self;
return out.str();
}
}
%pythoncode {
def __getitem__(self, idx):
return self.getitem(idx)
#
ifdef
USE_CODI
class
sdpmDouble
{}
;
%
extend
sdpmDouble
{
double __float__()
{
return (*self).getValue();
}
// use repr instead of str so that iterables also print nicely
std::string __repr__()
{
std::ostringstream out; out << *self;
return out.str();
}
}
#
endif
// Interface to SDPM classes
namespace
sdpm
{
...
...
This diff is collapsed.
Click to expand it.
sdpm/api/om.py
+
2
−
2
View file @
23090ab7
...
...
@@ -80,8 +80,8 @@ class SdpmSolver(om.ExplicitComponent):
self
.
adj
.
solve
()
# Set outputs
for
i
in
range
(
self
.
nf
):
outputs
[
'
Q_re
'
][
i
,
:,
:]
=
np
.
array
(
self
.
sol
.
getGafMatrixRe
(
i
))
outputs
[
'
Q_im
'
][
i
,
:,
:]
=
np
.
array
(
self
.
sol
.
getGafMatrixIm
(
i
))
outputs
[
'
Q_re
'
][
i
,
:,
:]
=
np
.
array
(
self
.
sol
.
getGafMatrixRe
(
i
)
,
dtype
=
float
)
outputs
[
'
Q_im
'
][
i
,
:,
:]
=
np
.
array
(
self
.
sol
.
getGafMatrixIm
(
i
)
,
dtype
=
float
)
class
SdpmBuilder
(
Builder
):
"""
SDPM builder for OpenMDAO
...
...
This diff is collapsed.
Click to expand it.
sdpm/src/sdpm.h
+
2
−
0
View file @
23090ab7
...
...
@@ -35,6 +35,7 @@
#include
<Eigen/Dense>
#include
<complex>
#ifndef SWIG
#ifndef USE_CODI
using
sdpmDouble
=
double
;
#else // USE_CODI
...
...
@@ -51,6 +52,7 @@ using sdpmVector3d = Eigen::Matrix<sdpmDouble, 3, 1>;
using
sdpmMatrixXcd
=
Eigen
::
Matrix
<
sdpmComplex
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
>
;
using
sdpmVectorXcd
=
Eigen
::
Matrix
<
sdpmComplex
,
Eigen
::
Dynamic
,
1
>
;
using
sdpmVector3cd
=
Eigen
::
Matrix
<
sdpmComplex
,
3
,
1
>
;
#endif // SWIG
namespace
sdpm
{
...
...
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