-
Notifications
You must be signed in to change notification settings - Fork 107
Add factory for LaplaceXY, LaplaceXY2, LaplaceXY2Hypre #3187
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
Changes from all commits
2792afd
96c86b8
84a684b
84d5406
7c7acad
8fa9f2c
2cb2280
b497f89
fbe8a7f
d1ae6b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,33 +28,26 @@ | |
|
|
||
| /*******************************************************************************/ | ||
|
|
||
| #include "bout/build_defines.hxx" | ||
| #include "bout/options.hxx" | ||
| #include <bout/bout.hxx> | ||
| #include <bout/constants.hxx> | ||
| #include <bout/derivs.hxx> | ||
| #include <bout/field_factory.hxx> | ||
| #include <bout/initialprofiles.hxx> | ||
| #include <bout/interpolation.hxx> | ||
| #include <bout/invert/laplacexy.hxx> | ||
| #include <bout/invert_laplace.hxx> | ||
| #include <bout/invert_parderiv.hxx> | ||
| #include <bout/msg_stack.hxx> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: duplicate include [readability-duplicate-include] examples/elm-pb-outerloop/elm_pb_outerloop.cxx:40: - #include <bout/invert_laplace.hxx>
- #include <bout/invert_laplace.hxx>
+ #include <bout/invert_laplace.hxx> |
||
| #include <bout/sourcex.hxx> | ||
| #include <bout/utils.hxx> | ||
|
|
||
| #include <math.h> | ||
|
|
||
| #include <bout/derivs.hxx> | ||
| #include <bout/invert_laplace.hxx> | ||
| #include <bout/physicsmodel.hxx> | ||
| #include <bout/rajalib.hxx> // Defines BOUT_FOR_RAJA | ||
| #include <bout/single_index_ops.hxx> | ||
| #include <bout/smoothing.hxx> | ||
| #include <bout/sourcex.hxx> | ||
| #include <bout/utils.hxx> | ||
|
|
||
| #include <bout/rajalib.hxx> // Defines BOUT_FOR_RAJA | ||
|
|
||
| #if BOUT_HAS_HYPRE | ||
| #include <bout/invert/laplacexy2_hypre.hxx> | ||
| #endif | ||
|
|
||
| #include <bout/field_factory.hxx> | ||
| #include <math.h> | ||
|
|
||
| CELL_LOC loc = CELL_CENTRE; | ||
|
|
||
|
|
@@ -91,6 +84,10 @@ BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_target", "neumann"); | |
| BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_xin", "none"); | ||
| BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_xout", "none"); | ||
|
|
||
| #if BOUT_HAS_HYPRE | ||
| BOUT_OVERRIDE_DEFAULT_OPTION("laplacexy:type", "hypre"); | ||
| #endif | ||
|
|
||
| /// 3-field ELM simulation | ||
| class ELMpb : public PhysicsModel { | ||
| private: | ||
|
|
@@ -242,11 +239,7 @@ class ELMpb : public PhysicsModel { | |
|
|
||
| bool split_n0; // Solve the n=0 component of potential | ||
|
|
||
| #if BOUT_HAS_HYPRE | ||
| std::unique_ptr<LaplaceXY2Hypre> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0) | ||
| #else | ||
| std::unique_ptr<LaplaceXY> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0) | ||
| #endif | ||
|
|
||
| Field2D phi2D; // Axisymmetric phi | ||
|
|
||
|
|
@@ -567,13 +560,11 @@ class ELMpb : public PhysicsModel { | |
| split_n0 = options["split_n0"] | ||
| .doc("Solve zonal (n=0) component of potential using LaplaceXY?") | ||
| .withDefault(false); | ||
|
|
||
| if (split_n0) { | ||
| // Create an XY solver for n=0 component | ||
| #if BOUT_HAS_HYPRE | ||
| laplacexy = bout::utils::make_unique<LaplaceXY2Hypre>(mesh); | ||
| #else | ||
| laplacexy = bout::utils::make_unique<LaplaceXY>(mesh); | ||
| #endif | ||
| laplacexy = LaplaceXY::create(mesh); | ||
|
|
||
| // Set coefficients for Boussinesq solve | ||
| laplacexy->setCoefs(1.0, 0.0); | ||
| phi2D = 0.0; // Starting guess | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,10 +22,6 @@ | |
|
|
||
| #include <math.h> | ||
|
|
||
| #if BOUT_HAS_HYPRE | ||
| #include <bout/invert/laplacexy2_hypre.hxx> | ||
| #endif | ||
|
|
||
| #include <bout/field_factory.hxx> | ||
|
|
||
| CELL_LOC loc = CELL_CENTRE; | ||
|
|
@@ -36,6 +32,10 @@ BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_target", "neumann"); | |
| BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_xin", "none"); | ||
| BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_xout", "none"); | ||
|
|
||
| #if BOUT_HAS_HYPRE | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "BOUT_HAS_HYPRE" is directly included [misc-include-cleaner] examples/elm-pb/elm_pb.cxx:7: - #include <bout/bout.hxx>
+ #include "bout/build_defines.hxx"
+ #include <bout/bout.hxx> |
||
| BOUT_OVERRIDE_DEFAULT_OPTION("laplacexy:type", "hypre"); | ||
| #endif | ||
|
|
||
| /// 3-field ELM simulation | ||
| class ELMpb : public PhysicsModel { | ||
| private: | ||
|
|
@@ -188,11 +188,7 @@ class ELMpb : public PhysicsModel { | |
|
|
||
| bool split_n0; // Solve the n=0 component of potential | ||
|
|
||
| #if BOUT_HAS_HYPRE | ||
| std::unique_ptr<LaplaceXY2Hypre> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0) | ||
| #else | ||
| std::unique_ptr<LaplaceXY> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0) | ||
| #endif | ||
|
|
||
| Field2D phi2D; // Axisymmetric phi | ||
|
|
||
|
|
@@ -525,11 +521,8 @@ class ELMpb : public PhysicsModel { | |
| .withDefault(false); | ||
| if (split_n0) { | ||
| // Create an XY solver for n=0 component | ||
| #if BOUT_HAS_HYPRE | ||
| laplacexy = bout::utils::make_unique<LaplaceXY2Hypre>(mesh); | ||
| #else | ||
| laplacexy = bout::utils::make_unique<LaplaceXY>(mesh); | ||
| #endif | ||
| laplacexy = LaplaceXY::create(mesh); | ||
|
|
||
| // Set coefficients for Boussinesq solve | ||
| laplacexy->setCoefs(1.0, 0.0); | ||
| phi2D = 0.0; // Starting guess | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # | ||
| # Simple test of the LaplaceXY solver using HYPRE | ||
| # | ||
| # Inverts a given function (rhs), writing "rhs" and solution "x" to file | ||
| # | ||
|
|
||
| [mesh] | ||
|
|
||
| # Mesh sizes | ||
| nx = 20 | ||
| ny = 32 | ||
| nz = 1 | ||
|
|
||
| # mesh spacing | ||
| dx = 1.0 | ||
| dy = 1.0 | ||
| dz = 1.0 | ||
|
|
||
| [laplacexy] | ||
| type = hypre | ||
|
|
||
| # Function to be inverted | ||
| rhs = sin(2*pi*x)*sin(y) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,20 +7,18 @@ int main(int argc, char** argv) { | |||||
| BoutInitialise(argc, argv); | ||||||
|
|
||||||
| /// Create a LaplaceXY object | ||||||
| LaplaceXY laplacexy(bout::globals::mesh); | ||||||
| auto laplacexy = LaplaceXY::create(bout::globals::mesh); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "bout::globals::mesh" is directly included [misc-include-cleaner] examples/laplacexy/simple/test-laplacexy.cxx:1: - #include <bout/bout.hxx>
+ #include "bout/globals.hxx"
+ #include <bout/bout.hxx> |
||||||
|
|
||||||
| /// Generate rhs function | ||||||
| Field2D rhs = FieldFactory::get()->create2D("laplacexy:rhs", Options::getRoot(), | ||||||
| bout::globals::mesh); | ||||||
|
|
||||||
| /// Solution | ||||||
| Field2D x = 0.0; | ||||||
|
|
||||||
| x = laplacexy.solve(rhs, x); | ||||||
| Field2D result = laplacexy->solve(rhs, 0.0); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'result' of type 'Field2D' can be declared 'const' [misc-const-correctness]
Suggested change
|
||||||
|
|
||||||
| Options dump; | ||||||
| dump["rhs"] = rhs; | ||||||
| dump["x"] = x; | ||||||
| dump["result"] = result; | ||||||
| bout::writeDefaultOutputFile(dump); | ||||||
|
|
||||||
| BoutFinalise(); | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: duplicate include [readability-duplicate-include]
examples/elm-pb-outerloop/elm_pb_outerloop.cxx:34: