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
9a7ba18a
Commit
9a7ba18a
authored
8 years ago
by
Patrick Dular
Browse files
Options
Downloads
Patches
Plain Diff
Update
parent
3727d808
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
demos/struct/struct.geo
+10
-8
10 additions, 8 deletions
demos/struct/struct.geo
with
10 additions
and
8 deletions
demos/struct/struct.geo
+
10
−
8
View file @
9a7ba18a
...
...
@@ -4,7 +4,7 @@
// A data structure is a group of data elements grouped together under one name,
// the structure identifier. These data elements, defining the structure members,
// can be of different types: real, string, list of real.
// can be of different types: real, string, list of real
, list of string
.
// The syntax should be clear from the example below:
Struct
struct_identifier
[
...
...
@@ -26,8 +26,8 @@ Struct St1 [ Type 1 ]; // Tag will be 2 = 1 (the one of last Struct) + 1
Struct
St2
[
Type
2
,
Tag
10
];
// Tag is forced to 10
tag_of_struct_St3
=
Struct
St3
[
Type
3
];
// Tag will be 11 = 10 + 1
// For clear classifications (contexts), structures can be defined in
a
//
given
namespace (other than the global one used until now).
// For clear classifications (contexts), structures can be defined in
// namespace
s
(other than the global one used until now).
// Their names then start with the namespace name followed by the
// scope operator '::'. The 'Tag' numbering is proper to each namespace. E.g.,
...
...
@@ -41,28 +41,29 @@ Struct NS1::St3 [ Type 3 ];
val_Type_of_Struct_St2
=
St2
.
Type
;
val_Type_of_Struct_St2_in_NS1
=
NS1
::
St2
.
Type
;
//
A
ccess
to
list members
//
To a
ccess
real
list members
:
one_element_from_a_list_member
=
struct_identifier
.
struct_member_list_of_real_1
(
1
);
full_list_from_a_list_member
()
=
struct_identifier
.
struct_member_list_of_real_1
();
dim_list_member
=
#
struct_identifier
.
struct_member_list_of_real_1
();
// To access string list members:
one_string_from_a_list_member
=
Str
[
struct_identifier
.
struct_member_list_of_string_1
(
1
)];
full_string_list_from_a_list_member
()
=
Str
[
struct_identifier
.
struct_member_list_of_string_1
()];
dim_string_list_member
=
#
struct_identifier
.
struct_member_list_of_string_1
();
//
The f
unction DimNameSpace(.) returns the number of structures in a given namespace:
//
F
unction DimNameSpace(.) returns the number of structures in a given namespace:
nb_struct_namespace_global
=
DimNameSpace
();
nb_struct_namespace_NS1
=
DimNameSpace
(
NS1
);
//
The f
unction NameStruct(namespace::#index)
//
F
unction NameStruct(namespace::#index)
// (or NameStruct(#index) for the global namespace)
// returns the name (as a string) of the index-th structures in the given namespace:
name_of_struct_2_in_namespace_global
=
NameStruct
(
#
2
);
name_of_struct_2_in_namespace_NS1
=
NameStruct
[
NS1
::
#
2
];
// Thanks to these two functions, and
the S2N[.]
function ('StringToName'),
// Thanks to these two functions, and function
S2N[.]
('StringToName'),
// one can make loops on structures of a given namespace and
// access their members values:
...
...
@@ -81,6 +82,7 @@ EndFor
Struct
NS1
::
St2
(
Append
)
[
AdditionalMember
222
];
Struct
NS1
::
St3
(
Append
)
[
AdditionalMember
333
,
HColor
"Orange"
];
// STRUCT FOR ENUMERATIONS
// A structure can be used to define an enumeration, to give automatically
// incremented values to the members (by default, starting at 0, or at any fixed value).
// This is useful, e.g., for defining constants to be used for types (hidding the values):
...
...
@@ -91,7 +93,7 @@ Struct T::REGION_TYPE [ Enum, NONE, PHYS, SKIN, GATE, BC ];
Struct
T
::
REGION_TYPE_2
[
Enum
,
PHYS
10
,
SKIN
,
GATE
20
,
BC
];
// Automatic values will be: PHYS 10, SKIN 11, GATE 20, BC 21
//
A
dd members with Append:
//
To a
dd members with Append:
Struct
T
::
REGION_TYPE
(
Append
)
[
Enum
,
CUTBOX
];
// CUTBOX will be 5
// Using explicit name for constants:
...
...
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