Skip to content
Open
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
5 changes: 4 additions & 1 deletion DEMSystems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
set(SourceFiles
domainDistribute/domainDistribute.cpp
DEMSystem/DEMSystem.cpp
sphereDEMSystem/sphereFluidParticles.cpp
sphereDEMSystem/sphereDEMSystem.cpp

sphereDEMSystem/thermalSphereDEMSystem.cpp
sphereDEMSystem/multiReactiveShrinkingDEMSystem.cpp

grainDEMSystem/grainFluidParticles.cpp
grainDEMSystem/grainDEMSystem.cpp
)
Expand Down
147 changes: 89 additions & 58 deletions DEMSystems/DEMSystem/DEMSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
Expand All @@ -11,80 +11,111 @@
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.

phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-----------------------------------------------------------------------------*/

// from phasicFlow
#include "KokkosTypes.hpp"

#include "DEMSystem.hpp"


pFlow::DEMSystem::DEMSystem(
word demSystemName,
const std::vector<box>& domains,
int argc,
char* argv[])
:
ControlDict_()
namespace pFlow
{

REPORT(0)<<"Initializing host/device execution spaces . . . \n";
REPORT(1)<<"Host execution space is "<< Green_Text(DefaultHostExecutionSpace::name())<<END_REPORT;
REPORT(1)<<"Device execution space is "<<Green_Text(DefaultExecutionSpace::name())<<END_REPORT;

// initialize Kokkos
Kokkos::initialize( argc, argv );
// ========================================================================= //
// Section 1: Constructors and Destructors
// ========================================================================= //

DEMSystem::DEMSystem
(
word demSystemName,
const std::vector<box>& domains,
int argc,
char* argv[]
)
:
ControlDict_()
{
// ------------------------------------------------------------------------
// Kokkos Bootstrapping
// Probes the hardware, allocates thread pools (CPU), and locks GPU resources.
// ------------------------------------------------------------------------
REPORT(0) << "Initializing host/device execution spaces . . . \n";
REPORT(1) << "Host execution space is "
<< Green_Text(DefaultHostExecutionSpace::name()) << END_REPORT;
REPORT(1) << "Device execution space is "
<< Green_Text(DefaultExecutionSpace::name()) << END_REPORT;

REPORT(0)<<"\nCreating Control repository . . ."<<END_REPORT;
Control_ = makeUnique<systemControl>(
ControlDict_.startTime(),
ControlDict_.endTime(),
ControlDict_.saveInterval(),
ControlDict_.startTimeName());
Kokkos::initialize(argc, argv);

timers_ = makeUnique<Timers>(demSystemName, &Control_().timers());
// ------------------------------------------------------------------------
// System Control & Profiling Initialization
// ------------------------------------------------------------------------
REPORT(0) << "\nCreating Control repository . . ." << END_REPORT;
Control_ = makeUnique<systemControl>
(
ControlDict_.startTime(),
ControlDict_.endTime(),
ControlDict_.saveInterval(),
ControlDict_.startTimeName()
);

timers_ = makeUnique<Timers>(demSystemName, &Control_().timers());
}

pFlow::DEMSystem::~DEMSystem()
DEMSystem::~DEMSystem()
{

Control_.reset();
// Explicitly reset the control repository to release its memory before
// shutting down the execution spaces.
Control_.reset();

output<< "\nFinalizing host/device execution space ...."<<endl;
Kokkos::finalize();
// ------------------------------------------------------------------------
// Kokkos Shutdown
// Safely flushes memory buffers and releases hardware locks.
// ------------------------------------------------------------------------
output << "\nFinalizing host/device execution space ...." << endl;
Kokkos::finalize();
}

// ========================================================================= //
// Section 2: Factory Pattern Implementation
// ========================================================================= //

pFlow::uniquePtr<pFlow::DEMSystem>
pFlow::DEMSystem::create(
word demSystemName,
const std::vector<box>& domains,
int argc,
char* argv[],
bool requireRVel
)
uniquePtr<DEMSystem> DEMSystem::create
(
word demSystemName,
const std::vector<box>& domains,
int argc,
char* argv[],
bool requireRVel
)
{
if( wordvCtorSelector_.search(demSystemName) )
{
return wordvCtorSelector_[demSystemName] (demSystemName, domains, argc, argv, requireRVel);
}
else
{
printKeys
(
fatalError << "Ctor Selector "<< demSystemName << " dose not exist. \n"
<<"Avaiable ones are: \n\n"
,
wordvCtorSelector_
);
return nullptr;
}
// Search the macro-generated hash map to see if a class matching
// the requested string has been registered.
if (wordvCtorSelector_.search(demSystemName))
{
// Invoke the registered constructor function via function pointer
return wordvCtorSelector_[demSystemName]
(
demSystemName,
domains,
argc,
argv,
requireRVel
);
}
else
{
// Graceful error handling: List available options if a typo is made
printKeys
(
fatalError << "Ctor Selector " << demSystemName << " does not exist. \n"
<< "Available ones are: \n\n",
wordvCtorSelector_
);
return nullptr;
}

return nullptr;
return nullptr;
}

} // namespace pFlow


Loading