Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CoMISo
CoMISo
Commits
584b840f
Commit
584b840f
authored
Aug 30, 2019
by
Max Lyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update symmetric dirichlet example
parent
609c8410
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
Examples/small_symmetric_dirichlet/main.cc
Examples/small_symmetric_dirichlet/main.cc
+10
-14
No files found.
Examples/small_symmetric_dirichlet/main.cc
View file @
584b840f
...
...
@@ -40,23 +40,19 @@ int main(void)
COMISO
::
SymmetricDirichletProblem
sd_problem
(
n_vertices
);
COMISO
::
SymmetricDirichletProblem
::
IndexVector
indices
(
0
,
1
,
2
);
COMISO
::
SymmetricDirichletProblem
::
ReferencePositionVector2D
positions
;
positions
<<
0
,
0
,
1
,
0
,
0
,
1
;
positions
<<
0
,
0
,
// first point
1
,
0
,
// second point
0
,
1
;
// third point
sd_problem
.
add_triangle
(
indices
,
positions
);
COMISO
::
SymmetricDirichletProblem
::
IndexVector
indices2
(
3
,
2
,
1
);
sd_problem
.
add_triangle
(
indices2
,
positions
);
// same reference positions can be used because we want both triangles to be isosceles
std
::
vector
<
double
>
initial_solution
{
0.0
,
0.0
,
2
,
0.0
,
0.0
,
2.0
,
3.0
,
4.0
};
std
::
vector
<
double
>
initial_solution
{
0.0
,
0.0
,
2.0
,
0.0
,
2.0
,
2.0
,
3.0
,
4.0
};
sd_problem
.
x
()
=
initial_solution
;
auto
f
=
sd_problem
.
eval_f
(
initial_solution
.
data
());
std
::
vector
<
double
>
grad
(
8
);
sd_problem
.
eval_gradient
(
initial_solution
.
data
(),
grad
.
data
());
std
::
cout
<<
"energy: "
<<
f
<<
std
::
endl
;
std
::
cout
<<
"grad: "
<<
grad
[
0
]
<<
", "
<<
grad
[
1
]
<<
", "
<<
grad
[
2
]
<<
", "
<<
grad
[
3
]
<<
", "
<<
grad
[
4
]
<<
", "
<<
grad
[
5
]
<<
", "
<<
grad
[
6
]
<<
", "
<<
grad
[
7
]
<<
std
::
endl
;
std
::
cout
<<
"---------- 2) Set up constraints..."
<<
std
::
endl
;
// fix first vertex to origin to fix translational degree of freedom
sd_problem
.
add_fix_point_constraint
(
0
,
0.0
,
0.0
);
...
...
@@ -67,12 +63,12 @@ int main(void)
COMISO
::
SymmetricDirichletProblem
::
VectorD
b
;
COMISO
::
SymmetricDirichletProblem
::
SMatrixD
A
;
sd_problem
.
get_constraints
(
A
,
b
);
COMISO
::
NewtonSolver
nsolver
(
1e-6
,
1e-9
,
20000
)
;
COMISO
::
NewtonSolver
nsolver
;
nsolver
.
solve
(
&
sd_problem
,
A
,
b
);
// print result
for
(
unsigned
int
i
=
0
;
i
<
sd_problem
.
x
().
size
()
;
++
i
)
std
::
cerr
<<
"
x[
"
<<
i
<<
"
]
= "
<<
sd_problem
.
x
()[
i
]
<<
std
::
endl
;
for
(
unsigned
int
i
=
0
;
i
<
n_vertices
;
++
i
)
std
::
cerr
<<
"
p
"
<<
i
<<
" =
( "
<<
sd_problem
.
x
()[
2
*
i
+
0
]
<<
",
"
<<
sd_problem
.
x
()[
2
*
i
+
1
]
<<
")"
<<
std
::
endl
;
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment