Skip to content

Commit

Permalink
Get # of ODEs to solve
Browse files Browse the repository at this point in the history
  • Loading branch information
JCGoran committed Oct 21, 2024
1 parent 9b58feb commit a6ea5ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/language/codegen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
type: Name
node_name: true
suffix: {value: " "}
- n_odes:
brief: "number of ODEs to solve"
type: Integer
prefix: {value: "["}
suffix: {value: "]"}
- non_stiff_block:
brief: "Block with statements of the form Dvar = f(var), used for updating non-stiff systems"
type: StatementBlock
Expand Down
10 changes: 6 additions & 4 deletions src/visitors/cvode_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,12 @@ void CvodeVisitor::visit_program(ast::Program& node) {

NonStiffVisitor(node.get_symbol_table()).visit_statement_block(*non_stiff_block);
StiffVisitor(node.get_symbol_table()).visit_statement_block(*stiff_block);
node.emplace_back_node(
new ast::CvodeBlock(der_block->get_name(),
std::shared_ptr<ast::StatementBlock>(non_stiff_block),
std::shared_ptr<ast::StatementBlock>(stiff_block)));
auto prime_vars = collect_nodes(*der_block, {ast::AstNodeType::PRIME_NAME});
node.emplace_back_node(new ast::CvodeBlock(
der_block->get_name(),
std::shared_ptr<ast::Integer>(new ast::Integer(prime_vars.size(), nullptr)),
std::shared_ptr<ast::StatementBlock>(non_stiff_block),
std::shared_ptr<ast::StatementBlock>(stiff_block)));
}
}

Expand Down

0 comments on commit a6ea5ab

Please sign in to comment.