Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
amfe-solvers
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
amfe-solvers
Commits
72e01dc3
Commit
72e01dc3
authored
1 year ago
by
Boman Romain
Browse files
Options
Downloads
Patches
Plain Diff
fix indentation of lambdas
parent
c80ce341
No related branches found
No related tags found
1 merge request
!2
Upgrade docker image & clang-format
Pipeline
#16296
passed
1 year ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
heat/src/wSolver.cpp
+127
-109
127 additions, 109 deletions
heat/src/wSolver.cpp
waves/src/wTimeIntegration.cpp
+65
-55
65 additions, 55 deletions
waves/src/wTimeIntegration.cpp
with
192 additions
and
164 deletions
heat/src/wSolver.cpp
+
127
−
109
View file @
72e01dc3
...
@@ -256,47 +256,50 @@ void Solver::start(MshExport *mshWriter)
...
@@ -256,47 +256,50 @@ void Solver::start(MshExport *mshWriter)
Eigen
::
Vector2d
qM
=
Eigen
::
Vector2d
::
Zero
();
Eigen
::
Vector2d
qM
=
Eigen
::
Vector2d
::
Zero
();
for
(
auto
mat
:
pbl
->
media
)
for
(
auto
mat
:
pbl
->
media
)
{
{
tbb
::
parallel_for_each
(
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
[
&
](
Element
*
e
)
tbb
::
parallel_for_each
(
{
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
if
(
e
->
type
()
!=
ElType
::
TRI3
)
[
&
](
Element
*
e
)
return
;
{
//std::cout << "processing element #" << e->no << "\n";
if
(
e
->
type
()
!=
ElType
::
TRI3
)
return
;
// std::cout << "processing element #" << e->no << "\n";
// (flux moyen . volume) sur l'element
// (flux moyen . volume) sur l'element
Eigen
::
VectorXd
qV
=
HeatTerm
::
computeFlux
(
*
e
,
T1
,
*
mat
->
k
);
Eigen
::
VectorXd
qV
=
HeatTerm
::
computeFlux
(
*
e
,
T1
,
*
mat
->
k
);
double
V
=
e
->
getVol
();
double
V
=
e
->
getVol
();
if
(
save
)
if
(
save
)
{
{
// gradient of T at GP 0
// gradient of T at GP 0
Eigen
::
VectorXd
grad
=
e
->
computeGradient
(
T1
,
0
);
Eigen
::
VectorXd
grad
=
e
->
computeGradient
(
T1
,
0
);
int
i
=
e
->
no
-
1
;
int
i
=
e
->
no
-
1
;
gradT_x
[
i
]
=
grad
(
0
);
gradT_x
[
i
]
=
grad
(
0
);
gradT_y
[
i
]
=
grad
(
1
);
gradT_y
[
i
]
=
grad
(
1
);
gradT
[
i
]
=
Eigen
::
Vector3d
(
grad
(
0
),
grad
(
1
),
0
);
gradT
[
i
]
=
Eigen
::
Vector3d
(
grad
(
0
),
grad
(
1
),
0
);
// mean q over the element
// mean q over the element
kgradT
[
i
]
=
Eigen
::
Vector3d
(
qV
(
0
)
/
V
,
qV
(
1
)
/
V
,
0
);
kgradT
[
i
]
=
Eigen
::
Vector3d
(
qV
(
0
)
/
V
,
qV
(
1
)
/
V
,
0
);
// mean k over the element
// mean k over the element
Eigen
::
MatrixXd
kmean
=
HeatTerm
::
computeMatrix
(
*
e
,
T1
,
*
mat
->
k
)
/
V
;
Eigen
::
MatrixXd
kmean
=
HeatTerm
::
computeMatrix
(
*
e
,
T1
,
*
mat
->
k
)
/
V
;
kmoy11
[
i
]
=
kmean
(
0
,
0
);
kmoy11
[
i
]
=
kmean
(
0
,
0
);
kmoy22
[
i
]
=
kmean
(
1
,
1
);
kmoy22
[
i
]
=
kmean
(
1
,
1
);
kmoy12
[
i
]
=
kmean
(
0
,
1
);
kmoy12
[
i
]
=
kmean
(
0
,
1
);
kmoy21
[
i
]
=
kmean
(
1
,
0
);
kmoy21
[
i
]
=
kmean
(
1
,
0
);
// tensor
// tensor
kmean
.
conservativeResize
(
3
,
3
);
kmean
.
conservativeResize
(
3
,
3
);
kmean
.
row
(
2
)
=
Eigen
::
RowVector3d
::
Zero
();
kmean
.
row
(
2
)
=
Eigen
::
RowVector3d
::
Zero
();
kmean
.
col
(
2
)
=
Eigen
::
Vector3d
::
Zero
();
kmean
.
col
(
2
)
=
Eigen
::
Vector3d
::
Zero
();
kmoy
[
i
]
=
kmean
;
kmoy
[
i
]
=
kmean
;
//std::cout << kmean << '\n';
//
std::cout << kmean << '\n';
}
}
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
Vtot
+=
V
;
Vtot
+=
V
;
qM
+=
qV
;
// qM = qM + qV });
qM
+=
qV
;
// qM = qM + qV
});
}
}
qM
/=
Vtot
;
qM
/=
Vtot
;
...
@@ -371,25 +374,28 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map
...
@@ -371,25 +374,28 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map
{
{
if
(
verbose
>
1
)
if
(
verbose
>
1
)
std
::
cout
<<
"
\t
processing "
<<
*
mat
<<
'\n'
;
std
::
cout
<<
"
\t
processing "
<<
*
mat
<<
'\n'
;
tbb
::
parallel_for_each
(
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
[
&
](
Element
*
e
)
tbb
::
parallel_for_each
(
{
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
if
(
e
->
type
()
!=
ElType
::
TRI3
)
[
&
](
Element
*
e
)
return
;
{
//std::cout << "processing element #" << e->no << "\n";
if
(
e
->
type
()
!=
ElType
::
TRI3
)
return
;
// std::cout << "processing element #" << e->no << "\n";
Eigen
::
MatrixXd
Ke
=
HeatTerm
::
build
(
*
e
,
T1
,
*
mat
->
k
,
false
);
Eigen
::
MatrixXd
Ke
=
HeatTerm
::
build
(
*
e
,
T1
,
*
mat
->
k
,
false
);
// assembly
// assembly
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
{
Node
*
nodi
=
e
->
nodes
[
ii
];
for
(
size_t
jj
=
0
;
jj
<
e
->
nodes
.
size
();
++
jj
)
{
{
Node
*
nodj
=
e
->
nodes
[
jj
];
Node
*
nodi
=
e
->
nodes
[
ii
];
T
.
push_back
(
Eigen
::
Triplet
<
double
>
(
rows
[
nodi
->
row
],
nodj
->
row
,
Ke
(
ii
,
jj
)));
for
(
size_t
jj
=
0
;
jj
<
e
->
nodes
.
size
();
++
jj
)
{
Node
*
nodj
=
e
->
nodes
[
jj
];
T
.
push_back
(
Eigen
::
Triplet
<
double
>
(
rows
[
nodi
->
row
],
nodj
->
row
,
Ke
(
ii
,
jj
)));
}
}
}
}
});
});
}
}
}
}
else
else
...
@@ -522,25 +528,28 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map
...
@@ -522,25 +528,28 @@ void Solver::buildK(Eigen::SparseMatrix<double, Eigen::RowMajor> &K2, Eigen::Map
for
(
auto
mat
:
pbl
->
media
)
for
(
auto
mat
:
pbl
->
media
)
{
{
// std::cout << "\tprocessing " << *mat << '\n';
// std::cout << "\tprocessing " << *mat << '\n';
tbb
::
parallel_for_each
(
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
[
&
](
Element
*
e
)
tbb
::
parallel_for_each
(
{
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
if
(
e
->
type
()
!=
ElType
::
TRI3
)
[
&
](
Element
*
e
)
return
;
{
//std::cout << "processing element #" << e->no << "\n";
if
(
e
->
type
()
!=
ElType
::
TRI3
)
return
;
// std::cout << "processing element #" << e->no << "\n";
// ** Ce matrix => K matrix
// ** Ce matrix => K matrix
Eigen
::
VectorXd
Ce
=
HeatTerm
::
build
(
*
e
,
T1
,
Fct0C
(
1.0
));
Eigen
::
VectorXd
Ce
=
HeatTerm
::
build
(
*
e
,
T1
,
Fct0C
(
1.0
));
// assembly
// assembly
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
for
(
size_t
jj
=
0
;
jj
<
e
->
nodes
.
size
();
++
jj
)
for
(
size_t
jj
=
0
;
jj
<
e
->
nodes
.
size
();
++
jj
)
{
{
Node
*
nodj
=
e
->
nodes
[
jj
];
Node
*
nodj
=
e
->
nodes
[
jj
];
K2
.
coeffRef
(
n1
->
row
,
nodj
->
row
)
+=
(
mat
->
rhoc
)
*
Ce
(
jj
);
K2
.
coeffRef
(
n1
->
row
,
nodj
->
row
)
+=
(
mat
->
rhoc
)
*
Ce
(
jj
);
Vtot
+=
Ce
(
jj
);
Vtot
+=
Ce
(
jj
);
rhocM_Vtot
+=
(
mat
->
rhoc
)
*
Ce
(
jj
);
rhocM_Vtot
+=
(
mat
->
rhoc
)
*
Ce
(
jj
);
}
});
}
});
}
}
rhs
(
n1
->
row
)
=
rhocM_Vtot
*
TM
;
rhs
(
n1
->
row
)
=
rhocM_Vtot
*
TM
;
if
(
verbose
>
1
)
if
(
verbose
>
1
)
...
@@ -593,21 +602,24 @@ void Solver::buildqint(Eigen::VectorXd &qint)
...
@@ -593,21 +602,24 @@ void Solver::buildqint(Eigen::VectorXd &qint)
{
{
if
(
verbose
>
1
)
if
(
verbose
>
1
)
std
::
cout
<<
"
\t
processing "
<<
*
mat
<<
'\n'
;
std
::
cout
<<
"
\t
processing "
<<
*
mat
<<
'\n'
;
tbb
::
parallel_for_each
(
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
[
&
](
Element
*
e
)
tbb
::
parallel_for_each
(
{
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
if
(
e
->
type
()
!=
ElType
::
TRI3
)
[
&
](
Element
*
e
)
return
;
{
//std::cout << "processing element #" << e->no << "\n";
if
(
e
->
type
()
!=
ElType
::
TRI3
)
return
;
// std::cout << "processing element #" << e->no << "\n";
Eigen
::
VectorXd
qe
=
HeatTerm
::
build2
(
*
e
,
T1
,
*
mat
->
k
);
Eigen
::
VectorXd
qe
=
HeatTerm
::
build2
(
*
e
,
T1
,
*
mat
->
k
);
// assembly
// assembly
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
{
{
Node
*
nodi
=
e
->
nodes
[
ii
];
Node
*
nodi
=
e
->
nodes
[
ii
];
qint
(
nodi
->
row
)
+=
qe
(
ii
);
qint
(
nodi
->
row
)
+=
qe
(
ii
);
}
});
}
});
}
}
if
(
!
pbl
->
dBCs
.
empty
())
if
(
!
pbl
->
dBCs
.
empty
())
...
@@ -642,23 +654,26 @@ void Solver::builds(Eigen::Map<Eigen::VectorXd> &s)
...
@@ -642,23 +654,26 @@ void Solver::builds(Eigen::Map<Eigen::VectorXd> &s)
for
(
auto
src
:
pbl
->
srcs
)
for
(
auto
src
:
pbl
->
srcs
)
{
{
// std::cout << "\tprocessing " << *src << '\n';
// std::cout << "\tprocessing " << *src << '\n';
tbb
::
parallel_for_each
(
src
->
tag
->
elems
.
begin
(),
src
->
tag
->
elems
.
end
(),
[
&
](
Element
*
e
)
tbb
::
parallel_for_each
(
{
src
->
tag
->
elems
.
begin
(),
src
->
tag
->
elems
.
end
(),
if
(
e
->
type
()
!=
ElType
::
TRI3
&&
e
->
type
()
!=
ElType
::
LINE2
)
[
&
](
Element
*
e
)
return
;
{
//std::cout << "processing element #" << e->no << "\n";
if
(
e
->
type
()
!=
ElType
::
TRI3
&&
e
->
type
()
!=
ElType
::
LINE2
)
return
;
// std::cout << "processing element #" << e->no << "\n";
// ** se vector => s vector
// ** se vector => s vector
Eigen
::
VectorXd
se
=
HeatTerm
::
build
(
*
e
,
T1
,
*
src
->
f
);
Eigen
::
VectorXd
se
=
HeatTerm
::
build
(
*
e
,
T1
,
*
src
->
f
);
// assembly
// assembly
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
{
{
Node
*
nodi
=
e
->
nodes
[
ii
];
Node
*
nodi
=
e
->
nodes
[
ii
];
s
(
nodi
->
row
)
+=
se
(
ii
);
s
(
nodi
->
row
)
+=
se
(
ii
);
}
});
}
});
}
}
if
(
verbose
>
1
)
if
(
verbose
>
1
)
...
@@ -681,23 +696,26 @@ void Solver::buildq(Eigen::Map<Eigen::VectorXd> &q)
...
@@ -681,23 +696,26 @@ void Solver::buildq(Eigen::Map<Eigen::VectorXd> &q)
for
(
auto
bnd
:
pbl
->
bnds
)
for
(
auto
bnd
:
pbl
->
bnds
)
{
{
// std::cout << "\tprocessing " << *src << '\n';
// std::cout << "\tprocessing " << *src << '\n';
tbb
::
parallel_for_each
(
bnd
->
tag
->
elems
.
begin
(),
bnd
->
tag
->
elems
.
end
(),
[
&
](
Element
*
e
)
tbb
::
parallel_for_each
(
{
bnd
->
tag
->
elems
.
begin
(),
bnd
->
tag
->
elems
.
end
(),
if
(
e
->
type
()
!=
ElType
::
LINE2
)
[
&
](
Element
*
e
)
return
;
{
//std::cout << "processing element #" << e->no << "\n";
if
(
e
->
type
()
!=
ElType
::
LINE2
)
return
;
// std::cout << "processing element #" << e->no << "\n";
// ** qe vector => q vector
// ** qe vector => q vector
Eigen
::
VectorXd
qe
=
HeatTerm
::
build
(
*
e
,
T1
,
*
bnd
->
f
);
Eigen
::
VectorXd
qe
=
HeatTerm
::
build
(
*
e
,
T1
,
*
bnd
->
f
);
// assembly
// assembly
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
{
{
Node
*
nodi
=
e
->
nodes
[
ii
];
Node
*
nodi
=
e
->
nodes
[
ii
];
q
(
nodi
->
row
)
+=
qe
(
ii
);
q
(
nodi
->
row
)
+=
qe
(
ii
);
}
});
}
});
}
}
if
(
verbose
>
1
)
if
(
verbose
>
1
)
...
...
This diff is collapsed.
Click to expand it.
waves/src/wTimeIntegration.cpp
+
65
−
55
View file @
72e01dc3
...
@@ -102,27 +102,30 @@ void TimeIntegration::buildS(Eigen::SparseMatrix<double, Eigen::RowMajor> &S2)
...
@@ -102,27 +102,30 @@ void TimeIntegration::buildS(Eigen::SparseMatrix<double, Eigen::RowMajor> &S2)
{
{
std
::
cout
<<
"
\t
processing "
<<
*
bnd
<<
'\n'
;
std
::
cout
<<
"
\t
processing "
<<
*
bnd
<<
'\n'
;
std
::
cout
<<
"normal="
<<
static_cast
<
Quad4
*>
(
bnd
->
tag
->
elems
[
0
])
->
getNormal
()
<<
'\n'
;
std
::
cout
<<
"normal="
<<
static_cast
<
Quad4
*>
(
bnd
->
tag
->
elems
[
0
])
->
getNormal
()
<<
'\n'
;
tbb
::
parallel_for_each
(
bnd
->
tag
->
elems
.
begin
(),
bnd
->
tag
->
elems
.
end
(),
[
&
](
Element
*
e
)
tbb
::
parallel_for_each
(
{
bnd
->
tag
->
elems
.
begin
(),
bnd
->
tag
->
elems
.
end
(),
if
(
e
->
type
()
!=
ElType
::
QUAD4
)
[
&
](
Element
*
e
)
return
;
{
//std::cout << "processing element #" << e->no << "\n";
if
(
e
->
type
()
!=
ElType
::
QUAD4
)
return
;
// std::cout << "processing element #" << e->no << "\n";
// ** Se matrix => S vector
// ** Se matrix => S vector
Eigen
::
MatrixXd
Se
=
WaveTerm
::
buildM
(
*
e
);
Eigen
::
MatrixXd
Se
=
WaveTerm
::
buildM
(
*
e
);
// assembly
// assembly
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
{
Node
*
nodi
=
e
->
nodes
[
ii
];
for
(
size_t
jj
=
0
;
jj
<
e
->
nodes
.
size
();
++
jj
)
{
{
Node
*
nodj
=
e
->
nodes
[
jj
];
Node
*
nodi
=
e
->
nodes
[
ii
];
T
.
push_back
(
Eigen
::
Triplet
<
double
>
(
nodi
->
row
,
nodj
->
row
,
bnd
->
c
*
Se
(
ii
,
jj
)));
for
(
size_t
jj
=
0
;
jj
<
e
->
nodes
.
size
();
++
jj
)
{
Node
*
nodj
=
e
->
nodes
[
jj
];
T
.
push_back
(
Eigen
::
Triplet
<
double
>
(
nodi
->
row
,
nodj
->
row
,
bnd
->
c
*
Se
(
ii
,
jj
)));
}
}
}
}
});
});
}
}
// Build, clean and turn to compressed row format
// Build, clean and turn to compressed row format
S2
.
setFromTriplets
(
T
.
begin
(),
T
.
end
());
S2
.
setFromTriplets
(
T
.
begin
(),
T
.
end
());
...
@@ -158,31 +161,34 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM
...
@@ -158,31 +161,34 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM
for
(
auto
mat
:
pbl
->
media
)
for
(
auto
mat
:
pbl
->
media
)
{
{
std
::
cout
<<
"
\t
processing "
<<
*
mat
<<
'\n'
;
std
::
cout
<<
"
\t
processing "
<<
*
mat
<<
'\n'
;
tbb
::
parallel_for_each
(
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
[
&
](
Element
*
e
)
tbb
::
parallel_for_each
(
{
mat
->
tag
->
elems
.
begin
(),
mat
->
tag
->
elems
.
end
(),
if
(
e
->
type
()
!=
ElType
::
HEX8
)
[
&
](
Element
*
e
)
return
;
{
//std::cout << "processing element #" << e->no << "\n";
if
(
e
->
type
()
!=
ElType
::
HEX8
)
return
;
// std::cout << "processing element #" << e->no << "\n";
// ** Me matrix => Md vector
// ** Me matrix => Md vector
Eigen
::
MatrixXd
Me
=
WaveTerm
::
buildM
(
*
e
);
Eigen
::
MatrixXd
Me
=
WaveTerm
::
buildM
(
*
e
);
// ** Ke matrix => K matrix
// ** Ke matrix => K matrix
Eigen
::
MatrixXd
Ke
=
WaveTerm
::
buildK
(
*
e
,
u
);
Eigen
::
MatrixXd
Ke
=
WaveTerm
::
buildK
(
*
e
,
u
);
// assembly
// assembly
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
tbb
::
spin_mutex
::
scoped_lock
lock
(
mutex
);
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
for
(
size_t
ii
=
0
;
ii
<
e
->
nodes
.
size
();
++
ii
)
{
Node
*
nodi
=
e
->
nodes
[
ii
];
for
(
size_t
jj
=
0
;
jj
<
e
->
nodes
.
size
();
++
jj
)
{
{
Node
*
nodj
=
e
->
nodes
[
jj
];
Node
*
nodi
=
e
->
nodes
[
ii
];
T
.
push_back
(
Eigen
::
Triplet
<
double
>
(
nodi
->
row
,
nodj
->
row
,
(
mat
->
c
*
mat
->
c
)
*
Ke
(
ii
,
jj
)));
for
(
size_t
jj
=
0
;
jj
<
e
->
nodes
.
size
();
++
jj
)
Md
[
nodi
->
row
]
+=
Me
(
ii
,
jj
);
{
Node
*
nodj
=
e
->
nodes
[
jj
];
T
.
push_back
(
Eigen
::
Triplet
<
double
>
(
nodi
->
row
,
nodj
->
row
,
(
mat
->
c
*
mat
->
c
)
*
Ke
(
ii
,
jj
)));
Md
[
nodi
->
row
]
+=
Me
(
ii
,
jj
);
}
}
}
}
});
});
}
}
// Build, clean and turn to compressed row format
// Build, clean and turn to compressed row format
K2
.
setFromTriplets
(
T
.
begin
(),
T
.
end
());
K2
.
setFromTriplets
(
T
.
begin
(),
T
.
end
());
...
@@ -194,7 +200,8 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM
...
@@ -194,7 +200,8 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM
std
::
cout
<<
"[cpu] "
<<
chrono1
<<
'\n'
;
std
::
cout
<<
"[cpu] "
<<
chrono1
<<
'\n'
;
}
}
/*void TimeIntegration::build(MATTYPE type, Eigen::SparseMatrix<double, Eigen::RowMajor> &A2)
/*
void TimeIntegration::build(MATTYPE type, Eigen::SparseMatrix<double, Eigen::RowMajor> &A2)
{
{
tbb::spin_mutex mutex;
tbb::spin_mutex mutex;
tbb::global_control control(tbb::global_control::max_allowed_parallelism, nthreads); // TODO mettre ça ailleurs...
tbb::global_control control(tbb::global_control::max_allowed_parallelism, nthreads); // TODO mettre ça ailleurs...
...
@@ -207,24 +214,26 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM
...
@@ -207,24 +214,26 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM
for (auto mat : pbl->media)
for (auto mat : pbl->media)
{
{
std::cout << "\tprocessing " << *mat << '\n';
std::cout << "\tprocessing " << *mat << '\n';
tbb::parallel_for_each(mat->tag->elems.begin(), mat->tag->elems.end(),
tbb::parallel_for_each(
[&](Element *e) {
mat->tag->elems.begin(), mat->tag->elems.end(),
if (e->type() != ElType::HEX8)
[&](Element *e)
return;
{
Eigen::MatrixXd Ae = e->build(type);
if (e->type() != ElType::HEX8)
return;
// assembly
Eigen::MatrixXd Ae = e->build(type);
tbb::spin_mutex::scoped_lock lock(mutex);
for (size_t ii = 0; ii < e->nodes.size(); ++ii)
// assembly
{
tbb::spin_mutex::scoped_lock lock(mutex);
Node *nodi = e->nodes[ii];
for (size_t ii = 0; ii < e->nodes.size(); ++ii)
for (size_t jj = 0; jj < e->nodes.size(); ++jj)
{
{
Node *nodi = e->nodes[ii];
Node *nodj = e->nodes[jj];
for (size_t jj = 0; jj < e->nodes.size(); ++jj)
T.push_back(Eigen::Triplet<double>(nodi->row, nodj->row, Ae(ii, jj)));
{
}
Node *nodj = e->nodes[jj];
}
T.push_back(Eigen::Triplet<double>(nodi->row, nodj->row, Ae(ii, jj)));
});
}
}
});
}
}
// Build, clean and turn to compressed row format
// Build, clean and turn to compressed row format
A2.setFromTriplets(T.begin(), T.end());
A2.setFromTriplets(T.begin(), T.end());
...
@@ -234,7 +243,8 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM
...
@@ -234,7 +243,8 @@ void TimeIntegration::buildKM_tbb_lambda(Eigen::SparseMatrix<double, Eigen::RowM
std::cout << "S (" << A2.rows() << "," << A2.cols() << ") nnz=" << A2.nonZeros() << "\n";
std::cout << "S (" << A2.rows() << "," << A2.cols() << ") nnz=" << A2.nonZeros() << "\n";
chrono1.read();
chrono1.read();
std::cout << "[cpu] " << chrono1 << '\n';
std::cout << "[cpu] " << chrono1 << '\n';
}*/
}
*/
void
TimeIntegration
::
write
(
std
::
ostream
&
out
)
const
void
TimeIntegration
::
write
(
std
::
ostream
&
out
)
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