Skip to content
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

Start to use more forward declarations #1464

Open
wants to merge 34 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ebe17f5
Reduce includes in Field.hxx
d7919 Dec 17, 2018
1b6dbef
Use mostly forward declarations in mesh.hxx
d7919 Dec 17, 2018
45aa4b8
More forward declarations in Field* headers
d7919 Dec 17, 2018
7699551
More forward declares in utils
d7919 Dec 17, 2018
9c170f7
More forward declares in Datafile
d7919 Dec 17, 2018
50457d0
Remove unused include in dataformat
d7919 Dec 17, 2018
28f3d27
More forward declares
d7919 Dec 17, 2018
f0c4ecf
More forward declares in field_factory.hxx
d7919 Dec 17, 2018
a6133a2
Forward declares in interpolation and initialprofiles
d7919 Dec 17, 2018
4c579dd
Some more forward declares
d7919 Dec 17, 2018
5cfd5c7
More forward declarations
d7919 Dec 17, 2018
e5b16fa
Update tests for change to headers
d7919 Dec 17, 2018
041bf0d
Minimise number of times iostream is included
d7919 Dec 17, 2018
13472ee
Update boutcore for header changes
d7919 Dec 17, 2018
593198c
More fiddling with includes
d7919 Dec 17, 2018
6a31166
Update test-interchange for include updates
d7919 Dec 18, 2018
7ff486e
Prefer CELL_LOC_STRING to strLocation in generated_fieldops
d7919 Dec 18, 2018
868d9bc
Small tweak to interpolation includes
d7919 Dec 18, 2018
15dcf5f
Merge remote-tracking branch 'refs/remotes/origin/next' into forward_…
d7919 Dec 18, 2018
c5d37d4
Move map and function definitions into source file for bout_types
d7919 Dec 18, 2018
52e72e2
Make function internals static in bout_types as we return a reference…
d7919 Dec 18, 2018
13964c2
A few more header tweaks
d7919 Dec 19, 2018
8415871
Merge remote-tracking branch 'refs/remotes/origin/next' into forward_…
d7919 Dec 19, 2018
cd6929c
Move getMesh into source file
d7919 Dec 19, 2018
05fdac5
Move ENUM_STRING into source file
d7919 Dec 21, 2018
4135a74
Move paralleltransform signatures into local header rather than paral…
d7919 Dec 21, 2018
469c711
Move some Mesh member function bodies into source file
d7919 Dec 21, 2018
3f61984
Remove explicit mpi.h includes -- prefer use of boutcomm
d7919 Dec 21, 2018
baedb7f
Small tweaks of bout++.cxx includes
d7919 Dec 21, 2018
f5c6b38
Add missing header files
d7919 Dec 30, 2018
9b33e46
Fix for moved header component
d7919 Jan 2, 2019
88936fe
Fix for moved header component
d7919 Jan 2, 2019
0968e10
Merge remote-tracking branch 'refs/remotes/origin/next' into forward_…
d7919 Jan 2, 2019
7f7118d
Add missing include
d7919 Jan 4, 2019
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
10 changes: 6 additions & 4 deletions include/boundary_op.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ class BoundaryModifier;
#ifndef __BNDRY_OP__
#define __BNDRY_OP__

#include "boundary_region.hxx"
#include "field2d.hxx"
#include "field3d.hxx"
#include "bout_types.hxx"
#include "unused.hxx"
#include "vector2d.hxx"
#include "vector3d.hxx"
#include "unused.hxx"

class BoundaryRegion;
class Field2D;
class Field3D;

#include <cmath>
#include <string>
Expand Down
11 changes: 0 additions & 11 deletions include/bout.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,19 @@
#define __BOUT_H__

#include "boutcomm.hxx"

#include "globals.hxx"

#include "field2d.hxx"
#include "field3d.hxx"
#include "vector2d.hxx"
#include "vector3d.hxx"

#include "difops.hxx" // Differential operators

#include "vecops.hxx" // Vector differential operations

#include "smoothing.hxx" // Smoothing functions

#include "sourcex.hxx" // source and mask functions

#include "bout/solver.hxx"

#include "datafile.hxx"

#include "where.hxx"

#include "output.hxx"

#include "utils.hxx"

const BoutReal BOUT_VERSION = BOUT_VERSION_DOUBLE; ///< Version number
Expand Down
4 changes: 0 additions & 4 deletions include/bout/array.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
#include <vector>
#include <memory>

#ifdef _OPENMP
#include <omp.h>
#endif

#ifdef BOUT_ARRAY_WITH_VALARRAY
#include <valarray>
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/bout/assert.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef __BOUT_ASSERT_H__
#define __BOUT_ASSERT_H__

#include "../boutexception.hxx"
#include "boutexception.hxx"

#ifndef CHECK
#define CHECKLEVEL 0
Expand Down
9 changes: 6 additions & 3 deletions include/bout/coordinates.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ class Coordinates;
#ifndef __COORDINATES_H__
#define __COORDINATES_H__

#include "mesh.hxx"
#include "datafile.hxx"
#include "utils.hxx"
#include <bout_types.hxx>
#include <field2d.hxx>
#include <field3d.hxx>
#include <fieldperp.hxx>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about this... should we use <> for system headers and "" for BOUT++ headers?

Copy link
Member Author

@d7919 d7919 Dec 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to view <> as being something provided by a library (including bout) and "" for local files. Or in other words <> for things in an include path and "" for things that aren't. This is just my interpretation though. I think "" can search more places, but if this is an advantage or a disadvantage may be a matter of opinion.

( I should add "" falls back to <> if the first (implementation defined) search fails -- in practice I think that means most of our uses of "" fall back to <> anyway ).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice, there is not much difference. The C standard says both are implementation defined, which the exception that "" explicitly looks for a file and <> for a header, which might not be a file.

  • For "", gcc searches the current directory first, then paths specified with -iquote, then "a standard list of system paths" which includes those in -I.

  • For <>, gcc searches the system paths only (including those in -I and -isystem).

I don't think we use -I., so private headers do really need to be "", while the public ones can be <>. Beyond that, I think it is a matter of opinion -- but it would be nice to be consistent! As a note, the gcc docs below say to use "" for "your own program" and <> for "system headers".

https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One reason to prefer "" for all BOUT++ headers: clang-format and include-what-you-use can group headers together, and it might be nice to separate the system headers from ours.


class Mesh;
class Datafile;

/*!
* Represents a coordinate system, and associated operators
Expand Down
9 changes: 4 additions & 5 deletions include/bout/fieldgroup.hxx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#ifndef __FIELDGROUP_H__
#define __FIELDGROUP_H__

#include "field_data.hxx"
#include <field3d.hxx>
#include <vector>

#include <field2d.hxx>
#include <field3d.hxx>
#include <vector2d.hxx>
#include <vector3d.hxx>

#include <vector>

#include <algorithm>
class FieldData;

/// Group together fields for easier communication
///
Expand Down
10 changes: 5 additions & 5 deletions include/bout/fv_ops.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#ifndef __FV_OPS_H__
#define __FV_OPS_H__

#include "../globals.hxx"
#include "../field3d.hxx"
#include "../vector2d.hxx"

#include "../utils.hxx"
#include "field3d.hxx"
#include "globals.hxx"
#include "utils.hxx"
#include "vector2d.hxx"
#include <bout/coordinates.hxx>

namespace FV {
/*!
Expand Down
1 change: 0 additions & 1 deletion include/bout/generic_factory.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "boutexception.hxx"

#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
Expand Down
12 changes: 5 additions & 7 deletions include/bout/griddata.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ class GridDataSource;
#ifndef __GRIDDATA_H__
#define __GRIDDATA_H__

#include "options.hxx"

#include "bout_types.hxx"
#include "dataformat.hxx"

#include "mesh.hxx"

#include <field2d.hxx>
#include <field3d.hxx>

#include <list>

class Options;
class Mesh;
class Field2D;
class Field3D;

/// Interface class to serve grid data
/*!
* Provides a generic interface for sources of
Expand Down
1 change: 0 additions & 1 deletion include/bout/index_derivs.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#define __INDEX_DERIVS_HXX__

#include <functional>
#include <iostream>

#include <bout/assert.hxx>
#include <bout/constants.hxx>
Expand Down
97 changes: 23 additions & 74 deletions include/bout/mesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,35 @@
*
**************************************************************************/

class Mesh;

#ifndef __MESH_H__
#define __MESH_H__
class Mesh;

#include "mpi.h"

#include <bout/deprecated.hxx>
#include <bout/deriv_store.hxx>
#include <bout/index_derivs_interface.hxx>
// The following is relatively expensive to include because it includes mpi.h
#include <boutcomm.hxx>

#include "field_data.hxx"
#include "bout_types.hxx"
#include "field2d.hxx"
#include "field3d.hxx"
#include "datafile.hxx"
#include "options.hxx"

#include "fieldgroup.hxx"

#include "boundary_region.hxx"
#include "parallel_boundary_region.hxx"

#include "sys/range.hxx" // RangeIterator

#include <bout/griddata.hxx>

#include "coordinates.hxx" // Coordinates class

#include "paralleltransform.hxx" // ParallelTransform class

#include "unused.hxx"
#include <bout/deprecated.hxx>
#include <bout/index_derivs_interface.hxx>
#include <bout/paralleltransform.hxx>

class Field3D;
class Field2D;
class RangeIterator;
class Coordinates;
class GridDataSource;
class FieldData;
class Datafile;
class Options;
class BoundaryRegion;
class BoundaryRegionPar;
template <typename T>
class Region;

#include <bout/region.hxx>

#include <list>
#include <memory>
#include <map>
#include <string>

/// Type used to return pointers to handles
typedef void* comm_handle;
Expand Down Expand Up @@ -451,57 +442,15 @@ class Mesh {

/// Returns the non-CELL_CENTRE location
/// allowed as a staggered location
CELL_LOC getAllowedStaggerLoc(DIRECTION direction) const {
AUTO_TRACE();
switch (direction) {
case (DIRECTION::X):
return CELL_XLOW;
case (DIRECTION::Y):
case (DIRECTION::YOrthogonal):
case (DIRECTION::YAligned):
return CELL_YLOW;
case (DIRECTION::Z):
return CELL_ZLOW;
default:
throw BoutException("Unhandled direction encountered in getAllowedStaggerLoc");
}
};
CELL_LOC getAllowedStaggerLoc(DIRECTION direction) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three functions now can't be inlined -- but it doesn't look like they're used in any tight loops so presumably this isn't that bad

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is one of the reasons I think this PR might be more for discussion/experimentation to decide on a policy. I'd prefer runtime performance over compilation performance but there may be places we can get both.


/// Returns the number of grid points in the
/// particular direction
int getNpoints(DIRECTION direction) const {
AUTO_TRACE();
switch (direction) {
case (DIRECTION::X):
return LocalNx;
case (DIRECTION::Y):
case (DIRECTION::YOrthogonal):
case (DIRECTION::YAligned):
return LocalNy;
case (DIRECTION::Z):
return LocalNz;
default:
throw BoutException("Unhandled direction encountered in getNpoints");
}
};
int getNpoints(DIRECTION direction) const;

/// Returns the number of guard points in the
/// particular direction
int getNguard(DIRECTION direction) const {
AUTO_TRACE();
switch (direction) {
case (DIRECTION::X):
return xstart;
case (DIRECTION::Y):
case (DIRECTION::YOrthogonal):
case (DIRECTION::YAligned):
return ystart;
case (DIRECTION::Z):
return 2;
default:
throw BoutException("Unhandled direction encountered in getNguard");
}
};
int getNguard(DIRECTION direction) const;

///////////////////////////////////////////////////////////
// INDEX DERIVATIVE OPERATORS
Expand Down
4 changes: 4 additions & 0 deletions include/bout/openmpwrap.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#ifndef __OPENMPWRAP_H__
#define __OPENMPWRAP_H__

#ifdef _OPENMP
#include <omp.h>
#endif

//Some helpers for indirection -- required so that the _Pragma gets "omp <x>"
//where <x> is any number of valid omp options/environments (e.g. atomic, critical etc.)
#define INDIRECT0(a) #a
Expand Down
Loading