1414
1515#include " ModelMPI.hpp"
1616#include " ModelMetadata.hpp"
17+ #include " cgVector.hpp"
1718#include " include/DGModelArray.hpp"
1819#include " include/Halo.hpp"
20+ #include " include/Interpolations.hpp"
1921
2022namespace Nextsim {
2123
2224const std::string testFilesDir = TEST_FILES_DIR;
2325const std::string file = testFilesDir + " /partition_metadata_3_cb.nc" ;
2426
2527static const int DG = 3 ;
28+ static const int CGDEGREE = 2 ;
2629static const bool debug = false ;
2730
2831// reference data for each process
@@ -239,7 +242,7 @@ MPI_TEST_CASE("DGField", 3)
239242 }
240243}
241244
242- MPI_TEST_CASE (" DGVector" , 3 )
245+ MPI_TEST_CASE (" DGVector and CGVector " , 3 )
243246{
244247 auto & modelMPI = ModelMPI::getInstance ();
245248 auto & metadata = ModelMetadata::getInstance ();
@@ -258,13 +261,13 @@ MPI_TEST_CASE("DGVector", 3)
258261 ParametricMesh smesh (CARTESIAN);
259262 smesh.nx = localNx;
260263 smesh.ny = localNy;
261- smesh.nnodes = localNx * localNy;
262264 smesh.nelements = localNx * localNy;
263- smesh.vertices .resize (smesh.nelements , Eigen::NoChange);
264- for (size_t i = 0 ; i < localNx; ++i) {
265- for (size_t j = 0 ; j < localNy; ++j) {
266- smesh.vertices (i * localNy + j, 0 ) = i;
267- smesh.vertices (i * localNy + j, 1 ) = j;
265+ smesh.nnodes = (localNx + 1 ) * (localNy + 1 );
266+ smesh.vertices .resize (smesh.nnodes , Eigen::NoChange);
267+ for (size_t i = 0 ; i < localNx + 1 ; ++i) {
268+ for (size_t j = 0 ; j < localNy + 1 ; ++j) {
269+ smesh.vertices (i * (localNy + 1 ) + j, 0 ) = i;
270+ smesh.vertices (i * (localNy + 1 ) + j, 1 ) = j;
268271 }
269272 }
270273
@@ -304,5 +307,14 @@ MPI_TEST_CASE("DGVector", 3)
304307 }
305308 }
306309 }
310+
311+ // initialize CGVector (after halo exchange on DGVector)
312+ CGVector<CGDEGREE> cgVector;
313+ cgVector.resize_by_mesh (smesh);
314+ Interpolations::DG2CG (smesh, cgVector, testData);
315+
316+ // create halo for testData model array
317+ Halo haloCG (testData);
318+ // haloCG.exchangeHalos(cgVector);
307319}
308320}
0 commit comments