Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dg
dg
Commits
792dba47
Commit
792dba47
authored
Oct 19, 2016
by
Jonathan Lambrechts
Browse files
rewrite readMsh and rename to readIdx
parent
e2e4b25f
Pipeline
#1172
passed with stage
in 27 minutes and 33 seconds
Changes
63
Pipelines
2
Show whitespace changes
Inline
Side-by-side
benchmarks/congo/particles.py
View file @
792dba47
...
...
@@ -66,7 +66,7 @@ groups.splitGroupsByPhysicalTag()
# Bathymetry
bathDC
=
dgDofContainer
(
groups
,
1
)
bathDC
.
readMsh
(
"Bath/congoCoast-labels-clean_bath_smooth/congoCoast-labels-clean_bath_smooth.idx"
)
bathDC
.
importIdx
(
"Bath/congoCoast-labels-clean_bath_smooth/congoCoast-labels-clean_bath_smooth.idx"
)
#-------------------------------------------------------------------------------
#------- SET UP DIFFUSIVITY ----------------------------------------------------
...
...
@@ -190,7 +190,7 @@ for n in range(1,LP_TotIter+1):
print
(
'Problem in loadedSolutions!'
)
else
:
print
(
'-> simSolution not already loaded. Loading it from file. File is (gbr-%06d'
%
(
iterNumberWanted
)
+
').'
)
simSolution
.
readMsh
(
'output/idx/idx-%06d'
%
(
iterNumberWanted
/
simExportGap
)
+
'.idx'
)
simSolution
.
importIdx
(
'output/idx/idx-%06d'
%
(
iterNumberWanted
/
simExportGap
)
+
'.idx'
)
loadedSolutions
[
0
]
=
iterNumberWanted
else
:
...
...
@@ -217,7 +217,7 @@ for n in range(1,LP_TotIter+1):
else
:
print
(
'-> simSolutionUnder not already loaded. Loading it from file. l is:'
,
l
,
'. File is (gbr-%06d'
%
(
iterNumberWanted
-
l
)
+
').'
)
t_solUnder
=
simStartTime
+
float
(
iterNumberWanted
-
l
)
*
simDt
simSolutionUnder
.
readMsh
(
'output/idx/idx-%06d'
%
(
(
iterNumberWanted
-
l
)
/
simExportGap
)
+
'.idx'
)
simSolutionUnder
.
importIdx
(
'output/idx/idx-%06d'
%
(
(
iterNumberWanted
-
l
)
/
simExportGap
)
+
'.idx'
)
loadedSolutions
[
2
]
=
iterNumberWanted
-
l
m
=
0
...
...
@@ -242,7 +242,7 @@ for n in range(1,LP_TotIter+1):
else
:
print
(
'-> simSolutionOver not already loaded. Loading it from file. m is:'
,
m
,
'. File is (gbr-%06d'
%
(
iterNumberWanted
+
m
)
+
').'
)
t_solOver
=
simStartTime
+
float
(
iterNumberWanted
+
m
)
*
simDt
simSolutionOver
.
readMsh
(
'output/idx/idx-%06d'
%
(
(
iterNumberWanted
+
m
)
/
simExportGap
)
+
'.idx'
)
simSolutionOver
.
importIdx
(
'output/idx/idx-%06d'
%
(
(
iterNumberWanted
+
m
)
/
simExportGap
)
+
'.idx'
)
loadedSolutions
[
1
]
=
iterNumberWanted
+
m
scaleFactor
=
1.0
-
(
t
-
t_solUnder
)
/
(
t_solOver
-
t_solUnder
)
...
...
benchmarks/congo/prepro.py
View file @
792dba47
...
...
@@ -136,7 +136,7 @@ def partitionMultirate(fileName, bathFileName, nMRGroups, mRAlgo, nPart, outputF
UTMtoLonLatDegrees
=
functionNumpy
(
3
,
UTMtoLonLatDegrees_func
,
[
UTM
])
#lonLatDegrees = functionC("./lib_congo.so","UTMtoLonLatDegrees",3,[UTM])
bath
=
dgDofContainer
(
groups
,
1
);
bath
.
readMsh
(
bathFileName
)
bath
.
importIdx
(
bathFileName
)
claw
=
dgConservationLawShallowWater2d
()
solution
=
dgDofContainer
(
groups
,
claw
.
getNbFields
())
Cd
=
functionNumpy
(
1
,
bottomDrag_const_n0235
,
[
solution
.
getFunction
(),
bath
.
getFunction
()])
...
...
@@ -221,7 +221,7 @@ if Msg.GetCommRank() == 0 :
groups
=
dgGroupCollection
(
model
,
2
,
1
,
True
)
# Bathymetry of the model.
bathDof
=
dgDofContainer
(
groups
,
1
)
bathDof
.
readMsh
(
"Bath/"
+
param
.
fileName
+
"_bath_smooth/"
+
param
.
fileName
+
"_bath_smooth.idx"
)
bathDof
.
importIdx
(
"Bath/"
+
param
.
fileName
+
"_bath_smooth/"
+
param
.
fileName
+
"_bath_smooth.idx"
)
# Associate bathymetry to every mesh node.
globNodeId2Bath
=
{}
...
...
benchmarks/congo/run2d.py
View file @
792dba47
...
...
@@ -88,7 +88,7 @@ groups.splitGroupsByPhysicalTag()
# Grouped parameters.
bath
=
dgDofContainer
(
groups
,
1
)
bath
.
readMsh
(
"Bath/"
+
param
.
fileName
+
"_bath_smooth/"
+
param
.
fileName
+
"_bath_smooth.idx"
)
bath
.
importIdx
(
"Bath/"
+
param
.
fileName
+
"_bath_smooth/"
+
param
.
fileName
+
"_bath_smooth.idx"
)
bath_PC
=
functionPrecomputed
(
groups
,
3
,
1
)
bath_PC
.
compute
(
bath
.
getFunction
())
bathGradient_PC
=
functionPrecomputed
(
groups
,
3
,
3
)
...
...
@@ -104,7 +104,7 @@ solution = dgDofContainer(groups, 3)
start
=
0
if
(
param
.
realTi
!=
param
.
Ti
):
start
=
int
((
t
-
param
.
realTi
)
/
(
dt
*
param
.
export
))
solution
.
readMsh
(
param
.
outputDir
+
"/idx/idx-"
+
str
(
start
).
zfill
(
6
)
+
".idx"
)
solution
.
importIdx
(
param
.
outputDir
+
"/idx/idx-"
+
str
(
start
).
zfill
(
6
)
+
".idx"
)
else
:
solution
.
setAll
(
0.
)
...
...
benchmarks/meshGeneration/extrudeWorld.py
View file @
792dba47
...
...
@@ -18,7 +18,7 @@ bath = dgDofContainer(groups, 1);
filename
=
"world"
outputDir
=
"bath"
bathname
=
outputDir
+
"/"
+
filename
+
"_bath_smooth"
+
"/"
+
filename
+
"_bath_smooth.idx"
bath
.
readMsh
(
bathname
)
bath
.
importIdx
(
bathname
)
def
getLayers
(
x
,
y
,
iGroup
,
iElement
,
iVertex
)
:
h
=
bath
.
getGroupProxy
(
iGroup
)(
iVertex
,
iElement
);
MinDiff
=
1e10
...
...
benchmarks/sw2Converge/ConvergenceInSpace.py
View file @
792dba47
...
...
@@ -142,7 +142,7 @@ gRef = GModel()
gRef
.
load
(
"output/"
+
FileName
+
"-ref-%i.msh"
%
ref
)
groupsRef
=
dgGroupCollection
(
gRef
,
2
,
1
)
dofRef
=
dgDofContainer
(
groupsRef
,
3
)
dofRef
.
readMsh
(
"output/dof-ref-%i-end/dof-ref-%i-end.idx"
%
(
ref
,
ref
))
dofRef
.
importIdx
(
"output/dof-ref-%i-end/dof-ref-%i-end.idx"
%
(
ref
,
ref
))
XYZRef
=
groupsRef
.
getFunctionCoordinates
()
solRef
=
dofRef
.
getFunction
()
...
...
@@ -163,7 +163,7 @@ for i in range(0, nstage+1):
g
.
load
(
"output/"
+
FileName
+
"-%i.msh"
%
i
)
groups
=
dgGroupCollection
(
g
,
2
,
1
)
dof
=
dgDofContainer
(
groups
,
3
)
dof
.
readMsh
(
"output/dof-%i-end/dof-%i-end.idx"
%
(
i
,
i
))
dof
.
importIdx
(
"output/dof-%i-end/dof-%i-end.idx"
%
(
i
,
i
))
evaluator
=
dgFunctionEvaluator
(
groups
,
dof
.
getFunction
())
fsol
=
evaluator
.
newFunction
(
XYZRef
)
...
...
benchmarks/sw2Converge/conv.py
View file @
792dba47
...
...
@@ -58,7 +58,7 @@ gRef = GModel()
gRef
.
load
(
"output/square-%i.msh"
%
nstage
)
groupsRef
=
dgGroupCollection
(
gRef
,
2
,
1
)
dofRef
=
dgDofContainer
(
groupsRef
,
3
)
dofRef
.
readMsh
(
"output/dof-%i-end/dof-%i-end.idx"
%
(
nstage
,
nstage
))
dofRef
.
importIdx
(
"output/dof-%i-end/dof-%i-end.idx"
%
(
nstage
,
nstage
))
XYZRef
=
groupsRef
.
getFunctionCoordinates
()
solRef
=
dofRef
.
getFunction
()
...
...
@@ -75,7 +75,7 @@ for i in range(0, nstage):
g
.
load
(
"output/square-%i.msh"
%
i
)
groups
=
dgGroupCollection
(
g
,
2
,
1
)
dof
=
dgDofContainer
(
groups
,
3
)
dof
.
readMsh
(
"output/dof-%i-end/dof-%i-end.idx"
%
(
i
,
i
))
dof
.
importIdx
(
"output/dof-%i-end/dof-%i-end.idx"
%
(
i
,
i
))
evaluator
=
dgFunctionEvaluator
(
groups
,
dof
.
getFunction
())
fsol
=
evaluator
.
newFunction
(
XYZRef
)
...
...
benchmarks/swe3d/gbr/prepro.py
View file @
792dba47
...
...
@@ -92,7 +92,7 @@ def process(name) :
model
.
load
(
mesh1
)
groups
=
dgGroupCollection
(
model
,
2
,
1
,
True
)
bathDof
=
dgDofContainer
(
groups
,
1
)
bathDof
.
readMsh
(
"./bathSmooth/bathSmooth.idx"
)
bathDof
.
importIdx
(
"./bathSmooth/bathSmooth.idx"
)
globNodeId2Bath
=
{}
dataProx
=
fullMatrixDouble
()
...
...
benchmarks/swe3d/rhineRofi/plotting/rhineRofiPlotSurfStimes.py
View file @
792dba47
...
...
@@ -132,13 +132,13 @@ for ifig,export_count in enumerate(export_counts) :
SFunc
=
SDof
.
getFunction
()
uvFunc
=
uvDof
.
getFunction
()
#etaDof.
readMsh
( idxDir + 'eta2d/'+ 'eta2d'+istr+'.idx')
#etaDof.
importIdx
( idxDir + 'eta2d/'+ 'eta2d'+istr+'.idx')
#print 'Reading '+idxDir + 'uv/'+ 'uv'+istr+'.idx'
#SDof.
readMsh
( idxDir + 'S/'+ 'S'+istr+'.idx')
#uvDof.
readMsh
( idxDir + 'uv/'+ 'uv'+istr+'.idx')
#SDof.
importIdx
( idxDir + 'S/'+ 'S'+istr+'.idx')
#uvDof.
importIdx
( idxDir + 'uv/'+ 'uv'+istr+'.idx')
print
'Reading '
+
idxDir
+
'uv'
+
istr
+
'.idx'
SDof
.
readMsh
(
idxDir
+
'S'
+
istr
+
'.idx'
)
uvDof
.
readMsh
(
idxDir
+
'uv'
+
istr
+
'.idx'
)
SDof
.
importIdx
(
idxDir
+
'S'
+
istr
+
'.idx'
)
uvDof
.
importIdx
(
idxDir
+
'uv'
+
istr
+
'.idx'
)
dgDCMap
=
dataCacheMap
(
dataCacheMap
.
POINT_MODE
,
groups
)
SCache
=
dgDCMap
.
get
(
SFunc
)
...
...
benchmarks/swe3d/rhineRofi/plotting/rhineRofiPlotTurbtimes.py
View file @
792dba47
...
...
@@ -100,14 +100,14 @@ if generateData :
for
i
,
export_count
in
enumerate
(
export_counts
)
:
istr
=
"_{0:05}"
.
format
(
export_count
)
print
'Reading '
+
idxDir
+
'nn/'
+
'nn'
+
istr
+
'.idx'
#etaDof.
readMsh
( idxDir + 'eta2d/'+ 'eta2d'+istr+'.idx')
#nnDof.
readMsh
( idxDir + 'S/'+ 'S'+istr+'.idx')
#uvDof.
readMsh
( idxDir + 'uv/'+ 'uv'+istr+'.idx')
[
time
,
step
]
=
etaDof
.
readMsh
(
idxDir
+
'eta2d'
+
istr
+
'.idx'
)
[
time
,
step
]
=
nnDof
.
readMsh
(
idxDir
+
'nn'
+
istr
+
'.idx'
)
[
time
,
step
]
=
ssDof
.
readMsh
(
idxDir
+
'ss'
+
istr
+
'.idx'
)
[
time
,
step
]
=
uvDof
.
readMsh
(
idxDir
+
'uv'
+
istr
+
'.idx'
)
[
time
,
step
]
=
SDof
.
readMsh
(
idxDir
+
'S'
+
istr
+
'.idx'
)
#etaDof.
importIdx
( idxDir + 'eta2d/'+ 'eta2d'+istr+'.idx')
#nnDof.
importIdx
( idxDir + 'S/'+ 'S'+istr+'.idx')
#uvDof.
importIdx
( idxDir + 'uv/'+ 'uv'+istr+'.idx')
[
time
,
step
]
=
etaDof
.
importIdx
(
idxDir
+
'eta2d'
+
istr
+
'.idx'
)
[
time
,
step
]
=
nnDof
.
importIdx
(
idxDir
+
'nn'
+
istr
+
'.idx'
)
[
time
,
step
]
=
ssDof
.
importIdx
(
idxDir
+
'ss'
+
istr
+
'.idx'
)
[
time
,
step
]
=
uvDof
.
importIdx
(
idxDir
+
'uv'
+
istr
+
'.idx'
)
[
time
,
step
]
=
SDof
.
importIdx
(
idxDir
+
'S'
+
istr
+
'.idx'
)
dgCG3d
.
apply
(
nnDof
,
nnDof
)
dgCG3d
.
apply
(
ssDof
,
ssDof
)
nnDof
.
exportMsh
(
dataDir
+
'/nnCG'
+
istr
,
time
,
export_count
)
...
...
benchmarks/swe3d/rhineRofi/plotting/rhineRofiPlotUVtimes.py
View file @
792dba47
...
...
@@ -88,12 +88,12 @@ if generateData :
for
i
,
export_count
in
enumerate
(
export_counts
)
:
istr
=
"_{0:05}"
.
format
(
export_count
)
print
'Reading '
+
idxDir
+
'uv/'
+
'uv'
+
istr
+
'.idx'
#etaDof.
readMsh
( idxDir + 'eta2d/'+ 'eta2d'+istr+'.idx')
#SDof.
readMsh
( idxDir + 'S/'+ 'S'+istr+'.idx')
#uvDof.
readMsh
( idxDir + 'uv/'+ 'uv'+istr+'.idx')
etaDof
.
readMsh
(
idxDir
+
'eta2d'
+
istr
+
'.idx'
)
SDof
.
readMsh
(
idxDir
+
'S'
+
istr
+
'.idx'
)
uvDof
.
readMsh
(
idxDir
+
'uv'
+
istr
+
'.idx'
)
#etaDof.
importIdx
( idxDir + 'eta2d/'+ 'eta2d'+istr+'.idx')
#SDof.
importIdx
( idxDir + 'S/'+ 'S'+istr+'.idx')
#uvDof.
importIdx
( idxDir + 'uv/'+ 'uv'+istr+'.idx')
etaDof
.
importIdx
(
idxDir
+
'eta2d'
+
istr
+
'.idx'
)
SDof
.
importIdx
(
idxDir
+
'S'
+
istr
+
'.idx'
)
uvDof
.
importIdx
(
idxDir
+
'uv'
+
istr
+
'.idx'
)
dgDCMap2d
.
setPoint
(
groups2d
,
x
,
y
,
0
)
eta
=
etaCache
.
get
()(
0
,
0
)
zs
=
linspace
(
zMin
,
eta
,
nZ
)
...
...
benchmarks/swe3d/warnerEstuary/plotting/warnerEstuaryPlotTrans.py
View file @
792dba47
...
...
@@ -66,8 +66,8 @@ istr = "_{0:05}".format(export_count)
#tkeDof.importMsh( odir + 'tke' + istr)
#epsDof.importMsh( odir + 'eps' + istr)
#lDof.importMsh( odir + 'l' + istr)
etaDof
.
readMsh
(
idxDir
+
'eta2d'
+
istr
+
'.idx'
)
SDof
.
readMsh
(
idxDir
+
'S'
+
istr
+
'.idx'
)
etaDof
.
importIdx
(
idxDir
+
'eta2d'
+
istr
+
'.idx'
)
SDof
.
importIdx
(
idxDir
+
'S'
+
istr
+
'.idx'
)
def
bathFunc
(
x
)
:
return
10
*
(
1.
-
x
/
50000.
)
/
2.0
+
5
*
(
1.
+
x
/
50000.
)
/
2.0
...
...
benchmarks/swe3d/warnerEstuary/plotting/warnerEstuaryPlotTransUVSframes.py
View file @
792dba47
...
...
@@ -95,10 +95,10 @@ tkeCache = dgDCMap.get(tkeFunc)
for
export_count
in
export_counts
:
istr
=
"_{0:05}"
.
format
(
export_count
)
etaDof
.
readMsh
(
idxDir
+
'eta2d'
+
istr
+
'.idx'
)
SDof
.
readMsh
(
idxDir
+
'S'
+
istr
+
'.idx'
)
#tkeDof.
readMsh
( idxDir + 'tke'+istr+'.idx')
uvDof
.
readMsh
(
idxDir
+
'uv'
+
istr
+
'.idx'
)
etaDof
.
importIdx
(
idxDir
+
'eta2d'
+
istr
+
'.idx'
)
SDof
.
importIdx
(
idxDir
+
'S'
+
istr
+
'.idx'
)
#tkeDof.
importIdx
( idxDir + 'tke'+istr+'.idx')
uvDof
.
importIdx
(
idxDir
+
'uv'
+
istr
+
'.idx'
)
# get eta value (depends onthe mesh!)
for
i
,
x
in
enumerate
(
xs
)
:
...
...
benchmarks/titan/run.py
View file @
792dba47
...
...
@@ -67,9 +67,9 @@ if continue_time:
#sol_old.setFieldName(0, 'eta_old')
#sol_old.setFieldName(0, 'u_old')
#sol_old.setFieldName(0, 'v_old')
#sol_old.
readMsh
(path_output + "/idx/idx-" + t_start + "_COMP_0.idx",0,0)
#sol_old.
readMsh
(path_output + "/idx/idx-" + t_start + "_COMP_1.idx",1,1)
#sol_old.
readMsh
(path_output + "/idx/idx-" + t_start + "_COMP_2.idx",2,2)
#sol_old.
importIdx
(path_output + "/idx/idx-" + t_start + "_COMP_0.idx",0,0)
#sol_old.
importIdx
(path_output + "/idx/idx-" + t_start + "_COMP_1.idx",1,1)
#sol_old.
importIdx
(path_output + "/idx/idx-" + t_start + "_COMP_2.idx",2,2)
else
:
...
...
@@ -89,7 +89,7 @@ else:
bath
=
dgDofContainer
(
groups
,
1
)
bath
.
setFieldName
(
0
,
'bath'
)
bath
.
readMsh
(
path_mesh
+
"B"
+
bathy_acc
+
"_bath_part/"
+
domain
+
mesh_acc
+
"B"
+
bathy_acc
+
"_bath_part.idx"
)
bath
.
importIdx
(
path_mesh
+
"B"
+
bathy_acc
+
"_bath_part/"
+
domain
+
mesh_acc
+
"B"
+
bathy_acc
+
"_bath_part.idx"
)
bath_PC
=
functionPrecomputed
(
groups
,
3
,
1
)
bath_PC
.
compute
(
bath
.
getFunction
())
...
...
benchmarks/titan/run_old.py
View file @
792dba47
...
...
@@ -73,7 +73,7 @@ solution.setFieldName(2, 'v')
bath
=
dgDofContainer
(
groups
,
1
)
bath
.
setFieldName
(
0
,
'bath'
)
bath
.
readMsh
(
path_mesh
+
"B"
+
bathy_acc
+
"_bath_part/"
+
domain
+
mesh_acc
+
"B"
+
bathy_acc
+
"_bath_part.idx"
)
bath
.
importIdx
(
path_mesh
+
"B"
+
bathy_acc
+
"_bath_part/"
+
domain
+
mesh_acc
+
"B"
+
bathy_acc
+
"_bath_part.idx"
)
bath_PC
=
functionPrecomputed
(
groups
,
3
,
1
)
bath_PC
.
compute
(
bath
.
getFunction
())
...
...
dgpy/scripts/slim.py
View file @
792dba47
...
...
@@ -1016,7 +1016,7 @@ class Loop:
index
=
self
.
_index_start
+
self
.
_n_iter_offline
%
self
.
_n_index_per_period
else
:
index
=
self
.
_n_iter_offline
i
.
_hydro_sol_dof
.
readMsh
(
i
.
_datafile
+
"-%06d_%06d.idx"
%
(
index
,
j
))
i
.
_hydro_sol_dof
.
importIdx
(
i
.
_datafile
+
"-%06d_%06d.idx"
%
(
index
,
j
))
i
.
_hydro_sol_dof
.
scatter
()
newton_converged
=
i
.
_temporal_solver
.
subiterate
(
i
.
_solution
,
self
.
_dt
,
self
.
_time
)
if
not
newton_converged
:
...
...
@@ -1026,7 +1026,7 @@ class Loop:
index
=
self
.
_index_start
+
self
.
_n_iter_offline
%
self
.
_n_index_per_period
else
:
index
=
self
.
_n_iter_offline
i
.
_hydro_sol_dof
.
readMsh
(
i
.
_datafile
+
"-%06d_%06d.idx"
%
(
index
,
j
))
i
.
_hydro_sol_dof
.
importIdx
(
i
.
_datafile
+
"-%06d_%06d.idx"
%
(
index
,
j
))
i
.
_hydro_sol_dof
.
scatter
()
for
e
in
self
.
_export_dofs_full
:
e
[
0
].
exportIdxSubTimeStep
(
self
.
_index_exporter_full
,
j
,
self
.
_time
-
e
[
1
])
...
...
dgpy/scripts/slim_private.py
View file @
792dba47
...
...
@@ -149,7 +149,7 @@ def _load(dof, data_file):
elif
(
file_name
[
-
4
:]
==
".msh"
):
dof
.
importMsh
(
file_name
)
elif
(
file_name
[
-
4
:]
==
".idx"
):
dof
.
readMsh
(
file_name
)
dof
.
importIdx
(
file_name
)
else
:
dgpy
.
Msg
.
Fatal
(
file_name
+
" must have one of the following extensions: '.idx', '.msh', '.nc'"
)
dof
.
scatter
(
False
)
...
...
@@ -176,7 +176,7 @@ def _load_function(data_file, groups):
return
f
elif
(
file_name
[
-
4
:]
==
".idx"
):
dof
=
dgpy
.
dgDofContainer
(
groups
,
1
)
dof
.
readMsh
(
file_name
)
dof
.
importIdx
(
file_name
)
dof
.
scatter
()
f
=
dof
.
getFunction
()
f
.
dof
=
dof
...
...
dofContainer/dgDofContainer.cpp
View file @
792dba47
...
...
@@ -1627,6 +1627,121 @@ void dgDofContainer::exportFunctionSurf (functor * fun, const std::string name,
}
}
void
_readMsh
(
dgDofContainer
&
dof
,
std
::
string
name
,
double
&
time
,
int
&
step
,
std
::
map
<
int
,
int
>
componentMap
){
std
::
ifstream
f
(
name
.
c_str
());
if
(
!
f
.
is_open
()){
Msg
::
Fatal
(
"Unable to open import file '%s'"
,
name
.
c_str
());
}
std
::
string
word
;
int
ibuff
;
double
dbuff
;
f
>>
word
;
if
(
word
!=
"$MeshFormat"
)
Msg
::
Fatal
(
"bad file '%s'"
,
name
.
c_str
());
f
>>
dbuff
;
if
(
dbuff
<
2.0
)
Msg
::
Fatal
(
"bad file '%s'"
,
name
.
c_str
());
f
>>
ibuff
>>
ibuff
;
f
>>
word
;
if
(
word
!=
"$EndMeshFormat"
)
Msg
::
Fatal
(
"bad file '%s'"
,
name
.
c_str
());
f
>>
word
;
if
(
word
==
"$InterpolationScheme"
)
{
while
(
word
!=
"$EndInterpolationScheme"
&&
!
f
.
eof
())
f
>>
word
;
f
>>
word
;
}
if
(
word
!=
"$ElementNodeData"
)
Msg
::
Fatal
(
"bad file '%s'"
,
name
.
c_str
());
int
nStrings
;
f
>>
nStrings
;
getline
(
f
,
word
);
for
(
int
i
=
0
;
i
<
nStrings
;
i
++
)
getline
(
f
,
word
);
int
ndouble
;
f
>>
ndouble
>>
time
;
for
(
int
i
=
1
;
i
<
ndouble
;
++
i
)
f
>>
dbuff
;
int
nint
,
ncomp
,
count
;
f
>>
nint
>>
step
>>
ncomp
>>
count
;
for
(
int
i
=
3
;
i
<
nint
;
++
i
)
f
>>
ibuff
;
fullMatrix
<
double
>
sol
;
std
::
vector
<
int
>
ocomps
(
ncomp
,
-
1
);
for
(
auto
it
:
componentMap
)
{
ocomps
[
it
.
second
]
=
it
.
first
;
}
if
(
componentMap
.
empty
())
{
for
(
int
i
=
0
;
i
<
ncomp
;
++
i
)
ocomps
[
i
]
=
i
;
}
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
int
elementNum
,
size
;
f
>>
elementNum
>>
size
;
int
iGroup
,
iElem
;
dof
.
getGroups
()
->
find
(
elementNum
,
iGroup
,
iElem
);
if
(
iGroup
!=
-
1
){
dof
.
getGroupProxy
(
iGroup
).
getBlockProxy
(
iElem
,
sol
);
if
(
size
!=
sol
.
size1
())
Msg
::
Fatal
(
"bad size (%i) for element id (%i) in file '%s'"
,
size
,
elementNum
,
name
.
c_str
());
for
(
int
k
=
0
;
k
<
sol
.
size1
();
++
k
){
for
(
int
icomp
=
0
;
icomp
<
ncomp
;
++
icomp
)
{
int
ocomp
=
ocomps
[
icomp
];
if
(
ocomp
==
-
1
||
ocomp
>=
sol
.
size2
()){
f
>>
dbuff
;
}
else
{
if
(
!
(
f
>>
sol
(
k
,
ocomp
)))
Msg
::
Fatal
(
"bad file '%s'"
,
name
.
c_str
());
}
}
}
}
else
{
getline
(
f
,
word
);
}
}
f
>>
word
;
if
(
word
!=
"$EndElementNodeData"
)
Msg
::
Fatal
(
"bad file '%s' (got '%s')"
,
name
.
c_str
(),
word
.
c_str
());
}
static
double
_importIdx
(
dgDofContainer
&
dof
,
std
::
string
filename
,
std
::
map
<
int
,
int
>
componentMap
,
int
next_field
)
{
std
::
ifstream
f
(
filename
);
std
::
string
buf
;
auto
dirend
=
filename
.
find_last_of
(
"/"
);
std
::
string
dirname
;
if
(
dirend
!=
std
::
string
::
npos
)
dirname
=
filename
.
substr
(
0
,
dirend
+
1
);
double
time
=
0
;
while
(
f
>>
buf
)
{
if
(
buf
==
"Merge"
){
getline
(
f
,
buf
);
auto
p0
=
buf
.
find
(
'\"'
);
auto
p1
=
buf
.
find
(
'\"'
,
p0
+
1
);
if
(
p0
==
std
::
string
::
npos
||
p1
==
std
::
string
::
npos
)
Msg
::
Error
(
"invalid file : %s"
,
filename
.
c_str
());
std
::
string
sname
=
buf
.
substr
(
p0
+
1
,
p1
-
p0
-
1
);
std
::
string
ext
=
sname
.
substr
(
sname
.
find_last_of
(
"."
));
if
(
ext
==
".idx"
)
_importIdx
(
dof
,
dirname
+
sname
,
componentMap
,
next_field
);
else
{
std
::
map
<
int
,
int
>
shiftedCMap
;
for
(
auto
it
:
componentMap
)
shiftedCMap
[
it
.
first
]
=
it
.
second
-
next_field
;
double
time
;
int
step
;
_readMsh
(
dof
,
dirname
+
sname
,
time
,
step
,
shiftedCMap
);
}
}
else
if
(
buf
==
"//"
)
{
f
>>
buf
;
if
(
buf
==
"field"
)
{
f
>>
next_field
;
getline
(
f
,
buf
);
}
}
else
{
getline
(
f
,
buf
);
}
}
return
time
;
}
double
dgDofContainer
::
importIdx
(
const
std
::
string
filename
,
std
::
map
<
int
,
int
>
componentMap
)
{
return
_importIdx
(
*
this
,
filename
,
componentMap
,
0
);
}
static
void
writeMshInterpolationSchemes
(
FILE
*
f
,
const
std
::
string
&
name
,
const
dgGroupCollection
&
groups
)
{
std
::
set
<
const
nodalBasis
*>
allPb
;
...
...
@@ -1806,129 +1921,6 @@ void dgDofContainer::importMshNodeData(const std::string name, bool multiFile)
}
void
dgDofContainer
::
_readMsh
(
std
::
string
name
,
std
::
string
name_dir
,
double
&
time
,
int
&
step
,
int
nb_parts
,
int
dofF
){
size_t
endp
=
name
.
size
();
std
::
string
f2name
=
std
::
string
(
name
,
1
,
endp
-
3
);
std
::
ifstream
f
((
name_dir
+
f2name
).
c_str
());
if
(
!
f
.
is_open
()){
Msg
::
Fatal
(
"Unable to open import file '%s'"
,
(
name_dir
+
f2name
).
c_str
());
}
std
::
string
word
;
int
ibuff
;
double
dbuff
;
f
>>
word
;
if
(
word
!=
"$MeshFormat"
)
Msg
::
Fatal
(
"bad file '%s'"
,(
name_dir
+
f2name
).
c_str
());
f
>>
dbuff
;
if
(
dbuff
<
2.0
)
Msg
::
Fatal
(
"bad file '%s'"
,(
name_dir
+
f2name
).
c_str
());
f
>>
ibuff
>>
ibuff
;
f
>>
word
;
if
(
word
!=
"$EndMeshFormat"
)
Msg
::
Fatal
(
"bad file '%s'"
,(
name_dir
+
f2name
).
c_str
());
f
>>
word
;
if
(
word
==
"$InterpolationScheme"
)
{
while
(
word
!=
"$EndInterpolationScheme"
&&
!
f
.
eof
())
f
>>
word
;
f
>>
word
;
}
if
(
word
!=
"$ElementNodeData"
)
Msg
::
Fatal
(
"bad file '%s'"
,(
name_dir
+
f2name
).
c_str
());
int
nStrings
;
f
>>
nStrings
;
getline
(
f
,
word
);
for
(
int
i
=
0
;
i
<
nStrings
;
i
++
)
getline
(
f
,
word
);
f
>>
dbuff
>>
time
;
f
>>
dbuff
>>
step
;
int
count
,
rank
,
cr
;
f
>>
rank
>>
count
;
if
(
nb_parts
>
1
)
f
>>
cr
;
fullMatrix
<
double
>
sol
;
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
int
elementNum
,
size
;
f
>>
elementNum
>>
size
;
int
iGroup
,
iElem
;
_groups
->
find
(
elementNum
,
iGroup
,
iElem
);
if
(
iGroup
!=
-
1
){
getGroupProxy
(
iGroup
).
getBlockProxy
(
iElem
,
sol
);
if
(
size
!=
sol
.
size1
())
Msg
::
Fatal
(
"bad size (%i) for element id (%i) in file '%s'"
,
size
,
elementNum
,
(
name_dir
+
f2name
).
c_str
());
for
(
int
k
=
0
;
k
<
sol
.
size1
();
++
k
)
{
if
(
!
(
f
>>
sol
(
k
,
dofF
)))
Msg
::
Fatal
(
"bad file '%s'"
,(
name_dir
+
f2name
).
c_str
());
}
}
else
{
getline
(
f
,
word
);
}
}
f
>>
word
;
if
(
word
!=
"$EndElementNodeData"
)
Msg
::
Fatal
(
"bad file '%s' (got '%s')"
,
(
name_dir
+
f2name
).
c_str
(),
word
.
c_str
());
}
void
dgDofContainer
::
readMsh
(
const
std
::
string
name
,
double
&
time
,
int
&
step
,
int
inField
,
int
outField
)
{
if
((
inField
==
-
1
&&
outField
!=-
1
)
||
(
outField
==
-
1
&&
inField
!=-
1
))
Msg
::
Fatal
(
"Both fields ids need to be -1 to import all fields or 2 existing positive fields ids should be considered"
);
std
::
string
name_file
,
name_dir
;
size_t
lastp
=
name
.
find_last_of
(
'/'
);
size_t
endp
=
name
.
size
();
if
(
lastp
!=
std
::
string
::
npos
){
name_file
=
std
::
string
(
name
,
lastp
+
1
,
endp
);
name_dir
=
std
::
string
(
name
,
0
,
lastp
+
1
);
}
else
{
name_file
=
name
;
name_dir
=
""
;
}
std
::
ifstream
g1
(
name
.
c_str
());
if
(
!
g1
.
is_open
()){
Msg
::
Fatal
(
"Unable to open import file '%s'"
,
name
.
c_str
());
}
std
::
string
text
,
f1name
;
int
nb_fields
,
nb_parts
,
iField
,
jField
;
g1
>>
text
>>
text
;
g1
>>
nb_fields
;
if
(
inField
<
-
1
||
inField
>=
nFieldMax
()){
Msg
::
Fatal
(
"Field %d does not exist for the actual dgDofContainer"
,
inField
);
}
if
(
outField
<
-
1
||
outField
>=
nb_fields
){
Msg
::
Fatal
(
"Field %d does not exist in the file %s"
,
outField
,
name
.
c_str
());
}
g1
>>
text
>>
text
;
g1
>>
nb_parts
;
if
(
nb_fields
>
1
){
for
(
int
iF
=
0
;
iF
<
nb_fields
;
iF
++
){
g1
>>
text
>>
text
;
g1
>>
iField
;
g1
>>
text
>>
text
;
if
(
iField
==
outField
||
outField
==
-
1
){
int
dofF
;
if
(
inField
==
-
1
){
dofF
=
iF
;
}
else
{
dofF
=
inField
;
}
size_t
endp
=
text
.
size
();
f1name
=
std
::
string
(
text
,
1
,
endp
-
3
);
std
::
ifstream
g2
((
name_dir
+
f1name
).
c_str
());
if
(
!
g2
.
is_open
()){
Msg
::
Fatal
(
"Unable to open import file '%s'"
,
f1name
.
c_str
());
}
g2
>>
text
>>
text
;
g2
>>
jField
;
if
(
iField
!=
jField
)
Msg
::
Fatal
(
"Fields are not compatible!"
);
for
(
int
iP
=
0
;
iP
<
nb_parts
;
iP
++
){
g2
>>
text
>>
text
;
_readMsh
(
text
,
name_dir
,
time
,
step
,
nb_parts
,
dofF
);
}
}
}
}
else
{
for
(
int
iP
=
0
;
iP
<
nb_parts
;
iP
++
){
g1
>>
text
>>
text
;
_readMsh
(
text
,
name_dir
,
time
,
step
,
nb_parts
,
0
);
}
}
}
void
dgDofContainer
::
exportMsh
(
const
std
::
string
name
,
double
time
,
int
step
,
std
::
string
fieldName
)
const
{
for
(
int
ICOMP
=
0
;
ICOMP
<
nFieldMax
();
++
ICOMP
)
...
...
dofContainer/dgDofContainer.h
View file @
792dba47
...
...
@@ -74,9 +74,8 @@ class dgDofContainer
std
::
vector
<
dgFullMatrix
<
double
>
>
_dataProxys
;
// proxys
std
::
vector
<
int
>
_groupFirstDofId
;
// _readMsh, is a subfunction of readMsh, which reads msh files from idx files
void
_readMsh
(
std
::
string
name
,
std
::
string
name_dir
,
double
&
time
,
int
&
step
,
int
nb_parts
,
int
dofF
);
void
_init
();
// read continuous (CG) data
void
readNodeData
(
std
::
ifstream
&
f
,
const
std
::
string
name
,
int
ICOMP
);
protected:
...
...
@@ -190,8 +189,8 @@ class dgDofContainer
void
importMsh
(
const
std
::
string
filename
,
double
&
time
,
int
&
step
,
std
::
string
&
fieldName
);
/** Import a msh file in the dof container using the "NodeData" file format. 'filename' refers to the part of the file name before _COMPXX.msh */
void
importMshNodeData
(
const
std
::
string
name
,
bool
multiFile
=
true
);
/** Import a
msh or
idx file
*/
void
readMsh
(
const
std
::
string
name
,
double
&
time
,
int
&
step
,
int
inField
=-
1
,
int
outField
=-
1
);
/** Import a
ll the idx and msh files listed in an
idx file*/
double
importIdx
(
const
std
::
string
name
,
std
::
map
<
int
,
int
>
componentMap
=
{}
);
/** Export a function for gmsh visualization, (this dof is used as solution). If the function is a vector, export a vector field instead of the three component fields of the vector */
void
exportFunctionMsh
(
const
functor
*
fun
,
const
std
::
string
name
,
double
time
=
0.0
,
int
step
=
0
,
std
::
string
fieldname
=
""
)
const
;
/** Export a function for gmsh visualization, (this dof is used as solution). It will export a field on a physical surface*/
...
...
modules/shallowWater/tests/interface_sw2Converge/test.py
View file @
792dba47
...
...
@@ -33,9 +33,9 @@ def mergeEtaUV(cmap,val,eta,uv):
groupsRef
=
dgpy
.
dgGroupCollection
(
"output/square-%i.msh"
%
nstage
,
1
)
etaRef
=
dgpy
.
dgDofContainer
(
groupsRef
,
1
)
etaRef
.
readMsh
(
"output/dof-%i-end/sw2d/eta/eta-000001.idx"
%
(
nstage
))