Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
06cd12a1
Commit
06cd12a1
authored
Apr 12, 2021
by
Alexiane Plessier
Browse files
Options
Downloads
Patches
Plain Diff
add some corrections on Boundary conditions
[ci skip]
parent
149388ad
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/scheme/CMakeLists.txt
+1
-0
1 addition, 0 deletions
src/scheme/CMakeLists.txt
src/scheme/UpwindExplicitTrafficSolver.cpp
+132
-53
132 additions, 53 deletions
src/scheme/UpwindExplicitTrafficSolver.cpp
src/scheme/UpwindExplicitTrafficSolver.hpp
+1
-1
1 addition, 1 deletion
src/scheme/UpwindExplicitTrafficSolver.hpp
with
134 additions
and
54 deletions
src/scheme/CMakeLists.txt
+
1
−
0
View file @
06cd12a1
...
@@ -6,4 +6,5 @@ add_library(
...
@@ -6,4 +6,5 @@ add_library(
DiscreteFunctionInterpoler.cpp
DiscreteFunctionInterpoler.cpp
DiscreteFunctionUtils.cpp
DiscreteFunctionUtils.cpp
ImplicitAcousticSolver.cpp
ImplicitAcousticSolver.cpp
UpwindExplicitTrafficSolver.cpp
PerfectGas.cpp
)
PerfectGas.cpp
)
This diff is collapsed.
Click to expand it.
src/scheme/UpwindExplicitTrafficSolver.cpp
+
132
−
53
View file @
06cd12a1
#include
<scheme/UpwindExplicitTrafficSolver.hpp>
#include
<scheme/UpwindExplicitTrafficSolver.hpp>
#include
<language/utils/FunctionSymbolId.hpp>
#include
<mesh/ItemValueUtils.hpp>
#include
<mesh/ItemValueUtils.hpp>
#include
<mesh/MeshNodeBoundary.hpp>
#include
<mesh/MeshNodeBoundary.hpp>
#include
<scheme/DirichletBoundaryConditionDescriptor.hpp>
#include
<scheme/DirichletBoundaryConditionDescriptor.hpp>
#include
<scheme/DiscreteFunctionP0.hpp>
#include
<scheme/DiscreteFunctionP0.hpp>
#include
<scheme/DiscreteFunctionUtils.hpp>
#include
<scheme/DiscreteFunctionUtils.hpp>
#include
<scheme/FreeBoundaryConditionDescriptor.hpp>
#include
<scheme/IBoundaryConditionDescriptor.hpp>
#include
<scheme/IBoundaryConditionDescriptor.hpp>
#include
<scheme/IDiscreteFunction.hpp>
#include
<scheme/IDiscreteFunction.hpp>
#include
<scheme/IDiscreteFunctionDescriptor.hpp>
#include
<scheme/IDiscreteFunctionDescriptor.hpp>
#include
<scheme/SymmetryBoundaryConditionDescriptor.hpp>
#include
<scheme/SymmetryBoundaryConditionDescriptor.hpp>
#include
<variant>
#include
<variant>
#include
<vector>
#include
<vector>
...
@@ -36,6 +37,11 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
...
@@ -36,6 +37,11 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
BoundaryConditionList
m_boundary_condition_list
;
BoundaryConditionList
m_boundary_condition_list
;
const
MeshType
&
m_mesh
;
const
MeshType
&
m_mesh
;
NodeValue
<
const
Rd
>
m_ur
;
NodeValue
<
const
Rd
>
m_upwind_flux
;
CellValue
<
const
Rd
>
m_tauj_carre
;
CellValue
<
const
Rd
>
m_Mj
;
CellValue
<
const
double
>
CellValue
<
const
double
>
_getRho
(
const
DiscreteScalarFunction
&
tau
)
_getRho
(
const
DiscreteScalarFunction
&
tau
)
{
{
...
@@ -85,12 +91,13 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
...
@@ -85,12 +91,13 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
return
inv_Mj
;
return
inv_Mj
;
}
}
const
NodeValue
<
const
double
>
_getUpwindFlux
=
(
const
DiscreteScalarFunction
&
tau
)[
&
]()
NodeValue
<
const
Rd
>
_getUpwindFlux
(
const
DiscreteScalarFunction
&
tau
)
{
{
const
auto
&
node_to_cell_matrix
=
m_mesh
.
connectivity
().
nodeToCellMatrix
();
const
auto
&
node_to_cell_matrix
=
m_mesh
.
connectivity
().
nodeToCellMatrix
();
const
auto
&
node_local_numbers_in_their_cells
=
m_mesh
.
connectivity
().
nodeLocalNumbersInTheirCells
();
const
auto
&
node_local_numbers_in_their_cells
=
m_mesh
.
connectivity
().
nodeLocalNumbersInTheirCells
();
NodeValue
<
d
ouble
>
computed_flux
(
m_mesh
.
connectivity
());
NodeValue
<
R
d
>
computed_flux
(
m_mesh
.
connectivity
());
parallel_for
(
parallel_for
(
m_mesh
.
numberOfNodes
(),
PUGS_LAMBDA
(
NodeId
r
)
{
m_mesh
.
numberOfNodes
(),
PUGS_LAMBDA
(
NodeId
r
)
{
const
auto
&
node_cells
=
node_to_cell_matrix
[
r
];
const
auto
&
node_cells
=
node_to_cell_matrix
[
r
];
...
@@ -128,7 +135,83 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
...
@@ -128,7 +135,83 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
return
computed_flux
;
return
computed_flux
;
}
}
NodeValue
<
const
Rd
>
_computeUr
=
(
const
MeshType
&
mesh
,
NodeValue
<
const
double
>
upwind_flux
)
BoundaryConditionList
_getBCList
(
const
std
::
shared_ptr
<
const
MeshType
>&
mesh
,
const
std
::
vector
<
std
::
shared_ptr
<
const
IBoundaryConditionDescriptor
>>&
bc_descriptor_list
)
{
BoundaryConditionList
bc_list
;
constexpr
ItemType
FaceType
=
[]
{
if
constexpr
(
Dimension
>
1
)
{
return
ItemType
::
face
;
}
else
{
return
ItemType
::
node
;
}
}();
for
(
const
auto
&
bc_descriptor
:
bc_descriptor_list
)
{
bool
is_valid_boundary_condition
=
true
;
switch
(
bc_descriptor
->
type
())
{
case
IBoundaryConditionDescriptor
::
Type
::
dirichlet
:
{
const
DirichletBoundaryConditionDescriptor
&
dirichlet_bc_descriptor
=
dynamic_cast
<
const
DirichletBoundaryConditionDescriptor
&>
(
*
bc_descriptor
);
if
(
dirichlet_bc_descriptor
.
name
()
==
"velocity"
)
{
for
(
size_t
i_ref_face_list
=
0
;
i_ref_face_list
<
mesh
->
connectivity
().
template
numberOfRefItemList
<
FaceType
>();
++
i_ref_face_list
)
{
const
auto
&
ref_face_list
=
mesh
->
connectivity
().
template
refItemList
<
FaceType
>(
i_ref_face_list
);
const
RefId
&
ref
=
ref_face_list
.
refId
();
if
(
ref
==
dirichlet_bc_descriptor
.
boundaryDescriptor
())
{
MeshNodeBoundary
<
Dimension
>
mesh_node_boundary
{
mesh
,
ref_face_list
};
const
FunctionSymbolId
velocity_id
=
dirichlet_bc_descriptor
.
rhsSymbolId
();
const
auto
&
node_list
=
mesh_node_boundary
.
nodeList
();
Array
<
const
TinyVector
<
Dimension
>>
value_list
=
InterpolateItemValue
<
TinyVector
<
Dimension
>
(
TinyVector
<
Dimension
>
)
>::
template
interpolate
<
ItemType
::
node
>(
velocity_id
,
mesh
->
xr
(),
node_list
);
bc_list
.
push_back
(
VelocityBoundaryCondition
{
node_list
,
value_list
});
}
}
}
else
{
is_valid_boundary_condition
=
false
;
}
break
;
}
case
IBoundaryConditionDescriptor
::
Type
::
free
:
{
// <- Free boundary
const
FreeBoundaryConditionDescriptor
&
free_bc_descriptor
=
dynamic_cast
<
const
FreeBoundaryConditionDescriptor
&>
(
*
bc_descriptor
);
for
(
size_t
i_ref_face_list
=
0
;
i_ref_face_list
<
mesh
->
connectivity
().
template
numberOfRefItemList
<
ItemType
::
node
>();
++
i_ref_face_list
)
{
const
auto
&
ref_face_list
=
mesh
->
connectivity
().
template
refItemList
<
ItemType
::
node
>(
i_ref_face_list
);
const
RefId
&
ref
=
ref_face_list
.
refId
();
if
(
ref
==
free_bc_descriptor
.
boundaryDescriptor
())
{
MeshNodeBoundary
<
Dimension
>
mesh_node_boundary
{
mesh
,
ref_face_list
};
const
auto
&
node_list
=
mesh_node_boundary
.
nodeList
();
bc_list
.
push_back
(
FreeBoundaryCondition
{
node_list
});
}
}
break
;
}
default
:
{
is_valid_boundary_condition
=
false
;
}
}
if
(
not
is_valid_boundary_condition
)
{
std
::
ostringstream
error_msg
;
error_msg
<<
*
bc_descriptor
<<
" is an invalid boundary condition for acoustic solver"
;
throw
NormalError
(
error_msg
.
str
());
}
}
return
bc_list
;
}
NodeValue
<
const
Rd
>
_computeUr
(
const
MeshType
&
mesh
,
NodeValue
<
const
double
>
upwind_flux
)
{
{
NodeValue
<
Rd
>
computed_ur
(
mesh
.
connectivity
());
NodeValue
<
Rd
>
computed_ur
(
mesh
.
connectivity
());
parallel_for
(
parallel_for
(
...
@@ -140,32 +223,34 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
...
@@ -140,32 +223,34 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
UpwindExplicitTrafficSolver
(
UpwindExplicitTrafficSolver
(
const
std
::
shared_ptr
<
const
MeshType
>&
p_mesh
,
const
std
::
shared_ptr
<
const
MeshType
>&
p_mesh
,
const
DiscreteScalarFunction
tau
,
const
DiscreteScalarFunction
tau
,
const
std
::
vector
<
std
::
shared_ptr
<
const
IBoundaryConditionDescrpt
i
or
>>&
bc_descriptor_list
)
const
std
::
vector
<
std
::
shared_ptr
<
const
IBoundaryConditionDescr
i
ptor
>>&
bc_descriptor_list
)
:
m_boundary_condition_list
{
this
->
_getBCList
(
p_mesh
,
bc_descriptor_list
)}
:
m_boundary_condition_list
{
this
->
_getBCList
(
p_mesh
,
bc_descriptor_list
)}
,
m_mesh
{
*
p_mesh
}
{
{
const
MeshType
&
mesh
=
*
p_mesh
;
const
MeshType
&
mesh
=
*
p_mesh
;
CellValue
<
double
>
rhoj
=
this
->
_getRho
(
tau
);
CellValue
<
double
>
rhoj
=
this
->
_getRho
(
tau
);
CellValue
<
double
>
uj
=
this
->
_getU
(
tau
);
CellValue
<
double
>
uj
=
this
->
_getU
(
tau
);
CellValue
<
double
>
tauj_carre
=
this
->
_getTau_carre
(
tau
);
CellValue
<
double
>
Mj
=
this
->
_getMj
(
tau
);
CellValue
<
double
>
inv_Mj
=
this
->
_getInv_Mj
(
tau
);
CellValue
<
double
>
inv_Mj
=
this
->
_getInv_Mj
(
tau
);
m_upwind_flux
=
this
->
_getUpwindFlux
(
tau
);
m_upwind_flux
=
this
->
_getUpwindFlux
(
tau
);
m_ur
=
this
->
_computeUr
(
mesh
,
m_upwind_flux
);
m_ur
=
this
->
_computeUr
(
mesh
,
m_upwind_flux
);
m_tauj_carre
=
this
->
_getTaucarre
(
tau
);
m_Mj
=
this
->
_getMj
(
tau
);
;
}
}
public
:
public
:
std
::
tuple
<
std
::
shared_ptr
<
const
IMesh
>
,
std
::
shared_ptr
<
const
DiscreteFunctionP0
<
Dimension
,
double
>>>
std
::
tuple
<
std
::
shared_ptr
<
const
IMesh
>
,
std
::
shared_ptr
<
const
DiscreteFunctionP0
<
Dimension
,
double
>>>
apply
(
const
std
::
shared_ptr
<
const
MeshType
>&
mesh
,
const
DiscreteFunctionP0
<
Dimension
,
double
>&
tau
)
const
apply
(
const
std
::
shared_ptr
<
const
MeshType
>&
mesh
,
const
DiscreteFunctionP0
<
Dimension
,
double
>&
tau
)
const
{
{
MeshDataType
&
mesh_data
=
MeshDataManager
::
instance
().
getMeshData
(
mesh
);
double
c
=
0
;
double
c
=
0
;
c
=
1.
/
min
(
tauj_carre
);
c
=
1.
/
min
(
m_
tauj_carre
);
double
dt
=
0
;
double
dt
=
0
;
dt
=
0.5
*
min
(
Mj
)
/
c
;
dt
=
0.5
*
min
(
m_
Mj
)
/
c
;
const
NodeValuePerCell
<
const
TinyVector
<
1
,
double
>
>
Cjr
=
mesh_data
.
Cjr
();
const
NodeValuePerCell
<
Rd
>
Cjr
=
mesh_data
.
Cjr
();
const
auto
&
cell_to_node_matrix
=
mesh
->
connectivity
().
cellToNodeMatrix
();
const
auto
&
cell_to_node_matrix
=
mesh
->
connectivity
().
cellToNodeMatrix
();
...
@@ -177,7 +262,7 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
...
@@ -177,7 +262,7 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
CellValue
<
const
double
>
Vj
=
MeshDataManager
::
instance
().
getMeshData
(
*
mesh
).
Vj
();
CellValue
<
const
double
>
Vj
=
MeshDataManager
::
instance
().
getMeshData
(
*
mesh
).
Vj
();
const
NodeValuePerCell
<
const
Rd
>&
Cjr
=
MeshDataManager
::
instance
().
getMeshData
(
*
mesh
).
Cjr
();
Cjr
=
MeshDataManager
::
instance
().
getMeshData
(
*
mesh
).
Cjr
();
CellValue
<
double
>
new_tau
=
copy
(
tau
.
cellValues
());
CellValue
<
double
>
new_tau
=
copy
(
tau
.
cellValues
());
...
@@ -195,9 +280,6 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
...
@@ -195,9 +280,6 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
CellValue
<
const
double
>
new_Vj
=
MeshDataManager
::
instance
().
getMeshData
(
*
new_mesh
).
Vj
();
CellValue
<
const
double
>
new_Vj
=
MeshDataManager
::
instance
().
getMeshData
(
*
new_mesh
).
Vj
();
parallel_for
(
mesh
->
numberOfCells
(),
PUGS_LAMBDA
(
CellId
j
)
{
new_rho
[
j
]
*=
Vj
[
j
]
/
new_Vj
[
j
];
});
return
{
new_mesh
,
std
::
make_shared
<
DiscreteScalarFunction
>
(
new_mesh
,
new_tau
)};
return
{
new_mesh
,
std
::
make_shared
<
DiscreteScalarFunction
>
(
new_mesh
,
new_tau
)};
}
}
std
::
tuple
<
std
::
shared_ptr
<
const
IMesh
>
,
std
::
shared_ptr
<
const
IDiscreteFunction
>>
std
::
tuple
<
std
::
shared_ptr
<
const
IMesh
>
,
std
::
shared_ptr
<
const
IDiscreteFunction
>>
...
@@ -228,34 +310,34 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
...
@@ -228,34 +310,34 @@ class UpwindExplicitTrafficSolverHandler ::UpwindExplicitTrafficSolver final
};
};
template
<
size_t
Dimension
>
template
<
size_t
Dimension
>
void
class
UpwindExplicitTrafficSolverHandler
::
UpwindExplicitTrafficSolver
<
Dimension
>::
VelocityBoundaryCondition
UpwindExplicitTrafficSolverHandler
::
UpwindExplicitTrafficSolver
<
Dimension
>::
_applyVelocityBC
(
NodeValue
<
Rdxd
>&
Ar
,
NodeValue
<
Rd
>&
br
)
{
{
for
(
const
auto
&
boundary_condition
:
m_boundary_condition_list
)
{
private:
std
::
visit
(
const
Array
<
const
TinyVector
<
Dimension
>>
m_value_list
;
[
&
](
auto
&&
bc
)
{
const
Array
<
const
NodeId
>
m_node_list
;
using
T
=
std
::
decay_t
<
decltype
(
bc
)
>
;
if
constexpr
(
std
::
is_same_v
<
VelocityBoundaryCondition
,
T
>
)
{
const
auto
&
node_list
=
bc
.
nodeList
();
const
auto
&
value_list
=
bc
.
valueList
();
parallel_for
(
node_list
.
size
(),
PUGS_LAMBDA
(
size_t
i_node
)
{
NodeId
node_id
=
node_list
[
i_node
];
const
auto
&
value
=
value_list
[
i_node
];
Ar
[
node_id
]
=
identity
;
public:
br
[
node_id
]
=
value
;
const
Array
<
const
NodeId
>&
});
nodeList
()
const
}
{
},
return
m_node_list
;
boundary_condition
);
}
}
const
Array
<
const
TinyVector
<
Dimension
>>&
valueList
()
const
{
return
m_value_list
;
}
}
VelocityBoundaryCondition
(
const
Array
<
const
NodeId
>&
node_list
,
const
Array
<
const
TinyVector
<
Dimension
>>&
value_list
)
:
m_value_list
{
value_list
},
m_node_list
{
node_list
}
{}
~
VelocityBoundaryCondition
()
=
default
;
};
template
<
size_t
Dimension
>
template
<
size_t
Dimension
>
class
UpwindExplicitTrafficHandler
::
UpwindExplicitTrafficSolver
<
Dimension
>::
FreeBoundaryCondition
class
UpwindExplicitTraffic
Solver
Handler
::
UpwindExplicitTrafficSolver
<
Dimension
>::
FreeBoundaryCondition
{
{
private:
private:
const
Array
<
const
NodeId
>
m_node_list
;
const
Array
<
const
NodeId
>
m_node_list
;
...
@@ -272,13 +354,7 @@ class UpwindExplicitTrafficHandler::UpwindExplicitTrafficSolver<Dimension>::Free
...
@@ -272,13 +354,7 @@ class UpwindExplicitTrafficHandler::UpwindExplicitTrafficSolver<Dimension>::Free
~
FreeBoundaryCondition
()
=
default
;
~
FreeBoundaryCondition
()
=
default
;
};
};
template
UpwindExplicitTrafficHandler
::
UpwindExplicitTrafficSolver
<
1
>
::
UpwindExplicitTrafficAlgorithm
(
UpwindExplicitTrafficSolverHandler
::
UpwindExplicitTrafficSolverHandler
(
std
::
shared_ptr
<
const
IMesh
>
,
const
std
::
vector
<
std
::
shared_ptr
<
const
IBoundaryConditionDescriptor
>>&
,
const
FunctionSymbolId
&
,
const
double
&
);
UpwindExplicitTrafficHandler
::
UpwindExplicitTrafficSolverHandler
(
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
tau
,
const
std
::
shared_ptr
<
const
IDiscreteFunction
>&
tau
,
const
std
::
vector
<
std
::
shared_ptr
<
const
IBoundaryConditionDescriptor
>>&
bc_descriptor_list
)
const
std
::
vector
<
std
::
shared_ptr
<
const
IBoundaryConditionDescriptor
>>&
bc_descriptor_list
)
{
{
...
@@ -293,15 +369,18 @@ UpwindExplicitTrafficHandler::UpwindExplicitTrafficSolverHandler(
...
@@ -293,15 +369,18 @@ UpwindExplicitTrafficHandler::UpwindExplicitTrafficSolverHandler(
switch
(
i_mesh
->
dimension
())
{
switch
(
i_mesh
->
dimension
())
{
case
1
:
{
case
1
:
{
m_traffic_solver
=
std
::
make_unique
<
UpwindExplicitTrafficSolver
<
1
>>
(
i_mesh
,
tau
,
bc_descriptor_list
);
m_upwind_explicit_traffic_solver
=
std
::
make_unique
<
UpwindExplicitTrafficSolver
<
1
>>
(
i_mesh
,
tau
,
bc_descriptor_list
);
break
;
break
;
}
}
case
2
:
{
case
2
:
{
m_traffic_solver
=
std
::
make_unique
<
UpwindExplicitTrafficSolver
<
2
>>
(
i_mesh
,
tau
,
bc_descriptor_list
);
m_upwind_explicit_traffic_solver
=
std
::
make_unique
<
UpwindExplicitTrafficSolver
<
2
>>
(
i_mesh
,
tau
,
bc_descriptor_list
);
break
;
break
;
}
}
case
3
:
{
case
3
:
{
m_traffic_solver
=
std
::
make_unique
<
UpwindExplicitTrafficSolver
<
3
>>
(
i_mesh
,
tau
,
bc_descriptor_list
);
m_upwind_explicit_traffic_solver
=
std
::
make_unique
<
UpwindExplicitTrafficSolver
<
3
>>
(
i_mesh
,
tau
,
bc_descriptor_list
);
break
;
break
;
}
}
default
:
{
default
:
{
...
...
This diff is collapsed.
Click to expand it.
src/scheme/UpwindExplicitTrafficSolver.hpp
+
1
−
1
View file @
06cd12a1
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#include
<tuple>
#include
<tuple>
#include
<vector>
#include
<vector>
class
IDiscreteF
U
nction
;
class
IDiscreteF
u
nction
;
class
IBoundaryConditionDescriptor
;
class
IBoundaryConditionDescriptor
;
class
IMesh
;
class
IMesh
;
...
...
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