Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kirill Terekhov
INMOST
Commits
97929c07
Commit
97929c07
authored
Oct 19, 2020
by
Kirill Terekhov
Browse files
use Mesh::SetFileOption to control skipping data tags when loading or saving the mesh
parent
334b8867
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Source/Headers/inmost_mesh.h
View file @
97929c07
...
...
@@ -3090,8 +3090,17 @@ namespace INMOST
/// - "ECL_TOPOLOGY" - If "TRUE" checks topology of the grid for errors, this may provide useful
/// warnings if layers of the mesh enter each other and the grid cannot be
/// considered conformal. Default: "FALSE".
/// "ECL_PARALLEL_READ"-
i
f "TRUE" then each processor loads part of the eclipse mesh, requires some synchronization.
/// "ECL_PARALLEL_READ"-
I
f "TRUE" then each processor loads part of the eclipse mesh, requires some synchronization.
/// Otherwise if "FALSE" then each processor loads entire mesh. Default: "TRUE".
/// "Tag:TAGNAME" - Set comman-separated rules for tag with the name TAGNAME, the rules list is:
/// nosave - do not save the tag data into files;
/// noload - do not load the tag data from files;
/// noderivatives - do not save/load the derivatives for data with type DATA_VARIABLE (for .xml and .pmf);
/// loadonly - this creates an exclusive list for data to be loaded from files, all other tag names will be ignored;
/// saveonly - this creates an exclusive list for data to be saved to files, all other tag names will be ignored.
/// Example: mesh->SetFileOption("Tag:PressureGradient","noload,noderivatives");
/// the tag with the name PressureGradient will not be loaded from files and
/// when recording the derivaives data will be not saved.
///
/// \todo
/// introduce "SET_TAGS_LOAD", "SET_TAGS_SAVE" to explicitly provide set of tags to write
...
...
@@ -3099,7 +3108,15 @@ namespace INMOST
void
SetFileOption
(
std
::
string
,
std
::
string
);
/// Get current option corresponding to key.
/// @param key options for which options should be retrieven
std
::
string
GetFileOption
(
std
::
string
key
);
std
::
string
GetFileOption
(
std
::
string
key
)
const
;
/// Collect file options realated to records Tag:TAGNAME.
/// @param given option name, such as nosave, noload, noderivatives, loadonly, saveonly
/// @return a set of tags that has given option
std
::
set
<
std
::
string
>
TagOptions
(
std
::
string
name
)
const
;
/// Check if tag loading should be skipped.
bool
CheckLoadSkip
(
std
::
string
name
,
const
std
::
set
<
std
::
string
>
&
noload
,
const
std
::
set
<
std
::
string
>
&
loadonly
)
const
;
/// Check if tag saving should be skipped.
bool
CheckSaveSkip
(
std
::
string
name
,
const
std
::
set
<
std
::
string
>
&
noload
,
const
std
::
set
<
std
::
string
>
&
loadonly
)
const
;
/// Acceptable file formats for reading
/// - ".vtk" - legacy vtk format for unstructured grid
/// - ".pvtk" - legacy parallel vtk format
...
...
Source/Headers/inmost_xml.h
View file @
97929c07
...
...
@@ -10,7 +10,7 @@ namespace INMOST
std
::
string
ReferenceToString
(
INMOST
::
HandleType
h
,
int
pos
);
#endif
#if defined(USE_AUTODIFF)
std
::
string
VariableToString
(
INMOST
::
variable
v
);
std
::
string
VariableToString
(
INMOST
::
variable
v
,
bool
noder
=
false
);
#endif
...
...
Source/IO/mesh_file.cpp
View file @
97929c07
...
...
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "io.hpp"
#include "../Misc/utils.h"
...
...
@@ -57,7 +57,7 @@ namespace INMOST
file_options
.
push_back
(
std
::
make_pair
(
key
,
val
));
}
std
::
string
Mesh
::
GetFileOption
(
std
::
string
key
)
std
::
string
Mesh
::
GetFileOption
(
std
::
string
key
)
const
{
for
(
INMOST_DATA_ENUM_TYPE
k
=
0
;
k
<
file_options
.
size
();
k
++
)
{
...
...
@@ -69,6 +69,49 @@ namespace INMOST
return
""
;
}
std
::
set
<
std
::
string
>
Mesh
::
TagOptions
(
std
::
string
name
)
const
{
std
::
set
<
std
::
string
>
ret
;
std
::
vector
<
std
::
string
>
name_split
;
std
::
vector
<
std
::
string
>
value_split
;
for
(
INMOST_DATA_ENUM_TYPE
k
=
0
;
k
<
file_options
.
size
();
k
++
)
{
split_string
(
file_options
[
k
].
first
,
name_split
,
":"
);
if
(
name_split
[
0
]
==
"Tag"
)
{
split_string
(
file_options
[
k
].
second
,
value_split
,
","
);
for
(
size_t
q
=
0
;
q
<
value_split
.
size
();
++
q
)
{
if
(
value_split
[
q
]
==
name
)
{
ret
.
insert
(
name_split
[
1
]);
break
;
}
}
}
}
return
ret
;
}
bool
Mesh
::
CheckLoadSkip
(
std
::
string
name
,
const
std
::
set
<
std
::
string
>
&
noload
,
const
std
::
set
<
std
::
string
>
&
loadonly
)
const
{
bool
skip
=
false
;
if
(
!
loadonly
.
empty
()
&&
loadonly
.
find
(
name
)
==
loadonly
.
end
()
)
skip
=
true
;
else
if
(
noload
.
find
(
name
)
!=
noload
.
end
()
)
skip
=
true
;
return
skip
;
}
bool
Mesh
::
CheckSaveSkip
(
std
::
string
name
,
const
std
::
set
<
std
::
string
>
&
nosave
,
const
std
::
set
<
std
::
string
>
&
saveonly
)
const
{
bool
skip
=
false
;
if
(
saveonly
.
empty
()
&&
saveonly
.
find
(
name
)
==
saveonly
.
end
()
)
skip
=
true
;
else
if
(
nosave
.
find
(
name
)
!=
nosave
.
end
()
)
skip
=
true
;
return
skip
;
}
void
Mesh
::
Load
(
std
::
string
File
)
{
...
...
Source/IO/mesh_gmv_file.cpp
View file @
97929c07
...
...
@@ -11,6 +11,9 @@ namespace INMOST
{
void
Mesh
::
SaveGMV
(
std
::
string
File
)
{
std
::
set
<
std
::
string
>
nosave
,
saveonly
;
nosave
=
TagOptions
(
"nosave"
);
saveonly
=
TagOptions
(
"saveonly"
);
Storage
::
integer
keynum
;
Storage
::
real
keyval
;
//ReorderEmpty(CELL | FACE | NODE | ESET);
...
...
@@ -92,12 +95,14 @@ namespace INMOST
if
(
etype
==
EDGE
)
continue
;
for
(
Mesh
::
iteratorTag
t
=
BeginTag
();
t
!=
EndTag
();
t
++
)
if
(
t
->
isDefined
(
etype
)
&&
t
->
GetSize
()
==
1
&&
!
t
->
isSparse
(
etype
)
&&
t
->
GetTagName
().
substr
(
0
,
9
)
!=
"PROTECTED"
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
t
->
GetSize
()
==
1
&&
!
t
->
isSparse
(
etype
)
&&
t
->
GetTagName
().
substr
(
0
,
9
)
!=
"PROTECTED"
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
{
if
(
CheckSaveSkip
(
t
->
GetTagName
(),
nosave
,
saveonly
)
)
continue
;
sprintf
(
keyword
,
"%s"
,
t
->
GetTagName
().
substr
(
0
,
8
).
c_str
());
fwrite
(
keyword
,
1
,
8
,
file
);
switch
(
etype
)
...
...
@@ -133,11 +138,12 @@ namespace INMOST
if
(
etype
==
EDGE
)
continue
;
for
(
Mesh
::
iteratorTag
t
=
BeginTag
();
t
!=
EndTag
();
t
++
)
if
(
t
->
isDefined
(
etype
)
&&
t
->
GetSize
()
==
1
&&
t
->
isSparse
(
etype
)
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
t
->
GetSize
()
==
1
&&
t
->
isSparse
(
etype
)
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
{
if
(
CheckSaveSkip
(
t
->
GetTagName
(),
nosave
,
saveonly
)
)
continue
;
Storage
::
integer
temp
;
keynum
=
0
;
for
(
Mesh
::
iteratorElement
e
=
BeginElement
(
etype
);
e
!=
EndElement
();
e
++
)
...
...
@@ -171,7 +177,7 @@ namespace INMOST
case
DATA_REAL
:
keyval
=
e
->
Real
(
*
t
);
break
;
case
DATA_BULK
:
keyval
=
static_cast
<
Storage
::
real
>
(
e
->
Bulk
(
*
t
));
break
;
#if defined(USE_AUTODIFF)
case
DATA_VARIABLE
:
keyval
=
e
->
Variable
(
*
t
).
GetValue
();
break
;
case
DATA_VARIABLE
:
keyval
=
e
->
Variable
(
*
t
).
GetValue
();
break
;
#endif
default:
throw
NotImplemented
;
}
...
...
@@ -227,14 +233,15 @@ namespace INMOST
if
(
etype
==
EDGE
)
continue
;
for
(
Mesh
::
iteratorTag
t
=
BeginTag
();
t
!=
EndTag
();
t
++
)
if
(
t
->
isDefined
(
etype
)
&&
t
->
GetSize
()
!=
1
&&
t
->
GetSize
()
!=
ENUMUNDEF
&&
!
t
->
isSparse
(
etype
)
&&
t
->
GetTagName
().
substr
(
0
,
9
)
!=
"PROTECTED"
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
t
->
GetSize
()
!=
1
&&
t
->
GetSize
()
!=
ENUMUNDEF
&&
!
t
->
isSparse
(
etype
)
&&
t
->
GetTagName
().
substr
(
0
,
9
)
!=
"PROTECTED"
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
{
if
(
CheckSaveSkip
(
t
->
GetTagName
(),
nosave
,
saveonly
)
)
continue
;
sprintf
(
keyword
,
"%s"
,
t
->
GetTagName
().
substr
(
0
,
8
).
c_str
());
fwrite
(
keyword
,
1
,
8
,
file
);
switch
(
etype
)
...
...
@@ -298,4 +305,4 @@ namespace INMOST
}
}
#endif
\ No newline at end of file
#endif
Source/IO/mesh_pmf_file.cpp
View file @
97929c07
This diff is collapsed.
Click to expand it.
Source/IO/mesh_vtk_file.cpp
View file @
97929c07
This diff is collapsed.
Click to expand it.
Source/IO/mesh_vtu_file.cpp
View file @
97929c07
...
...
@@ -21,6 +21,9 @@ namespace INMOST
void
Mesh
::
LoadVTU
(
std
::
string
File
)
{
std
::
set
<
std
::
string
>
noload
,
loadonly
;
noload
=
TagOptions
(
"noload"
);
loadonly
=
TagOptions
(
"loadonly"
);
int
verbosity
=
0
;
for
(
INMOST_DATA_ENUM_TYPE
k
=
0
;
k
<
file_options
.
size
();
++
k
)
{
...
...
@@ -78,7 +81,6 @@ namespace INMOST
//}
}
std
::
vector
<
Tag
>
datatags
;
std
::
vector
<
HandleType
>
newnodes
;
std
::
vector
<
HandleType
>
newpolyh
;
std
::
vector
<
HandleType
>
newcells
;
...
...
@@ -478,12 +480,15 @@ namespace INMOST
int
ncomps
=
1
;
int
nca
=
pd
->
FindAttrib
(
"NumberOfComponents"
);
if
(
nca
!=
pd
->
NumAttrib
())
ncomps
=
atoi
(
pd
->
GetAttrib
(
nca
).
value
.
c_str
());
TagRealArray
t
=
CreateTag
(
pd
->
GetAttrib
(
"Name"
),
DATA_REAL
,
dtype
[
j
],
dsparse
[
j
],
ncomps
);
std
::
stringstream
inp
(
pd
->
GetContents
());
for
(
int
l
=
0
;
l
<
dsize
[
j
];
++
l
)
{
for
(
INMOST_DATA_ENUM_TYPE
q
=
0
;
q
<
t
.
GetSize
();
++
q
)
inp
>>
t
[
darray
[
j
][
l
]][
q
];
if
(
!
CheckLoadSkip
(
pd
->
GetAttrib
(
"Name"
),
noload
,
loadonly
)
)
{
TagRealArray
t
=
CreateTag
(
pd
->
GetAttrib
(
"Name"
),
DATA_REAL
,
dtype
[
j
],
dsparse
[
j
],
ncomps
);
std
::
stringstream
inp
(
pd
->
GetContents
());
for
(
int
l
=
0
;
l
<
dsize
[
j
];
++
l
)
{
for
(
INMOST_DATA_ENUM_TYPE
q
=
0
;
q
<
t
.
GetSize
();
++
q
)
inp
>>
t
[
darray
[
j
][
l
]][
q
];
}
}
}
else
std
::
cout
<<
__FILE__
<<
":"
<<
__LINE__
<<
"I don't know yet what is "
<<
pd
->
GetName
()
<<
" in point data"
<<
std
::
endl
;
...
...
Source/IO/mesh_xml_file.cpp
View file @
97929c07
This diff is collapsed.
Click to expand it.
Source/Misc/utils.cpp
View file @
97929c07
...
...
@@ -49,4 +49,15 @@ namespace INMOST {
return
rank
;
}
void
split_string
(
const
std
::
string
&
str
,
std
::
vector
<
std
::
string
>
&
str_list
,
const
std
::
string
&
delims
)
{
std
::
string
::
size_type
end
=
str
.
find_first_not_of
(
delims
,
0
);
std
::
string
::
size_type
pos
=
str
.
find_first_of
(
delims
,
end
);
while
(
std
::
string
::
npos
!=
pos
||
std
::
string
::
npos
!=
end
)
{
str_list
.
push_back
(
str
.
substr
(
end
,
pos
-
end
));
end
=
str
.
find_first_not_of
(
delims
,
pos
);
pos
=
str
.
find_first_of
(
delims
,
end
);
}
}
}
Source/Misc/utils.h
View file @
97929c07
...
...
@@ -24,6 +24,8 @@ namespace INMOST
ss
<<
value
;
return
ss
.
str
();
}
void
split_string
(
const
std
::
string
&
str
,
std
::
vector
<
std
::
string
>
&
str_list
,
const
std
::
string
&
delims
=
","
);
std
::
string
string_to_lower
(
const
std
::
string
&
str
);
...
...
Source/Misc/xml.cpp
View file @
97929c07
...
...
@@ -98,23 +98,28 @@ namespace INMOST
#if defined(USE_AUTODIFF)
std
::
string
VariableToString
(
INMOST
::
variable
v
)
std
::
string
VariableToString
(
INMOST
::
variable
v
,
bool
noder
)
{
std
::
stringstream
ret
;
const
INMOST
::
Sparse
::
Row
&
r
=
v
.
GetRow
();
ret
<<
"("
;
ret
<<
v
.
GetValue
()
<<
";"
;
ret
<<
r
.
Size
();
if
(
!
r
.
Empty
()
)
if
(
noder
)
ret
<<
0
;
else
{
ret
<<
";"
;
for
(
int
q
=
0
;
q
<
(
int
)
r
.
Size
()
-
1
;
++
q
)
ret
<<
r
.
Size
()
;
if
(
!
r
.
Empty
()
)
{
ret
<<
r
.
GetValue
(
q
)
<<
";"
;
ret
<<
r
.
GetIndex
(
q
)
<<
";"
;
ret
<<
";"
;
for
(
int
q
=
0
;
q
<
(
int
)
r
.
Size
()
-
1
;
++
q
)
{
ret
<<
r
.
GetValue
(
q
)
<<
";"
;
ret
<<
r
.
GetIndex
(
q
)
<<
";"
;
}
ret
<<
r
.
GetValue
(
r
.
Size
()
-
1
)
<<
";"
;
ret
<<
r
.
GetIndex
(
r
.
Size
()
-
1
);
}
ret
<<
r
.
GetValue
(
r
.
Size
()
-
1
)
<<
";"
;
ret
<<
r
.
GetIndex
(
r
.
Size
()
-
1
);
}
ret
<<
")"
;
return
ret
.
str
();
...
...
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