phasicFlow/src/Integration/integration/integration.hpp

165 lines
3.7 KiB
C++
Raw Normal View History

2022-09-04 21:26:29 +00:00
/*------------------------------- 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.
-----------------------------------------------------------------------------*/
2022-12-09 22:02:54 +00:00
#ifndef __integration_hpp__
#define __integration_hpp__
2022-09-04 21:26:29 +00:00
2022-12-09 22:02:54 +00:00
#include "virtualConstructor.hpp"
#include "Vectors.hpp"
#include "pointStructure.hpp"
#include "repository.hpp"
2022-09-04 21:26:29 +00:00
namespace pFlow
{
2023-04-23 19:47:12 +00:00
/**
* Base class for integrating the first order ODE (IVP)
*
* The ODE should be in the following form:
*\f[
\frac{dy}{dt} = f(y,t)
\f]
* for example the equation of motion is in the following form:
*\f[
m\frac{d\vec{v}}{dt} = m\vec{g} + \sum \vec{f_c}(\vec{v},t)
\f]
*
* The integration method can be either one-step or predictor-corrector type.
*
*/
2022-09-04 21:26:29 +00:00
class integration
{
protected:
2023-04-23 19:47:12 +00:00
// - Protected data members
/// The owner repository that all fields are storred in
repository& owner_;
2022-09-04 21:26:29 +00:00
2023-04-23 19:47:12 +00:00
/// The base name for integration
const word baseName_;
2022-09-04 21:26:29 +00:00
2023-04-23 19:47:12 +00:00
/// A reference to pointStructure
const pointStructure& pStruct_;
2022-09-04 21:26:29 +00:00
public:
2023-04-23 19:47:12 +00:00
/// Type info
2022-12-09 22:02:54 +00:00
TypeInfo("integration");
2022-09-04 21:26:29 +00:00
2023-04-23 19:47:12 +00:00
// - Constructors
/// Construct from components
2022-09-04 21:26:29 +00:00
integration(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
2023-04-23 19:47:12 +00:00
/// Copy constructor
integration(const integration&) = default;
/// Move constructor
integration(integration&&) = default;
/// Copy assignment
integration& operator = (const integration&) = default;
/// Move assignment
integration& operator = (integration&&) = default;
/// Polymorphic copy/cloning
virtual
uniquePtr<integration> clone()const=0;
/// Destructor
2022-09-04 21:26:29 +00:00
virtual ~integration()=default;
2023-04-23 19:47:12 +00:00
/// Add a virtual constructor
2022-09-04 21:26:29 +00:00
create_vCtor(
integration,
word,
(const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method),
(baseName, owner, pStruct, method) );
2023-04-23 19:47:12 +00:00
// - Methods
2022-09-04 21:26:29 +00:00
2023-04-23 19:47:12 +00:00
/// Const ref to pointStructure
inline
2022-09-04 21:26:29 +00:00
const auto& pStruct()const
{
return pStruct_;
}
2023-04-23 19:47:12 +00:00
/// Base name
inline
2022-09-04 21:26:29 +00:00
const word& baseName()const
{
return baseName_;
}
2023-04-23 19:47:12 +00:00
/// Ref to the owner repository
inline
2022-09-04 21:26:29 +00:00
repository& owner()
{
return owner_;
}
2023-04-23 19:47:12 +00:00
/// Prediction step in integration
virtual
bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0;
/// Correction/main integration step
virtual
bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0;
/// Set the initial values for new indices
virtual
bool setInitialVals(
const int32IndexContainer& newIndices,
const realx3Vector& y) = 0;
/// Check if the method requires any set initial vals
virtual
bool needSetInitialVals()const = 0;
/// Create the polymorphic object based on inputs
2022-09-04 21:26:29 +00:00
static
uniquePtr<integration> create(
const word& baseName,
repository& owner,
const pointStructure& pStruct,
const word& method);
2023-04-23 19:47:12 +00:00
}; // integration
2022-09-04 21:26:29 +00:00
} // pFlow
2022-12-09 22:02:54 +00:00
#endif //__integration_hpp__