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
252 changes: 252 additions & 0 deletions DEMSystems/sphereDEMSystem/thermalSphereDEMSystem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
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.

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

#include "thermalSphereDEMSystem.hpp"
#include "vocabs.hpp"

namespace pFlow
{

//----------------------------- protected methods -----------------------------

// ========================================================================= //
// Section 3: Core Physics Loop
// ========================================================================= //

bool thermalSphereDEMSystem::loop()
{
do
{
// 3.1 Handle particle injection triggers
if (!insertion_().insertParticles(
Control().time().currentIter(),
Control().time().currentTime(),
Control().time().dt()))
{
fatalError << "Particle insertion failed "
<< "in thermalSphereDEMSystem.\n";
return false;
}

// 3.2 Initialize physics accumulators
geometry_->beforeIteration();
interaction_->beforeIteration();
particles_->beforeIteration();

// 3.3 Mechanical collision evaluation
interaction_->iterate();

// 3.4 Thermodynamic evaluation (Q_pp, Q_pfp, Q_rad)
if (thermalInteraction_)
{
thermalInteraction_->iterate();
}

// 3.5 Equations of motion and explicit energy integration
particles_->iterate();

// 3.6 Clean up and state finalization
geometry_->iterate();
particles_->afterIteration();
geometry_->afterIteration();

} while(Control()++);

return true;
}

//----------------------------- constructors ----------------------------------

// ========================================================================= //
// Section 1: Constructors
// ========================================================================= //

thermalSphereDEMSystem::thermalSphereDEMSystem(
word demSystemName,
const std::vector<box>& domains,
int argc,
char* argv[],
bool requireRVel)
:
sphereDEMSystem(demSystemName, domains, argc, argv, requireRVel)
{
REPORT(0) << "\nInitializing thermal DEM components..." << END_REPORT;

// Reset base instances for thermal override
interaction_.reset();
insertion_.reset();
particles_.reset();
spheres_.reset();

// 1.1 Load thermal properties
auto thermalProps = thermalProperty(
propertyFile__,
Control().caseSetup().path());

// 1.2 Initialize thermal shapes
auto* combinedShape = new thermalSphereShape(
shapeFile__,
&Control().caseSetup(),
thermalProps);

spheres_ = uniquePtr<sphereShape>(combinedShape);

// 1.3 Initialize thermal particles on GPU
auto* tp = new thermalSphereParticles(
Control(),
*combinedShape,
*combinedShape);

particles_ = uniquePtr<sphereFluidParticles>(tp);
thermalParticles_ = tp;

// 1.4 Reconstruct insertion mechanism
insertion_ = makeUnique<sphereInsertion>(
particles_(),
particles_().spheres());

if (!thermalParticles_->initializeThermalParticles())
{
fatalError << "Failed to initialize thermal properties "
<< "for particles.\n";
}

// 1.5 Reconstruct mechanical interactions
interaction_ = interaction::create(
Control(),
Particles(),
Geometry());

// 1.6 Initialize Unified Thermal Interaction Model
REPORT(0) << "Creating thermal interactions "
<< "(Conduction, Radiation, PFP)..." << END_REPORT;

box localDomain = domains.empty() ? box() : domains[0];

thermalInteraction_ = makeUnique<thermalInteraction>(
Control(),
*thermalParticles_,
localDomain);

// 1.7 Update distribution boundaries
real minD, maxD;
particles_->boundingSphereMinMax(minD, maxD);
particleDistribution_ = makeUnique<domainDistribute>(domains, maxD);
}

//---------------------------- public methods ---------------------------------

// ========================================================================= //
// Section 2: Time Integration Constraints
// ========================================================================= //

bool thermalSphereDEMSystem::iterate(
real upToTime,
real timeToWrite,
word timeName)
{
Control().time().setStopAt(upToTime);
Control().time().setOutputToFile(timeToWrite, timeName);

return loop();
}

bool thermalSphereDEMSystem::iterate(real upToTime)
{
Control().time().setStopAt(upToTime);

return loop();
}

// ========================================================================= //
// Section 4: Data Exchange Interfaces (CFD-DEM Coupling)
// ========================================================================= //

span<real> thermalSphereDEMSystem::temperature()
{
auto& hVec = thermalParticles_->temperatureHost();
return span<real>(hVec.data(), hVec.size());
}

span<real> thermalSphereDEMSystem::emissivity()
{
auto& hVec = thermalParticles_->emissivityHost();
return span<real>(hVec.data(), hVec.size());
}

span<real> thermalSphereDEMSystem::radSumTemp()
{
auto& hVec = thermalParticles_->radSumTempHost();
return span<real>(hVec.data(), hVec.size());
}

span<uint32> thermalSphereDEMSystem::radNumPrt()
{
auto& hVec = thermalParticles_->radNumPrtHost();
return span<uint32>(hVec.data(), hVec.size());
}

span<real> thermalSphereDEMSystem::parFluidHeatSourceConv()
{
auto& hVec = thermalParticles_->heatSourceConvHost();
return span<real>(hVec.data(), hVec.size());
}

span<real> thermalSphereDEMSystem::parFluidHeatSourceRad()
{
auto& hVec = thermalParticles_->heatSourceRadHost();
return span<real>(hVec.data(), hVec.size());
}

bool thermalSphereDEMSystem::sendFluidHeatSourcesToDEM()
{
thermalParticles_->heatSourcesHostUpdatedSync();
return true;
}

// ========================================================================= //
// Section 5: PFP Pipeline Exchange
// ========================================================================= //

span<real> thermalSphereDEMSystem::parFluidKappa()
{
auto& hVec = thermalParticles_->fluidKappaHost();
return span<real>(hVec.data(), hVec.size());
}

span<real> thermalSphereDEMSystem::parFluidAlpha()
{
auto& hVec = thermalParticles_->fluidAlphaHost();
return span<real>(hVec.data(), hVec.size());
}

bool thermalSphereDEMSystem::sendFluidPropertiesToDEM()
{
thermalParticles_->fluidPropertiesHostUpdatedSync();
return true;
}

//+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

} // pFlow




129 changes: 129 additions & 0 deletions DEMSystems/sphereDEMSystem/thermalSphereDEMSystem.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
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.

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

#ifndef pFlow_thermalSphereDEMSystem_hpp
#define pFlow_thermalSphereDEMSystem_hpp

#include "sphereDEMSystem.hpp"
#include "thermalSphereParticles.hpp"
#include "thermalInteraction.hpp"
#include "thermalProperty.hpp"
#include "thermalSphereShape.hpp"

namespace pFlow
{

/**
* @brief Extends the base mechanical DEM solver to handle thermodynamic
* physics (Conduction, PFP, and Radiation).
*/
class thermalSphereDEMSystem
:
public sphereDEMSystem
{
protected:

//- protected members

/// @brief Direct host-view access for thermal particles.
thermalSphereParticles* thermalParticles_ = nullptr;

/// @brief Manages inter-particle conduction, fluid-bridge heat, radiation.
uniquePtr<thermalInteraction> thermalInteraction_ = nullptr;

//- protected methods

/**
* @brief Core integration loop encompassing mechanical & thermal updates.
* @return True upon successful execution.
*/
bool loop();

public:

//- Type info

TypeInfo("thermalSphereDEMSystem");

//- constructors

thermalSphereDEMSystem(
word demSystemName,
const std::vector<box>& domains,
int argc,
char* argv[],
bool requireRVel = false);

~thermalSphereDEMSystem() override = default;

//- public methods

add_vCtor(
DEMSystem,
thermalSphereDEMSystem,
word
);

bool iterate(
real upToTime,
real timeToWrite,
word timeName) override;

bool iterate(real upToTime) override;

span<real> temperature() override;

span<real> emissivity() override;

span<real> radSumTemp() override;

span<uint32> radNumPrt() override;

span<real> parFluidHeatSourceConv() override;

span<real> parFluidHeatSourceRad() override;

bool sendFluidHeatSourcesToDEM() override;

span<real> parFluidKappa() override;

span<real> parFluidAlpha() override;

bool sendFluidPropertiesToDEM() override;

/**
* @brief Evaluates radiation module availability.
* @return True if the module is active and enabled by user dictionary.
*/
inline
bool hasRadiation() const override
{
return thermalInteraction_ != nullptr &&
thermalInteraction_->isRadiationEnabled();
}

}; // thermalSphereDEMSystem

} // pFlow

#endif // pFlow_thermalSphereDEMSystem_hpp



7 changes: 7 additions & 0 deletions solvers/heatSphereGranFlow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

set(source_files
heatSphereGranFlow.cpp
)
set(link_lib Kokkos::kokkos phasicFlow Particles Geometry Property Interaction Interaction Utilities)

pFlow_make_executable_install(heatSphereGranFlow source_files link_lib)
Loading