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

Add standalone sub-domain sample in parallel and using a case file #1645

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading