diff options
author | diener <diener@4ec1db94-0e4f-0410-ada3-8bed251432c9> | 2008-02-05 22:44:56 +0000 |
---|---|---|
committer | diener <diener@4ec1db94-0e4f-0410-ada3-8bed251432c9> | 2008-02-05 22:44:56 +0000 |
commit | d822d7044d70a9fd43c8be48b0c5bdce51789ed9 (patch) | |
tree | 965ae465296e0b26971012df86712c7b75b7f814 /src/copy_mask.cc | |
parent | 9e06e812ba64f52bfd91e4cd933c416d58fb4166 (diff) |
Change the scheme for reductions. Before, reductions was done over the full
grid functions using CCTK_Reduce. Now, reductions are done alongside the
computations into local arrays and then these are reduced using
CCTK_ReduceLocArrayToArray1D. This is much more efficient. In addition
OpenMP directives are added to allow for mixed MPI/OpenMP usage.
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinInitialData/NoExcision/trunk@15 4ec1db94-0e4f-0410-ada3-8bed251432c9
Diffstat (limited to 'src/copy_mask.cc')
-rw-r--r-- | src/copy_mask.cc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/copy_mask.cc b/src/copy_mask.cc new file mode 100644 index 0000000..4dd0538 --- /dev/null +++ b/src/copy_mask.cc @@ -0,0 +1,47 @@ +#include <cmath> + +#include <cctk.h> +#include <cctk_Arguments.h> +#include <cctk_Parameters.h> + +#include "copy_mask.hh" + +namespace NoExcision { + +#ifdef HAVE_CARPET + using namespace Carpet; +#endif + + /** + * Modify the mask according to the CarpetReduce mask in order to be able to do the local reductions. + */ + + extern "C" + void CopyMask (CCTK_ARGUMENTS) + { + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + CCTK_REAL * const weight = + static_cast <CCTK_REAL *> + (CCTK_VarDataPtr (cctkGH, 0, "CarpetReduce::weight")); + + if (not weight) { + CCTK_WARN (CCTK_WARN_ABORT, + "CarpetReduce is not active, or CarpetReduce::mask does not have storage"); + } + + for (int k = 0; k < cctk_lsh[2]; ++ k) { + for (int j = 0; j < cctk_lsh[1]; ++ j) { + for (int i = 0; i < cctk_lsh[0]; ++ i) { + int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k); + + red_mask[ind] = weight[ind]; + } + } + } + + } + + +} // namespace NoExcision |