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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
faf88978
Commit
faf88978
authored
12 years ago
by
Francois Henrotte
Browse files
Options
Downloads
Patches
Plain Diff
loop index stored in onelab::number
parent
c4b47a4d
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Common/onelab.h
+11
-1
11 additions, 1 deletion
Common/onelab.h
Common/onelabUtils.cpp
+24
-12
24 additions, 12 deletions
Common/onelabUtils.cpp
Fltk/onelabWindow.cpp
+5
-1
5 additions, 1 deletion
Fltk/onelabWindow.cpp
with
40 additions
and
14 deletions
Common/onelab.h
+
11
−
1
View file @
faf88978
...
@@ -268,17 +268,21 @@ namespace onelab{
...
@@ -268,17 +268,21 @@ namespace onelab{
class
number
:
public
parameter
{
class
number
:
public
parameter
{
private:
private:
double
_value
,
_min
,
_max
,
_step
;
double
_value
,
_min
,
_max
,
_step
;
// when in a loop, indicates current index in the vector _choices
// is -1 when not in a loop
int
_index
;
std
::
vector
<
double
>
_choices
;
std
::
vector
<
double
>
_choices
;
std
::
map
<
double
,
std
::
string
>
_valueLabels
;
std
::
map
<
double
,
std
::
string
>
_valueLabels
;
public:
public:
number
(
const
std
::
string
&
name
=
""
,
double
value
=
0.
,
number
(
const
std
::
string
&
name
=
""
,
double
value
=
0.
,
const
std
::
string
&
label
=
""
,
const
std
::
string
&
help
=
""
)
const
std
::
string
&
label
=
""
,
const
std
::
string
&
help
=
""
)
:
parameter
(
name
,
label
,
help
),
_value
(
value
),
:
parameter
(
name
,
label
,
help
),
_value
(
value
),
_min
(
-
maxNumber
()),
_max
(
maxNumber
()),
_step
(
0.
)
{}
_min
(
-
maxNumber
()),
_max
(
maxNumber
()),
_step
(
0.
)
,
_index
(
0
)
{}
void
setValue
(
double
value
){
_value
=
value
;
}
void
setValue
(
double
value
){
_value
=
value
;
}
void
setMin
(
double
min
){
_min
=
min
;
}
void
setMin
(
double
min
){
_min
=
min
;
}
void
setMax
(
double
max
){
_max
=
max
;
}
void
setMax
(
double
max
){
_max
=
max
;
}
void
setStep
(
double
step
){
_step
=
step
;
}
void
setStep
(
double
step
){
_step
=
step
;
}
void
setIndex
(
int
index
){
_index
=
index
;
}
void
setChoices
(
const
std
::
vector
<
double
>
&
choices
){
_choices
=
choices
;
}
void
setChoices
(
const
std
::
vector
<
double
>
&
choices
){
_choices
=
choices
;
}
void
setChoiceLabels
(
const
std
::
vector
<
std
::
string
>
&
labels
)
void
setChoiceLabels
(
const
std
::
vector
<
std
::
string
>
&
labels
)
{
{
...
@@ -299,6 +303,7 @@ namespace onelab{
...
@@ -299,6 +303,7 @@ namespace onelab{
double
getMin
()
const
{
return
_min
;
}
double
getMin
()
const
{
return
_min
;
}
double
getMax
()
const
{
return
_max
;
}
double
getMax
()
const
{
return
_max
;
}
double
getStep
()
const
{
return
_step
;
}
double
getStep
()
const
{
return
_step
;
}
int
getIndex
()
const
{
return
_index
;
}
const
std
::
vector
<
double
>
&
getChoices
()
const
{
return
_choices
;
}
const
std
::
vector
<
double
>
&
getChoices
()
const
{
return
_choices
;
}
const
std
::
map
<
double
,
std
::
string
>
&
getValueLabels
()
const
const
std
::
map
<
double
,
std
::
string
>
&
getValueLabels
()
const
{
{
...
@@ -325,6 +330,7 @@ namespace onelab{
...
@@ -325,6 +330,7 @@ namespace onelab{
setMin
(
p
.
getMin
());
setMin
(
p
.
getMin
());
setMax
(
p
.
getMax
());
setMax
(
p
.
getMax
());
setStep
(
p
.
getStep
());
setStep
(
p
.
getStep
());
setIndex
(
p
.
getIndex
());
setChoices
(
p
.
getChoices
());
setChoices
(
p
.
getChoices
());
setValueLabels
(
p
.
getValueLabels
());
setValueLabels
(
p
.
getValueLabels
());
}
}
...
@@ -333,6 +339,7 @@ namespace onelab{
...
@@ -333,6 +339,7 @@ namespace onelab{
std
::
ostringstream
sstream
;
std
::
ostringstream
sstream
;
sstream
<<
parameter
::
toChar
()
<<
_value
<<
charSep
()
sstream
<<
parameter
::
toChar
()
<<
_value
<<
charSep
()
<<
_min
<<
charSep
()
<<
_max
<<
charSep
()
<<
_step
<<
charSep
()
<<
_min
<<
charSep
()
<<
_max
<<
charSep
()
<<
_step
<<
charSep
()
<<
_index
<<
charSep
()
<<
_choices
.
size
()
<<
charSep
();
<<
_choices
.
size
()
<<
charSep
();
for
(
unsigned
int
i
=
0
;
i
<
_choices
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
_choices
.
size
();
i
++
)
sstream
<<
_choices
[
i
]
<<
charSep
();
sstream
<<
_choices
[
i
]
<<
charSep
();
...
@@ -352,6 +359,7 @@ namespace onelab{
...
@@ -352,6 +359,7 @@ namespace onelab{
setMin
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setMin
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setMax
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setMax
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setStep
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setStep
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setIndex
(
atoi
(
getNextToken
(
msg
,
pos
).
c_str
()));
_choices
.
resize
(
atoi
(
getNextToken
(
msg
,
pos
).
c_str
()));
_choices
.
resize
(
atoi
(
getNextToken
(
msg
,
pos
).
c_str
()));
for
(
unsigned
int
i
=
0
;
i
<
_choices
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
_choices
.
size
();
i
++
)
_choices
[
i
]
=
atof
(
getNextToken
(
msg
,
pos
).
c_str
());
_choices
[
i
]
=
atof
(
getNextToken
(
msg
,
pos
).
c_str
());
...
@@ -402,6 +410,8 @@ namespace onelab{
...
@@ -402,6 +410,8 @@ namespace onelab{
setChanged
(
true
);
setChanged
(
true
);
}
}
setChoices
(
p
.
getChoices
());
setChoices
(
p
.
getChoices
());
if
(
getName
().
find
(
"/Action"
)
!=
std
::
string
::
npos
)
setChanged
(
false
);
}
}
std
::
string
toChar
()
const
std
::
string
toChar
()
const
{
{
...
...
This diff is collapsed.
Click to expand it.
Common/onelabUtils.cpp
+
24
−
12
View file @
faf88978
...
@@ -100,8 +100,10 @@ namespace onelabUtils {
...
@@ -100,8 +100,10 @@ namespace onelabUtils {
std
::
vector
<
onelab
::
number
>
numbers
;
std
::
vector
<
onelab
::
number
>
numbers
;
onelab
::
server
::
instance
()
->
get
(
numbers
);
onelab
::
server
::
instance
()
->
get
(
numbers
);
for
(
unsigned
int
i
=
0
;
i
<
numbers
.
size
();
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
numbers
.
size
();
i
++
){
if
(
numbers
[
i
].
getAttribute
(
"Loop"
)
==
level
){
if
(
numbers
[
i
].
getAttribute
(
"Loop"
)
==
level
){
if
(
numbers
[
i
].
getChoices
().
size
()
>
1
){
if
(
numbers
[
i
].
getChoices
().
size
()
>
1
){
numbers
[
i
].
setIndex
(
0
);
numbers
[
i
].
setValue
(
numbers
[
i
].
getChoices
()[
0
]);
numbers
[
i
].
setValue
(
numbers
[
i
].
getChoices
()[
0
]);
onelab
::
server
::
instance
()
->
set
(
numbers
[
i
]);
onelab
::
server
::
instance
()
->
set
(
numbers
[
i
]);
changed
=
true
;
changed
=
true
;
...
@@ -139,20 +141,30 @@ namespace onelabUtils {
...
@@ -139,20 +141,30 @@ namespace onelabUtils {
loop
=
true
;
loop
=
true
;
if
(
numbers
[
i
].
getChoices
().
size
()
>
1
){
if
(
numbers
[
i
].
getChoices
().
size
()
>
1
){
// FIXME should store loopVariable attribute in the parameter
int
j
=
numbers
[
i
].
getIndex
();
// -- the following test will loop forever if 2 values are
if
((
j
>=
0
)
&&
(
j
<
numbers
[
i
].
getChoices
().
size
())){
// identical in the list of choices
numbers
[
i
].
setValue
(
numbers
[
i
].
getChoices
()[
j
]);
std
::
vector
<
double
>
choices
(
numbers
[
i
].
getChoices
());
numbers
[
i
].
setIndex
(
j
+
1
);
for
(
unsigned
int
j
=
0
;
j
<
choices
.
size
()
-
1
;
j
++
){
if
(
numbers
[
i
].
getValue
()
==
choices
[
j
]){
numbers
[
i
].
setValue
(
choices
[
j
+
1
]);
onelab
::
server
::
instance
()
->
set
(
numbers
[
i
]);
onelab
::
server
::
instance
()
->
set
(
numbers
[
i
]);
Msg
::
Info
(
"Recomputing with
new
choice %s=%g"
,
Msg
::
Info
(
"Recomputing with
%dth
choice %s=%g"
,
j
,
numbers
[
i
].
getName
().
c_str
(),
numbers
[
i
].
getValue
());
numbers
[
i
].
getName
().
c_str
(),
numbers
[
i
].
getValue
());
recompute
=
true
;
recompute
=
true
;
break
;
}
}
}
// FIXME should store loopVariable attribute in the parameter
// -- the following test will loop forever if 2 values are
// identical in the list of choices
// std::vector<double> choices(numbers[i].getChoices());
// for(unsigned int j = 0; j < choices.size() - 1; j++){
// if(numbers[i].getValue() == choices[j]){
// numbers[i].setValue(choices[j + 1]);
// onelab::server::instance()->set(numbers[i]);
// Msg::Info("Recomputing with new choice %s=%g",
// numbers[i].getName().c_str(), numbers[i].getValue());
// recompute = true;
// break;
// }
// }
}
}
else
if
(
numbers
[
i
].
getStep
()
>
0
){
else
if
(
numbers
[
i
].
getStep
()
>
0
){
if
(
numbers
[
i
].
getMax
()
!=
onelab
::
parameter
::
maxNumber
()
&&
if
(
numbers
[
i
].
getMax
()
!=
onelab
::
parameter
::
maxNumber
()
&&
...
...
This diff is collapsed.
Click to expand it.
Fltk/onelabWindow.cpp
+
5
−
1
View file @
faf88978
...
@@ -530,9 +530,13 @@ void onelab_cb(Fl_Widget *w, void *data)
...
@@ -530,9 +530,13 @@ void onelab_cb(Fl_Widget *w, void *data)
o
.
setVisible
(
false
);
o
.
setVisible
(
false
);
onelab
::
server
::
instance
()
->
set
(
o
);
onelab
::
server
::
instance
()
->
set
(
o
);
c
->
run
();
c
->
run
();
if
(
action
==
"compute"
)
if
(
action
==
"compute"
)
{
FlGui
::
instance
()
->
onelab
->
checkForErrors
(
c
->
getName
());
FlGui
::
instance
()
->
onelab
->
checkForErrors
(
c
->
getName
());
if
(
metamodel
)
onelab
::
server
::
instance
()
->
setChanged
(
false
,
c
->
getName
());
}
if
(
FlGui
::
instance
()
->
onelab
->
stop
())
break
;
if
(
FlGui
::
instance
()
->
onelab
->
stop
())
break
;
}
}
// update geometry which might have been changed by the metamodel
// update geometry which might have been changed by the metamodel
...
...
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