-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified Block and BlockClasses method names Merged RecDomain class into Range class Simplified git-svn-id: https://svn.code.sf.net/p/schnek/code/trunk@50 af45edbf-8987-4407-81ba-83f5d200ebee
- Loading branch information
hschmitz
committed
Jul 14, 2014
1 parent
9626459
commit 02c3a1b
Showing
24 changed files
with
366 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,44 @@ | ||
EXTRA_PROGRAMS = example_grids_basics | ||
# Makefile.am | ||
# | ||
# Created on: 08 Jul 2014 | ||
# Author: Holger Schmitz | ||
# Email: holger@notjustphysics.com | ||
# | ||
# Copyright 2012 Holger Schmitz | ||
# | ||
# This file is part of Schnek. | ||
# | ||
# Schnek is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Schnek is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Schnek. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
|
||
EXTRA_PROGRAMS = example_grids_basics \ | ||
example_setup_first \ | ||
example_range | ||
|
||
example_grids_basics_SOURCES = example_grids_basics.cpp | ||
example_grids_basics_LDADD = -L../src -lschnek | ||
|
||
examples: example_grids_basics$(EXEEXT) | ||
example_setup_first_SOURCES = example_setup_first.cpp | ||
example_setup_first_LDADD = -L../src -lschnek | ||
|
||
example_range_SOURCES = example_range.cpp | ||
example_range_LDADD = -L../src -lschnek | ||
|
||
SCHNEK_EXAMPLES_OBJ = example_grids_basics$(EXEEXT) \ | ||
example_setup_first$(EXEEXT) \ | ||
example_range$(EXEEXT) | ||
|
||
examples: $(SCHNEK_EXAMPLES_OBJ) | ||
|
||
.PHONY: bench |
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,40 @@ | ||
/* | ||
* example_grids_basics.cpp | ||
* | ||
* Created on: 2 Jul 2014 | ||
* Author: Holger Schmitz | ||
* Email: holger@notjustphysics.com | ||
*/ | ||
|
||
#include "../src/grid/range.hpp" | ||
|
||
#include <iostream> | ||
|
||
using namespace schnek; | ||
|
||
int main() | ||
{ | ||
Range<int, 2>::LimitType low(1, 2); | ||
Range<int, 2>::LimitType high(4, 5); | ||
|
||
// create range using limits | ||
Range<int, 2> range(low, high); | ||
|
||
// read lower and upper bounds | ||
low = range.getLo(); | ||
high = range.getHi(); | ||
|
||
// modify bounds | ||
range.getLo() = Range<int, 2>::LimitType(5,2); | ||
range.getHi() = Range<int, 2>::LimitType(9,7); | ||
|
||
range.grow(-1); | ||
|
||
// iterate over range | ||
for (Range<int, 2>::iterator it=range.begin(); it!=range.end(); ++it) | ||
{ | ||
const Range<int, 2>::LimitType &pos = *it; | ||
std::cout << pos[0] << " " << pos[1] << std::endl; | ||
} | ||
|
||
} |
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,66 @@ | ||
/* | ||
* example_setup_first.cpp | ||
* | ||
* Created on: 8 Jul 2014 | ||
* Author: Holger Schmitz | ||
* Email: holger@notjustphysics.com | ||
*/ | ||
|
||
|
||
#include "../src/parser/parser.hpp" | ||
#include "../src/variables/block.hpp" | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
|
||
using namespace schnek; | ||
|
||
class SimulationBlock : public Block | ||
{ | ||
private: | ||
int size; | ||
double dx; | ||
std::string name; | ||
|
||
protected: | ||
void initParameters(BlockParameters ¶meters) | ||
{ | ||
parameters.addParameter("size", &size); | ||
parameters.addParameter("dx", &dx); | ||
parameters.addParameter("name", &name); | ||
} | ||
|
||
public: | ||
void writeValues() | ||
{ | ||
std::cout << "size = " << size << std::endl; | ||
std::cout << "dx = " << dx << std::endl; | ||
std::cout << "name = " << name << std::endl; | ||
} | ||
}; | ||
|
||
int main() | ||
{ | ||
BlockClasses blocks; | ||
|
||
blocks.addBlock("sim").setClass<SimulationBlock>(); | ||
|
||
// blocks.addBlock("sim"); | ||
// blocks("sim").setClass<SimulationBlock>(); | ||
|
||
std::ifstream in("example_setup_first03.setup"); | ||
|
||
Parser P("my_simulation", "sim", blocks); | ||
registerCMath(P.getFunctionRegistry()); | ||
pBlock application = P.parse(in); | ||
|
||
SimulationBlock &mysim = dynamic_cast<SimulationBlock&>(*application); | ||
mysim.evaluateParameters(); | ||
mysim.writeValues(); | ||
|
||
return 0; | ||
} | ||
|
||
|
||
|
||
|
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,3 @@ | ||
size = 123; | ||
dx = 3.056; | ||
name = "Setup Test"; |
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,7 @@ | ||
|
||
float pihalf = 3.14159/2; | ||
int counter = 7; | ||
|
||
size = counter^2; | ||
dx = 3.056*pihalf; | ||
name = "data"+counter+".out"; |
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,7 @@ | ||
|
||
float pihalf = 3.14159/2; | ||
int counter = 7; | ||
|
||
size = counter^2; | ||
dx = sin(pihalf*0.5)*exp(-1.5^2); | ||
name = "data"+counter+".out"; |
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
Oops, something went wrong.