Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Develop (#18)" #19

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 0 additions & 257 deletions bugs/Pressure_droplet_id.json

This file was deleted.

25 changes: 0 additions & 25 deletions src/architecture/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,6 @@ class Network {
*/
bool isGround(int nodeId) const;

/**
* @brief Checks and returns if an edge is a channel
*/
bool isChannel(int edgeId) const;

/**
* @brief Checks and returns if an edge is a pressure pump
*/
bool isPressurePump(int edgeId) const;

/**
* @brief Checks and returns if an edge is a flowRate pump
*/
bool isFlowRatePump(int edgeId) const;

/**
* @brief Get a pointer to the node with the specific id.
*/
Expand Down Expand Up @@ -317,16 +302,6 @@ class Network {
*/
RectangularChannel<T>* getChannel(int channelId) const;

/**
* @brief Get a pointer to the pressure pump with the specific id.
*/
PressurePump<T>* getPressurePump(int pumpId) const;

/**
* @brief Get a pointer to the flowrate pump with the specific id.
*/
FlowRatePump<T>* getFlowRatePump(int pumpId) const;

/**
* @brief Get the channels of the network.
* @returns Channels.
Expand Down
25 changes: 0 additions & 25 deletions src/architecture/Network.hh
Original file line number Diff line number Diff line change
Expand Up @@ -362,21 +362,6 @@ bool Network<T>::isGround(int nodeId_) const {
return nodes.at(nodeId_)->getGround();
}

template<typename T>
bool Network<T>::isChannel(int edgeId_) const {
return channels.count(edgeId_);
}

template<typename T>
bool Network<T>::isPressurePump(int edgeId_) const {
return pressurePumps.count(edgeId_);
}

template<typename T>
bool Network<T>::isFlowRatePump(int edgeId_) const {
return flowRatePumps.count(edgeId_);
}

template<typename T>
std::shared_ptr<Node<T>>& Network<T>::getNode(int nodeId) {
return nodes.at(nodeId);
Expand Down Expand Up @@ -411,16 +396,6 @@ RectangularChannel<T>* Network<T>::getChannel(int channelId_) const {
return channels.at(channelId_).get();
}

template<typename T>
PressurePump<T>* Network<T>::getPressurePump(int pumpId_) const {
return pressurePumps.at(pumpId_).get();
}

template<typename T>
FlowRatePump<T>* Network<T>::getFlowRatePump(int pumpId_) const {
return flowRatePumps.at(pumpId_).get();
}

template<typename T>
const std::unordered_map<int, std::unique_ptr<RectangularChannel<T>>>& Network<T>::getChannels() const {
return channels;
Expand Down
6 changes: 3 additions & 3 deletions src/porting/jsonPorter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ void simulationFromJSON(std::string jsonFile, arch::Network<T>* network_, sim::S
simulation.setNetwork(network_);

readFluids<T>(jsonString, simulation);
readPumps<T>(jsonString, network_);

if (platform == sim::Platform::Continuous) {
if (simType == sim::Type::CFD) {
Expand Down Expand Up @@ -98,6 +97,7 @@ void simulationFromJSON(std::string jsonFile, arch::Network<T>* network_, sim::S

readBoundaryConditions<T>(jsonString, simulation, activeFixture);
readContinuousPhase<T>(jsonString, simulation, activeFixture);
readPumps<T>(jsonString, network_);
readResistanceModel<T>(jsonString, simulation);
}

Expand All @@ -113,8 +113,7 @@ sim::Simulation<T> simulationFromJSON(json jsonString, arch::Network<T>* network
simulation.setNetwork(network_);

readFluids<T>(jsonString, simulation);
readPumps<T>(jsonString, network_);


if (platform == sim::Platform::Continuous) {
if (simType == sim::Type::CFD) {
throw std::invalid_argument("Continuous simulations are currently not supported for CFD simulations.");
Expand Down Expand Up @@ -151,6 +150,7 @@ sim::Simulation<T> simulationFromJSON(json jsonString, arch::Network<T>* network

readBoundaryConditions<T>(jsonString, simulation, activeFixture);
readContinuousPhase<T>(jsonString, simulation, activeFixture);
readPumps<T>(jsonString, network_);
readResistanceModel<T>(jsonString, simulation);

return simulation;
Expand Down
32 changes: 12 additions & 20 deletions src/porting/jsonReaders.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ namespace porting {
template<typename T>
void readNodes(json jsonString, arch::Network<T>& network) {
for (auto& node : jsonString["network"]["nodes"]) {
if (node.contains("virtual") && node["virtual"]) {
continue;
} else {
bool ground = false;
if(node.contains("ground")) {
ground = node["ground"];
}
auto addedNode = network.addNode(T(node["x"]), T(node["y"]), ground);
if(node.contains("sink")) {
if (node["sink"]) {
network.setSink(addedNode->getId());
}
bool ground = false;
if(node.contains("ground")) {
ground = node["ground"];
}
auto addedNode = network.addNode(T(node["x"]), T(node["y"]), ground);
if(node.contains("sink")) {
if (node["sink"]) {
network.setSink(addedNode->getId());
}
}
}
Expand All @@ -25,12 +21,8 @@ void readNodes(json jsonString, arch::Network<T>& network) {
template<typename T>
void readChannels(json jsonString, arch::Network<T>& network) {
for (auto& channel : jsonString["network"]["channels"]) {
if (channel.contains("virtual") && channel["virtual"]) {
continue;
} else {
arch::ChannelType type = arch::ChannelType::NORMAL;
network.addChannel(channel["node1"], channel["node2"], channel["height"], channel["width"], type);
}
arch::ChannelType type = arch::ChannelType::NORMAL;
network.addChannel(channel["node1"], channel["node2"], channel["height"], channel["width"], type);
}
}

Expand Down Expand Up @@ -261,12 +253,12 @@ template<typename T>
void readResistanceModel(json jsonString, sim::Simulation<T>& simulation) {
sim::ResistanceModel<T>* resistanceModel;
if (jsonString["simulation"].contains("resistanceModel")) {
if (jsonString["simulation"]["resistanceModel"] == "Rectangular") {
if (jsonString["simulation"]["resistanceModel"] == "1D") {
resistanceModel = new sim::ResistanceModel1D<T>(simulation.getContinuousPhase()->getViscosity());
} else if (jsonString["simulation"]["resistanceModel"] == "Poiseuille") {
resistanceModel = new sim::ResistanceModelPoiseuille<T>(simulation.getContinuousPhase()->getViscosity());
} else {
throw std::invalid_argument("Invalid resistance model. Options are:\nRectangular\nPoiseuille");
throw std::invalid_argument("Invalid resistance model. Options are:\n1D\nPoiseuille");
}
} else {
throw std::invalid_argument("No resistance model defined.");
Expand Down
25 changes: 4 additions & 21 deletions src/simulation/Simulation.hh
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,13 @@ namespace sim {
}

template<typename T>
MixtureInjection<T>* Simulation<T>::addMixtureInjection(int mixtureId, int edgeId, T injectionTime) {
MixtureInjection<T>* Simulation<T>::addMixtureInjection(int mixtureId, int channelId, T injectionTime) {
auto id = mixtureInjections.size();
auto channel = network->getChannel(channelId);

if (network->isChannel(edgeId)) {
auto channel = network->getChannel(edgeId);
auto result = mixtureInjections.insert_or_assign(id, std::make_unique<MixtureInjection<T>>(id, mixtureId, channel, injectionTime));
return result.first->second.get();

} else if (network->isPressurePump(edgeId)) {
auto pump = network->getPressurePump(edgeId);
for (auto& channel : network->getChannelsAtNode(pump->getNodeB())) {
auto result = mixtureInjections.insert_or_assign(id, std::make_unique<MixtureInjection<T>>(id, mixtureId, channel, injectionTime));
}
return nullptr;

} else if (network->isFlowRatePump(edgeId)) {
auto pump = network->getFlowRatePump(edgeId);
for (auto& channel : network->getChannelsAtNode(pump->getNodeB())) {
auto result = mixtureInjections.insert_or_assign(id, std::make_unique<MixtureInjection<T>>(id, mixtureId, channel, injectionTime));
}
return nullptr;
}

auto result = mixtureInjections.insert_or_assign(id, std::make_unique<MixtureInjection<T>>(id, mixtureId, channel, injectionTime));

return result.first->second.get();
}

template<typename T>
Expand Down
Loading