Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
348a2368
Commit
348a2368
authored
10 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
create temp files in same directory as pend.exe
parent
cafc8017
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/solvers/c++/pend.cpp
+18
-10
18 additions, 10 deletions
utils/solvers/c++/pend.cpp
with
18 additions
and
10 deletions
utils/solvers/c++/pend.cpp
+
18
−
10
View file @
348a2368
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
#include
<stdio.h>
#include
<stdio.h>
#include
"onelab.h"
#include
"onelab.h"
void
exportMsh
(
double
le1
,
double
le2
)
void
exportMsh
(
const
std
::
string
&
path
,
double
le1
,
double
le2
)
{
{
FILE
*
mshFile
=
fopen
(
"pend.msh"
,
"w"
);
FILE
*
mshFile
=
fopen
(
(
path
+
"pend.msh"
).
c_str
()
,
"w"
);
if
(
!
mshFile
)
return
;
if
(
!
mshFile
)
return
;
fprintf
(
mshFile
,
"$MeshFormat
\n
2.2 0 8
\n
$EndMeshFormat
\n
"
);
fprintf
(
mshFile
,
"$MeshFormat
\n
2.2 0 8
\n
$EndMeshFormat
\n
"
);
fprintf
(
mshFile
,
"$Nodes
\n
3
\n
1 0 0 0
\n
2 0 %f 0
\n
3 0 %f 0
\n
$EndNodes
\n
"
,
fprintf
(
mshFile
,
"$Nodes
\n
3
\n
1 0 0 0
\n
2 0 %f 0
\n
3 0 %f 0
\n
$EndNodes
\n
"
,
...
@@ -17,9 +17,9 @@ void exportMsh(double le1, double le2)
...
@@ -17,9 +17,9 @@ void exportMsh(double le1, double le2)
fclose
(
mshFile
);
fclose
(
mshFile
);
}
}
void
exportMshOpt
()
void
exportMshOpt
(
const
std
::
string
&
path
)
{
{
FILE
*
optFile
=
fopen
(
"pend.msh.opt"
,
"w"
);
FILE
*
optFile
=
fopen
(
(
path
+
"pend.msh.opt"
).
c_str
()
,
"w"
);
if
(
!
optFile
)
return
;
if
(
!
optFile
)
return
;
fprintf
(
optFile
,
"n = PostProcessing.NbViews - 1;
\n
"
);
fprintf
(
optFile
,
"n = PostProcessing.NbViews - 1;
\n
"
);
fprintf
(
optFile
,
"If(n >= 0)
\n
View[n].ShowScale = 0;
\n
View[n].VectorType = 5;
\n
"
);
fprintf
(
optFile
,
"If(n >= 0)
\n
View[n].ShowScale = 0;
\n
View[n].VectorType = 5;
\n
"
);
...
@@ -29,9 +29,10 @@ void exportMshOpt()
...
@@ -29,9 +29,10 @@ void exportMshOpt()
fclose
(
optFile
);
fclose
(
optFile
);
}
}
void
exportIter
(
int
iter
,
double
t
,
double
x1
,
double
y1
,
double
x2
,
double
y2
)
void
exportIter
(
const
std
::
string
&
path
,
int
iter
,
double
t
,
double
x1
,
double
y1
,
double
x2
,
double
y2
)
{
{
FILE
*
mshFile
=
fopen
(
"pend.msh"
,
"a"
);
FILE
*
mshFile
=
fopen
(
(
path
+
"pend.msh"
).
c_str
()
,
"a"
);
if
(
!
mshFile
)
return
;
if
(
!
mshFile
)
return
;
fprintf
(
mshFile
,
"$NodeData
\n
1
\n\"
motion
\"\n
1
\n\t
%f
\n
3
\n\t
%d
\n
3
\n
"
,
t
,
iter
);
fprintf
(
mshFile
,
"$NodeData
\n
1
\n\"
motion
\"\n
1
\n\t
%f
\n
3
\n\t
%d
\n
3
\n
"
,
t
,
iter
);
fprintf
(
mshFile
,
"
\t
3
\n\t
1 0 0 0
\n\t
2 %f %f 0
\n\t
3 %f %f 0
\n
$EndNodeData
\n
"
,
fprintf
(
mshFile
,
"
\t
3
\n\t
1 0 0 0
\n\t
2 %f %f 0
\n\t
3 %f %f 0
\n
$EndNodeData
\n
"
,
...
@@ -95,6 +96,13 @@ int main(int argc, char **argv)
...
@@ -95,6 +96,13 @@ int main(int argc, char **argv)
c
->
get
(
ns
,
name
+
"/Action"
);
c
->
get
(
ns
,
name
+
"/Action"
);
if
(
ns
.
size
())
action
=
ns
[
0
].
getValue
();
if
(
ns
.
size
())
action
=
ns
[
0
].
getValue
();
std
::
string
path
(
argv
[
0
]);
int
islash
=
(
int
)
path
.
find_last_of
(
"/
\\
"
);
if
(
islash
>
0
)
path
=
path
.
substr
(
0
,
islash
+
1
);
else
path
=
""
;
double
g
=
9.8
;
// acceleration of gravity
double
g
=
9.8
;
// acceleration of gravity
double
m
=
0.3
;
// mass of pendulum balls
double
m
=
0.3
;
// mass of pendulum balls
...
@@ -157,7 +165,7 @@ int main(int argc, char **argv)
...
@@ -157,7 +165,7 @@ int main(int argc, char **argv)
time
+=
dt
;
time
+=
dt
;
refr
+=
dt
;
refr
+=
dt
;
exportMshOpt
();
exportMshOpt
(
path
);
if
(
refr
>=
refresh
){
if
(
refr
>=
refresh
){
refr
=
0
;
refr
=
0
;
...
@@ -180,9 +188,9 @@ int main(int argc, char **argv)
...
@@ -180,9 +188,9 @@ int main(int argc, char **argv)
c
->
get
(
ns
,
name
+
"/Action"
);
c
->
get
(
ns
,
name
+
"/Action"
);
if
(
ns
.
size
()
&&
ns
[
0
].
getValue
()
==
"stop"
)
break
;
if
(
ns
.
size
()
&&
ns
[
0
].
getValue
()
==
"stop"
)
break
;
exportMsh
(
l1
,
l2
);
exportMsh
(
path
,
l1
,
l2
);
exportIter
(
iter
,
time
,
x1
,
y1
+
l1
,
x2
,
y2
+
l1
+
l2
);
exportIter
(
path
,
iter
,
time
,
x1
,
y1
+
l1
,
x2
,
y2
+
l1
+
l2
);
c
->
sendMergeFileRequest
(
"pend.msh"
);
c
->
sendMergeFileRequest
(
path
+
"pend.msh"
);
iter
+=
1
;
iter
+=
1
;
}
}
}
}
...
...
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