Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hydraulicModel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘乐
hydraulicModel
Commits
2c6877e8
Commit
2c6877e8
authored
Jun 10, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1, 水力模型转inp文件,增加阀门,水泵
parent
a818b0dd
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
200 additions
and
49 deletions
+200
-49
CivHydrCalc.cpp
pandaAnalysis/CivHydrCalc.cpp
+43
-10
CivDbConnection.cpp
pandaDbManager/CivDbConnection.cpp
+133
-19
CivDbConnection.h
pandaDbManager/CivDbConnection.h
+3
-1
CivTypes.h
pandaDbManager/CivTypes.h
+12
-17
CivHydrCalcMiddle.cpp
pandaHydrCalcMiddle/CivHydrCalcMiddle.cpp
+5
-0
CivHydrCalcMiddle.h
pandaHydrCalcMiddle/CivHydrCalcMiddle.h
+1
-0
Program.cs
pandaHydrDemo/Program.cs
+3
-2
水力模型.docx
建模文档/水力模型.docx
+0
-0
水力模型产品规划V1.0.xmind
建模文档/水力模型产品规划V1.0.xmind
+0
-0
No files found.
pandaAnalysis/CivHydrCalc.cpp
View file @
2c6877e8
...
...
@@ -85,7 +85,6 @@ bool CivHydrCalc::qualitySimulation(char* inpFile, char* rptFile, char* binOutFi
return
true
;
}
bool
CivHydrCalc
::
exportInp
(
char
*
fileName
)
{
//1 ,获取管网组件
...
...
@@ -105,12 +104,12 @@ bool CivHydrCalc::exportInp(char* fileName)
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
std
::
string
table
=
tables
[
i
];
if
(
"管线"
==
table
)
if
(
PIPELINE
==
table
)
continue
;
assemble
(
table
,
civInp
);
}
assemble
(
"管线"
,
civInp
);
assemble
(
PIPELINE
,
civInp
);
// 初始化选择
Options
options
;
options
.
units
=
Options
::
UNITS
::
LPS
;
...
...
@@ -160,9 +159,9 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
Componet
comp
=
comps
[
i
];
// 过滤掉与阀门和水泵连接的管线
Str
number
=
comp
.
find
(
"
编号
"
)
->
second
;
Str
number
=
comp
.
find
(
"
id
"
)
->
second
;
FiledFilter
filter
=
mDbConn
->
getFilter
();
std
::
set
<
Str
>
lineFilter
=
filter
.
find
(
"管线"
)
->
second
;
auto
lineFilter
=
filter
.
find
(
PIPELINE
)
->
second
;
if
(
lineFilter
.
count
(
number
)
>
0
)
continue
;
...
...
@@ -292,23 +291,23 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
std
::
vector
<
Str
>
vec
;
Str
head
=
comp
.
find
(
fields
.
head
)
->
second
;
if
(
!
head
.
empty
())
vec
.
push_back
(
fields
.
head
+
"
"
+
head
);
vec
.
push_back
(
"HEAD
"
+
head
);
Str
power
=
comp
.
find
(
fields
.
power
)
->
second
;
if
(
!
power
.
empty
())
vec
.
push_back
(
fields
.
power
+
"
"
+
power
);
vec
.
push_back
(
"POWER
"
+
power
);
Str
pattern
=
comp
.
find
(
fields
.
pattern
)
->
second
;
if
(
!
pattern
.
empty
())
vec
.
push_back
(
fields
.
pattern
+
"
"
+
pattern
);
vec
.
push_back
(
"PATTERN
"
+
pattern
);
Str
speed
=
comp
.
find
(
fields
.
speed
)
->
second
;
if
(
!
speed
.
empty
())
vec
.
push_back
(
fields
.
speed
+
"
"
+
speed
);
vec
.
push_back
(
"SPEED
"
+
speed
);
// 水池数据
CivItem
tankNode
;
tankNode
.
push_back
(
id
);
tankNode
.
push_back
(
"P"
+
id
);
tankNode
.
push_back
(
node1
);
tankNode
.
push_back
(
node2
);
...
...
@@ -370,6 +369,40 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
inp
.
writeComponet
(
nodeCoordItems
,
_COORDS
);
inp
.
writeComponet
(
tankItems
,
_TANKS
);
}
else
{
// 阀门
//;ID Node1 Node2 Diameter Type Setting MinorLoss
Componets
comps
=
mDbConn
->
getLikelyPipes
(
table
);
ValvesFields
fields
;
Civitems
vavleItems
;
int
total
=
comps
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
Str
id
=
comp
.
find
(
fields
.
ID
)
->
second
;
Str
node1
=
comp
.
find
(
fields
.
node1
)
->
second
;
Str
node2
=
comp
.
find
(
fields
.
node2
)
->
second
;
Str
diametor
=
comp
.
find
(
fields
.
Diameter
)
->
second
;
Str
label
=
comp
.
find
(
fields
.
type
)
->
second
;
Str
typeSeting
=
comp
.
find
(
fields
.
setting
)
->
second
;
Str
minorLoss
=
comp
.
find
(
fields
.
minorLoss
)
->
second
;
// 阀门数据
CivItem
vavleNode
;
vavleNode
.
push_back
(
"V"
+
id
);
vavleNode
.
push_back
(
node1
);
vavleNode
.
push_back
(
node2
);
vavleNode
.
push_back
(
diametor
);
vavleNode
.
push_back
(
label
);
vavleNode
.
push_back
(
typeSeting
);
vavleNode
.
push_back
(
minorLoss
);
vavleItems
.
push_back
(
vavleNode
);
}
inp
.
writeComponet
(
vavleItems
,
_VALVES
);
}
}
...
...
pandaDbManager/CivDbConnection.cpp
View file @
2c6877e8
...
...
@@ -36,7 +36,6 @@ void CivDbConnection::close()
mIsOpen
=
false
;
}
Tables
CivDbConnection
::
getTables
(
StrQuote
netName
,
StrQuote
schema
)
const
{
...
...
@@ -220,17 +219,46 @@ void CivDbConnection::getData(PGresult* result, Componets& comp) const
}
Componets
CivDbConnection
::
getNodeByCode
(
StrQuote
table
,
StrQuote
code
)
const
{
if
(
!
isValid
())
return
Nodes
();
char
sql
[
256
]
=
"select * from public.
\"
"
;
strcat_s
(
sql
,
table
.
c_str
());
strcat_s
(
sql
,
"
\"
"
);
strcat_s
(
sql
,
" where code = '"
);
strcat_s
(
sql
,
code
.
c_str
());
strcat_s
(
sql
,
"'"
);
std
::
string
utfStr
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
PGresult
*
result
=
PQexec
(
mConn
,
utfStr
.
c_str
());
if
(
result
==
NULL
)
{
return
Nodes
();
}
Componets
componets
;
getData
(
result
,
componets
);
PQclear
(
result
);
return
componets
;
}
Componets
CivDbConnection
::
getLineByCode
(
StrQuote
table
,
StrQuote
code
)
const
{
if
(
!
isValid
())
return
Nodes
();
char
sql
[
125
]
=
"select * from public.
\"
"
;
char
sql
[
256
]
=
"select * from public.
\"
"
;
strcat_s
(
sql
,
table
.
c_str
());
strcat_s
(
sql
,
"where from_code = "
);
strcat_s
(
sql
,
"
\"
"
);
strcat_s
(
sql
,
" where from_code = '"
);
strcat_s
(
sql
,
code
.
c_str
());
strcat_s
(
sql
,
"
or to_code=
"
);
strcat_s
(
sql
,
"
' or to_code= '
"
);
strcat_s
(
sql
,
code
.
c_str
());
strcat_s
(
sql
,
"'"
);
std
::
string
utfStr
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
PGresult
*
result
=
PQexec
(
mConn
,
utfStr
.
c_str
());
...
...
@@ -272,42 +300,128 @@ Componets CivDbConnection::getLikelyPipes(StrQuote tableName)
if
(
nodes
.
size
()
<=
0
)
return
Componets
();
// 查询:连接节点也有可能连接水源,或者水库
std
::
vector
<
Str
>
tables
;
tables
.
push_back
(
PIPENODE
);
tables
.
push_back
(
RESIVOIR
);
tables
.
push_back
(
TANK
);
// 阀门类型映射
std
::
map
<
Str
,
Str
>
mValvesMap
;
mValvesMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
PRV_TYPE
,
"PRV"
));
mValvesMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
PSV_TYPE
,
"PSV"
));
mValvesMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
PBV_TYPE
,
"PBV"
));
mValvesMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
FCV_TYPE
,
"FCV"
));
mValvesMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
TCV_TYPE
,
"TCV"
));
mValvesMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
GPV_TYPE
,
"PRV"
));
std
::
vector
<
Str
>
mVavesTables
;
mVavesTables
.
push_back
(
PRV_TYPE
);
mVavesTables
.
push_back
(
PSV_TYPE
);
mVavesTables
.
push_back
(
PBV_TYPE
);
mVavesTables
.
push_back
(
FCV_TYPE
);
mVavesTables
.
push_back
(
TCV_TYPE
);
mVavesTables
.
push_back
(
GPV_TYPE
);
// 不同阀门对应的特殊参数
std
::
map
<
Str
,
Str
>
mParameterMap
;
mParameterMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
PRV_TYPE
,
"恒定压力值"
));
mParameterMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
PSV_TYPE
,
"恒定压力值"
));
mParameterMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
PBV_TYPE
,
"恒定压力值"
));
mParameterMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
FCV_TYPE
,
"流量设置"
));
mParameterMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
TCV_TYPE
,
"流量设置"
));
mParameterMap
.
insert
(
std
::
pair
<
Str
,
Str
>
(
GPV_TYPE
,
"水头损失曲"
));
// 根据点数据查询起点和终点,管径
int
total
=
nodes
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
componet
=
nodes
[
i
];
nodes
[
i
][
"编号"
]
=
componet
.
find
(
"id"
)
->
second
;
Str
code
=
componet
.
find
(
"code"
)
->
second
;
Componets
lines
=
getLineByCode
(
"管线"
,
code
);
Componets
lines
=
getLineByCode
(
PIPELINE
,
code
);
int
lTotal
=
lines
.
size
();
for
(
int
j
=
0
;
j
<
lTotal
;
j
++
)
{
Componet
lin
=
lines
[
j
];
Str
from_code
=
lin
.
find
(
"from_code"
)
->
second
;
Str
to_code
=
lin
.
find
(
"to_code"
)
->
second
;
Str
fromCode
=
lin
.
find
(
"from_code"
)
->
second
;
Str
toCode
=
lin
.
find
(
"to_code"
)
->
second
;
if
(
from_code
==
code
)
Componets
codeNodes
;
if
(
fromCode
==
code
)
{
Str
lastPointNo
=
lin
.
find
(
"上点号"
)
->
second
;
componet
.
insert
(
std
::
pair
<
Str
,
Str
>
(
"上点号"
,
lastPointNo
));
int
size
=
tables
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
codeNodes
=
getNodeByCode
(
tables
[
i
],
toCode
);
if
(
codeNodes
.
size
()
>
0
)
break
;
}
if
(
codeNodes
.
size
()
>
0
)
{
Componet
comp
=
codeNodes
[
0
];
Str
pointNo
=
comp
.
find
(
"本点号"
)
->
second
;
nodes
[
i
][
"本点号"
]
=
pointNo
;
}
}
else
if
(
to
_c
ode
==
code
)
else
if
(
to
C
ode
==
code
)
{
Str
pointNo
=
lin
.
find
(
"本点号"
)
->
second
;
componet
.
insert
(
std
::
pair
<
Str
,
Str
>
(
"本点号"
,
pointNo
));
int
size
=
tables
.
size
();
Str
currTable
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
currTable
=
tables
[
i
];
codeNodes
=
getNodeByCode
(
tables
[
i
],
fromCode
);
if
(
codeNodes
.
size
()
>
0
)
break
;
}
// 查询
// codeNodes = getNodeByCode(PIPENODE, fromCode);
if
(
codeNodes
.
size
()
>
0
)
{
Componet
comp
=
codeNodes
[
0
];
Str
pointNo
=
comp
.
find
(
"本点号"
)
->
second
;
if
(
currTable
==
RESIVOIR
||
currTable
==
TANK
)
{
// 水源必须为起点:点转换为管线过程需要纠正方向
Str
lastPoint
=
nodes
[
i
][
"本点号"
];
nodes
[
i
][
"本点号"
]
=
pointNo
;
if
(
nodes
[
i
][
"上点号"
].
empty
())
nodes
[
i
][
"上点号"
]
=
lastPoint
;
}
else
{
nodes
[
i
][
"上点号"
]
=
pointNo
;
}
}
}
Str
diameter
=
lin
.
find
(
"管径"
)
->
second
;
componet
.
insert
(
std
::
pair
<
Str
,
Str
>
(
"管径"
,
diameter
));
Str
number
=
lin
.
find
(
"编号"
)
->
second
;
addFilter
(
"管线"
,
number
);
nodes
[
i
][
"管径"
]
=
diameter
;
Str
number
=
lin
.
find
(
"id"
)
->
second
;
addFilter
(
PIPELINE
,
number
);
// 阀门类型设置特殊字段
std
::
vector
<
Str
>::
iterator
iter
=
std
::
find
(
mVavesTables
.
begin
(),
mVavesTables
.
end
(),
tableName
);
if
(
iter
!=
mVavesTables
.
end
())
{
nodes
[
i
][
"类型"
]
=
mValvesMap
.
find
(
tableName
)
->
second
;
Str
fieldType
=
mParameterMap
.
find
(
tableName
)
->
second
;
nodes
[
i
][
"参数设置"
]
=
componet
.
find
(
fieldType
)
->
second
;
}
}
nodes
[
i
]
=
componet
;
}
return
nodes
;
}
...
...
pandaDbManager/CivDbConnection.h
View file @
2c6877e8
...
...
@@ -36,7 +36,7 @@ public:
*@tableName: 组件表
*/
Componets
getLikelyPipes
(
StrQuote
tableName
);
/**
*@brief 创建表格
...
...
@@ -72,6 +72,8 @@ private:
*/
Componets
getLineByCode
(
StrQuote
table
,
StrQuote
code
)
const
;
Componets
getNodeByCode
(
StrQuote
table
,
StrQuote
code
)
const
;
/**
*@brief 从查询集取出数据
*@result: 查询结果集
...
...
pandaDbManager/CivTypes.h
View file @
2c6877e8
...
...
@@ -10,11 +10,17 @@ typedef const std::string& StrQuote;
#define PIPELINE Str("管段")
#define PIPENODE Str("节点")
#define RESIVOIR Str("水库")
#define TANK Str("水池")
#define PUMP Str("水泵")
#define PRV_TYPE Str("稳压阀")
#define PSV_TYPE Str("减压阀")
#define PBV_TYPE Str("压力制动阀")
#define FCV_TYPE Str("流量控制阀")
#define TCV_TYPE Str("节流控制阀")
#define GPV_TYPE Str("常规阀门")
// 管点
#define Node std::map<Str,Str>
#define Nodes std::vector<Node>
...
...
@@ -43,17 +49,6 @@ enum ValvesType
GPV
/* 常规阀门 */
};
// 阀门数据库的表
struct
ValvesTables
{
Str
PRV
=
"减压阀"
;
Str
PSV
=
"稳压阀"
;
Str
PBV
=
"压力制动阀"
;
Str
FCV
=
"流量控制阀"
;
Str
TCV
=
"节流控制阀"
;
Str
GPV
=
"常规阀门"
;
};
// 水泵参数
enum
PumpParameter
{
...
...
@@ -107,10 +102,10 @@ struct ValvesFields {
Str
ID
=
"编号"
;
// 水泵表的本点号
Str
node1
=
"上点号"
;
// 与水泵连接的输入段本点号
Str
node2
=
"本点号"
;
// 水泵连接的下游管段
Str
Diameter
=
"
直
径"
;
// 直径
Str
Diameter
=
"
管
径"
;
// 直径
Str
type
=
"类型"
;
// 阀门类型
Str
setting
=
"
参数设置"
;
// 不同阀门对应不同参数
Str
minorLoss
=
"局部损失系数"
;
Str
setting
=
"参数设置"
;
// 不同阀门对应不同参数
Str
minorLoss
=
"局部损失系数"
;
//
};
// 水库字段
...
...
@@ -121,7 +116,7 @@ struct ResivoirFields {
Str
X_Coord
=
"横坐标"
;
Str
Y_Coord
=
"纵坐标"
;
Str
Pattern
=
"水头模式曲"
;
Str
Flow
=
"
输
出流量"
;
Str
Flow
=
"
流
出流量"
;
};
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
...
...
pandaHydrCalcMiddle/CivHydrCalcMiddle.cpp
View file @
2c6877e8
...
...
@@ -25,6 +25,11 @@ namespace CivHydr {
return
false
;
}
Boolean
CivHydrCalcMiddle
::
getInpFile
(
String
^
inpFile
)
{
return
mHydrCalc
->
exportInp
(
StringToCharStar
(
inpFile
));
}
Boolean
CivHydrCalcMiddle
::
hyDrCompute
()
{
return
mHydrCalc
->
hydrSimulation
(
mInpFile
,
mRptFile
,
mBinOutFile
);
...
...
pandaHydrCalcMiddle/CivHydrCalcMiddle.h
View file @
2c6877e8
...
...
@@ -29,6 +29,7 @@ namespace CivHydr {
*@flag: 计算标志, HDY:水力计算 QUALITY:水质计算
*/
Boolean
simulation
(
String
^
flag
);
Boolean
getInpFile
(
String
^
inpFile
);
void
setInpFile
(
String
^
inpFileName
);
...
...
pandaHydrDemo/Program.cs
View file @
2c6877e8
...
...
@@ -20,8 +20,9 @@ namespace pandaHydrDemo
calc
.
setOutBinFile
(
"test.bin"
);
String
flag
=
"HDY"
;
Boolean
sucess
=
calc
.
simulation
(
flag
);
Console
.
WriteLine
(
sucess
);
calc
.
getInpFile
(
"test.inp"
);
// Boolean sucess = calc.simulation(flag);
// Console.WriteLine(sucess);
}
}
}
建模文档/水力模型.docx
View file @
2c6877e8
No preview for this file type
建模文档/水力模型产品规划V1.0.xmind
View file @
2c6877e8
No preview for this file type
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