refactor upto pointField read
This commit is contained in:
parent
f5d8daa608
commit
90a1ac8f16
|
@ -60,12 +60,11 @@ if(pFlow_Build_MPI)
|
|||
find_package(MPI REQUIRED)
|
||||
endif()
|
||||
|
||||
|
||||
include(cmake/makeLibraryGlobals.cmake)
|
||||
include(cmake/makeExecutableGlobals.cmake)
|
||||
|
||||
configure_file(phasicFlowConfig.H.in phasicFlowConfig.H)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
#add a global include directory
|
||||
include_directories(src/setHelpers src/demComponent "${PROJECT_BINARY_DIR}")
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ repository/IOobject/IOPattern.cpp
|
|||
repository/repository/repository.cpp
|
||||
repository/Time/Time.cpp
|
||||
repository/Time/timeControl.cpp
|
||||
repository/Time/baseTimeControl.cpp
|
||||
repository/systemControl/systemControl.cpp
|
||||
repository/systemControl/dynamicLinkLibs.cpp
|
||||
|
||||
|
|
|
@ -178,6 +178,35 @@ iOstream& operator <<(iOstream& os, const Pair<T1,T2>& p)
|
|||
return os;
|
||||
}
|
||||
|
||||
template<typename T, typename... properties>
|
||||
INLINE_FUNCTION_H
|
||||
span<T> makeSpan(ViewType1D<T, properties...> & v)
|
||||
{
|
||||
return span<T>(v.data(), v.size());
|
||||
}
|
||||
|
||||
template<typename T, typename... properties>
|
||||
INLINE_FUNCTION_H
|
||||
span<T> makeSpan(ViewType1D<T, properties...> & v, uint32 size)
|
||||
{
|
||||
return span<T>(v.data(), size);
|
||||
}
|
||||
|
||||
template<typename T, typename... properties>
|
||||
INLINE_FUNCTION_H
|
||||
span<T> makeSpan(const ViewType1D<T, properties...> & v)
|
||||
{
|
||||
return span<T>(const_cast<T*>(v.data()), v.size());
|
||||
}
|
||||
|
||||
template<typename T, typename... properties>
|
||||
INLINE_FUNCTION_H
|
||||
span<T> makeSpan(const ViewType1D<T, properties...> & v, uint32 size)
|
||||
{
|
||||
return span<T>(const_cast<T*>(v.data()), size);
|
||||
}
|
||||
|
||||
|
||||
template<typename T, typename... properties>
|
||||
INLINE_FUNCTION_H
|
||||
iOstream& operator <<(iOstream& os, const ViewType1D<T, properties...> & v)
|
||||
|
|
|
@ -46,7 +46,7 @@ public Kokkos::pair<T,T>
|
|||
{
|
||||
using Pair = Kokkos::pair<T,T>;
|
||||
|
||||
TypeInfoTemplateNV("Range", T)
|
||||
TypeInfoTemplateNV11("Range", T)
|
||||
|
||||
//// - Constructors
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ Licence:
|
|||
#include "Timers.hpp"
|
||||
#include "streams.hpp"
|
||||
|
||||
pFlow::Timer::Timer(const word name, Timers* parrent)
|
||||
pFlow::Timer::Timer(const word& name, Timers* parrent)
|
||||
:
|
||||
name_(name),
|
||||
parrent_(parrent)
|
||||
|
|
|
@ -63,15 +63,15 @@ public:
|
|||
|
||||
TypeInfo("Timer");
|
||||
|
||||
Timer(){}
|
||||
Timer() = default;
|
||||
|
||||
Timer(const word name)
|
||||
explicit Timer(const word& name)
|
||||
:
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
|
||||
Timer(const word name, Timers* parrent);
|
||||
Timer(const word& name, Timers* parrent);
|
||||
|
||||
|
||||
const word& name()const
|
||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
|||
public:
|
||||
|
||||
/// type info
|
||||
TypeInfoTemplateNV2("Field", T, VectorType::memoerySpaceName());
|
||||
TypeInfoTemplateNV111("Field", T, VectorType::memoerySpaceName());
|
||||
|
||||
//// - Constructors
|
||||
|
||||
|
@ -178,10 +178,15 @@ public:
|
|||
//// - Methods
|
||||
|
||||
/// return field key
|
||||
const word& fieldKey()const
|
||||
word fieldKey()const
|
||||
{
|
||||
return fieldKey_;
|
||||
}
|
||||
|
||||
word name()const
|
||||
{
|
||||
return VectorType::name();
|
||||
}
|
||||
|
||||
//// - IO operations
|
||||
/*bool readField(iIstream& is, const size_t len, bool resume, bool readLength = true);
|
||||
|
@ -196,28 +201,7 @@ public:
|
|||
bool read(iIstream& is, const IOPattern& iop);
|
||||
|
||||
|
||||
bool write(iOstream& os, const IOPattern& iop )const;
|
||||
|
||||
template<typename HostMask>
|
||||
bool write(
|
||||
iOstream& os,
|
||||
const IOPattern& iop,
|
||||
const HostMask& mask)const
|
||||
{
|
||||
|
||||
os.writeWordKeyword(fieldKey_)<<endl;
|
||||
|
||||
if(!os.check(FUNCTION_NAME))return false;
|
||||
|
||||
if(!VectorType::write(os, iop)) return false;
|
||||
|
||||
os.endEntry();
|
||||
if(!os.check(FUNCTION_NAME))return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool write(iOstream& os, const IOPattern& iop )const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ protected:
|
|||
public:
|
||||
|
||||
// - Type info
|
||||
TypeInfoTemplateNV("List", T);
|
||||
TypeInfoTemplateNV11("List", T);
|
||||
|
||||
//// - Constructors
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ protected:
|
|||
public:
|
||||
|
||||
// - Type info
|
||||
TypeInfoTemplateNV("ListPtr", T);
|
||||
TypeInfoTemplateNV11("ListPtr", T);
|
||||
|
||||
//// - Contructors
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
using valueType = typename mapType::value_type;
|
||||
|
||||
// - type info
|
||||
TypeInfoTemplateNV("Map", Key);
|
||||
TypeInfoTemplateNV11("Map", Key);
|
||||
|
||||
//// - Constructors
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
public:
|
||||
|
||||
// - type info
|
||||
TypeInfoTemplateNV("MapPtr", Key);
|
||||
TypeInfoTemplateNV11("MapPtr", Key);
|
||||
|
||||
//// Contructors
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
using valueType = typename hashmapType::value_type;
|
||||
|
||||
|
||||
TypeInfoTemplateNV("hashMap", Key);
|
||||
TypeInfoTemplateNV11("hashMap", Key);
|
||||
|
||||
//// - Constructors
|
||||
|
||||
|
|
|
@ -87,16 +87,13 @@ protected:
|
|||
|
||||
static constexpr bool isHostAccessible_ = true;
|
||||
|
||||
constexpr static inline const char* memoerySpaceName()
|
||||
{
|
||||
return "std";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// - Type info
|
||||
TypeInfoTemplateNV2("Vector", T, memoerySpaceName());
|
||||
TypeInfoTemplateNV111("Vector", T, memoerySpaceName());
|
||||
|
||||
//// - Constructors
|
||||
|
||||
|
@ -372,6 +369,10 @@ public:
|
|||
return writeVector(os, iop);
|
||||
}
|
||||
|
||||
constexpr static inline const char* memoerySpaceName()
|
||||
{
|
||||
return "std";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -101,14 +101,6 @@ protected:
|
|||
static constexpr
|
||||
bool isDeviceAccessible_ = isDeviceAccessible<execution_space>();
|
||||
|
||||
|
||||
/// Name of the memory space
|
||||
constexpr static inline
|
||||
const char* memoerySpaceName()
|
||||
{
|
||||
return memory_space::name();
|
||||
}
|
||||
|
||||
/// Evaluate capacity based on the input size
|
||||
static INLINE_FUNCTION_H uint32 evalCapacity(uint32 n)
|
||||
{
|
||||
|
@ -136,7 +128,7 @@ protected:
|
|||
public:
|
||||
|
||||
/// Type info
|
||||
TypeInfoTemplateNV2("VectorSingle", T, memoerySpaceName());
|
||||
TypeInfoTemplateNV111("VectorSingle", T, memoerySpaceName());
|
||||
|
||||
//// - Constructors
|
||||
|
||||
|
@ -416,6 +408,12 @@ public:
|
|||
return writeSpan(os, sp, iop);
|
||||
|
||||
}
|
||||
/// Name of the memory space
|
||||
constexpr static inline
|
||||
const char* memoerySpaceName()
|
||||
{
|
||||
return memory_space::name();
|
||||
}
|
||||
|
||||
}; // class VectorSingle
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ Licence:
|
|||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
pFlow::boundaryField<VectorField, T, MemorySpace>::boundaryField
|
||||
(
|
||||
const boundaryBase& boundary,
|
||||
FieldType &internal
|
||||
const boundaryBase& boundary,
|
||||
InternalFieldType& internal
|
||||
)
|
||||
:
|
||||
observer(),
|
||||
|
@ -30,3 +30,33 @@ pFlow::boundaryField<VectorField, T, MemorySpace>::boundaryField
|
|||
internal_(internal)
|
||||
{}
|
||||
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
pFlow::uniquePtr<pFlow::boundaryField<VectorField, T, MemorySpace>>
|
||||
pFlow::boundaryField<VectorField, T, MemorySpace>::create
|
||||
(
|
||||
const boundaryBase& boundary,
|
||||
InternalFieldType& internal
|
||||
)
|
||||
{
|
||||
|
||||
word bType = angleBracketsNames("boundaryField", boundary.type());
|
||||
|
||||
if(boundaryBasevCtorSelector_.search(bType))
|
||||
{
|
||||
return boundaryBasevCtorSelector_[bType](boundary, internal);
|
||||
}
|
||||
else
|
||||
{
|
||||
printKeys
|
||||
(
|
||||
fatalError << "Ctor Selector "<< bType << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
boundaryBasevCtorSelector_
|
||||
);
|
||||
fatalExit;
|
||||
|
||||
}
|
||||
return nullptr;
|
||||
}
|
|
@ -22,7 +22,7 @@ Licence:
|
|||
|
||||
#include "observer.hpp"
|
||||
#include "boundaryBase.hpp"
|
||||
#include "Field.hpp"
|
||||
#include "internalField.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
@ -33,19 +33,51 @@ class boundaryField
|
|||
public observer
|
||||
{
|
||||
public:
|
||||
using FieldType = Field<VectorField, T, MemorySpace>;
|
||||
|
||||
using BoundaryFieldType = boundaryField<VectorField, T, MemorySpace>;
|
||||
|
||||
using InternalFieldType = internalField<VectorField, T, MemorySpace>;
|
||||
|
||||
using memory_space = typename InternalFieldType::memory_space;
|
||||
|
||||
using execution_space = typename InternalFieldType::execution_space;
|
||||
|
||||
protected:
|
||||
|
||||
const boundaryBase& boundary_;
|
||||
|
||||
/// @brief a ref to the internal field
|
||||
FieldType& internal_;
|
||||
InternalFieldType& internal_;
|
||||
|
||||
public:
|
||||
|
||||
boundaryField(const boundaryBase& boundary, FieldType& internal);
|
||||
TypeInfo("boundaryField<none>");
|
||||
|
||||
bool update
|
||||
boundaryField(
|
||||
const boundaryBase& boundary,
|
||||
InternalFieldType& internal);
|
||||
|
||||
create_vCtor
|
||||
(
|
||||
boundaryField,
|
||||
boundaryBase,
|
||||
(
|
||||
const boundaryBase& boundary,
|
||||
InternalFieldType& internal
|
||||
),
|
||||
(boundary, internal)
|
||||
);
|
||||
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
BoundaryFieldType,
|
||||
BoundaryFieldType,
|
||||
boundaryBase
|
||||
);
|
||||
|
||||
|
||||
bool hearChanges
|
||||
(
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
|
@ -55,6 +87,21 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
auto size()const
|
||||
{
|
||||
return boundary_.size();
|
||||
}
|
||||
|
||||
auto capacity()const
|
||||
{
|
||||
return boundary_.capacity();
|
||||
}
|
||||
|
||||
static
|
||||
uniquePtr<boundaryField> create(
|
||||
const boundaryBase& boundary,
|
||||
InternalFieldType& internal);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -34,9 +34,10 @@ class boundaryFieldList
|
|||
{
|
||||
public:
|
||||
|
||||
using boundaryFieldType = boundaryField<VectorField, T, MemorySpace>;
|
||||
using BoundaryFieldType = boundaryField<VectorField, T, MemorySpace>;
|
||||
|
||||
using FieldType = typename boundaryFieldType::FieldType;
|
||||
using InternalFieldType = typename BoundaryFieldType::InternalFieldType;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -44,9 +45,9 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
boundaryFieldList(const boundaryList& boundaries, FieldType& internal)
|
||||
boundaryFieldList(const boundaryList& boundaries, InternalFieldType& internal)
|
||||
:
|
||||
ListPtr<boundaryFieldType>(boundaries.size()),
|
||||
ListPtr<BoundaryFieldType>(boundaries.size()),
|
||||
boundaries_(boundaries)
|
||||
{
|
||||
for(auto i=0; i<boundaries.size(); i++)
|
||||
|
@ -54,17 +55,11 @@ public:
|
|||
this->set
|
||||
(
|
||||
i,
|
||||
makeUnique<boundaryFieldType>
|
||||
(
|
||||
boundaries_[i],
|
||||
internal
|
||||
)
|
||||
BoundaryFieldType::create(boundaries_[i], internal)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*------------------------------- 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 __createBoundaryFields_hpp__
|
||||
#define __createBoundaryFields_hpp__
|
||||
|
||||
#include "boundaryField.hpp"
|
||||
#include "exitBoundaryField.hpp"
|
||||
|
||||
#define createBaseBoundary(VectorFieldType, DataType, MemorySpaceType) \
|
||||
template class pFlow::boundaryField<VectorFieldType, DataType, MemorySpaceType>;
|
||||
|
||||
|
||||
#define createBoundary(VectorFieldType, DataType, MemorySpaceType, BoundaryType) \
|
||||
template class pFlow::BoundaryType##BoundaryField<VectorFieldType, DataType, MemorySpaceType>;
|
||||
|
||||
|
||||
#endif //__createBoundaryFields_hpp__
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
pFlow::exitBoundaryField<VectorField, T, MemorySpace>::exitBoundaryField
|
||||
(
|
||||
const boundaryBase& boundary,
|
||||
InternalFieldType& internal
|
||||
)
|
||||
:
|
||||
BoundaryFieldType(boundary, internal)
|
||||
{}
|
|
@ -0,0 +1,81 @@
|
|||
/*------------------------------- 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 __exitBoundaryField_hpp__
|
||||
#define __exitBoundaryField_hpp__
|
||||
|
||||
#include "boundaryField.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template< template<class, class> class VectorField, class T, class MemorySpace = void>
|
||||
class exitBoundaryField
|
||||
:
|
||||
public boundaryField<VectorField, T, MemorySpace>
|
||||
{
|
||||
public:
|
||||
|
||||
using ExitBoundaryFieldType = exitBoundaryField<VectorField, T, MemorySpace>;
|
||||
|
||||
using BoundaryFieldType = boundaryField<VectorField, T, MemorySpace>;
|
||||
|
||||
using InternalFieldType = typename BoundaryFieldType::InternalFieldType;
|
||||
|
||||
using memory_space = typename BoundaryFieldType::memory_space;
|
||||
|
||||
using execution_space = typename BoundaryFieldType::execution_space;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("boundaryField<exit>");
|
||||
|
||||
exitBoundaryField(
|
||||
const boundaryBase& boundary,
|
||||
InternalFieldType& internal);
|
||||
|
||||
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
BoundaryFieldType,
|
||||
ExitBoundaryFieldType,
|
||||
boundaryBase
|
||||
);
|
||||
|
||||
|
||||
bool hearChanges
|
||||
(
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include "exitBoundaryField.cpp"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,86 @@
|
|||
/*------------------------------- 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.
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
pFlow::internalField<VectorField, T, MemorySpace>::internalField
|
||||
(
|
||||
const word& name,
|
||||
const internalPoints& internal
|
||||
)
|
||||
:
|
||||
observer
|
||||
(
|
||||
&internal,
|
||||
message::CAP_CHANGED+message::ITEM_INSERT+message::ITEM_REARRANGE+message::ITEM_DELETE
|
||||
),
|
||||
field_
|
||||
(
|
||||
name,
|
||||
"ineternalField",
|
||||
internal.capacity(),
|
||||
internal.size(),
|
||||
RESERVE()
|
||||
),
|
||||
internalPoints_(internal)
|
||||
{}
|
||||
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
pFlow::hostViewType1D<T>
|
||||
pFlow::internalField<VectorField, T, MemorySpace>::activeValuesHost()const
|
||||
{
|
||||
auto maskH = internalPoints_.activePointsMaskHost();
|
||||
auto fieldH = field_.hostVector();
|
||||
|
||||
hostViewType1D<T> aField("Active field", maskH.numActive());
|
||||
auto aRange = maskH.activeRange();
|
||||
|
||||
uint32 n = 0;
|
||||
for(auto i=aRange.start(); i<aRange.end(); i++)
|
||||
{
|
||||
if( maskH.isActive(i) )
|
||||
{
|
||||
aField[n] = fieldH[i];
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
return aField;
|
||||
}
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
bool pFlow::internalField<VectorField, T, MemorySpace>::write
|
||||
(
|
||||
iOstream& os,
|
||||
const IOPattern& iop
|
||||
)const
|
||||
{
|
||||
if( internalPoints_.isAllActive() )
|
||||
{
|
||||
return field_.write(os, iop);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto aValues = activeValuesHost();
|
||||
auto spanValues = makeSpan(aValues);
|
||||
return writeSpan(os, spanValues, iop);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/*------------------------------- 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 __internalField_hpp__
|
||||
#define __internalField_hpp__
|
||||
|
||||
#include "internalPoints.hpp"
|
||||
#include "Field.hpp"
|
||||
#include "observer.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace=void>
|
||||
class internalField
|
||||
:
|
||||
public observer
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
using FieldType = Field<VectorField, T, MemorySpace>;
|
||||
|
||||
using VectorType = typename FieldType::VectorType;
|
||||
|
||||
using memory_space = typename FieldType::memory_space;
|
||||
|
||||
using execution_space = typename FieldType::execution_space;
|
||||
|
||||
protected:
|
||||
|
||||
FieldType field_;
|
||||
|
||||
const internalPoints& internalPoints_;
|
||||
|
||||
public:
|
||||
|
||||
internalField(
|
||||
const word& name,
|
||||
const internalPoints& internal);
|
||||
|
||||
|
||||
auto fieldDevice()const
|
||||
{
|
||||
return field_.deviceVector();
|
||||
}
|
||||
|
||||
auto fieldHost()const
|
||||
{
|
||||
return field_.hostVector();
|
||||
}
|
||||
|
||||
hostViewType1D<T> activeValuesHost()const;
|
||||
|
||||
inline
|
||||
auto size()const
|
||||
{
|
||||
return field_.size();
|
||||
}
|
||||
|
||||
inline
|
||||
auto capacity()const
|
||||
{
|
||||
return field_.capacity();
|
||||
}
|
||||
|
||||
inline
|
||||
word name()const
|
||||
{
|
||||
return field_.name();
|
||||
}
|
||||
|
||||
inline
|
||||
word fieldKey()const
|
||||
{
|
||||
return field_.fieldKey();
|
||||
}
|
||||
|
||||
inline
|
||||
auto activeRange()const
|
||||
{
|
||||
return internalPoints_.activeRange();
|
||||
}
|
||||
|
||||
inline
|
||||
auto isAllActive()const
|
||||
{
|
||||
return internalPoints_.isAllActive();
|
||||
}
|
||||
|
||||
//// - IO
|
||||
|
||||
bool write(iOstream& os, const IOPattern& iop)const;
|
||||
|
||||
};
|
||||
|
||||
/*template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
inline
|
||||
iOstream& operator<<
|
||||
(
|
||||
iOstream& os,
|
||||
const internalField<VectorField, T, MemorySpace>& if
|
||||
)
|
||||
{
|
||||
if( !if.write(os, IOPattern::AllProcessorsDifferent) )
|
||||
{
|
||||
ioErrorInFile(os.name(), os.lineNumber());
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
return os;
|
||||
}*/
|
||||
|
||||
} // pFlow
|
||||
|
||||
#include "internalField.cpp"
|
||||
|
||||
#endif // __internalField_hpp__
|
|
@ -0,0 +1,204 @@
|
|||
/*------------------------------- 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 __internalField_hpp__
|
||||
#define __internalField_hpp__
|
||||
|
||||
#include "pointStructure.hpp"
|
||||
#include "Field.hpp"
|
||||
#include "observer.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace=void>
|
||||
class internalField
|
||||
:
|
||||
public observer,
|
||||
public Field<VectorField, T, MemorySpace>
|
||||
{
|
||||
public:
|
||||
|
||||
using pointFieldType = pointField<VectorField, T, MemorySpace>;
|
||||
|
||||
using FieldType = Field<VectorField, T, MemorySpace>;
|
||||
|
||||
using boundaryFieldListType = boundaryFieldList<VectorField, T, MemorySpace>;
|
||||
|
||||
using VectorType = typename FieldType::VectorType;
|
||||
|
||||
using iterator = typename FieldType::iterator;
|
||||
|
||||
using const_iterator = typename FieldType::const_iterator;
|
||||
|
||||
using reference = typename FieldType::reference;
|
||||
|
||||
using const_reference = typename FieldType::const_reference;
|
||||
|
||||
using value_type = typename FieldType::value_type;
|
||||
|
||||
using pointer = typename FieldType::pointer;
|
||||
|
||||
using const_pointer = typename FieldType::const_pointer;
|
||||
|
||||
protected:
|
||||
|
||||
//// - data members
|
||||
|
||||
/// @brief list of boundaries
|
||||
boundaryFieldListType boundaryFieldList_;
|
||||
|
||||
/// @brief refrence to point structure
|
||||
const pointStructure& pStruct_;
|
||||
|
||||
/// @brief value when a new item is added to field
|
||||
T defaultValue_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// - type info
|
||||
TypeInfoTemplateNV2("pointField", T, VectorType::memoerySpaceName());
|
||||
|
||||
|
||||
//// - Constructors
|
||||
|
||||
// - construct a field from pointStructure and set defaultValue_ and field value to defVal
|
||||
pointField(
|
||||
const objectFile& objf,
|
||||
pointStructure& pStruct,
|
||||
const T& defVal);
|
||||
|
||||
// - construct from iIOEntity, pointStructure and a value
|
||||
/*pointField( const pointStructure& pStruct, const T& val, const T& defVal, bool subscribe = true);
|
||||
|
||||
// - construct from another pointField
|
||||
// subscribe to events if true
|
||||
pointField( const pointField& src, bool subscribe);
|
||||
|
||||
|
||||
// - copy construct
|
||||
pointField(const pointField& src);
|
||||
|
||||
// - no move construct
|
||||
pointField(pointField&& src) = delete;
|
||||
|
||||
|
||||
// assignment, only assign the VectorField and preserve other parts of this
|
||||
pointField& operator = (const pointField& rhs);
|
||||
|
||||
// no move assignment
|
||||
pointField& operator = (pointField&&) = delete;
|
||||
|
||||
|
||||
inline uniquePtr<pointFieldType> clone() const
|
||||
{
|
||||
return makeUnique<pointFieldType>(*this);
|
||||
}
|
||||
|
||||
inline pointFieldType* clonePtr()const
|
||||
{
|
||||
return new pointFieldType(*this);
|
||||
}
|
||||
|
||||
//// - Methods
|
||||
|
||||
// - reference to pointStructure
|
||||
inline const pointStructure& pStruct()const {
|
||||
return pStruct_;
|
||||
}
|
||||
|
||||
// if all points are active
|
||||
INLINE_FUNCTION_H
|
||||
bool allActive()const {
|
||||
return pStruct_.allActive();
|
||||
}
|
||||
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
bool isActive(label i)const {
|
||||
return pStruct_.isActive(i);
|
||||
}
|
||||
|
||||
const auto& pointFlag()const
|
||||
{
|
||||
return pStruct_.pointFlag();
|
||||
}
|
||||
|
||||
range activeRange()const
|
||||
{
|
||||
return pStruct_.activeRange();
|
||||
}
|
||||
|
||||
// - update the field if any changes occure in pStruct
|
||||
// for now it checks for deleted points
|
||||
bool update(const eventMessage& msg);
|
||||
|
||||
|
||||
//// - IO operations
|
||||
bool readPointField(iIstream& is);
|
||||
|
||||
bool writePointField(iOstream& os)const;
|
||||
|
||||
|
||||
bool read(iIstream& is)
|
||||
{
|
||||
return readPointField(is);
|
||||
}
|
||||
|
||||
bool write(iOstream& os)const
|
||||
{
|
||||
return writePointField(os);
|
||||
}*/
|
||||
};
|
||||
|
||||
/*template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
iIstream& operator >> (iIstream & is, pointField<VectorField, T, MemorySpace> & pF )
|
||||
{
|
||||
if( !pF.read(is))
|
||||
{
|
||||
ioErrorInFile( is.name(), is.lineNumber() ) <<
|
||||
"error in reading pointField from file. \n";
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
iOstream& operator << (iOstream& os, const pointField<VectorField, T, MemorySpace>& pF )
|
||||
{
|
||||
if(! pF.write(os) )
|
||||
{
|
||||
ioErrorInFile( os.name(), os.lineNumber() )<<
|
||||
"error in writing pointField into file. \n";
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
return os;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
#include "pointField.cpp"
|
||||
//#include "pointFieldAlgorithms.hpp"
|
||||
|
||||
#endif // __pointField_hpp__
|
|
@ -21,34 +21,30 @@ Licence:
|
|||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
pFlow::pointField<VectorField, T, MemorySpace>::pointField
|
||||
(
|
||||
const pointStructure& pStruct,
|
||||
const T& defVal,
|
||||
message msg
|
||||
const objectFile& objf,
|
||||
pointStructure& pStruct,
|
||||
const T& defVal
|
||||
)
|
||||
:
|
||||
IOobject
|
||||
(
|
||||
objf,
|
||||
pStruct.ioPattern(),
|
||||
pStruct.owner()
|
||||
),
|
||||
InternalFieldType
|
||||
(
|
||||
objf.name(),
|
||||
pStruct
|
||||
),
|
||||
boundaryFieldList_(pStruct.boundaries(), *this),
|
||||
pStruct_(pStruct),
|
||||
defaultValue_(defVal)
|
||||
{}
|
||||
|
||||
/*template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
bool pFlow::pointField<VectorField, T, MemorySpace>::readPointField
|
||||
(
|
||||
iIstream& is
|
||||
)
|
||||
{
|
||||
|
||||
return FieldType::readField(is, pStruct_.size(), false);
|
||||
}
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
bool pFlow::pointField<VectorField, T, MemorySpace>::writePointField
|
||||
(
|
||||
iOstream& os
|
||||
)const
|
||||
{
|
||||
return FieldType::write(os);
|
||||
}
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
@ -144,3 +140,58 @@ bool pFlow::pointField<VectorField, T, MemorySpace>::update(const eventMessage&
|
|||
return true;
|
||||
}*/
|
||||
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
bool pFlow::pointField<VectorField, T, MemorySpace>::readPointField
|
||||
(
|
||||
iIstream& is,
|
||||
const IOPattern& iop
|
||||
)
|
||||
{
|
||||
Field<Vector, T , vecAllocator<T>>
|
||||
fRead("file_read"+InternalFieldType::name(), InternalFieldType::fieldKey());
|
||||
|
||||
if( !fRead.read(is, iop))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in reading pointPosition from stream "<< is.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto thisN = pStruct_.simDomain().initialNumberInThis();
|
||||
|
||||
Field<Vector, T , vecAllocator<T>> internal
|
||||
(
|
||||
"internalField"+InternalFieldType::name(),
|
||||
InternalFieldType::fieldKey(),
|
||||
thisN,
|
||||
thisN,
|
||||
RESERVE()
|
||||
);
|
||||
|
||||
auto pSpan = fRead.getSpan();
|
||||
auto iSpan = internal.getSpan();
|
||||
|
||||
if(!pStruct_.simDomain().initialTransferBlockData(pSpan, iSpan))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in transfering the block data for field "<<
|
||||
InternalFieldType::name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
this->field_.assign(internal);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
bool pFlow::pointField<VectorField, T, MemorySpace>::writePointField
|
||||
(
|
||||
iOstream& os,
|
||||
const IOPattern& iop
|
||||
)const
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
}
|
|
@ -21,10 +21,10 @@ Licence:
|
|||
#ifndef __pointField_hpp__
|
||||
#define __pointField_hpp__
|
||||
|
||||
#include "boundaryFieldList.hpp"
|
||||
|
||||
#include "pointStructure.hpp"
|
||||
#include "Field.hpp"
|
||||
#include "observer.hpp"
|
||||
#include "internalField.hpp"
|
||||
#include "boundaryFieldList.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
@ -32,32 +32,24 @@ namespace pFlow
|
|||
template<template<class, class> class VectorField, class T, class MemorySpace=void>
|
||||
class pointField
|
||||
:
|
||||
public observer,
|
||||
public Field<VectorField, T, MemorySpace>
|
||||
public IOobject,
|
||||
public internalField<VectorField, T, MemorySpace>
|
||||
{
|
||||
public:
|
||||
|
||||
using pointFieldType = pointField<VectorField, T, MemorySpace>;
|
||||
|
||||
using FieldType = Field<VectorField, T, MemorySpace>;
|
||||
using PointFieldType = pointField<VectorField, T, MemorySpace>;
|
||||
|
||||
using InternalFieldType = internalField<VectorField, T, MemorySpace>;
|
||||
|
||||
using FieldType = typename InternalFieldType::FieldType;
|
||||
|
||||
using boundaryFieldListType = boundaryFieldList<VectorField, T, MemorySpace>;
|
||||
|
||||
using VectorType = typename FieldType::VectorType;
|
||||
|
||||
using iterator = typename FieldType::iterator;
|
||||
using VectorType = typename InternalFieldType::VectorType;
|
||||
|
||||
using const_iterator = typename FieldType::const_iterator;
|
||||
using memory_space = typename InternalFieldType::memory_space;
|
||||
|
||||
using reference = typename FieldType::reference;
|
||||
|
||||
using const_reference = typename FieldType::const_reference;
|
||||
|
||||
using value_type = typename FieldType::value_type;
|
||||
|
||||
using pointer = typename FieldType::pointer;
|
||||
|
||||
using const_pointer = typename FieldType::const_pointer;
|
||||
using execution_space = typename InternalFieldType::execution_space;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -74,18 +66,19 @@ protected:
|
|||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
// - type info
|
||||
TypeInfoTemplateNV2("pointField", T, VectorType::memoerySpaceName());
|
||||
TypeInfoTemplate111("pointField", T, VectorType::memoerySpaceName());
|
||||
|
||||
|
||||
//// - Constructors
|
||||
|
||||
// - construct a field from pointStructure and set defaultValue_ and field value to defVal
|
||||
pointField(
|
||||
const pointStructure& pStruct,
|
||||
const T& defVal,
|
||||
message msg);
|
||||
pointField(
|
||||
const objectFile& objf,
|
||||
pointStructure& pStruct,
|
||||
const T& defVal);
|
||||
|
||||
// - construct from iIOEntity, pointStructure and a value
|
||||
/*pointField( const pointStructure& pStruct, const T& val, const T& defVal, bool subscribe = true);
|
||||
|
@ -150,24 +143,24 @@ public:
|
|||
|
||||
// - update the field if any changes occure in pStruct
|
||||
// for now it checks for deleted points
|
||||
bool update(const eventMessage& msg);
|
||||
bool update(const eventMessage& msg);*/
|
||||
|
||||
|
||||
//// - IO operations
|
||||
bool readPointField(iIstream& is);
|
||||
bool readPointField(iIstream& is, const IOPattern& iop);
|
||||
|
||||
bool writePointField(iOstream& os)const;
|
||||
bool writePointField(iOstream& os, const IOPattern& iop)const;
|
||||
|
||||
|
||||
bool read(iIstream& is)
|
||||
bool read(iIstream& is, const IOPattern& iop)override
|
||||
{
|
||||
return readPointField(is);
|
||||
return readPointField(is, iop);
|
||||
}
|
||||
|
||||
bool write(iOstream& os)const
|
||||
bool write(iOstream& os, const IOPattern& iop)const override
|
||||
{
|
||||
return writePointField(os);
|
||||
}*/
|
||||
return writePointField(os, iop);
|
||||
}
|
||||
};
|
||||
|
||||
/*template<template<class, class> class VectorField, class T, class MemorySpace>
|
||||
|
|
|
@ -20,9 +20,17 @@ Licence:
|
|||
|
||||
|
||||
#include "pointFields.hpp"
|
||||
#include "createBoundaryFields.hpp"
|
||||
|
||||
|
||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::int8>;
|
||||
createBaseBoundary(pFlow::VectorSingle, pFlow::int8, pFlow::HostSpace);
|
||||
createBoundary(pFlow::VectorSingle, pFlow::int8, pFlow::HostSpace, exit);
|
||||
|
||||
template class pFlow::pointField<pFlow::VectorSingle, pFlow::real>;
|
||||
createBaseBoundary(pFlow::VectorSingle, pFlow::real, pFlow::HostSpace);
|
||||
createBoundary(pFlow::VectorSingle, pFlow::real, pFlow::HostSpace, exit);
|
||||
|
||||
|
||||
/*template class pFlow::pointField<pFlow::VectorSingle, pFlow::int8, pFlow::HostSpace>;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
TypeInfoTemplateNV("span", T);
|
||||
TypeInfoTemplateNV11("span", T);
|
||||
|
||||
/// Constructor
|
||||
INLINE_FUNCTION_HD
|
||||
|
@ -229,7 +229,6 @@ span<const char> charSpan(span<const T> s)
|
|||
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
#endif //__span_hpp__
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
virtual
|
||||
bool beforeTimeLoop()
|
||||
{
|
||||
notImplementedFunction;
|
||||
notImplementedFunction
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
virtual
|
||||
bool afterTimeLoop()
|
||||
{
|
||||
notImplementedFunction;
|
||||
notImplementedFunction
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,9 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
std::bitset<16> events_{0x0000};
|
||||
static constexpr size_t numberOfEvents_ = 8;
|
||||
|
||||
std::bitset<numberOfEvents_> events_{0x0000};
|
||||
|
||||
|
||||
public:
|
||||
|
@ -59,7 +61,7 @@ public:
|
|||
|
||||
message(size_t i )
|
||||
{
|
||||
if(i<16)
|
||||
if(i<numberOfEvents_)
|
||||
{
|
||||
events_.set(i);
|
||||
}
|
||||
|
@ -118,7 +120,12 @@ public:
|
|||
{
|
||||
return remove(evnt);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
auto constexpr numEvents()
|
||||
{
|
||||
return numberOfEvents_;
|
||||
}
|
||||
static
|
||||
message Default()
|
||||
{
|
||||
|
|
|
@ -66,8 +66,13 @@ public:
|
|||
subscriber_ = nullptr;
|
||||
}
|
||||
|
||||
static
|
||||
constexpr auto numEvents()
|
||||
{
|
||||
return message::numEvents();
|
||||
}
|
||||
|
||||
virtual bool update(const message& msg, const anyList& varList)=0;
|
||||
virtual bool hearChanges(const message& msg, const anyList& varList)=0;
|
||||
};
|
||||
|
||||
} // pFlow
|
||||
|
|
|
@ -45,12 +45,6 @@ bool pFlow::subscriber::subscribe
|
|||
observer* obsevr
|
||||
)const
|
||||
{
|
||||
if( msg.size()>16 )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"message size is greater than 16!"<<endl;
|
||||
return false;
|
||||
}
|
||||
// do not subscribe nullptr
|
||||
if(!obsevr)return false;
|
||||
|
||||
|
@ -92,20 +86,14 @@ bool pFlow::subscriber::notify
|
|||
const anyList& varList
|
||||
)
|
||||
{
|
||||
if( msg.size()>16 )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"message size is greater than 16!"<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for(size_t i=0; i<msg.size(); i++)
|
||||
{
|
||||
if(msg.equivalentTo(i))
|
||||
{
|
||||
for( auto obsvr: observerList_[i] )
|
||||
{
|
||||
obsvr->update(message(i), varList);
|
||||
obsvr->hearChanges(message(i), varList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ Licence:
|
|||
#include <array>
|
||||
|
||||
#include "List.hpp"
|
||||
#include "message.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class observer;
|
||||
class message;
|
||||
class anyList;
|
||||
|
||||
class subscriber
|
||||
|
@ -38,7 +38,7 @@ class subscriber
|
|||
protected:
|
||||
|
||||
// - list of subsribed objectd that recieve updage messages
|
||||
mutable std::array<List<observer*>,16> observerList_;
|
||||
mutable std::array<List<observer*>,message::numEvents()> observerList_;
|
||||
|
||||
word subName_;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
|||
static inline const T minVal = largestNegative<T>();
|
||||
public:
|
||||
|
||||
TypeInfoTemplateNV("intervalRange",T);
|
||||
TypeInfoTemplateNV11("intervalRange",T);
|
||||
|
||||
intervalRange(T begin, T end)
|
||||
:
|
||||
|
|
|
@ -35,18 +35,20 @@ stridedRange
|
|||
{
|
||||
protected:
|
||||
|
||||
T begin_;
|
||||
T begin_ = 0;
|
||||
|
||||
T end_;
|
||||
T end_ = 1;
|
||||
|
||||
T stride_;
|
||||
T stride_ = 1;
|
||||
|
||||
static inline const T maxVal = largestPositive<T>();
|
||||
static inline const T minVal = largestNegative<T>();
|
||||
|
||||
public:
|
||||
|
||||
TypeInfoTemplateNV("stridedRange",T);
|
||||
TypeInfoTemplateNV11("stridedRange",T);
|
||||
|
||||
stridedRange()=default;
|
||||
|
||||
stridedRange(T begin, T end, T stride)
|
||||
:
|
||||
|
@ -96,12 +98,20 @@ public:
|
|||
{
|
||||
return stride_;
|
||||
}
|
||||
|
||||
inline
|
||||
bool isInRange(T val)const
|
||||
{
|
||||
return val>= begin_ && val<= end_;
|
||||
}
|
||||
|
||||
inline
|
||||
bool isMember(T val, T epsilon = 0)const
|
||||
{
|
||||
if(!isInRange(val)) return false;
|
||||
if(abs(mod(val-begin_,stride_))<= epsilon) return true;
|
||||
if(equal(val,begin_))return true;
|
||||
if(equal(val,end_))return true;
|
||||
if(abs(mod(val-begin_,stride_))<= epsilon) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,11 @@ public:
|
|||
return owner_;
|
||||
}
|
||||
|
||||
repository* owner()
|
||||
{
|
||||
return owner_;
|
||||
}
|
||||
|
||||
repository* releaseOwner(bool fromOwner = false);
|
||||
|
||||
//// - IO operations
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/*------------------------------- 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 "baseTimeControl.hpp"
|
||||
|
||||
|
||||
|
||||
pFlow::baseTimeControl::baseTimeControl
|
||||
(
|
||||
const dictionary &dict,
|
||||
const word& intervalPrefix
|
||||
)
|
||||
{
|
||||
auto tControl = dict.getVal<word>("timeControl");
|
||||
if(tControl == "timeStep")
|
||||
isTimeStep_ = true;
|
||||
else if( tControl == "runTime" ||
|
||||
tControl == "simulationTime")
|
||||
isTimeStep_ = false;
|
||||
else
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"bad input for intervalControl in dictionary "<< dict.globalName()<<endl<<
|
||||
"valid inputs are "<<
|
||||
wordList({"timeStep", "runTime", "simulationTime"})<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
word intervalWord = intervalPrefix.size()==0? word("interval"): intervalPrefix+"Interval";
|
||||
|
||||
if(isTimeStep_)
|
||||
{
|
||||
auto startTime = (dict.getValOrSet<real>("startTime", 0.0));
|
||||
auto endTime = (dict.getValOrSet<real>("endTime", largeValue));
|
||||
auto interval = dict.getVal<real>(intervalWord);
|
||||
rRange_ = realStridedRange(startTime, endTime, interval);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
auto startTime = (dict.getValOrSet<int32>("startTime", 0.0));
|
||||
auto endTime = (dict.getValOrSet<int32>("endTime", largestPosInt32));
|
||||
auto interval = dict.getVal<int32>(intervalWord);
|
||||
iRange_ = int32StridedRagne(startTime, endTime, interval);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::baseTimeControl::timeEvent(uint32 iter, real t, real dt) const
|
||||
{
|
||||
if(isTimeStep_)
|
||||
{
|
||||
return iRange_.isMember(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
return rRange_.isMember(t, 0.51*dt);
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*------------------------------- 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 __baseTimeControl_hpp__
|
||||
#define __baseTimeControl_hpp__
|
||||
|
||||
#include "dictionary.hpp"
|
||||
#include "ranges.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class baseTimeControl
|
||||
{
|
||||
private:
|
||||
|
||||
bool isTimeStep_;
|
||||
|
||||
int32StridedRagne iRange_;
|
||||
|
||||
realStridedRange rRange_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
baseTimeControl(const dictionary& dict, const word& intervalPrefix = "");
|
||||
|
||||
|
||||
bool timeEvent(uint32 iter, real t, real dt)const;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -25,7 +25,7 @@ Licence:
|
|||
#include "systemControl.hpp"
|
||||
#include "vocabs.hpp"
|
||||
|
||||
bool pFlow::systemControl::readDomainDict()
|
||||
/*bool pFlow::systemControl::readDomainDict()
|
||||
{
|
||||
if(!domainDict_)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ bool pFlow::systemControl::readDomainDict()
|
|||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
pFlow::word pFlow::systemControl::getRunName
|
||||
(
|
||||
|
@ -176,7 +176,7 @@ pFlow::systemControl::systemControl
|
|||
),
|
||||
writeToFileTimer_("Write to file", &timers_)
|
||||
{
|
||||
readDomainDict();
|
||||
//readDomainDict();
|
||||
}
|
||||
|
||||
pFlow::systemControl::systemControl(
|
||||
|
@ -250,13 +250,13 @@ pFlow::systemControl::systemControl(
|
|||
),
|
||||
writeToFileTimer_("Write to file", &timers_)
|
||||
{
|
||||
readDomainDict();
|
||||
//readDomainDict();
|
||||
}
|
||||
|
||||
pFlow::fileDictionary& pFlow::systemControl::domainDict()
|
||||
/*pFlow::fileDictionary& pFlow::systemControl::domainDict()
|
||||
{
|
||||
return domainDict_();
|
||||
}
|
||||
}*/
|
||||
|
||||
bool pFlow::systemControl::operator ++(int)
|
||||
{
|
||||
|
|
|
@ -62,8 +62,6 @@ protected:
|
|||
/// caseSetup folder repository
|
||||
uniquePtr<repository> caseSetup_;
|
||||
|
||||
uniquePtr<fileDictionary> domainDict_ = nullptr;
|
||||
|
||||
/// extra libs to be loaded
|
||||
dynamicLinkLibs libs_;
|
||||
|
||||
|
@ -81,7 +79,7 @@ protected:
|
|||
|
||||
Timer writeToFileTimer_;
|
||||
|
||||
bool readDomainDict();
|
||||
//bool readDomainDict();
|
||||
|
||||
static word getRunName( const fileSystem& path);
|
||||
|
||||
|
@ -159,7 +157,7 @@ public:
|
|||
return settingsDict_();
|
||||
}
|
||||
|
||||
fileDictionary& domainDict();
|
||||
//fileDictionary& domainDict();
|
||||
|
||||
|
||||
virtual word runName() const
|
||||
|
@ -172,10 +170,10 @@ public:
|
|||
return settingsDict_().getVal<realx3>("g");
|
||||
}
|
||||
|
||||
inline box domain()
|
||||
/*inline box domain()
|
||||
{
|
||||
return box(domainDict().subDict("globalBox"));
|
||||
}
|
||||
}*/
|
||||
|
||||
bool operator ++(int);
|
||||
|
||||
|
|
|
@ -60,8 +60,18 @@ pFlow::boundaryBase::boundaryBase
|
|||
|
||||
}
|
||||
|
||||
typename pFlow::boundaryBase::pointFieldAccessType
|
||||
pFlow::boundaryBase::thisPoints()
|
||||
void pFlow::boundaryBase::setSize(uint32 newSize)
|
||||
{
|
||||
indexList_.resize(newSize);
|
||||
|
||||
if( indexList_.capacity() <= newSize+1 )
|
||||
{
|
||||
indexList_.reserve(newSize+1);
|
||||
}
|
||||
}
|
||||
|
||||
typename pFlow::boundaryBase::pointFieldAccessType
|
||||
pFlow::boundaryBase::thisPoints()
|
||||
{
|
||||
|
||||
return pointFieldAccessType
|
||||
|
|
|
@ -46,10 +46,6 @@ public:
|
|||
using pointFieldAccessType =
|
||||
scatterFieldAccess<realx3,DefaultExecutionSpace>;
|
||||
|
||||
enum DIRECTION: int8
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -110,6 +106,37 @@ public:
|
|||
(dict, bplane, internal)
|
||||
);
|
||||
|
||||
inline
|
||||
auto neighborLength()const
|
||||
{
|
||||
return neighborLength_;
|
||||
}
|
||||
|
||||
|
||||
const word& type()const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
const word& name()const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
auto size()const
|
||||
{
|
||||
return indexList_.size();
|
||||
}
|
||||
|
||||
auto capacity()const
|
||||
{
|
||||
return indexList_.capacity();
|
||||
}
|
||||
|
||||
/// @brief set the size of indexList
|
||||
/// Always make sure that size+1 <= capacity
|
||||
void setSize(uint32 newSize);
|
||||
|
||||
virtual
|
||||
bool beforeIteratoin(uint32 iterNum, real t) = 0 ;
|
||||
|
||||
|
@ -119,6 +146,12 @@ public:
|
|||
virtual
|
||||
bool afterIteration(uint32 iterNum, real t) = 0;
|
||||
|
||||
|
||||
const auto& indexList()const
|
||||
{
|
||||
return indexList_;
|
||||
}
|
||||
|
||||
pointFieldAccessType thisPoints();
|
||||
|
||||
virtual
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
bool pFlow::regularSimulationDomain::createBoundaryDicts()
|
||||
{
|
||||
auto& boundaries = globalDomainDict_.subDict("boundaries");
|
||||
auto& boundaries = this->subDict("boundaries");
|
||||
|
||||
globalDomainDict_.addDict("regularSimulationDomainBoundaries", boundaries);
|
||||
auto& rbBoundaries = globalDomainDict_.subDict("regularSimulationDomainBoundaries");
|
||||
this->addDict("regularSimulationDomainBoundaries", boundaries);
|
||||
auto& rbBoundaries = this->subDict("regularSimulationDomainBoundaries");
|
||||
|
||||
real neighborLength = boundaries.getVal<real>("neighborLength");
|
||||
|
||||
|
@ -52,10 +52,10 @@ bool pFlow::regularSimulationDomain::setThisDomain()
|
|||
|
||||
pFlow::regularSimulationDomain::regularSimulationDomain
|
||||
(
|
||||
const dictionary &dict
|
||||
systemControl& control
|
||||
)
|
||||
:
|
||||
simulationDomain(dict)
|
||||
simulationDomain(control)
|
||||
{}
|
||||
|
||||
bool pFlow::regularSimulationDomain::initialUpdateDomains(span<realx3> pointPos)
|
||||
|
@ -93,7 +93,7 @@ bool pFlow::regularSimulationDomain::initialTransferBlockData
|
|||
span<char> src,
|
||||
span<char> dst,
|
||||
size_t sizeOfElement
|
||||
)
|
||||
) const
|
||||
{
|
||||
size_t requiredSize = sizeOfElement*initialNumberInThis();
|
||||
if(dst.size() < requiredSize)
|
||||
|
@ -122,7 +122,7 @@ bool pFlow::regularSimulationDomain::initialTransferBlockData
|
|||
(
|
||||
span<realx3> src,
|
||||
span<realx3> dst
|
||||
)
|
||||
) const
|
||||
{
|
||||
return initialTransferBlockData(
|
||||
charSpan(src),
|
||||
|
@ -134,7 +134,7 @@ bool pFlow::regularSimulationDomain::initialTransferBlockData
|
|||
(
|
||||
span<real> src,
|
||||
span<real> dst
|
||||
)
|
||||
) const
|
||||
{
|
||||
return initialTransferBlockData(
|
||||
charSpan(src),
|
||||
|
@ -146,7 +146,7 @@ bool pFlow::regularSimulationDomain::initialTransferBlockData
|
|||
(
|
||||
span<uint32> src,
|
||||
span<uint32> dst
|
||||
)
|
||||
) const
|
||||
{
|
||||
return initialTransferBlockData(
|
||||
charSpan(src),
|
||||
|
@ -158,7 +158,7 @@ bool pFlow::regularSimulationDomain::initialTransferBlockData
|
|||
(
|
||||
span<int32> src,
|
||||
span<int32> dst
|
||||
)
|
||||
) const
|
||||
{
|
||||
return initialTransferBlockData(
|
||||
charSpan(src),
|
||||
|
@ -168,7 +168,7 @@ bool pFlow::regularSimulationDomain::initialTransferBlockData
|
|||
|
||||
const pFlow::dictionary &pFlow::regularSimulationDomain::thisBoundaryDict() const
|
||||
{
|
||||
return globalDomainDict_.subDict("regularSimulationDomainBoundaries");
|
||||
return this->subDict("regularSimulationDomainBoundaries");
|
||||
}
|
||||
|
||||
bool pFlow::regularSimulationDomain::requiresDataTransfer()const
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
TypeInfo("simulationDomain<regular>");
|
||||
|
||||
regularSimulationDomain(const dictionary& dict);
|
||||
regularSimulationDomain(systemControl& control);
|
||||
|
||||
virtual
|
||||
~regularSimulationDomain()=default;
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
(
|
||||
simulationDomain,
|
||||
regularSimulationDomain,
|
||||
dictionary
|
||||
systemControl
|
||||
);
|
||||
|
||||
bool initialUpdateDomains(span<realx3> pointPos) override;
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
bool initialTransferBlockData(
|
||||
span<char> src,
|
||||
span<char> dst,
|
||||
size_t sizeOfElement) override;
|
||||
size_t sizeOfElement) const override;
|
||||
|
||||
|
||||
/// @brief
|
||||
|
@ -59,19 +59,19 @@ public:
|
|||
/// @return
|
||||
bool initialTransferBlockData(
|
||||
span<realx3> src,
|
||||
span<realx3> dst) override;
|
||||
span<realx3> dst) const override;
|
||||
|
||||
bool initialTransferBlockData(
|
||||
span<real> src,
|
||||
span<real> dst) override;
|
||||
span<real> dst) const override;
|
||||
|
||||
bool initialTransferBlockData(
|
||||
span<uint32> src,
|
||||
span<uint32> dst) override;
|
||||
span<uint32> dst) const override;
|
||||
|
||||
bool initialTransferBlockData(
|
||||
span<int32> src,
|
||||
span<int32> dst) override;
|
||||
span<int32> dst) const override;
|
||||
|
||||
|
||||
const dictionary& thisBoundaryDict()const override;
|
||||
|
|
|
@ -20,26 +20,38 @@ Licence:
|
|||
|
||||
#include "simulationDomain.hpp"
|
||||
#include "pFlowProcessors.hpp"
|
||||
#include "systemControl.hpp"
|
||||
#include "vocabs.hpp"
|
||||
|
||||
pFlow::simulationDomain::simulationDomain(const dictionary& dict)
|
||||
pFlow::simulationDomain::simulationDomain(systemControl& control)
|
||||
:
|
||||
globalBox_(dict.subDict("globalBox")),
|
||||
globalDomainDict_(dict)
|
||||
fileDictionary
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
domainFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
&control.settings()
|
||||
),
|
||||
globalBox_(subDict("globalBox"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pFlow::uniquePtr<pFlow::simulationDomain>
|
||||
pFlow::simulationDomain::create(const dictionary &dict)
|
||||
pFlow::simulationDomain::create(systemControl& control)
|
||||
{
|
||||
word sType = angleBracketsNames(
|
||||
"simulationDomain",
|
||||
pFlowProcessors().localRunTypeName());
|
||||
|
||||
|
||||
if( dictionaryvCtorSelector_.search(sType) )
|
||||
if( systemControlvCtorSelector_.search(sType) )
|
||||
{
|
||||
return dictionaryvCtorSelector_[sType] (dict);
|
||||
return systemControlvCtorSelector_[sType] (control);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -48,7 +60,7 @@ pFlow::uniquePtr<pFlow::simulationDomain>
|
|||
fatalError << "Ctor Selector "<< sType << " dose not exist. \n"
|
||||
<<"Avaiable ones are: \n\n"
|
||||
,
|
||||
dictionaryvCtorSelector_
|
||||
systemControlvCtorSelector_
|
||||
);
|
||||
fatalExit;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ Licence:
|
|||
#include <array>
|
||||
|
||||
#include "domain.hpp"
|
||||
#include "fileDictionary.hpp"
|
||||
#include "span.hpp"
|
||||
#include "streams.hpp"
|
||||
#include "virtualConstructor.hpp"
|
||||
|
@ -31,9 +32,12 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
class systemControl;
|
||||
//class pFlagTypeHost;
|
||||
|
||||
class simulationDomain
|
||||
:
|
||||
public fileDictionary
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -43,20 +47,20 @@ static
|
|||
inline const std::array<word,6> boundaryNames_ =
|
||||
{
|
||||
"left", "right",
|
||||
"top", "bottom",
|
||||
"bottom", "top",
|
||||
"rear", "front"
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//fileDictionary globalDomainDict_ ;
|
||||
|
||||
/// @brief acutal limits of the simulation domain
|
||||
box globalBox_;
|
||||
|
||||
/// @brief the actual limits of this processor domain
|
||||
domain thisDomain_;
|
||||
|
||||
dictionary globalDomainDict_ ;
|
||||
|
||||
bool boundariesSet_ = false;
|
||||
|
||||
virtual bool createBoundaryDicts() = 0;
|
||||
|
@ -69,7 +73,7 @@ public:
|
|||
TypeInfo("simulationDomain");
|
||||
|
||||
/// Constrcut from components
|
||||
simulationDomain(const dictionary& dict);
|
||||
simulationDomain(systemControl& control);
|
||||
|
||||
/// Destructor
|
||||
virtual
|
||||
|
@ -79,9 +83,9 @@ public:
|
|||
create_vCtor
|
||||
(
|
||||
simulationDomain,
|
||||
dictionary,
|
||||
(const dictionary& dict),
|
||||
(dict)
|
||||
systemControl,
|
||||
(systemControl& control),
|
||||
(control)
|
||||
);
|
||||
|
||||
virtual
|
||||
|
@ -97,33 +101,33 @@ public:
|
|||
bool initialTransferBlockData(
|
||||
span<char> src,
|
||||
span<char> dst,
|
||||
size_t sizeOfElement) = 0;
|
||||
size_t sizeOfElement) const = 0;
|
||||
|
||||
virtual
|
||||
bool initialTransferBlockData(
|
||||
span<realx3> src,
|
||||
span<realx3> dst) = 0;
|
||||
span<realx3> dst) const = 0;
|
||||
|
||||
virtual
|
||||
bool initialTransferBlockData(
|
||||
span<real> src,
|
||||
span<real> dst) = 0;
|
||||
span<real> dst) const = 0;
|
||||
|
||||
virtual
|
||||
bool initialTransferBlockData(
|
||||
span<uint32> src,
|
||||
span<uint32> dst) = 0;
|
||||
span<uint32> dst) const = 0;
|
||||
|
||||
virtual
|
||||
bool initialTransferBlockData(
|
||||
span<int32> src,
|
||||
span<int32> dst) = 0;
|
||||
span<int32> dst) const = 0;
|
||||
|
||||
|
||||
/*template<typename T>
|
||||
template<typename T>
|
||||
bool initialTransferBlockData(
|
||||
span<T> src,
|
||||
span<T> dst )
|
||||
span<T> dst )const
|
||||
{
|
||||
size_t el=sizeof(T);
|
||||
return initialTransferBlockData
|
||||
|
@ -132,7 +136,7 @@ public:
|
|||
charSpan(dst),
|
||||
el
|
||||
);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -149,6 +153,18 @@ public:
|
|||
virtual
|
||||
bool requiresDataTransfer() const = 0;
|
||||
|
||||
inline
|
||||
const auto& thisDomain()const
|
||||
{
|
||||
return thisDomain_;
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& globalBoundaryDict()const
|
||||
{
|
||||
return static_cast<const fileDictionary&>(*this);
|
||||
}
|
||||
|
||||
inline
|
||||
const dictionary& boundaryDict(uint32 i)const
|
||||
{
|
||||
|
@ -174,7 +190,7 @@ public:
|
|||
}
|
||||
|
||||
static
|
||||
uniquePtr<simulationDomain> create(const dictionary& dict);
|
||||
uniquePtr<simulationDomain> create(systemControl& control);
|
||||
|
||||
}; // simulationDomain
|
||||
|
||||
|
|
|
@ -19,21 +19,78 @@ Licence:
|
|||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "boundaryList.hpp"
|
||||
#include "internalPoints.hpp"
|
||||
#include "simulationDomain.hpp"
|
||||
|
||||
pFlow::boundaryList::boundaryList
|
||||
(
|
||||
const simulationDomain& simD,
|
||||
internalPoints& internal
|
||||
)
|
||||
:
|
||||
ListPtr<boundaryBase>(simD.sizeOfBoundaries()),
|
||||
simDomain_(simD),
|
||||
internal_(internal)
|
||||
{}
|
||||
bool pFlow::boundaryList::resetLists()
|
||||
{
|
||||
clear();
|
||||
listSet_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::boundaryList::updateLists()
|
||||
{
|
||||
|
||||
std::array<real,6> dist;
|
||||
dist[0] = boundary(0).neighborLength();
|
||||
dist[1] = boundary(1).neighborLength();
|
||||
dist[2] = boundary(2).neighborLength();
|
||||
dist[3] = boundary(3).neighborLength();
|
||||
dist[4] = boundary(4).neighborLength();
|
||||
dist[5] = boundary(5).neighborLength();
|
||||
|
||||
|
||||
internal_.updateFlag(
|
||||
simDomain_.thisDomain(),
|
||||
dist);
|
||||
const auto& maskD = internal_.activePointsMaskDevice();
|
||||
boundary(0).setSize( maskD.leftSize() );
|
||||
boundary(1).setSize( maskD.rightSize() );
|
||||
boundary(2).setSize( maskD.bottomSize() );
|
||||
boundary(3).setSize( maskD.topSize() );
|
||||
boundary(4).setSize( maskD.rearSize() );
|
||||
boundary(5).setSize( maskD.frontSize() );
|
||||
|
||||
internal_.fillNeighborsLists(
|
||||
boundary(0).indexList().deviceVectorAll(),
|
||||
boundary(1).indexList().deviceVectorAll(),
|
||||
boundary(2).indexList().deviceVectorAll(),
|
||||
boundary(3).indexList().deviceVectorAll(),
|
||||
boundary(4).indexList().deviceVectorAll(),
|
||||
boundary(5).indexList().deviceVectorAll());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pFlow::boundaryList::boundaryList
|
||||
(
|
||||
const simulationDomain &simD,
|
||||
internalPoints &internal
|
||||
)
|
||||
:
|
||||
ListPtr<boundaryBase>(simD.sizeOfBoundaries()),
|
||||
internal_(internal),
|
||||
simDomain_(simD),
|
||||
timeControl_
|
||||
(
|
||||
simDomain_.subDict("boundaries"),
|
||||
"update"
|
||||
)
|
||||
{}
|
||||
|
||||
bool pFlow::boundaryList::updateLists(uint32 iter, real t, real dt)
|
||||
{
|
||||
if( timeControl_.timeEvent(iter, t, dt))
|
||||
{
|
||||
return updateLists();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::boundaryList::setLists()
|
||||
{
|
||||
if(listSet_)return true;
|
||||
|
||||
for(auto i=0; i<simDomain_.sizeOfBoundaries();i++)
|
||||
{
|
||||
|
@ -49,5 +106,6 @@ bool pFlow::boundaryList::updateLists()
|
|||
);
|
||||
}
|
||||
listSet_ = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,14 @@ Licence:
|
|||
|
||||
#include "boundaryBase.hpp"
|
||||
#include "ListPtr.hpp"
|
||||
#include "baseTimeControl.hpp"
|
||||
|
||||
#include "streams.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class simulationDomain;
|
||||
class internalPoints;
|
||||
|
||||
class boundaryList
|
||||
:
|
||||
|
@ -44,9 +45,15 @@ protected:
|
|||
|
||||
const simulationDomain& simDomain_;
|
||||
|
||||
baseTimeControl timeControl_;
|
||||
|
||||
bool listSet_ = false;
|
||||
|
||||
|
||||
bool resetLists();
|
||||
|
||||
/// @brief update neighbor list of boundaries regardless
|
||||
/// of the time intervals
|
||||
bool updateLists();
|
||||
|
||||
public:
|
||||
|
||||
|
@ -55,26 +62,30 @@ public:
|
|||
|
||||
|
||||
//// - Constructors
|
||||
|
||||
boundaryList(
|
||||
const simulationDomain& simD,
|
||||
internalPoints& internal);
|
||||
|
||||
//~boundaryList() = default;
|
||||
|
||||
~boundaryList() = default;
|
||||
~boundaryList() = default;
|
||||
|
||||
bool updateLists();
|
||||
/// @brief update neighbor list of boundaries based on
|
||||
/// the time intervals
|
||||
bool updateLists(uint32 iter, real t, real dt);
|
||||
|
||||
auto& boundary(size_t i)
|
||||
{
|
||||
return ListPtr<boundaryBase>::operator[](i);
|
||||
}
|
||||
|
||||
|
||||
const auto& boundary(size_t i)const
|
||||
{
|
||||
return ListPtr<boundaryBase>::operator[](i);
|
||||
}
|
||||
bool setLists();
|
||||
|
||||
auto& boundary(size_t i)
|
||||
{
|
||||
return ListPtr<boundaryBase>::operator[](i);
|
||||
}
|
||||
|
||||
const auto& boundary(size_t i)const
|
||||
{
|
||||
return ListPtr<boundaryBase>::operator[](i);
|
||||
}
|
||||
};
|
||||
|
||||
} // pFlow
|
||||
|
|
|
@ -20,7 +20,8 @@ Licence:
|
|||
|
||||
|
||||
#include "internalPoints.hpp"
|
||||
#include "Vector.hpp"
|
||||
#include "domain.hpp"
|
||||
#include "Vectors.hpp"
|
||||
|
||||
void pFlow::internalPoints::syncPFlag()const
|
||||
{
|
||||
|
@ -31,6 +32,170 @@ void pFlow::internalPoints::syncPFlag()const
|
|||
}
|
||||
}
|
||||
|
||||
pFlow::internalPoints::internalPoints()
|
||||
:
|
||||
subscriber("internalPoints"),
|
||||
pointPosition_("internalPoints", "internalPoints", initialCapacity_, 0, RESERVE()),
|
||||
pFlagsD_(initialCapacity_, 0 , 0)
|
||||
{}
|
||||
|
||||
|
||||
pFlow::internalPoints::internalPoints
|
||||
(
|
||||
const realx3Vector& posVec
|
||||
)
|
||||
:
|
||||
subscriber("internalPoints"),
|
||||
pointPosition_("internalPoints", "internalPoints", posVec.capacity(), 0, RESERVE()),
|
||||
pFlagsD_(posVec.capacity(), 0, posVec.size())
|
||||
{
|
||||
|
||||
pointPosition_.assign(posVec);
|
||||
|
||||
}
|
||||
|
||||
|
||||
const pFlow::pFlagTypeDevice&
|
||||
pFlow::internalPoints::activePointsMaskDevice() const
|
||||
{
|
||||
return pFlagsD_;
|
||||
}
|
||||
|
||||
|
||||
const pFlow::pFlagTypeHost&
|
||||
pFlow::internalPoints::activePointsMaskHost() const
|
||||
{
|
||||
syncPFlag();
|
||||
return pFlagsH_;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
const pFlow::realx3Field_D&
|
||||
pFlow::internalPoints::pointPosition()const
|
||||
{
|
||||
return pointPosition_;
|
||||
}
|
||||
|
||||
pFlow::hostViewType1D<pFlow::realx3>
|
||||
pFlow::internalPoints::activePointsHost() const
|
||||
{
|
||||
auto maskH = activePointsMaskHost();
|
||||
auto pointsH = pointPositionHost();
|
||||
|
||||
hostViewType1D<realx3> aPoints("Active pointst", maskH.numActive());
|
||||
auto aRange = maskH.activeRange();
|
||||
uint32 n = 0;
|
||||
for(auto i=aRange.start(); i<aRange.end(); i++)
|
||||
{
|
||||
if( maskH.isActive(i) )
|
||||
{
|
||||
aPoints[n] = pointsH[i];
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
return aPoints;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::realx3Field_D &pFlow::internalPoints::pointPosition()
|
||||
{
|
||||
return pointPosition_;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::uint32 pFlow::internalPoints::updateFlag
|
||||
(
|
||||
const domain& dm,
|
||||
const std::array<real,6>& dist
|
||||
)
|
||||
{
|
||||
return pFlagsD_.markPointRegions
|
||||
(
|
||||
dm,
|
||||
pointPosition_.deviceVectorAll(),
|
||||
dist[0],
|
||||
dist[1],
|
||||
dist[2],
|
||||
dist[3],
|
||||
dist[4],
|
||||
dist[5]
|
||||
);
|
||||
|
||||
pFlagSync_ = false;
|
||||
}
|
||||
|
||||
void pFlow::internalPoints::fillNeighborsLists
|
||||
(
|
||||
ViewType1D<uint32, memory_space> leftList,
|
||||
ViewType1D<uint32, memory_space> rightList,
|
||||
ViewType1D<uint32, memory_space> bottomList,
|
||||
ViewType1D<uint32, memory_space> topList,
|
||||
ViewType1D<uint32, memory_space> rearList,
|
||||
ViewType1D<uint32, memory_space> frontList
|
||||
)
|
||||
{
|
||||
pFlagsD_.fillNeighborsLists(
|
||||
leftList,
|
||||
rightList,
|
||||
bottomList,
|
||||
topList,
|
||||
rearList,
|
||||
frontList);
|
||||
|
||||
pFlagSync_ = false;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::internalPoints::read
|
||||
(
|
||||
iIstream& is,
|
||||
const IOPattern& iop
|
||||
)
|
||||
{
|
||||
|
||||
Field<Vector, realx3 , vecAllocator<realx3>> fRead("internalPoints", "internalPoints");
|
||||
|
||||
if( !fRead.read(is, iop))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in reading pointPosition from stream "<< is.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// here there should be some mechanism for field distribution between procesors
|
||||
|
||||
|
||||
pointPosition_.assign(fRead.vectorField());
|
||||
|
||||
pFlagsD_ = pFlagTypeDevice(pointPosition_.capacity(), 0, pointPosition_.size());
|
||||
pFlagSync_ = false;
|
||||
syncPFlag();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::internalPoints::write
|
||||
(
|
||||
iOstream& os,
|
||||
const IOPattern& iop
|
||||
)const
|
||||
{
|
||||
if( pFlagsD_.isAllActive())
|
||||
{
|
||||
return pointPosition_.write(os, iop);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto aPoints = this->activePointsHost();
|
||||
auto spanPoints = makeSpan(aPoints); //span<realx3>(aPoints.data(), aPoints.size());
|
||||
return writeSpan(os, spanPoints, iop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*FUNCTION_H
|
||||
bool pFlow::internalPoints::evaluateinternalPoints()
|
||||
|
@ -144,150 +309,4 @@ pFlow::uniquePtr<pFlow::int32IndexContainer>
|
|||
}
|
||||
|
||||
return nullptr;
|
||||
}*/
|
||||
|
||||
pFlow::internalPoints::internalPoints()
|
||||
:
|
||||
subscriber("internalPoints"),
|
||||
pointPosition_("internalPoints", "internalPoints", initialCapacity_, 0, RESERVE()),
|
||||
pFlagsD_(initialCapacity_, 0 , 0)
|
||||
{
|
||||
syncPFlag();
|
||||
}
|
||||
|
||||
|
||||
pFlow::internalPoints::internalPoints
|
||||
(
|
||||
const realx3Vector& posVec
|
||||
)
|
||||
:
|
||||
subscriber("internalPoints"),
|
||||
pointPosition_("internalPoints", "internalPoints", posVec.capacity(), 0, RESERVE()),
|
||||
pFlagsD_(posVec.capacity(), 0, posVec.size())
|
||||
{
|
||||
|
||||
pointPosition_.assign(posVec);
|
||||
|
||||
syncPFlag();
|
||||
|
||||
}
|
||||
|
||||
|
||||
const pFlow::pFlagTypeDevice&
|
||||
pFlow::internalPoints::activePointsMaskD() const
|
||||
{
|
||||
return pFlagsD_;
|
||||
}
|
||||
|
||||
|
||||
const pFlow::pFlagTypeHost&
|
||||
pFlow::internalPoints::activePointsMaskH() const
|
||||
{
|
||||
syncPFlag();
|
||||
return pFlagsH_;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
const pFlow::realx3Field_D&
|
||||
pFlow::internalPoints::pointPosition()const
|
||||
{
|
||||
return pointPosition_;
|
||||
}
|
||||
|
||||
pFlow::hostViewType1D<pFlow::realx3>
|
||||
pFlow::internalPoints::activePointsHost() const
|
||||
{
|
||||
auto maskH = activePointsMaskH();
|
||||
auto pointsH = pointPositionHost();
|
||||
|
||||
hostViewType1D<realx3> aPoints("Active pointst", maskH.numActive());
|
||||
auto aRange = maskH.activeRange();
|
||||
uint32 n = 0;
|
||||
for(auto i=aRange.start(); i<aRange.end(); i++)
|
||||
{
|
||||
if( maskH.isActive(i) )
|
||||
{
|
||||
aPoints[n] = pointsH[i];
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
return aPoints;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
pFlow::realx3Field_D &pFlow::internalPoints::pointPosition()
|
||||
{
|
||||
return pointPosition_;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
void pFlow::internalPoints::updateFlag
|
||||
(
|
||||
const domain& dm,
|
||||
const std::array<real,6>& dist
|
||||
)
|
||||
{
|
||||
pFlagsD_.markPointRegions
|
||||
(
|
||||
dm,
|
||||
pointPosition_.deviceVectorAll(),
|
||||
dist[0],
|
||||
dist[1],
|
||||
dist[2],
|
||||
dist[3],
|
||||
dist[4],
|
||||
dist[5]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::internalPoints::read
|
||||
(
|
||||
iIstream& is,
|
||||
const IOPattern& iop
|
||||
)
|
||||
{
|
||||
|
||||
Field<Vector, realx3 , vecAllocator<realx3>> fRead("internalPoints", "internalPoints");
|
||||
|
||||
if( !fRead.read(is, iop))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in reading pointPosition from stream "<< is.name()<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// here there should be some mechanism for field distribution between procesors
|
||||
|
||||
|
||||
pointPosition_.assign(fRead.vectorField());
|
||||
|
||||
pFlagsD_ = pFlagTypeDevice(pointPosition_.capacity(), 0, pointPosition_.size());
|
||||
pFlagSync_ = false;
|
||||
syncPFlag();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
bool pFlow::internalPoints::write
|
||||
(
|
||||
iOstream& os,
|
||||
const IOPattern& iop
|
||||
)const
|
||||
{
|
||||
if( pFlagsD_.isAllActive())
|
||||
{
|
||||
return pointPosition_.write(os, iop);
|
||||
}
|
||||
else
|
||||
{
|
||||
return pointPosition_.write(os, iop, activePointsMaskH());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}*/
|
|
@ -31,6 +31,8 @@ Licence:
|
|||
namespace pFlow
|
||||
{
|
||||
|
||||
class domain;
|
||||
|
||||
class internalPoints
|
||||
:
|
||||
public subscriber
|
||||
|
@ -97,16 +99,16 @@ public:
|
|||
internalPoints& operator=(internalPoints&&) = default;
|
||||
|
||||
/// Destructor
|
||||
virtual ~internalPoints() = default;
|
||||
~internalPoints()override = default;
|
||||
|
||||
|
||||
//// - Methods
|
||||
FUNCTION_H
|
||||
const pFlagTypeDevice& activePointsMaskD()const;
|
||||
const pFlagTypeDevice& activePointsMaskDevice()const;
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
const pFlagTypeHost& activePointsMaskH()const;
|
||||
const pFlagTypeHost& activePointsMaskHost()const;
|
||||
|
||||
// - Const access pointPosition
|
||||
FUNCTION_H
|
||||
|
@ -133,7 +135,7 @@ public:
|
|||
INLINE_FUNCTION_H
|
||||
uint32 size()const
|
||||
{
|
||||
return pointPosition_.size();
|
||||
return pFlagsD_.activeRange_.end();
|
||||
}
|
||||
|
||||
// - maximum capacity of data structure
|
||||
|
@ -165,55 +167,21 @@ public:
|
|||
|
||||
|
||||
FUNCTION_H
|
||||
void updateFlag(
|
||||
uint32 updateFlag(
|
||||
const domain& dm,
|
||||
const std::array<real,6>& dist);
|
||||
|
||||
/*FUNCTION_H
|
||||
size_t markDeleteOutOfBox(const box& domain);*/
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// - const access to points to be newly inserted
|
||||
/*FUNCTION_H
|
||||
auto insertedPointIndex()const
|
||||
{
|
||||
return tobeInsertedIndex_;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
auto insertedPointIndexH()const
|
||||
{
|
||||
return tobeInsertedIndex_.hostView();
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
auto insertedPointIndexD()const
|
||||
{
|
||||
return tobeInsertedIndex_.deviceView();
|
||||
}
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
auto mortonSortedIndex()const
|
||||
{
|
||||
return mortonSortedIndex_;
|
||||
}
|
||||
|
||||
|
||||
// - update data structure by inserting/setting new points
|
||||
// Notifies all the fields in the registered list of data structure
|
||||
// and exclude the fields that re in the exclusionList
|
||||
// retrun nullptr if it fails
|
||||
/*FUNCTION_H
|
||||
virtual uniquePtr<int32IndexContainer> insertPoints(
|
||||
const realx3Vector& pos,
|
||||
const setFieldList& setField,
|
||||
repository& owner,
|
||||
const List<eventObserver*>& exclusionList={nullptr}
|
||||
);*/
|
||||
void fillNeighborsLists(
|
||||
ViewType1D<uint32, memory_space> leftList,
|
||||
ViewType1D<uint32, memory_space> rightList,
|
||||
ViewType1D<uint32, memory_space> bottomList,
|
||||
ViewType1D<uint32, memory_space> topList,
|
||||
ViewType1D<uint32, memory_space> rearList,
|
||||
ViewType1D<uint32, memory_space> frontList);
|
||||
|
||||
|
||||
|
||||
|
||||
//// - IO operations
|
||||
|
||||
|
@ -243,8 +211,6 @@ iOstream& operator<<(iOstream& os, const internalPoints& ip)
|
|||
} // pFlow
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //__internalPoints_hpp__
|
||||
|
||||
|
||||
|
@ -331,4 +297,50 @@ iOstream& operator<<(iOstream& os, const internalPoints& ip)
|
|||
bool allActive()const {
|
||||
return allActive_;
|
||||
}
|
||||
};*/
|
||||
};*/
|
||||
|
||||
|
||||
/*FUNCTION_H`
|
||||
size_t markDeleteOutOfBox(const box& domain);*/
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// - const access to points to be newly inserted
|
||||
/*FUNCTION_H
|
||||
auto insertedPointIndex()const
|
||||
{
|
||||
return tobeInsertedIndex_;
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
auto insertedPointIndexH()const
|
||||
{
|
||||
return tobeInsertedIndex_.hostView();
|
||||
}
|
||||
|
||||
FUNCTION_H
|
||||
auto insertedPointIndexD()const
|
||||
{
|
||||
return tobeInsertedIndex_.deviceView();
|
||||
}
|
||||
|
||||
|
||||
FUNCTION_H
|
||||
auto mortonSortedIndex()const
|
||||
{
|
||||
return mortonSortedIndex_;
|
||||
}
|
||||
|
||||
|
||||
// - update data structure by inserting/setting new points
|
||||
// Notifies all the fields in the registered list of data structure
|
||||
// and exclude the fields that re in the exclusionList
|
||||
// retrun nullptr if it fails
|
||||
/*FUNCTION_H
|
||||
virtual uniquePtr<int32IndexContainer> insertPoints(
|
||||
const realx3Vector& pos,
|
||||
const setFieldList& setField,
|
||||
repository& owner,
|
||||
const List<eventObserver*>& exclusionList={nullptr}
|
||||
);*/
|
||||
|
|
|
@ -134,6 +134,43 @@ public:
|
|||
return numActive_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
auto leftSize()const
|
||||
{
|
||||
return nLeft_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
auto rightSize()const
|
||||
{
|
||||
return nRight_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
auto bottomSize()const
|
||||
{
|
||||
return nBottom_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
auto topSize()const
|
||||
{
|
||||
return nTop_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
auto rearSize()const
|
||||
{
|
||||
return nRear_;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
auto frontSize()const
|
||||
{
|
||||
return nFront_;
|
||||
}
|
||||
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool operator()(uint32 i)
|
||||
{
|
||||
|
@ -213,9 +250,28 @@ public:
|
|||
isAllActive_);
|
||||
}
|
||||
|
||||
|
||||
uint32 scanPointFlag();
|
||||
/// @brief Loop over the active points and mark those out of the box
|
||||
/// and return number of deleted points
|
||||
/// @param validBox the box whose inside is valid
|
||||
/// @param points list of all points
|
||||
/// @return number of deleted points
|
||||
uint32 markOutOfBoxDelete(
|
||||
const box& validBox,
|
||||
ViewType1D<realx3, memory_space> points);
|
||||
|
||||
|
||||
/// @brief mark points based on their position in the domain.
|
||||
/// This should be the first method to be called when updating
|
||||
/// boundaries (step 1 of 2).
|
||||
/// @param dm the domain for which particles are tested
|
||||
/// @param points list of points
|
||||
/// @param leftLength neighbor length of the left face
|
||||
/// @param rightLength neighbor length of the right face
|
||||
/// @param bottomLength neighbor length of the bottom face
|
||||
/// @param topLength neighbor length of the top face
|
||||
/// @param rearLength neighbor length of the rear face
|
||||
/// @param frontLength neighbor length of the front face
|
||||
/// @return number of deleted points
|
||||
uint32 markPointRegions(
|
||||
domain dm,
|
||||
ViewType1D<realx3, memory_space> points,
|
||||
|
@ -226,6 +282,16 @@ public:
|
|||
real rearLength,
|
||||
real frontLength);
|
||||
|
||||
|
||||
/// @brief fill the lists for boundary faces. Lists keep the index
|
||||
/// of particles in the neighborhood of the faces. This mehtod is
|
||||
/// called after markPointRegions (step 2 of 2).
|
||||
/// @param leftList neighbor list of the left face
|
||||
/// @param rightList neighbor list of the right face
|
||||
/// @param bottomList neighbor list of the bottom face
|
||||
/// @param topList neighbor list of the top face
|
||||
/// @param rearList neighbor list of the rear face
|
||||
/// @param frontList neighbor list of the front face
|
||||
void fillNeighborsLists(
|
||||
ViewType1D<uint32, memory_space> leftList,
|
||||
ViewType1D<uint32, memory_space> rightList,
|
||||
|
|
|
@ -20,9 +20,78 @@ Licence:
|
|||
#ifndef __pointFlagKernels_hpp__
|
||||
#define __pointFlagKernels_hpp__
|
||||
|
||||
|
||||
|
||||
template<typename ExecutionSpace>
|
||||
pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::markOutOfBoxDelete
|
||||
(
|
||||
const box& validBox,
|
||||
ViewType1D<realx3, memory_space> points
|
||||
)
|
||||
{
|
||||
using rpScanFlag = Kokkos::RangePolicy<execution_space,
|
||||
Kokkos::IndexType<uint32>>;
|
||||
|
||||
uint32 numDeleted = 0;
|
||||
|
||||
uint32 start = activeRange().start();
|
||||
uint32 end = activeRange().end();
|
||||
|
||||
uint32 minRange = end;
|
||||
uint32 maxRange = start;
|
||||
|
||||
if(start<end)
|
||||
{
|
||||
Kokkos::parallel_reduce(
|
||||
"pointFlagKernels::markOutOfBox",
|
||||
rpScanFlag(start, end),
|
||||
CLASS_LAMBDA_HD(
|
||||
uint32 i,
|
||||
uint32& minUpdate,
|
||||
uint32& maxUpdate,
|
||||
uint32& delToUpdate)
|
||||
{
|
||||
if(isActive(i))
|
||||
{
|
||||
if(validBox.isInside(points[i]))
|
||||
{
|
||||
|
||||
minUpdate = min(minUpdate,i);
|
||||
maxUpdate = max(maxUpdate,i);
|
||||
}
|
||||
else
|
||||
{
|
||||
flags_[i] = DELETED;
|
||||
delToUpdate++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
Kokkos::Min<uint32>(minRange),
|
||||
Kokkos::Max<uint32>(maxRange),
|
||||
numDeleted);
|
||||
}
|
||||
|
||||
if(numDeleted >= numActive_)
|
||||
{
|
||||
minRange = 0;
|
||||
maxRange = 0;
|
||||
numDeleted == numActive_;
|
||||
}
|
||||
else
|
||||
{
|
||||
// add one to maxRange to make it half-open
|
||||
maxRange ++;
|
||||
}
|
||||
|
||||
activeRange_ = {minRange, maxRange};
|
||||
numActive_ = numActive_ - numDeleted;
|
||||
isAllActive_ =
|
||||
(activeRange_.numElements() == numActive_)&& numActive_>0;
|
||||
|
||||
return numDeleted;
|
||||
}
|
||||
|
||||
/*template<typename ExecutionSpace>
|
||||
pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::scanPointFlag()
|
||||
{
|
||||
|
||||
|
@ -77,7 +146,7 @@ pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::scanPointFlag()
|
|||
isAllActive_ = activeRange_.numElements() == numActive_;
|
||||
|
||||
return numActive;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
template<typename ExecutionSpace>
|
||||
|
@ -102,7 +171,7 @@ pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::markPointRegions
|
|||
uint32 minRange = end;
|
||||
uint32 maxRange = start;
|
||||
|
||||
uint32 numMarked = 0;
|
||||
uint32 numMarkedDelete = 0;
|
||||
uint32 nLeft = 0, nRight = 0;
|
||||
uint32 nBottom = 0, nTop = 0;
|
||||
uint32 nRear = 0, nFront = 0;
|
||||
|
@ -181,7 +250,7 @@ pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::markPointRegions
|
|||
},
|
||||
Kokkos::Min<uint32>(minRange),
|
||||
Kokkos::Max<uint32>(maxRange),
|
||||
numMarked,
|
||||
numMarkedDelete,
|
||||
nLeft,
|
||||
nRight,
|
||||
nBottom,
|
||||
|
@ -192,10 +261,11 @@ pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::markPointRegions
|
|||
}
|
||||
|
||||
// means either range was empty or all points have been deleted.
|
||||
if(minRange<start || maxRange>end)
|
||||
if(numMarkedDelete>= numActive_)
|
||||
{
|
||||
minRange = 0;
|
||||
maxRange = 0;
|
||||
numMarkedDelete = numActive_;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -203,8 +273,8 @@ pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::markPointRegions
|
|||
}
|
||||
|
||||
activeRange_ = {minRange, maxRange};
|
||||
isAllActive_ = isAllActive_ && numMarked == 0;
|
||||
numActive_ -= numMarked;
|
||||
numActive_ -= numMarkedDelete;
|
||||
isAllActive_ = (activeRange_.numElements() == numActive_)&& numActive_>0;
|
||||
|
||||
nLeft_ = nLeft;
|
||||
nRight_ = nRight;
|
||||
|
@ -213,7 +283,7 @@ pFlow::uint32 pFlow::pointFlag<ExecutionSpace>::markPointRegions
|
|||
nRear_ = nRear;
|
||||
nFront_ = nFront;
|
||||
|
||||
return numMarked;
|
||||
return numMarkedDelete;
|
||||
}
|
||||
|
||||
template<typename ExecutionSpace>
|
||||
|
@ -235,7 +305,7 @@ void pFlow::pointFlag<ExecutionSpace>::fillNeighborsLists
|
|||
|
||||
ViewType1D<uint32, memory_space> nElems("nElems",6);
|
||||
|
||||
fill(nElems, 0, 6, 0);
|
||||
fill(nElems, 0, 6, static_cast<uint32>(0));
|
||||
|
||||
if(start<end)
|
||||
{
|
||||
|
|
|
@ -60,9 +60,9 @@ bool pFlow::pointStructure::setupPointStructure(const realx3Vector &points)
|
|||
return false;
|
||||
}
|
||||
|
||||
boundaries_.updateLists();
|
||||
boundaries_.setLists();
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ pFlow::pointStructure::pointStructure
|
|||
internalPoints(),
|
||||
simulationDomain_
|
||||
(
|
||||
simulationDomain::create(control.domainDict())
|
||||
simulationDomain::create(control)
|
||||
),
|
||||
boundaries_
|
||||
(
|
||||
|
@ -106,13 +106,13 @@ pFlow::pointStructure::pointStructure
|
|||
*this
|
||||
)
|
||||
{
|
||||
REPORT(0)<< "Reading point structure from file"<<
|
||||
IOobject::localPath()<<END_REPORT;
|
||||
REPORT(0)<< "Reading point structure from "<<
|
||||
IOobject::path()<<END_REPORT;
|
||||
|
||||
if( !IOobject::read() )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"Error in reading from file "<<IOobject::localPath()<<endl;
|
||||
"Error in reading from file "<<IOobject::path()<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ pFlow::pointStructure::pointStructure(
|
|||
internalPoints(),
|
||||
simulationDomain_
|
||||
(
|
||||
simulationDomain::create(control.domainDict())
|
||||
simulationDomain::create(control)
|
||||
),
|
||||
boundaries_
|
||||
(
|
||||
|
|
|
@ -116,6 +116,11 @@ public:
|
|||
return boundaries_[i];
|
||||
}
|
||||
|
||||
const auto& simDomain()const
|
||||
{
|
||||
return simulationDomain_();
|
||||
}
|
||||
|
||||
// - IO methods
|
||||
|
||||
/// @brief read the point structure from the input stream.
|
||||
|
|
|
@ -54,7 +54,7 @@ Licence:
|
|||
word typeName() const {return TYPENAME();}
|
||||
|
||||
|
||||
#define TypeInfoTemplate(tName, Type) \
|
||||
#define TypeInfoTemplate11(tName, Type) \
|
||||
has_static_member(TYPENAME); \
|
||||
inline static word TYPENAME() \
|
||||
{ \
|
||||
|
@ -66,7 +66,7 @@ Licence:
|
|||
} \
|
||||
virtual word typeName() const { return TYPENAME();}
|
||||
|
||||
#define TypeInfoTemplate2(tName, Type1, Type2) \
|
||||
#define TypeInfoTemplate12(tName, Type1, Type2) \
|
||||
has_static_member(TYPENAME); \
|
||||
inline static word TYPENAME() \
|
||||
{ \
|
||||
|
@ -78,7 +78,7 @@ Licence:
|
|||
} \
|
||||
virtual word typeName() const { return TYPENAME();}
|
||||
|
||||
#define TypeInfoTemplate3(tName, Type1, Type2, Type3) \
|
||||
#define TypeInfoTemplate13(tName, Type1, Type2, Type3) \
|
||||
inline static word TYPENAME() \
|
||||
{ \
|
||||
return word(tName)+"<"+Type1::TYPENAME()+","+Type2::TYPENAME()+","+Type3::TYPENAME()+">";\
|
||||
|
@ -86,7 +86,7 @@ Licence:
|
|||
virtual word typeName() const { return TYPENAME();}
|
||||
|
||||
// this is the non-virtual version
|
||||
#define TypeInfoTemplateNV(tName, Type) \
|
||||
#define TypeInfoTemplateNV11(tName, Type) \
|
||||
has_static_member(TYPENAME); \
|
||||
inline static word TYPENAME() \
|
||||
{ \
|
||||
|
@ -99,7 +99,7 @@ Licence:
|
|||
inline word typeName() const { return TYPENAME();}
|
||||
|
||||
|
||||
#define TypeInfoTemplateNV2(tName, Type, tName2) \
|
||||
#define TypeInfoTemplateNV111(tName, Type, tName2) \
|
||||
has_static_member(TYPENAME); \
|
||||
inline static word TYPENAME() \
|
||||
{ \
|
||||
|
@ -111,6 +111,20 @@ Licence:
|
|||
} \
|
||||
inline word typeName() const { return TYPENAME();}
|
||||
|
||||
#define TypeInfoTemplate111(tName, Type, tName2) \
|
||||
has_static_member(TYPENAME); \
|
||||
inline static word TYPENAME() \
|
||||
{ \
|
||||
if constexpr ( has_static_member_TYPENAME<Type,word(void)>::value) \
|
||||
{ return word(tName)+"<"+Type::TYPENAME()+","+word(tName2)+">";} \
|
||||
else \
|
||||
return word(tName)+"<"+basicTypeName<Type>()+","+word(tName2)+">"; \
|
||||
return "noTYPE"; \
|
||||
} \
|
||||
virtual word typeName() const { return TYPENAME();}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public: \
|
|||
|
||||
#define add_vCtor(baseClass, derivedClass, selectorName) \
|
||||
\
|
||||
inline static baseClass::create##selectorName##Callback<derivedClass> baseClass##derivedClass##selectorName##_;
|
||||
inline static typename baseClass::template create##selectorName##Callback<derivedClass> baseClass##derivedClass##selectorName##_;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,14 @@ pFlow::int32 pFlow::countChar( const char* s, const char c)
|
|||
pFlow::word pFlow::toUpper(const word & inStr)
|
||||
{
|
||||
word oStr(inStr);
|
||||
transform(inStr.begin(), inStr.end(), oStr.begin(), ::toupper);
|
||||
std::transform(inStr.begin(), inStr.end(), oStr.begin(), ::toupper);
|
||||
return oStr;
|
||||
}
|
||||
|
||||
pFlow::word pFlow::firstCapital(const word& inStr)
|
||||
{
|
||||
word oStr(inStr);
|
||||
oStr[0] = std::toupper(oStr[0]);
|
||||
return oStr;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ int32 countChar(const char* s, const char c);
|
|||
/// convert a word to all caps
|
||||
word toUpper(const word & inStr);
|
||||
|
||||
word firstCapital(const word& inStr);
|
||||
|
||||
/// Check if str equals "Yes", "Y", "True", "Ok", "ON", or "T"
|
||||
bool isYes(const word & str);
|
||||
|
||||
|
|
Loading…
Reference in New Issue