Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenFOAM-plus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Development
OpenFOAM-plus
Commits
5f0a5722
Commit
5f0a5722
authored
7 years ago
by
Mark OLESEN
Browse files
Options
Downloads
Patches
Plain Diff
BUG: parse issues for nastran long format (closes
#589
)
parent
0187cf5a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/fileFormats/nas/NASCore.C
+15
-10
15 additions, 10 deletions
src/fileFormats/nas/NASCore.C
src/fileFormats/nas/NASCore.H
+2
-2
2 additions, 2 deletions
src/fileFormats/nas/NASCore.H
src/surfMesh/triSurface/interfaces/NAS/readNAS.C
+5
-20
5 additions, 20 deletions
src/surfMesh/triSurface/interfaces/NAS/readNAS.C
with
22 additions
and
32 deletions
src/fileFormats/nas/NASCore.C
+
15
−
10
View file @
5f0a5722
...
...
@@ -34,28 +34,33 @@ Foam::fileFormats::NASCore::NASCore()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam
::
scalar
Foam
::
fileFormats
::
NASCore
::
parseNASCoord
(
const
string
&
s
)
Foam
::
scalar
Foam
::
fileFormats
::
NASCore
::
parseNASCoord
(
const
string
&
s
)
{
s
ize_t
expSign
=
s
.
find_last_of
(
"+-"
)
;
s
calar
value
=
0
;
if
(
expSign
!=
string
::
npos
&&
expSign
>
0
&&
!
isspace
(
s
[
expSign
-
1
]))
const
size_t
expSign
=
s
.
find_last_of
(
"+-"
);
if
(
expSign
!=
std
::
string
::
npos
&&
expSign
>
0
&&
!
isspace
(
s
[
expSign
-
1
]))
{
scalar
mantissa
=
readScalar
(
IStringStream
(
s
.
substr
(
0
,
expSign
))());
scalar
exponent
=
readScalar
(
IStringStream
(
s
.
substr
(
expSign
+
1
))());
scalar
exponent
=
0
;
// Parse as per strtod/strtof - allowing trailing space or [Ee]
readScalar
(
s
.
substr
(
0
,
expSign
).
c_str
(),
value
);
// mantissa
readScalar
(
s
.
substr
(
expSign
+
1
).
c_str
(),
exponent
);
if
(
s
[
expSign
]
==
'-'
)
{
exponent
=
-
exponent
;
}
return
mantissa
*
pow
(
10
,
exponent
);
value
*=
::
pow
(
10
,
exponent
);
}
else
{
return
readScalar
(
IStringStream
(
s
)()
);
readScalar
(
s
.
c_str
(),
value
);
}
return
value
;
}
...
...
This diff is collapsed.
Click to expand it.
src/fileFormats/nas/NASCore.H
+
2
−
2
View file @
5f0a5722
...
...
@@ -55,8 +55,8 @@ public:
// Public Member Functions
//-
Do weird things to extract number
static
scalar
parseNASCoord
(
const
string
&
);
//-
Extract numbers from things like "-2.358-8" (same as "-2.358e-8")
static
scalar
parseNASCoord
(
const
string
&
s
);
// Constructors
...
...
This diff is collapsed.
Click to expand it.
src/surfMesh/triSurface/interfaces/NAS/readNAS.C
+
5
−
20
View file @
5f0a5722
...
...
@@ -36,6 +36,7 @@ Description
\*---------------------------------------------------------------------------*/
#include
"triSurface.H"
#include
"NASCore.H"
#include
"IFstream.H"
#include
"IStringStream.H"
...
...
@@ -47,25 +48,9 @@ namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Do weird things to extract number
static
scalar
parseNASCoord
(
const
string
&
s
)
static
inline
scalar
parseNASCoord
(
const
string
&
s
)
{
size_t
expSign
=
s
.
find_last_of
(
"+-"
);
if
(
expSign
!=
string
::
npos
&&
expSign
>
0
&&
!
isspace
(
s
[
expSign
-
1
]))
{
scalar
mantissa
=
readScalar
(
IStringStream
(
s
.
substr
(
0
,
expSign
))());
scalar
exponent
=
readScalar
(
IStringStream
(
s
.
substr
(
expSign
+
1
))());
if
(
s
[
expSign
]
==
'-'
)
{
exponent
=
-
exponent
;
}
return
mantissa
*
pow
(
10
,
exponent
);
}
else
{
return
readScalar
(
IStringStream
(
s
)());
}
return
fileFormats
::
NASCore
::
parseNASCoord
(
s
);
}
...
...
@@ -311,8 +296,8 @@ bool triSurface::readNAS(const fileName& fName)
// GRID* 126 0 -5.55999875E+02 -5.68730474E+02
// * 2.14897901E+02
label
index
=
readLabel
(
IStringStream
(
readNASToken
(
line
,
8
,
linei
))());
readNASToken
(
line
,
8
,
linei
);
readLabel
(
IStringStream
(
readNASToken
(
line
,
16
,
linei
))());
readNASToken
(
line
,
16
,
linei
);
scalar
x
=
parseNASCoord
(
readNASToken
(
line
,
16
,
linei
));
scalar
y
=
parseNASCoord
(
readNASToken
(
line
,
16
,
linei
));
...
...
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