Skip to content

Commit

Permalink
Merge pull request #1645 from arcaneframework/dev/gg-improve-standalo…
Browse files Browse the repository at this point in the history
…ne-subdomain-sample

Add standalone sub-domain sample in parallel and using a case file
  • Loading branch information
grospelliergilles authored Sep 26, 2024
2 parents 1e8d832 + 5ba34ac commit 1d7edf8
Show file tree
Hide file tree
Showing 4 changed files with 637 additions and 9 deletions.
28 changes: 27 additions & 1 deletion arcane/samples_build/samples/standalone_subdomain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(StandaloneSubDomain LANGUAGES C CXX)

find_package(Arcane REQUIRED)
Expand All @@ -7,4 +7,30 @@ arcane_add_arcane_libraries_to_target(StandaloneSubDomain)

# Ajoute test de l'exécutable
configure_file(plancher.msh ${CMAKE_CURRENT_BINARY_DIR}/plancher.msh COPYONLY)
configure_file(square_v41.msh ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
configure_file(data.arc ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)

# ----------------------------------------------------------------------------
# Add tests without case file
add_test(NAME standalone_subdomain_test1 COMMAND StandaloneSubDomain)
if(MPIEXEC_EXECUTABLE)
add_test(NAME standalone_subdomain_test1_p4
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 ./StandaloneSubDomain
)
endif()

# ----------------------------------------------------------------------------
# Add tests with case file
add_test(NAME standalone_subdomain_test2 COMMAND StandaloneSubDomain data.arc)
if(MPIEXEC_EXECUTABLE)
add_test(NAME standalone_subdomain_test2_p4
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 ./StandaloneSubDomain data.arc
)
endif()

# ----------------------------------------------------------------------------
# Local Variables:
# tab-width: 2
# indent-tabs-mode: nil
# coding: utf-8-with-signature
# End:
18 changes: 18 additions & 0 deletions arcane/samples_build/samples/standalone_subdomain/data.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<cas codename="Arcane" xml:lang="fr" codeversion="1.0">
<arcane>
<titre>Test chargement de plusieurs maillages</titre>
<description>
Test chargement de plusieurs maillages avec options specifiques a chaque maillage
</description>
</arcane>

<meshes>
<mesh>
<filename>plancher.msh</filename>
</mesh>
<mesh>
<filename>square_v41.msh</filename>
</mesh>
</meshes>
</cas>
19 changes: 11 additions & 8 deletions arcane/samples_build/samples/standalone_subdomain/main.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* StandaloneSubDomain.cc (C) 2000-2023 */
/* StandaloneSubDomain.cc (C) 2000-2024 */
/* */
/* Sample for ArcaneLauncher::createStandaloneSubDomain(). */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -35,13 +35,13 @@

using namespace Arcane;

void executeSample()
void executeSample(const String& case_file)
{

// Create a standalone subdomain
// Arcane will automatically call finalization when the variable
// goes out of scope.
Arcane::StandaloneSubDomain launcher{ ArcaneLauncher::createStandaloneSubDomain(String{}) };
Arcane::StandaloneSubDomain launcher{ ArcaneLauncher::createStandaloneSubDomain(case_file) };
Arcane::ISubDomain* sd = launcher.subDomain();

// Get the trace class to display messages
Expand All @@ -52,7 +52,7 @@ void executeSample()

// Create a mesh named 'Mesh1' from the file 'plancher.msh'.
// The format is automatically choosen from the extension
Arcane::IMesh* mesh = mrm.readMesh("Mesh1", "plancher.msh");
Arcane::IMesh* mesh = mrm.readMesh("AdditionalMesh", "plancher.msh", sd->parallelMng());

Int32 nb_cell = mesh->nbCell();
tm->info() << "NB_CELL=" << nb_cell;
Expand All @@ -76,13 +76,16 @@ void executeSample()

int main(int argc, char* argv[])
{
auto func = [&]{
String case_file;

auto func = [&] {
std::cout << "Sample: StandaloneSubDomain\n";
// Initialize Arcane
Arcane::CommandLineArguments cmd_line_args(&argc, &argv);
Arcane::ArcaneLauncher::init(cmd_line_args);

executeSample();
if (argc > 1)
case_file = argv[argc - 1];
executeSample(case_file);
};

return arcaneCallFunctionAndCatchException(func);
Expand Down
Loading

0 comments on commit 1d7edf8

Please sign in to comment.