Legacy boundary conditions#3420
Conversation
…et and Neumann BCs. - This is what we used to do in Bout++ version 3. - Higher order extrapolation can be unstable sometimes so I added back the 1st order BC. You can use thm in the input file by setting e.g. dirichlet_o1. - Implementation for staggered grids is not done.
… the rest of the BC code. -This was a later change to the BCs
| class BoundaryDirichlet_O1 : public BoundaryOp { | ||
| public: | ||
| BoundaryDirichlet_O1() : gen(nullptr) {} | ||
| BoundaryDirichlet_O1(BoundaryRegion* region, std::shared_ptr<FieldGenerator> g) |
There was a problem hiding this comment.
warning: no header providing "FieldGenerator" is directly included [misc-include-cleaner]
include/bout/boundary_standard.hxx:7:
- #include "bout/unused.hxx"
+ #include "bout/sys/expressionparser.hxx"
+ #include "bout/unused.hxx"| class BoundaryDirichlet_O1 : public BoundaryOp { | ||
| public: | ||
| BoundaryDirichlet_O1() : gen(nullptr) {} | ||
| BoundaryDirichlet_O1(BoundaryRegion* region, std::shared_ptr<FieldGenerator> g) |
There was a problem hiding this comment.
warning: no header providing "std::shared_ptr" is directly included [misc-include-cleaner]
include/bout/boundary_standard.hxx:10:
- #include <utility>
+ #include <memory>
+ #include <utility>|
|
||
| BoundaryFactory::BoundaryFactory() { | ||
| add(new BoundaryDirichlet(), "dirichlet"); | ||
| add(new BoundaryDirichlet(), "dirichlet"); // Default |
There was a problem hiding this comment.
warning: initializing non-owner argument of type 'BoundaryOp *' with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]
add(new BoundaryDirichlet(), "dirichlet"); // Default
^| BoundaryFactory::BoundaryFactory() { | ||
| add(new BoundaryDirichlet(), "dirichlet"); | ||
| add(new BoundaryDirichlet(), "dirichlet"); // Default | ||
| add(new BoundaryDirichlet_O1(), "dirichlet_o1"); // Old implementation in v3 |
There was a problem hiding this comment.
warning: Potential memory leak [clang-analyzer-cplusplus.NewDeleteLeaks]
add(new BoundaryDirichlet_O1(), "dirichlet_o1"); // Old implementation in v3
^Additional context
src/mesh/boundary_factory.cxx:73: Assuming the condition is true
if (instance == nullptr) {
^src/mesh/boundary_factory.cxx:73: Taking true branch
if (instance == nullptr) {
^src/mesh/boundary_factory.cxx:75: Calling default constructor for 'BoundaryFactory'
instance = new BoundaryFactory();
^src/mesh/boundary_factory.cxx:22: Memory is allocated
add(new BoundaryDirichlet(), "dirichlet"); // Default
^src/mesh/boundary_factory.cxx:23: Potential memory leak
add(new BoundaryDirichlet_O1(), "dirichlet_o1"); // Old implementation in v3
^| BoundaryFactory::BoundaryFactory() { | ||
| add(new BoundaryDirichlet(), "dirichlet"); | ||
| add(new BoundaryDirichlet(), "dirichlet"); // Default | ||
| add(new BoundaryDirichlet_O1(), "dirichlet_o1"); // Old implementation in v3 |
There was a problem hiding this comment.
warning: initializing non-owner argument of type 'BoundaryOp *' with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]
add(new BoundaryDirichlet_O1(), "dirichlet_o1"); // Old implementation in v3
^| return new BoundaryDirichlet_O1(region, newgen); | ||
| } | ||
|
|
||
| void BoundaryDirichlet_O1::apply(Field2D& f) { BoundaryDirichlet_O1::apply(f, 0.); } |
There was a problem hiding this comment.
warning: no header providing "Field2D" is directly included [misc-include-cleaner]
src/mesh/boundary_standard.cxx:0:
- #include <bout/boundary_standard.hxx>
+ #include "bout/field2d.hxx"
+ #include <bout/boundary_standard.hxx>|
|
||
| void BoundaryDirichlet_O1::apply(Field2D& f) { BoundaryDirichlet_O1::apply(f, 0.); } | ||
|
|
||
| void BoundaryDirichlet_O1::apply(Field2D& f, BoutReal t) { |
There was a problem hiding this comment.
warning: no header providing "BoutReal" is directly included [misc-include-cleaner]
src/mesh/boundary_standard.cxx:0:
- #include <bout/boundary_standard.hxx>
+ #include "bout/bout_types.hxx"
+ #include <bout/boundary_standard.hxx>| // Set (at 1st order) the value at the grid cell to the guard cells. | ||
|
|
||
| Mesh* mesh = bndry->localmesh; | ||
| ASSERT1(mesh == f.getMesh()); |
There was a problem hiding this comment.
warning: no header providing "ASSERT1" is directly included [misc-include-cleaner]
src/mesh/boundary_standard.cxx:0:
- #include <bout/boundary_standard.hxx>
+ #include "bout/assert.hxx"
+ #include <bout/boundary_standard.hxx>|
|
||
| // Check for staggered grids | ||
|
|
||
| CELL_LOC loc = f.getLocation(); |
There was a problem hiding this comment.
warning: no header providing "CELL_LOC" is directly included [misc-include-cleaner]
CELL_LOC loc = f.getLocation();
^|
|
||
| // Check for staggered grids | ||
|
|
||
| CELL_LOC loc = f.getLocation(); |
There was a problem hiding this comment.
warning: variable 'loc' of type 'CELL_LOC' can be declared 'const' [misc-const-correctness]
| CELL_LOC loc = f.getLocation(); | |
| CELL_LOC const loc = f.getLocation(); |
Could you add an assert? Also, please fix the clang-tidy and clang-format issues. |
I have this line here: BOUT-dev/src/mesh/boundary_standard.cxx Line 154 in a960447 throw BoutException("neumann_o1 BC is not implementated for staggered grids."); That throws an Exception if this BC is used with staggered grids. Does this BoutException work as an error message or a an assert statement? Also, I used: git clang-format origin/next for the formatting. Is there another command I sue use for clang-tidy? |
Added a legacy implementation of 1st order Dirichlet and Neumann BCs.