mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-12 16:26:23 +00:00
refactor up to particles.hpp
This commit is contained in:
@ -42,7 +42,7 @@ protected:
|
||||
public:
|
||||
|
||||
|
||||
readFromTimeFolder(repository& rep);
|
||||
explicit readFromTimeFolder(repository& rep);
|
||||
|
||||
auto path()const
|
||||
{
|
||||
@ -65,9 +65,9 @@ public:
|
||||
bool pointFieldGetType(word& typeName)const
|
||||
{
|
||||
word fieldTYPENAME = pointField_H<T>::TYPENAME();
|
||||
word fldType{}, space{};
|
||||
word fldType{};
|
||||
|
||||
if( !pFlow::utilities::pointFieldGetType(
|
||||
if(word space{}; !pFlow::utilities::pointFieldGetType(
|
||||
fieldTYPENAME, fldType, space) )
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
@ -81,18 +81,19 @@ public:
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool pointFieldGetCheckType(word fieldName, word& typeName) const
|
||||
bool pointFieldGetCheckType(word const& fieldName, word& typeName) const
|
||||
{
|
||||
|
||||
word fieldTYPENAME = pointField_H<T>::TYPENAME();
|
||||
word flType{},fldType{};
|
||||
|
||||
|
||||
word flType{};
|
||||
if(!pointFieldFileGetType( fieldName, flType))
|
||||
{
|
||||
fatalExit;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
word fldType{};
|
||||
if( !pointFieldGetType<T>(fldType) )
|
||||
{
|
||||
fatalExit;
|
||||
@ -112,7 +113,7 @@ public:
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
pointField_H<T>& createUniformPointField_H(word name, T value)
|
||||
uniquePtr<pointField_H<T>> createUniformPointField_H(word const& name, T value)
|
||||
{
|
||||
if( !checkForPointStructure() )
|
||||
{
|
||||
@ -120,29 +121,28 @@ public:
|
||||
"cannot find " << pointStructureFile__ << " in repository "<< repository_.name()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
|
||||
|
||||
word fType;
|
||||
pointFieldGetType<T>(fType);
|
||||
word newName = name + fType;
|
||||
|
||||
auto& field = repository_.emplaceReplaceObject<pointField_H<T>>(
|
||||
objectFile(
|
||||
auto Ptr = makeUnique<pointField_H<T>>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
name,
|
||||
"",
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
),
|
||||
pStruct,
|
||||
T{},
|
||||
value
|
||||
);
|
||||
|
||||
return field;
|
||||
|
||||
);
|
||||
return Ptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
pointField_H<T>& readPointField_H(word name)
|
||||
uniquePtr<pointField_H<T>> readPointField_H(word const& name)
|
||||
{
|
||||
if( !checkForPointStructure() )
|
||||
{
|
||||
@ -152,23 +152,25 @@ public:
|
||||
}
|
||||
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
|
||||
|
||||
auto& field = repository_.emplaceObjectOrGet<pointField_H<T>>(
|
||||
objectFile(
|
||||
auto Ptr = makeUnique<pointField_H<T>>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
name,
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
),
|
||||
pStruct,
|
||||
T{}
|
||||
);
|
||||
);
|
||||
|
||||
return field;
|
||||
return Ptr;
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
pointField_D<T>& readPointField_D(word name)
|
||||
uniquePtr<pointField_D<T>> readPointField_D(word const& name)
|
||||
{
|
||||
if( !checkForPointStructure() )
|
||||
{
|
||||
@ -178,18 +180,20 @@ public:
|
||||
}
|
||||
auto& pStruct = repository_.lookupObject<pointStructure>(pointStructureFile__);
|
||||
|
||||
auto& field = repository_.emplaceObjectOrGet<pointField_H<T>>(
|
||||
objectFile(
|
||||
auto Ptr = makeUnique<pointField_D<T>>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
name,
|
||||
"",
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
),
|
||||
pStruct,
|
||||
T{}
|
||||
);
|
||||
);
|
||||
|
||||
return field;
|
||||
return Ptr;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -72,21 +72,10 @@ int main( int argc, char* argv[] )
|
||||
// this should be palced in each main
|
||||
#include "initialize_Control.hpp"
|
||||
|
||||
auto objCPDict = IOobject::make<fileDictionary>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"particlesDict",
|
||||
Control.settings().path(),
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
"particlesDict"
|
||||
);
|
||||
fileDictionary cpDict("particlesDict", Control.settings().path());
|
||||
|
||||
|
||||
auto& cpDict = objCPDict().getObject<fileDictionary>();
|
||||
|
||||
pointStructure* pStructPtr = nullptr;
|
||||
uniquePtr<pointStructure> pStructPtr = nullptr;
|
||||
|
||||
|
||||
if(!setOnly)
|
||||
@ -100,24 +89,11 @@ int main( int argc, char* argv[] )
|
||||
|
||||
auto finalPos = pointPosition().getFinalPosition();
|
||||
|
||||
|
||||
auto& pStruct = Control.time().emplaceObject<pointStructure>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
pointStructureFile__,
|
||||
Control.time().path(),
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
Control,
|
||||
finalPos
|
||||
);
|
||||
pStructPtr = makeUnique<pointStructure>(Control, finalPos);
|
||||
|
||||
pStructPtr = &pStruct;
|
||||
|
||||
REPORT(1)<< "Created pStruct with "<< pStruct.size() << " points and capacity "<<
|
||||
pStruct.capacity()<<" . . ."<< END_REPORT;
|
||||
REPORT(1)<< "Created pStruct with "<< pStructPtr().size() << " points and capacity "<<
|
||||
pStructPtr().capacity()<<" . . ."<< END_REPORT;
|
||||
|
||||
//REPORT(1)<< "Writing pStruct to " << Control.time().path()+ pointStructureFile__<< END_REPORT<<endl<<endl;
|
||||
|
||||
@ -130,20 +106,8 @@ int main( int argc, char* argv[] )
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
auto& pStruct = Control.time().emplaceObject<pointStructure>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
pointStructureFile__,
|
||||
Control.time().path(),
|
||||
objectFile::READ_NEVER,
|
||||
objectFile::WRITE_ALWAYS
|
||||
),
|
||||
Control
|
||||
);
|
||||
|
||||
pStructPtr = &pStruct;
|
||||
// read the content of pStruct from 0/pStructure
|
||||
pStructPtr = makeUnique<pointStructure>(Control);
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ Licence:
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "positionParticles.hpp"
|
||||
#include "vocabs.hpp"
|
||||
#include "box.hpp"
|
||||
#include "cylinder.hpp"
|
||||
#include "sphere.hpp"
|
||||
@ -101,7 +102,18 @@ pFlow::positionParticles::positionParticles
|
||||
}
|
||||
else
|
||||
{
|
||||
region_ = makeUnique<region<box>>( control.domainDict().subDict("globalBox"));
|
||||
fileDictionary domainDict
|
||||
(
|
||||
objectFile
|
||||
{
|
||||
domainFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER
|
||||
},
|
||||
&control.settings()
|
||||
);
|
||||
region_ = makeUnique<region<box>>( domainDict.subDict("globalBox"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user