-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Initial commit merged 1D and Hybrid Simulators
- Loading branch information
1 parent
3f1076c
commit d47d706
Showing
37 changed files
with
2,045 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file Channel.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file Edge.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file FlowRatePump.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Edge.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file Module.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file Network.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file Node.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file PressurePump.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Edge.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file lbmModule.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#define M_PI 3.14159265358979323846 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file NodalAnalysis.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <Network.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set(SOURCE_LIST | ||
Results.hh | ||
) | ||
|
||
set(HEADER_LIST | ||
Results.h | ||
) | ||
|
||
target_sources(${TARGET_NAME} PUBLIC ${SOURCE_LIST} ${HEADER_LIST}) | ||
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) | ||
target_link_libraries(${TARGET_NAME} PUBLIC lbmLib) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/** | ||
* @file Results.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <unordered_map> | ||
|
||
#include "../architecture/Network.h" | ||
#include "../simulation/Droplet.h" | ||
#include "../simulation/Fluid.h" | ||
#include "../simulation/Injection.h" | ||
|
||
namespace result { | ||
|
||
/** | ||
* @brief Struct to contain a state specified by time, an unordered map of pressures, an unordered map of flow rates, a vector of clogged channel ids, an unordered map of droplet positions. | ||
*/ | ||
template<typename T> | ||
struct State { | ||
int id; ///< Sequential id of the state | ||
T time; ///< Simulation time at which the following values were calculated. | ||
std::unordered_map<int, T> pressures; ///< Keys are the nodeIds. | ||
std::unordered_map<int, T> flowRates; ///< Keys are the edgeIds (channels and pumps). | ||
std::unordered_map<int, sim::DropletPosition<T>> dropletPositions; ///< Only contains the position of droplets that are currently inside the network (key is the droplet id). | ||
|
||
/** | ||
* @brief Constructs a state, which represent a time step during a simulation. | ||
* @param[in] id Id of the state | ||
* @param[in] time Value of the current time step. | ||
*/ | ||
State(int id, T time); | ||
|
||
/** | ||
* @brief Constructs a state, which represent a time step during a simulation. | ||
* @param[in] id Id of the state | ||
* @param[in] time Value of the current time step. | ||
* @param[in] pressures The pressure values at the nodes at the current time step. | ||
* @param[in] flowRates The flowRate values at the nodes at the current time step. | ||
*/ | ||
State(int id, T time, std::unordered_map<int, T> pressures, std::unordered_map<int, T> flowRates); | ||
|
||
/** | ||
* @brief Constructs a state, which represent a time step during a simulation. | ||
* @param[in] id Id of the state | ||
* @param[in] time Value of the current time step. | ||
* @param[in] pressures The pressure values at the nodes at the current time step. | ||
* @param[in] flowRates The flowRate values at the nodes at the current time step. | ||
*/ | ||
State(int id, T time, std::unordered_map<int, T> pressures, std::unordered_map<int, T> flowRates, std::unordered_map<int, sim::DropletPosition<T>> dropletPositions); | ||
|
||
/** | ||
* @brief Function to get pressure at a specific node. | ||
* @return Pressures of this state in Pa. | ||
*/ | ||
std::unordered_map<int, T>& getPressures() const; | ||
|
||
/** | ||
* @brief Function to get flow rate at a specific channel. | ||
* @return Flowrates of this state in m^3/s. | ||
*/ | ||
std::unordered_map<int, T>& getFlowRates() const; | ||
|
||
/** | ||
* @brief Function to get flow rate at a specific channel. | ||
* @return Flowrates of this state in m^3/s. | ||
*/ | ||
std::unordered_map<int, T>& getDropletPositions() const; | ||
}; | ||
|
||
/** | ||
* @brief Struct to contain the simulation result specified by a chip, an unordered map of fluids, an unordered map of droplets, an unordered map of injections, a vector of states, a continuous fluid id, the maximal adaptive time step and the id of a resistance model. | ||
*/ | ||
template<typename T> | ||
struct SimulationResult { | ||
arch::Network<T>* network; /// Contains the chip, with all the channels and pumps. | ||
std::unordered_map<int, sim::Fluid<T>>* fluids; /// Contains all fluids which were defined (i.e., also the fluids which were created when droplets merged). | ||
std::unordered_map<int, sim::Droplet<T>>* droplets; /// Contains all droplets that occurred during the simulation not only the once that were injected (i.e., also merged and splitted droplets)/ | ||
std::unordered_map<int, sim::DropletInjection<T>>* injections; /// Contains all injections that happened during the simulation. | ||
std::vector<std::unique_ptr<State<T>>> states; /// Contains all states ordered according to their simulation time (beginning at the start of the simulation). | ||
|
||
int continuousPhaseId; /// Fluid id which served as the continuous phase. | ||
T maximalAdaptiveTimeStep; /// Value for the maximal adaptive time step that was used. | ||
int resistanceModel; /// Id of the used resistance model. | ||
|
||
SimulationResult( arch::Network<T>* network, | ||
std::unordered_map<int, sim::Fluid<T>>* fluids, | ||
std::unordered_map<int, sim::Droplet<T>>* droplets, | ||
std::unordered_map<int, sim::DropletInjection<T>>* injections); | ||
|
||
/** | ||
* @brief Adds a state to the simulation results. | ||
* @param[in] state | ||
*/ | ||
void addState(T time, std::unordered_map<int, T> pressures, std::unordered_map<int, T> flowRates); | ||
|
||
/** | ||
* @brief Adds a state to the simulation results. | ||
* @param[in] state | ||
*/ | ||
void addState(T time, std::unordered_map<int, T> pressures, std::unordered_map<int, T> flowRates, std::unordered_map<int, sim::DropletPosition<T>> dropletPositions); | ||
|
||
/** | ||
* @brief Get the simulated pressures at the nodes. | ||
* @return Vector of pressure values | ||
*/ | ||
std::unordered_map<int, T>& getFinalPressures() const; | ||
|
||
/** | ||
* @brief Get the simulated flowrates in the channels. | ||
* @return Vector of flowrate values | ||
*/ | ||
std::unordered_map<int, T>& getFinalFlowRates() const; | ||
|
||
/** | ||
* @brief Get the simulated flowrates in the channels. | ||
* @return Vector of flowrate values | ||
*/ | ||
std::unordered_map<int, T>& getFinalDropletPositions() const; | ||
|
||
/** | ||
* @brief Get the simulated states that were stored during simulation. | ||
* @return Vector of states | ||
*/ | ||
std::vector<std::unique_ptr<State<T>>>& getStates() const; | ||
}; | ||
|
||
} // namespace results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "Results.h" | ||
|
||
#include <iostream> | ||
#include <ostream> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include <nlohmann/json.hpp> | ||
|
||
namespace result { | ||
|
||
template<typename T> | ||
State<T>::State(int id, T time) : id(id), time(time) { } | ||
|
||
template<typename T> | ||
T State<T>::getPressure(int nodeId) const { | ||
return pressures.at(nodeId); | ||
} | ||
|
||
template<typename T> | ||
T State<T>::getPressureDrop(int node0Id, int node1Id) const { | ||
return getPressure(node0Id) - getPressure(node1Id); | ||
} | ||
|
||
template<typename T> | ||
T State<T>::getFlowRate(int channelId) const { | ||
return flowRates.at(channelId); | ||
} | ||
|
||
|
||
std::unordered_map<int, double> SimulationResult::getPressures() const { | ||
return states[0].pressures; | ||
} | ||
|
||
std::unordered_map<int, double> SimulationResult::getFlowRates() const { | ||
return states[0].flowRates; | ||
} | ||
|
||
} // namespace droplet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @file CFDSim.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <olb2D.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
set(SOURCE_LIST | ||
CFDSim.hh | ||
Droplet.hh | ||
Fluid.hh | ||
Injection.hh | ||
ResistanceModels.hh | ||
Simulation.hh | ||
) | ||
|
||
set(HEADER_LIST | ||
CFDSim.h | ||
Droplet.h | ||
Fluid.h | ||
Injection.h | ||
ResistanceModels.h | ||
Simulation.h | ||
) | ||
|
||
target_sources(${TARGET_NAME} PUBLIC ${SOURCE_LIST} ${HEADER_LIST}) | ||
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) | ||
target_link_libraries(${TARGET_NAME} PUBLIC lbmLib) | ||
target_link_libraries(${TARGET_NAME} PUBLIC lbmLib) | ||
|
||
add_subdirectory(events) |
Oops, something went wrong.