Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simucene
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
simucene
Commits
ac063d4e
Commit
ac063d4e
authored
5 years ago
by
Erik Strand
Browse files
Options
Downloads
Patches
Plain Diff
Switch to periodic boundary conditions
parent
832649ce
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
simucene/glut_grapher.cpp
+1
-1
1 addition, 1 deletion
simucene/glut_grapher.cpp
simucene/main.cpp
+10
-4
10 additions, 4 deletions
simucene/main.cpp
simucene/matrix_builder.cpp
+6
-0
6 additions, 0 deletions
simucene/matrix_builder.cpp
simucene/matrix_builder.h
+3
-0
3 additions, 0 deletions
simucene/matrix_builder.h
with
20 additions
and
5 deletions
simucene/glut_grapher.cpp
+
1
−
1
View file @
ac063d4e
...
...
@@ -78,7 +78,7 @@ void GlutGrapher::display() const {
//..................................................................................................
void
GlutGrapher
::
idle
()
{
bool
const
wait_to_start
=
tru
e
;
bool
const
wait_to_start
=
fals
e
;
if
(
wait_to_start
&&
frame_
==
0
)
{
std
::
cout
<<
"Press enter to start a 5 second countdown"
<<
std
::
endl
;
do
{}
while
(
std
::
cin
.
get
()
!=
'\n'
);
...
...
This diff is collapsed.
Click to expand it.
simucene/main.cpp
+
10
−
4
View file @
ac063d4e
...
...
@@ -12,12 +12,18 @@ void mouse(int, int, int, int) { exit(0); }
//--------------------------------------------------------------------------------------------------
SparseMatrix
<
Scalar
>
d_x_first_order
(
int32_t
const
dim
)
{
return
MatrixBuilder
(
dim
).
stripe
(
0
,
-
1
).
stripe
(
1
,
1
);
// stripe(0, -1) means add a stripe of -1s on the diagonal
// stripe(1, 1) means add a stripe of 1s one above the diagonal
// element(dim - 1, 0, 1) means add a single 1 at row dim - 1 and column 0
return
MatrixBuilder
(
dim
).
stripe
(
0
,
-
1
).
stripe
(
1
,
1
).
element
(
dim
-
1
,
0
,
1
);
}
//--------------------------------------------------------------------------------------------------
SparseMatrix
<
Scalar
>
d_x2_first_order
(
int32_t
const
dim
)
{
return
MatrixBuilder
(
dim
).
stripe
(
-
1
,
1
).
stripe
(
0
,
-
2
).
stripe
(
1
,
1
);
return
MatrixBuilder
(
dim
)
.
stripe
(
-
1
,
1
).
element
(
0
,
dim
-
1
,
1
)
.
stripe
(
0
,
-
2
)
.
stripe
(
1
,
1
).
element
(
dim
-
1
,
0
,
1
);
}
//--------------------------------------------------------------------------------------------------
...
...
@@ -49,7 +55,7 @@ int main(int, char**) {
Scalar
const
alpha
=
advection_coefficient
*
h
/
d
;
Scalar
const
delta
=
diffusion_coefficient
*
h
/
(
d
*
d
);
// transport matrices
(assumes dirichlet boundary conditions identically zero)
// transport matrices
SparseMatrix
<
Scalar
>
const
advection_matrix
=
alpha
*
d_x_first_order
(
dim
);
SparseMatrix
<
Scalar
>
const
diffusion_matrix
=
delta
*
d_x2_first_order
(
dim
);
SparseMatrix
<
Scalar
>
const
reaction_matrix
=
h
*
diagonal_ones
(
dim
)
*
reaction_coefficients
.
asDiagonal
();
...
...
This diff is collapsed.
Click to expand it.
simucene/matrix_builder.cpp
+
6
−
0
View file @
ac063d4e
...
...
@@ -15,6 +15,12 @@ MatrixBuilder& MatrixBuilder::stripe(int32_t k, Scalar value) {
return
*
this
;
}
//..................................................................................................
MatrixBuilder
&
MatrixBuilder
::
element
(
int32_t
row
,
int32_t
col
,
Scalar
value
)
{
triplets_
.
emplace_back
(
row
,
col
,
value
);
return
*
this
;
}
//..................................................................................................
MatrixBuilder
::
operator
SparseMatrix
<
Scalar
>
()
const
{
SparseMatrix
<
Scalar
>
result
(
n_
,
n_
);
...
...
This diff is collapsed.
Click to expand it.
simucene/matrix_builder.h
+
3
−
0
View file @
ac063d4e
...
...
@@ -11,8 +11,11 @@ namespace simucene {
class
MatrixBuilder
{
public:
MatrixBuilder
(
int32_t
n
)
:
n_
(
n
)
{}
// k = 0 means on the diagonal, 1 means one above the diagonal, -1 one below, etc.
MatrixBuilder
&
stripe
(
int32_t
k
,
Scalar
value
);
MatrixBuilder
&
element
(
int32_t
row
,
int32_t
col
,
Scalar
value
);
operator
SparseMatrix
<
Scalar
>
()
const
;
private
:
...
...
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