mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
The main structure is tested. functons like execute and write are added and tested.
other components are left
This commit is contained in:
120
src/PostprocessData/postprocessData/postprocessData.cpp
Normal file
120
src/PostprocessData/postprocessData/postprocessData.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
|
||||
/*------------------------------- 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 "List.hpp"
|
||||
#include "systemControl.hpp"
|
||||
#include "postprocessData.hpp"
|
||||
#include "fileDictionary.hpp"
|
||||
#include "postprocessGlobals.hpp"
|
||||
#include "postprocessComponent.hpp"
|
||||
|
||||
pFlow::postprocessData::postprocessData(const systemControl &control)
|
||||
:
|
||||
auxFunctions(control),
|
||||
time_(control.time()),
|
||||
fieldsDataBase_(control.time(), true),
|
||||
dict_
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
"postprocessDataDict",
|
||||
control.settings().path(),
|
||||
objectFile::READ_IF_PRESENT,
|
||||
objectFile::WRITE_NEVER
|
||||
)
|
||||
),
|
||||
componentsDicts_(readDictList("components", dict_))
|
||||
{
|
||||
postProcessGlobals::defaultDir__ = CWD()/pFlow::postProcessGlobals::defaultRelDir__;
|
||||
|
||||
// if dictionary is not provided, no extra action is required.
|
||||
if( !dict_.fileExist() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
activeInSimulation_ = dict_.getValOrSet<Logical>(
|
||||
"activeInSimulation",
|
||||
Logical{true});
|
||||
|
||||
if(dict_.containsDictionay("defaultTimeControl"))
|
||||
{
|
||||
defaultTimeControlPtr_ =
|
||||
makeUnique<baseTimeControl>(
|
||||
dict_.subDict("defaultTimeControl"),
|
||||
"execution");
|
||||
}
|
||||
else
|
||||
{
|
||||
// default time control from settings
|
||||
defaultTimeControlPtr_ = makeUnique<baseTimeControl>(
|
||||
control.time().startTime(),
|
||||
control.time().endTime(),
|
||||
control.time().saveInterval(),
|
||||
"execution");
|
||||
}
|
||||
|
||||
for(auto& compDict:componentsDicts_)
|
||||
{
|
||||
postprocesses_.push_back( postprocessComponent::create(
|
||||
compDict,
|
||||
fieldsDataBase_,
|
||||
defaultTimeControlPtr_() ));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::postprocessData::execute()
|
||||
{
|
||||
const auto& ti = time_.TimeInfo();
|
||||
|
||||
for(auto& component:postprocesses_)
|
||||
{
|
||||
if(!component->execute(ti))
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<<"Error occured in executing postprocess component: "
|
||||
<<component->name()<<endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::postprocessData::write() const
|
||||
{
|
||||
for(auto& component:postprocesses_)
|
||||
{
|
||||
if(!component->executed())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(!component->write(postProcessGlobals::defaultDir__/component->name()))
|
||||
{
|
||||
fatalErrorInFunction
|
||||
<<"Error occured in writing postprocess component: "
|
||||
<<component->name()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
101
src/PostprocessData/postprocessData/postprocessData.hpp
Normal file
101
src/PostprocessData/postprocessData/postprocessData.hpp
Normal file
@ -0,0 +1,101 @@
|
||||
/*------------------------------- 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 __postprocessData_hpp__
|
||||
#define __postprocessData_hpp__
|
||||
|
||||
#include "auxFunctions.hpp"
|
||||
#include "Logical.hpp"
|
||||
#include "ListPtr.hpp"
|
||||
#include "fileDictionary.hpp"
|
||||
#include "baseTimeControl.hpp"
|
||||
#include "fieldsDataBase.hpp"
|
||||
#include "postprocessComponent.hpp"
|
||||
#include "dictionaryList.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
class systemControl;
|
||||
class Time;
|
||||
class timeInfo;
|
||||
|
||||
/**
|
||||
* @class postprocessData
|
||||
* @brief An interface class for handling post-processing of simulation data.
|
||||
*
|
||||
* This class provides methods and utilities to process and analyze
|
||||
* simulation data during/after simulation.
|
||||
*/
|
||||
class postprocessData
|
||||
:
|
||||
public auxFunctions
|
||||
{
|
||||
/// Indicates if a post-processing is active during simulatoin
|
||||
Logical activeInSimulation_{false};
|
||||
|
||||
/// a list of active post-process components
|
||||
ListPtr<postprocessComponent> postprocesses_;
|
||||
|
||||
/// const ref to Time
|
||||
const Time& time_;
|
||||
|
||||
/// Database for all the points fields on the host
|
||||
fieldsDataBase fieldsDataBase_;
|
||||
|
||||
/// file dictionary that is constructed from the file (postProcessDataDict)
|
||||
fileDictionary dict_;
|
||||
|
||||
/// list of dictionaries for postprocess components
|
||||
dictionaryList componentsDicts_;
|
||||
|
||||
/// @brief default time control that can be used for all post-process components
|
||||
uniquePtr<baseTimeControl> defaultTimeControlPtr_= nullptr;
|
||||
|
||||
public:
|
||||
|
||||
TypeInfo("postprocessData");
|
||||
|
||||
/// @brief Construct from systemControl and a boolean flag
|
||||
/// this constructor is used when postprocesing is active
|
||||
/// during simulation.
|
||||
/// @param control const reference to systemControl
|
||||
postprocessData(const systemControl& control);
|
||||
|
||||
~postprocessData()override = default;
|
||||
|
||||
add_vCtor
|
||||
(
|
||||
auxFunctions,
|
||||
postprocessData,
|
||||
systemControl
|
||||
);
|
||||
|
||||
bool execute() override;
|
||||
|
||||
|
||||
|
||||
bool write()const override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace pFlow
|
||||
|
||||
#endif // __postprocessData_hpp__
|
35
src/PostprocessData/postprocessData/postprocessGlobals.hpp
Normal file
35
src/PostprocessData/postprocessData/postprocessGlobals.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*------------------------------- 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 __postProcessGlobals_hpp__
|
||||
#define __postProcessGlobals_hpp__
|
||||
|
||||
#include "fileSystem.hpp"
|
||||
|
||||
namespace pFlow::postProcessGlobals
|
||||
{
|
||||
|
||||
static fileSystem defaultDir__;
|
||||
inline const word defaultRelDir__ = "VTK/postprocessData";
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // __postProcessGlobals_hpp__
|
@ -0,0 +1,65 @@
|
||||
/*------------------------------- 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 __postprocessTimeControl_hpp__
|
||||
#define __postprocessTimeControl_hpp__
|
||||
|
||||
#include "baseTimeControl.hpp"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
class postprocessTimeControl
|
||||
:
|
||||
public baseTimeControl
|
||||
{
|
||||
public:
|
||||
postprocessTimeControl(
|
||||
const dictionary& dict,
|
||||
const baseTimeControl& defaultTimeControl,
|
||||
const baseTimeControl& settingTimeControl
|
||||
)
|
||||
:
|
||||
baseTimeControl(0, 1, 1)
|
||||
{
|
||||
auto tControl = dict.getValOrSet<word>("timeControl", "default");
|
||||
if(tControl == "default")
|
||||
{
|
||||
baseTimeControl::operator=(
|
||||
defaultTimeControl
|
||||
);
|
||||
}
|
||||
else if(tControl == "settingsDict")
|
||||
{
|
||||
baseTimeControl::operator=(
|
||||
settingTimeControl
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
baseTimeControl::operator=( baseTimeControl(dict, "execution") );
|
||||
}
|
||||
}
|
||||
|
||||
// Additional methods and members can be added here
|
||||
};
|
||||
|
||||
} // namespace pFlow
|
||||
|
||||
#endif // __postprocessTimeControl_hpp__
|
Reference in New Issue
Block a user