Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-grid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-grid
Commits
3beccf81
Commit
3beccf81
authored
6 years ago
by
Robert K
Browse files
Options
Downloads
Patches
Plain Diff
[feature][GridPtr] distinguish file format by extension.
parent
87a9c61b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!312
GridPtr can also read gmsh files and then handle the load balance of user data.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/grid/io/file/dgfparser/gridptr.hh
+31
-29
31 additions, 29 deletions
dune/grid/io/file/dgfparser/gridptr.hh
with
31 additions
and
29 deletions
dune/grid/io/file/dgfparser/gridptr.hh
+
31
−
29
View file @
3beccf81
...
...
@@ -4,6 +4,7 @@
#define DUNE_DGF_GRIDPTR_HH
#include
<cassert>
#include
<cctype>
#include
<array>
#include
<iostream>
...
...
@@ -115,34 +116,25 @@ namespace Dune
}
};
typedef
MPIHelper
::
MPICommunicator
MPICommunicatorType
;
static
const
int
dimension
=
GridType
::
dimension
;
std
::
string
checkFileFormat
(
const
std
::
string
&
filename
)
const
protected
:
std
::
string
getFileExtension
(
const
std
::
string
&
filename
)
const
{
std
::
ifstream
input
(
filename
);
if
(
input
.
is_open
()
)
{
std
::
string
line
;
std
::
getline
(
input
,
line
);
// extract file extension
auto
extpos
=
filename
.
find_last_of
(
"."
);
std
::
string
ext
;
if
(
extpos
!=
std
::
string
::
npos
)
ext
=
filename
.
substr
(
extpos
+
1
);
// convert all letters to lower case
for
(
auto
&
item
:
ext
)
item
=
std
::
tolower
(
item
);
return
ext
;
}
int
pos
=
line
.
find
(
"DGF"
);
if
(
pos
>=
0
)
{
//std::cout << "Found DGF Format" << std::endl;
return
std
::
string
(
"DGF"
);
}
public
:
pos
=
line
.
find
(
"$MeshFormat"
);
if
(
pos
>=
0
)
{
//std::cout << "Found Gmsh Format" << std::endl;
return
std
::
string
(
"gmsh"
);
}
}
return
std
::
string
(
"unknown_format"
);
}
typedef
MPIHelper
::
MPICommunicator
MPICommunicatorType
;
static
const
int
dimension
=
GridType
::
dimension
;
//! constructor given the name of a DGF file
explicit
GridPtr
(
const
std
::
string
&
filename
,
...
...
@@ -157,14 +149,14 @@ namespace Dune
nofVtxParam_
(
0
),
haveBndParam_
(
false
)
{
std
::
string
file
ID
=
checkFileFormat
(
filename
);
std
::
string
file
Ext
=
getFileExtension
(
filename
);
if
(
file
ID
==
"
DGF
"
)
if
(
file
Ext
==
"
dgf
"
)
{
DGFGridFactory
<
GridType
>
dgfFactory
(
filename
,
comm
);
initialize
(
dgfFactory
);
}
else
if
(
file
ID
==
"
g
msh"
)
else
if
(
file
Ext
==
"msh"
)
{
GridFactory
<
GridType
>
gridFactory
;
std
::
vector
<
int
>
boundaryIDs
;
...
...
@@ -172,9 +164,19 @@ namespace Dune
GmshReader
<
GridType
>::
read
(
gridFactory
,
filename
,
boundaryIDs
,
elementsIDs
);
initialize
(
gridFactory
,
boundaryIDs
,
elementsIDs
);
}
else
if
(
fileExt
==
"amc"
||
fileExt
==
"2d"
||
fileExt
==
"3d"
)
{
// TODO: AlbertaReader
DUNE_THROW
(
NotImplemented
,
"GridPtr: file format '"
<<
fileExt
<<
"' not supported yet!"
);
}
else
if
(
fileExt
==
"vtu"
)
{
// TODO: vtu/vtk reader
DUNE_THROW
(
NotImplemented
,
"GridPtr: file format '"
<<
fileExt
<<
"' not supported yet!"
);
}
else
{
DUNE_THROW
(
NotImplemented
,
"GridPtr: file format not supported!"
);
DUNE_THROW
(
NotImplemented
,
"GridPtr: file format
'"
<<
fileExt
<<
"'
not supported
yet
!"
);
}
}
...
...
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