Skip to content
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
2 changes: 1 addition & 1 deletion examples/laplacexy/laplace_perp/square/BOUT.inp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

input = sin(pi*x - y)
input_field = sin(pi*x - y)

non_uniform = true # Include corrections to second derivatives

Expand Down
18 changes: 12 additions & 6 deletions examples/laplacexy/laplace_perp/test.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <bout/bout.hxx>
#include <bout/field2d.hxx>

#include <bout/derivs.hxx>
#include <bout/field_factory.hxx>
Expand All @@ -10,11 +11,15 @@ int main(int argc, char** argv) {
BoutInitialise(argc, argv);

///////////////////////////////////////
bool calc_metric;
calc_metric = Options::root()["calc_metric"].withDefault(false);
const bool calc_metric = Options::root()["calc_metric"].withDefault(false);
if (calc_metric) {
// Read metric tensor
Field2D Rxy, Btxy, Bpxy, B0, hthe, I;
Field2D Rxy;
Comment thread
ZedThree marked this conversation as resolved.
Field2D Btxy;
Field2D Bpxy;
Field2D B0;
Field2D hthe;
Field2D I;
mesh->get(Rxy, "Rxy"); // m
mesh->get(Btxy, "Btxy"); // T
mesh->get(Bpxy, "Bpxy"); // T
Expand Down Expand Up @@ -47,13 +52,14 @@ int main(int argc, char** argv) {
///////////////////////////////////////

// Read an analytic input
Field2D input = FieldFactory::get()->create2D("input", Options::getRoot(), mesh);
const Field2D input =
FieldFactory::get()->create2D("input_field", Options::getRoot(), mesh);

// Create a LaplaceXY solver
LaplaceXY* laplacexy = new LaplaceXY(mesh);
LaplaceXY laplacexy{mesh};

// Solve, using 0.0 as starting guess
Field2D solved = laplacexy->solve(input, 0.0);
Field2D solved = laplacexy.solve(input, 0.0);

// Need to communicate guard cells
mesh->communicate(solved);
Expand Down
2 changes: 1 addition & 1 deletion examples/laplacexy/laplace_perp/torus/BOUT.inp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

input = sin(pi*x - y)
input_field = sin(pi*x - y)
calc_metric = true # Read Rxy, Bpxy etc and calculate metric

non_uniform = true # Include corrections to second derivatives
Expand Down
2 changes: 1 addition & 1 deletion tests/MMS/laplace/data/BOUT.inp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MXG = 1


solution = sin(pi*x)
input = -pi^2*sin(pi*x)
input_field = -pi^2*sin(pi*x)

[mesh]

Expand Down
25 changes: 14 additions & 11 deletions tests/MMS/laplace/laplace.cxx
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
#include <bout/bout.hxx>

#include <bout/constants.hxx>
#include <bout/field3d.hxx>
#include <bout/field_factory.hxx>
#include <bout/invert_laplace.hxx>
#include <bout/output.hxx>

#include <string>

using bout::globals::mesh;
using namespace std::string_literals;

int main(int argc, char** argv) {
int init_err = BoutInitialise(argc, argv);
if (init_err < 0) {
return 0;
} else if (init_err > 0) {
}
if (init_err > 0) {
return init_err;
}

Expand All @@ -31,16 +36,14 @@ int main(int argc, char** argv) {

FieldFactory fact(mesh);

std::shared_ptr<FieldGenerator> gen = fact.parse("input");
output << "GEN = " << gen->str() << endl;

Field3D input = fact.create3D("input");

Field3D result = lap->solve(input);

Field3D solution = fact.create3D("solution");
const auto input_name = "input_field"s;
Comment thread
ZedThree marked this conversation as resolved.
Comment thread
ZedThree marked this conversation as resolved.
const auto gen = fact.parse(input_name);
output.write("GEN = {}\n", gen->str());
Comment thread
ZedThree marked this conversation as resolved.

Field3D error = result - solution;
const Field3D input = fact.create3D(input_name);
const Field3D result = lap->solve(input);
const Field3D solution = fact.create3D("solution");
const Field3D error = result - solution;

Options dump;
dump["input"] = input;
Expand Down
2 changes: 1 addition & 1 deletion tests/MMS/spatial/d2dx2/data/BOUT.inp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MXG = 1

MYG = 1 # No guard cells in Y

input = sin(0.5*pi*x)
input_field = sin(0.5*pi*x)
solution = -sin(0.5*pi*x) * 0.25*pi*pi

[mesh]
Expand Down
9 changes: 6 additions & 3 deletions tests/MMS/spatial/d2dx2/test_d2dx2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@

#include <bout/bout.hxx>
#include <bout/derivs.hxx>
#include <bout/field3d.hxx>
#include <bout/field_factory.hxx>
#include <bout/options.hxx>

using bout::globals::mesh;

int main(int argc, char** argv) {

BoutInitialise(argc, argv);

Field3D input = FieldFactory::get()->create3D("input", Options::getRoot(), mesh);
Field3D solution = FieldFactory::get()->create3D("solution", Options::getRoot(), mesh);
Field3D input = FieldFactory::get()->create3D("input_field", Options::getRoot(), mesh);
Comment thread
ZedThree marked this conversation as resolved.
Comment thread
ZedThree marked this conversation as resolved.
const Field3D solution =
FieldFactory::get()->create3D("solution", Options::getRoot(), mesh);
// At this point the boundary cells are set to the analytic solution

input.setBoundary("bndry");
input.applyBoundary(0.0);

// Boundaries of input now set using extrapolation around mid-point boundary

Field3D result = D2DX2(input);
const Field3D result = D2DX2(input);
// At this point result is not set in the boundary cells

Options dump;
Expand Down
2 changes: 1 addition & 1 deletion tests/MMS/spatial/d2dz2/data/BOUT.inp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ zperiod = 1
MXG = 0 # No guard cells in X
MYG = 1 # No guard cells in Y

input = sin(z)
input_field = sin(z)
solution = -sin(z)

[mesh]
Expand Down
8 changes: 6 additions & 2 deletions tests/MMS/spatial/d2dz2/test_d2dz2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@

#include <bout/bout.hxx>
#include <bout/derivs.hxx>
#include <bout/field3d.hxx>
#include <bout/field_factory.hxx>
#include <bout/options.hxx>

using bout::globals::mesh;

int main(int argc, char** argv) {

BoutInitialise(argc, argv);

Field3D input = FieldFactory::get()->create3D("input", Options::getRoot(), mesh);
Field3D solution = FieldFactory::get()->create3D("solution", Options::getRoot(), mesh);
const Field3D input =
FieldFactory::get()->create3D("input_field", Options::getRoot(), mesh);
const Field3D solution =
FieldFactory::get()->create3D("solution", Options::getRoot(), mesh);

Field3D result = D2DZ2(input);

Expand Down
Loading