mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 09:28:23 +01:00
additional example
This commit is contained in:
parent
2d9d318981
commit
c798c61706
@ -1,5 +1,7 @@
|
||||
add_executable(first_example first_example.cpp)
|
||||
add_executable(second_example second_example.cpp)
|
||||
add_executable(boundary_example1D boundary_example1D.cpp)
|
||||
|
||||
target_link_libraries(first_example tug)
|
||||
target_link_libraries(second_example tug)
|
||||
target_link_libraries(second_example tug)
|
||||
target_link_libraries(boundary_example1D tug)
|
||||
35
examples/boundary_example1D.cpp
Normal file
35
examples/boundary_example1D.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <algorithm>
|
||||
#include <tug/BoundaryCondition.hpp>
|
||||
#include <tug/Diffusion.hpp>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace tug::bc;
|
||||
using namespace tug::diffusion;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
TugInput input;
|
||||
|
||||
BoundaryCondition example(10);
|
||||
|
||||
uint8_t side = BC_SIDE_LEFT;
|
||||
boundary_condition bc;
|
||||
bc.type = BC_TYPE_CONSTANT;
|
||||
bc.value = 1;
|
||||
input.setBoundaryCondition(example);
|
||||
BoundaryCondition returnedBC = input.getBoundaryCondition();
|
||||
|
||||
// example.setSide(side, bc);
|
||||
vector<boundary_condition> result_left = example.getSide(side);
|
||||
// vector<boundary_condition> result_top = example.getSide(BC_SIDE_TOP);
|
||||
|
||||
for (auto i : result_left) {
|
||||
cout << i.value << " ";
|
||||
}
|
||||
cout << endl;
|
||||
// for (auto i : result_top) {
|
||||
// cout << i.value << " ";
|
||||
// }
|
||||
// cout << endl;
|
||||
}
|
||||
@ -13,7 +13,8 @@ namespace tug {
|
||||
namespace bc {
|
||||
|
||||
enum {
|
||||
BC_TYPE_CLOSED, /**< Defines a closed/Neumann boundary condition. */
|
||||
// flux = Neumann? Cauchy combination of Neumann and Dirichlet?
|
||||
BC_TYPE_CLOSED, /**< Defines a closed boundary condition (special case of Neumann condition). */
|
||||
BC_TYPE_FLUX, /**< Defines a flux/Cauchy boundary condition. */
|
||||
BC_TYPE_CONSTANT, /**< Defines a constant/Dirichlet boundary condition. */
|
||||
BC_UNSET /**< Indicates undefined boundary condition*/
|
||||
@ -66,9 +67,11 @@ public:
|
||||
* elements than needed and no exception is thrown if some index exceeding
|
||||
* grid limits.
|
||||
*
|
||||
* QUESTION: why not use non-squared grids with the correct size?
|
||||
*
|
||||
* \param x Number of grid cells in x-direction
|
||||
* \param y Number of grid cells in y-direction
|
||||
*
|
||||
*
|
||||
*/
|
||||
BoundaryCondition(int x, int y);
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@ tug::bc::BoundaryCondition::BoundaryCondition(int x, int y) {
|
||||
|
||||
void tug::bc::BoundaryCondition::setSide(
|
||||
uint8_t side, tug::bc::boundary_condition &input_bc) {
|
||||
// QUESTION: why cant the BC be changed for dim = 1?
|
||||
if (this->dim == 1) {
|
||||
throw_invalid_argument("setSide requires at least a 2D grid");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user