Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
CoMISo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
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)
...
@@ -40,23 +40,19 @@ int main(void)
COMISO
::
SymmetricDirichletProblem
sd_problem
(
n_vertices
);
COMISO
::
SymmetricDirichletProblem
sd_problem
(
n_vertices
);
COMISO
::
SymmetricDirichletProblem
::
IndexVector
indices
(
0
,
1
,
2
);
COMISO
::
SymmetricDirichletProblem
::
IndexVector
indices
(
0
,
1
,
2
);
COMISO
::
SymmetricDirichletProblem
::
ReferencePositionVector2D
positions
;
COMISO
::
SymmetricDirichletProblem
::
ReferencePositionVector2D
positions
;
positions
<<
0
,
0
,
positions
<<
0
,
0
,
// first point
1
,
0
,
1
,
0
,
// second point
0
,
1
;
0
,
1
;
// third point
sd_problem
.
add_triangle
(
indices
,
positions
);
sd_problem
.
add_triangle
(
indices
,
positions
);
COMISO
::
SymmetricDirichletProblem
::
IndexVector
indices2
(
3
,
2
,
1
);
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
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
;
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
;
std
::
cout
<<
"---------- 2) Set up constraints..."
<<
std
::
endl
;
// fix first vertex to origin to fix translational degree of freedom
// fix first vertex to origin to fix translational degree of freedom
sd_problem
.
add_fix_point_constraint
(
0
,
0.0
,
0.0
);
sd_problem
.
add_fix_point_constraint
(
0
,
0.0
,
0.0
);
...
@@ -67,12 +63,12 @@ int main(void)
...
@@ -67,12 +63,12 @@ int main(void)
COMISO
::
SymmetricDirichletProblem
::
VectorD
b
;
COMISO
::
SymmetricDirichletProblem
::
VectorD
b
;
COMISO
::
SymmetricDirichletProblem
::
SMatrixD
A
;
COMISO
::
SymmetricDirichletProblem
::
SMatrixD
A
;
sd_problem
.
get_constraints
(
A
,
b
);
sd_problem
.
get_constraints
(
A
,
b
);
COMISO
::
NewtonSolver
nsolver
(
1e-6
,
1e-9
,
20000
)
;
COMISO
::
NewtonSolver
nsolver
;
nsolver
.
solve
(
&
sd_problem
,
A
,
b
);
nsolver
.
solve
(
&
sd_problem
,
A
,
b
);
// print result
// print result
for
(
unsigned
int
i
=
0
;
i
<
sd_problem
.
x
().
size
()
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
n_vertices
;
++
i
)
std
::
cerr
<<
"
x["
<<
i
<<
"] = "
<<
sd_problem
.
x
()[
i
]
<<
std
::
endl
;
std
::
cerr
<<
"
p"
<<
i
<<
" = ( "
<<
sd_problem
.
x
()[
2
*
i
+
0
]
<<
", "
<<
sd_problem
.
x
()[
2
*
i
+
1
]
<<
")"
<<
std
::
endl
;
return
0
;
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