Giter VIP home page Giter VIP logo

cfd-mini-app's People

Contributors

grandpa-mtn avatar lifflander avatar marcinwrobel1986 avatar pierrepebay avatar ppebay avatar

Watchers

 avatar  avatar

cfd-mini-app's Issues

Checkpoint on issues (08/31)

  • Major issues

    • error in vertical velocity vector component in correction step (in multi color, chunk 0 appears to be most impacted ?)
    • single rank single color computation error (originates from correction step)
  • Minor issues

    • VTK file export:
      • fix ghost/shared_owned points erroneous value exported
      • improve usability when dealing with multiple parallel meshes (#58 )
    • Docker build needs MPI library
    • whitespace and tabs
  • Next big steps

    • scatter and gather pressure in multi node (MPI)
    • continue chunk border sending and receiving (MPI)
  • Miscellaneous

    • update unit tests
    • document and make diagrams for recent changes

Add visualization harness

The goal of this issue is to add a visualization backend to this mini-app, for instance by outputting time-varying solutions on a constant mesh via Exodus files (so these might be visualized with. e.g., ParaView).

Create a parallel mesh object with indexing scheme

  • GlobalToLocalNodeIndices -> (i,j) -> ((u,v),(k,l))
  • GlobalToLocalCellIndices -> (i,j) -> ((u,v),(k,l))
  • LocalToGlobalNodeIndices -> ((u,v),(k,l)) -> (i,j)
  • LocalToGlobalCellIndices -> ((u,v),(k,l)) -> (i,j)

memory error in allTests (Clang 11.0.0 build)

Error log with AddressSanitizer on:

./allTests
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from solver_test
[ RUN      ] solver_test.Laplacian_values_test
=================================================================
==56370==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffeea6a99c0 at pc 0x00010556974e bp 0x7ffeea6a91f0 sp 0x7ffeea6a91e8
READ of size 8 at 0x7ffeea6a99c0 thread T0
    #0 0x10556974d in MeshChunk::get_n_cells_x() const mesh_chunk.h:41
    #1 0x105566edd in Solver::solve(Solver::stopping_point, Solver::linear_solver, Solver::adaptative_time_step) solver.cpp:16
    #2 0x10557fa22 in solver_test_Laplacian_values_test_Test::TestBody() allTests.cpp:57
    #3 0x105ed2e3d in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) gtest.cc:2433
    #4 0x105e9d7da in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) gtest.cc:2469
    #5 0x105e9d712 in testing::Test::Run() gtest.cc:2508
    #6 0x105e9e951 in testing::TestInfo::Run() gtest.cc:2684
    #7 0x105e9f8e6 in testing::TestSuite::Run() gtest.cc:2816
    #8 0x105eac6f5 in testing::internal::UnitTestImpl::RunAllTests() gtest.cc:5338
    #9 0x105ed72ed in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) gtest.cc:2433
    #10 0x105eac06a in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) gtest.cc:2469
    #11 0x105eabf3f in testing::UnitTest::Run() gtest.cc:4925
    #12 0x1055816e0 in RUN_ALL_TESTS() gtest.h:2473
    #13 0x10558157c in main allTests.cpp:107
    #14 0x7fff70a373d4 in start (libdyld.dylib:x86_64+0x163d4)

Address 0x7ffeea6a99c0 is located in stack of thread T0 at offset 64 in frame
    #0 0x10557f5af in solver_test_Laplacian_values_test_Test::TestBody() allTests.cpp:55

  This frame has 28 object(s):
    [32, 176) 'sparse_Laplacian' (line 61) <== Memory access at offset 64 is inside this variable
    [240, 272) 'row' (line 65)
    [304, 312) 'ref.tmp' (line 68)
    [336, 344) 'ref.tmp16' (line 69)
    [368, 384) 'gtest_ar' (line 84)
    [400, 404) 'ref.tmp66' (line 84)
    [416, 424) 'ref.tmp74' (line 84)
    [448, 456) 'ref.tmp77' (line 84)
    [480, 496) 'gtest_ar90' (line 85)
    [512, 516) 'ref.tmp100' (line 85)
    [528, 536) 'ref.tmp109' (line 85)
    [560, 568) 'ref.tmp112' (line 85)
    [592, 608) 'gtest_ar129' (line 88)
    [624, 628) 'ref.tmp137' (line 88)
    [640, 648) 'ref.tmp146' (line 88)
    [672, 680) 'ref.tmp149' (line 88)
    [704, 720) 'gtest_ar192' (line 92)
    [736, 740) 'ref.tmp197' (line 92)
    [752, 760) 'ref.tmp206' (line 92)
    [784, 792) 'ref.tmp209' (line 92)
    [816, 832) 'gtest_ar224' (line 95)
    [848, 852) 'ref.tmp229' (line 95)
    [864, 872) 'ref.tmp238' (line 95)
    [896, 904) 'ref.tmp241' (line 95)
    [928, 944) 'gtest_ar265' (line 99)
    [960, 964) 'ref.tmp268' (line 99)
    [976, 984) 'ref.tmp277' (line 99)
    [1008, 1016) 'ref.tmp280' (line 99)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-use-after-scope mesh_chunk.h:41 in MeshChunk::get_n_cells_x() const
Shadow bytes around the buggy address:
  0x1fffdd4d52e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffdd4d52f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffdd4d5300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffdd4d5310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1fffdd4d5320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x1fffdd4d5330: f1 f1 f1 f1 f8 f8 f8 f8[f8]f8 f8 f8 f8 f8 f8 f8
  0x1fffdd4d5340: f8 f8 f8 f8 f8 f8 f2 f2 f2 f2 f2 f2 f2 f2 f8 f8
  0x1fffdd4d5350: f8 f8 f2 f2 f2 f2 f8 f2 f2 f2 f8 f2 f2 f2 f8 f8
  0x1fffdd4d5360: f2 f2 f8 f2 f8 f2 f2 f2 f8 f2 f2 f2 f8 f8 f2 f2
  0x1fffdd4d5370: f8 f2 f8 f2 f2 f2 f8 f2 f2 f2 f8 f8 f2 f2 f8 f2
  0x1fffdd4d5380: f8 f2 f2 f2 f8 f2 f2 f2 f8 f8 f2 f2 f8 f2 f8 f2
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==56370==ABORTING
in solve: zsh: abort      ./allTests

Clean up vtk file writing

When writing vtk files on different parallel meshes, the exported vtk files become quickly messy (unorganized directories etc.) and hard to track. A better way of exporting vtk files is needed.

Implement linear solver stub and baseline implementation

The baseline should be an iterative CG solver using Kokkos, as the Laplacian with zero-flow von Neumann boundary conditions result in a positive, symmetric sparse matrix.
N.B.: without a specific treatment said matrix is singular (positive semi definite). It should be verified that the RHS is indeed orthogonal to the (non-trivial) null space.

Fix velocity update during correction step

See lines:

void Solver::correct_velocity(){
for(uint64_t j = 1; j < this->mesh.get_n_points_y() - 1; j++){
for(uint64_t i = 1; i < this->mesh.get_n_points_x() - 1; i++){
this->mesh.set_velocity_u(i, j, (this->mesh.get_velocity_u(i, j) - (this->delta_t/this->rho) * (this->mesh.get_pressure(i, j) - this->mesh.get_pressure(i-1, j)) * 1/this->mesh.get_cell_size()));
this->mesh.set_velocity_v(i, j, (this->mesh.get_velocity_v(i, j) - (this->delta_t/this->rho) * (this->mesh.get_pressure(i, j) - this->mesh.get_pressure(i, j-1)) * 1/this->mesh.get_cell_size()));
}
}
}

Currently the correction is asymmetrical because it is only using pressure contributions from the top and right cells (not from the lower left).

Create unit test for GlobalToLocalCellIndices() and LocalToGlobalCellIndices()

Use e.g. the hard-coded example now in the manual test.cpp:

  uint64_t n_p = 3;
  uint64_t n_q = 2;
  ParallelMesh p_mesh(n_cells, n_cells, 1. / n_cells, n_p, n_q);
  std::map<std::array<uint64_t,2>, uint64_t> block_counts = {};
  for (uint64_t n = 0; n < n_cells; n++)
    for (uint64_t m = 0; m < n_cells; m++){
      LocalCoordinates loc = p_mesh.GlobalToLocalCellIndices(m, n);
      block_counts[{loc.block[0], loc.block[1]}] ++;
    }
  std::cout << "Mesh block counts in "
	    << n_p << " x " << n_q
	    << " partition of "
	    << n_cells << "x" << n_cells
	    << " parallel mesh:\n";
  uint64_t c_total = 0;
  for (const auto& it_block_counts : block_counts){
    auto n_in_block = it_block_counts.second;
    c_total += n_in_block;
    std:: cout << "  block ( "
	       << it_block_counts.first[0] << " ; "
	       << it_block_counts.first[1] << " ): "
	       << n_in_block << "\n";
  }
  std::cout << "  grand total: " << c_total << "\n\n";

and verify that for a 35x35 parallel mesh the following results are obtained:

  block ( 0 ; 0): 216
  block ( 0 ; 1): 204
  block ( 1 ; 0): 216
  block ( 1 ; 1): 204
  block ( 2 ; 0): 198
  block ( 2 ; 1): 187
  grand total: 1225

Regarding the reciprocal function LocalToGlobalCellIndices(), one may verify that the composition of both functions amounts the identity, at least in one direction, as such:

      auto g = p_mesh.LocalToGlobalCellIndices(loc);
      if (m != g[0])
	std::cout << "** ERROR: "
		  << m << " != " << g[0] << "\n";
      if (n != g[1])
	std::cout << "** ERROR: "
		  << n << " != " << g[1] << "\n";

Create automated comparaison to reference results

The script should have as input the path to an openFoam results file and the path to a text file created by test.cpp that contains data from the mesh. As output, graphs comparing both outputs with correlation coefficients would be a nice start.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.