diff --git a/src/Particles/GrainParticles/grainShape/grainShape.cpp b/src/Particles/GrainParticles/grainShape/grainShape.cpp index 4558940b..246b5be8 100644 --- a/src/Particles/GrainParticles/grainShape/grainShape.cpp +++ b/src/Particles/GrainParticles/grainShape/grainShape.cpp @@ -73,6 +73,18 @@ pFlow::grainShape::grainShape } } +pFlow::grainShape::grainShape +( + const word &shapeType, + const word &fileName, + repository *owner, + const property &prop +) +: + grainShape(fileName, owner, prop) +{ +} + pFlow::real pFlow::grainShape::maxBoundingSphere() const { return max(grainDiameters_); @@ -99,9 +111,12 @@ pFlow::real pFlow::grainShape::boundingDiameter(uint32 index) const { return grainDiameters_[index]; } - fatalErrorInFunction<<"Invalid index for diameter "<< - index< pFlow::shape::create +( + const word &shapeType, + const word &fileName, + repository *owner, + const property &prop +) +{ + word type = angleBracketsNames("shape", shapeType); + + if( wordvCtorSelector_.search(type) ) + { + auto objPtr = + wordvCtorSelector_[type] + (shapeType, fileName, owner, prop); + return objPtr; + } + else + { + printKeys + ( + fatalError << "Ctor Selector "<< + type << " dose not exist. \n" + <<"Avaiable ones are: \n\n" + , + wordvCtorSelector_ + ); + fatalExit; + return nullptr; + } + +} diff --git a/src/Particles/particles/shape/shape.hpp b/src/Particles/particles/shape/shape.hpp index 5a4007aa..4c7d74e9 100644 --- a/src/Particles/particles/shape/shape.hpp +++ b/src/Particles/particles/shape/shape.hpp @@ -60,9 +60,28 @@ public: const word& fileName, repository* owner, const property& prop); + + shape( + const word& shapeType, + const word& fileName, + repository* owner, + const property& prop); ~shape() override=default; + create_vCtor + ( + shape, + word, + ( + const word& shapeType, + const word& fileName, + repository* owner, + const property& prop + ), + (shapeType, fileName, owner, prop) + ); + inline const auto& properties()const { @@ -148,6 +167,9 @@ public: virtual realVector boundingDiameter()const = 0; + virtual + realVector volume()const = 0; + virtual bool mass(uint32 index, real& m)const = 0; @@ -187,6 +209,13 @@ public: virtual real Inertial_zz(uint32 index)const = 0; + static + uniquePtr create( + const word& shapeType, + const word& fileName, + repository* owner, + const property& prop); + }; } diff --git a/src/PostprocessData/CMakeLists.txt b/src/PostprocessData/CMakeLists.txt index bb3999d4..a68a6d75 100644 --- a/src/PostprocessData/CMakeLists.txt +++ b/src/PostprocessData/CMakeLists.txt @@ -4,6 +4,7 @@ set(SourceFiles # Fields database fieldsDataBase/fieldsDataBase.cpp + fieldsDataBase/simulationFieldsDataBase.cpp # Regions region/regionPoints/regionPoints/regionPoints.cpp @@ -21,6 +22,8 @@ set(SourceFiles operation/postprocessOperation/postprocessOperation.cpp operation/PostprocessOperation/PostprocessOperationSum.cpp operation/PostprocessOperation/PostprocessOperationAverage.cpp + operation/PostprocessOperation/PostprocessOperationAvMassVelocity.cpp + operation/includeMask/includeMask.cpp operation/includeMask/IncludeMasks.cpp diff --git a/src/PostprocessData/fieldsDataBase/fieldsDataBase.cpp b/src/PostprocessData/fieldsDataBase/fieldsDataBase.cpp index 508c572c..2ea4e81b 100644 --- a/src/PostprocessData/fieldsDataBase/fieldsDataBase.cpp +++ b/src/PostprocessData/fieldsDataBase/fieldsDataBase.cpp @@ -21,17 +21,43 @@ Licence: #include #include "vocabs.hpp" -#include "Time.hpp" +#include "systemControl.hpp" #include "fieldsDataBase.hpp" #include "fieldFunctions.hpp" -#include "dynamicPointStructure.hpp" -bool pFlow::fieldsDataBase::checkForUpdate(const word &name, bool forceUpdate) + +namespace pFlow +{ + +bool pointFieldGetType(const word& TYPENAME, word& fieldType, word& fieldSpace); + +} + +bool pFlow::fieldsDataBase::loadPointStructureToTime() +{ + return false; +} + +pFlow::word pFlow::fieldsDataBase::getPointFieldType(const word &name) const +{ + word pfType = time_.lookupObjectTypeName(name); + word type, space; + if(!pointFieldGetType(pfType, type, space)) + { + fatalErrorInFunction + <<"Error in retriving the type of pointField " + << pfType<second < t || forceUpdate; iter->second = t; @@ -39,7 +65,7 @@ bool pFlow::fieldsDataBase::checkForUpdate(const word &name, bool forceUpdate) else { shouldUpdate = true; - captureTime_.insertIf(name, t); + captureTime_.insertIf(compoundName, t); } return shouldUpdate; @@ -70,6 +96,105 @@ pFlow::span pFlow::fieldsDataBase::createOrGetRealField(const word field.size()); } +pFlow::span pFlow::fieldsDataBase::createOrGetVolume(bool forceUpdate) +{ + const word fName = "volume"; + bool shouldUpdate = checkForUpdate(fName, forceUpdate); + + if(shouldUpdate) + { + const auto index = updateFieldUint32("shapeIndex", true); + auto vols = getShape().volume(); + + FieldTypeHost volField + ( + fName, + "value", + pointFieldSize() + ); + + for(uint32 i=0; i< volField.size(); i++) + { + volField[i] = vols[index[i]]; + } + + allFields_.emplaceBackOrReplace> + ( + fName, + std::move(volField) + ); + } + + auto& field = allFields_.getObject>(fName); + return span( + field.data(), + field.size()); + +} + +pFlow::span pFlow::fieldsDataBase::createOrGetDensity(bool forceUpdate) +{ + const word fName = "density"; + + bool shouldUpdate = checkForUpdate(fName, forceUpdate); + + if(shouldUpdate) + { + const auto index = updateFieldUint32("shapeIndex", true); + const auto dens = getShape().density(); + + FieldTypeHost denFeild + ( + fName, + "value", + pointFieldSize() + ); + + for(uint32 i=0; i< denFeild.size(); i++) + { + denFeild[i] = dens[index[i]]; + } + + allFields_.emplaceBackOrReplace> + ( + fName, + std::move(denFeild) + ); + } + + auto& field = allFields_.getObject>(fName); + return span( + field.data(), + field.size()); +} + +pFlow::span pFlow::fieldsDataBase::createOrGetOne(bool forceUpdate) +{ + const word fName = "one"; + + bool shouldUpdate = checkForUpdate(fName, forceUpdate); + + if(shouldUpdate) + { + allFields_.emplaceBackOrReplace> + ( + fName, + FieldTypeHost + ( + fName, + "value", + pointFieldSize(), + 1.0 + ) + ); + } + + auto& field = allFields_.getObject>(fName); + return span( + field.data(), + field.size()); +} + bool pFlow::fieldsDataBase::findFunction( const word &compoundFieldName, word &fieldName, @@ -274,9 +399,9 @@ bool pFlow::fieldsDataBase::inputOutputType return false; } -pFlow::fieldsDataBase::fieldsDataBase(const Time &time, bool inSimulation) -: - time_(time), +pFlow::fieldsDataBase::fieldsDataBase(systemControl& control, bool inSimulation) +: + time_(control.time()), inSimulation_(inSimulation) {} @@ -285,84 +410,110 @@ pFlow::timeValue pFlow::fieldsDataBase::currentTime() const return time_.currentTime(); } -bool pFlow::fieldsDataBase::getPointFieldType +bool pFlow::fieldsDataBase::getFieldTypeNameFunction ( - const word& compoundName, - word& fieldName, + const word& compoundName, + word& pointFieldName, word& originalType, word& typeAfterFunction, Functions& func -) +)const { - if( !findFunction(compoundName, fieldName, func)) + if( !findFunction(compoundName, pointFieldName, func)) { - fatalErrorInFunction; + fatalErrorInFunction + <<"Error in processing function for field: " + <second; + // The name is in the reserved fields + originalType = reservedFieldNames_.find(pointFieldName)->second; } else { - word fieldTypeName = time_.lookupObjectTypeName(fieldName); - word space; - if(!pointFieldGetType(fieldTypeName, originalType, space)) + // the name is in the Time object + if(pointFieldNameExists(pointFieldName)) { - fatalErrorInFunction<<"Cannot extract type name from "<< fieldTypeName< pFlow::fieldsDataBase::updatePoints(bool forceUpdate) { - - bool shouldUpdate = checkForUpdate("position", forceUpdate); + const word fName = "position"; + bool shouldUpdate = checkForUpdate(fName, forceUpdate); if(shouldUpdate) { + // load pointStructure + if(!loadPointStructureToTime()) + { + fatalErrorInFunction<< "Error in loading pointStructure to Time object."<( - "position", - pstruct.activePointsHost()); + allFields_.emplaceBackOrReplace + ( + fName, + pstruct.activePointsHost() + ); } - auto& points = allFields_.getObject("position"); + auto& points = allFields_.getObject(fName); return span( points.data(), @@ -379,7 +530,12 @@ pFlow::span pFlow::fieldsDataBase::updateFieldRealx3 word originalType, typeAfterFunction, fieldName; Functions func; - if( !getPointFieldType(compoundName, fieldName, originalType, typeAfterFunction, func)) + if( !getFieldTypeNameFunction( + compoundName, + fieldName, + originalType, + typeAfterFunction, + func) ) { fatalErrorInFunction<< "Error in getting the type name of field: "<< compoundName<<", with type name: "<< originalType < pFlow::fieldsDataBase::updateFieldRealx4 word originalType, typeAfterFunction, fieldName; Functions func; - if( !getPointFieldType(compoundName, fieldName, originalType, typeAfterFunction, func)) + if( !getFieldTypeNameFunction( + compoundName, + fieldName, + originalType, + typeAfterFunction, + func)) { fatalErrorInFunction<< "Error in getting the type name of field: "<< compoundName<<", with type name: "<< originalType < pFlow::fieldsDataBase::updateFieldReal word originalType, typeAfterFunction, fieldName; Functions func; - if( !getPointFieldType(compoundName, fieldName, originalType, typeAfterFunction, func)) + if( !getFieldTypeNameFunction( + compoundName, + fieldName, + originalType, + typeAfterFunction, + func) ) { fatalErrorInFunction<< "Error in getting the type name of field: "<< compoundName<<", with type name: "<< originalType <(nullptr, 0); } - - if( typeAfterFunction== getTypeName() ) + if( typeAfterFunction == getTypeName() ) { return updateFieldRealx3(compoundName, forceUpdate); } @@ -642,19 +805,41 @@ pFlow::allPointFieldTypes pFlow::fieldsDataBase::updateFieldAll } } -const pFlow::pointStructure &pFlow::fieldsDataBase::pStruct() const + + +pFlow::uniquePtr + pFlow::fieldsDataBase::create(systemControl& control, bool inSimulation) { - if(inSimulation_) + word dbType; + if(inSimulation) { - return - static_cast( - time_.lookupObject(pointStructureFile__) - ); + dbType = "fieldsDataBase"; } else { - return time_.lookupObject(pointStructureFile__); + dbType = "fieldsDataBase"; } + + if( boolvCtorSelector_.search(dbType) ) + { + auto objPtr = + boolvCtorSelector_[dbType](control, inSimulation); + return objPtr; + } + else + { + printKeys + ( + fatalError << "Ctor Selector "<< + dbType << " does not exist. \n" + <<"Available ones are: \n\n" + , + boolvCtorSelector_ + ); + fatalExit; + } + + return nullptr; } bool pFlow::pointFieldGetType(const word& TYPENAME, word& fieldType, word& fieldSpace) diff --git a/src/PostprocessData/fieldsDataBase/fieldsDataBase.hpp b/src/PostprocessData/fieldsDataBase/fieldsDataBase.hpp index 13a71f31..ec8c577e 100644 --- a/src/PostprocessData/fieldsDataBase/fieldsDataBase.hpp +++ b/src/PostprocessData/fieldsDataBase/fieldsDataBase.hpp @@ -21,52 +21,23 @@ Licence: #ifndef __fieldsDataBase_hpp__ #define __fieldsDataBase_hpp__ -#include -#include - +#include "fieldsDataBaseDclr.hpp" #include "pointStructure.hpp" #include "pointFields.hpp" #include "anyList.hpp" #include "Map.hpp" -#include "span.hpp" +#include "shape.hpp" + namespace pFlow { +class systemControl; class Time; -bool pointFieldGetType(const word& TYPENAME, word& fieldType, word& fieldSpace); - -template -concept ValidFieldType = - std::same_as || - std::same_as || - std::same_as || - std::same_as; - -template -concept VectorType = - std::same_as || - std::same_as; - -template -concept ScalarType = - std::same_as; - - -template -concept ValidRegionFieldType = - std::same_as || - std::same_as || - std::same_as ; - - -using allPointFieldTypes = std::variant, span, span>; - class fieldsDataBase - { private: @@ -99,9 +70,6 @@ private: // - Member variables - - /// const reference to the Time object - const Time& time_; /// List to store all the point fields anyList allFields_; @@ -109,114 +77,95 @@ private: /// Map to store the last capture time of each field wordMap captureTime_; - /// + /// Reference to the Time object + Time& time_; + + /// Flag indicating if we're in simulation mode bool inSimulation_ = false; - + +protected: + + /// Map of reserved field names with their corresponding types static const inline std::map reservedFieldNames_ { {"position", "realx3"}, - {"one", "real"} + {"one", "real"}, + {"volume", "real"}, + {"density", "real"} }; - - // - Private member functions - uint32 pointFieldSize() - { - auto s = updatePoints(); - return s.size(); - } + /// check if pointField name exists in Time or time folder + virtual + bool pointFieldNameExists(const word& name)const = 0; - /// @brief Checks if a field needs to be updated. - /// @param name The name of the field to check. - /// @param forceUpdate Forces an update if true. Defaults to `false`. - /// @return `true` if the field needs updating or `forceUpdate` is true, `false` otherwise. - bool checkForUpdate(const word& name, bool forceUpdate = false); + /// Loads a pointField with a given name to the Time object + virtual + bool loadPointFieldToTime(const word& name)= 0; + + virtual + bool loadPointStructureToTime()=0; + + /// get the type name of the pointField in the Time object + word getPointFieldType(const word& name)const; + + /// Checks if a field needs to be updated based on capture time + bool checkForUpdate(const word& compoundName, bool forceUpdate = false); - /** - * @brief Updates and retrieves a point field of a specified type from the database. - * - * This is a template function that updates and retrieves a point field of type `T` - * from the database. It checks if the field needs to be updated based on the last - * capture time or if a forced update is requested. If an update is necessary, it - * retrieves the latest data for the field. - * - * @tparam T The type of the point field to update and retrieve. Must be a ValidFieldType. - * @param name The name of the field to update. - * @param forceUpdate A boolean flag indicating whether to force an update of the field - * regardless of its current state. Defaults to `false`. - * - * @return A span of `T` representing the updated field data. - * - * @throws message If the field cannot be found in the database or if there is a type mismatch. - */ template span updateField(const word& name, bool forceUpdate = false); + + template + span updateReservedField(const word& name, bool forceUpdate = false); - /// @brief Creates a new real field or retrieves an existing one. - /// - /// If a field with the given name already exists, it returns a span to that field. - /// If the field does not exist, it creates a new real field with the given name - /// and returns a span to the newly created field. - /// - /// @param name The name of the field to create or retrieve. - /// @return span of the field span createOrGetRealField(const word& name); - /** - * @brief Parses a compound field name to extract the base field name and function. - * - * This function takes a compound field name, which may include a function applied - * to a base field (e.g., "mag(velocity)"), and parses it to extract the base field - * name (e.g., "velocity") and the function to be applied (e.g., `Functions::Magnitude`). - * - * The function supports the following syntax for compound field names: - * - `fieldName` (no function applied) - * - `functionName(fieldName)` - * - * Supported function names are defined in the `Functions` enum. - * - * @param compoundFieldName The compound field name to parse. - * @param fieldName A reference to a `word` where the extracted base field name - * will be stored. - * @param func A reference to a `Functions` enum where the identified function - * will be stored. If no function is applied, this will be set to - * `Functions::None`. - * - * @return `true` if the compound field name was successfully parsed and the base - * field name and function were extracted, `false` otherwise. - * - * @note The function modifies the `fieldName` and `func` parameters to return the - * extracted information. - */ + span createOrGetVolume(bool forceUpdate=false); + + span createOrGetDensity(bool forceUpdate=false); + + span createOrGetOne(bool forceUpdate=false); + static bool findFunction( const word& compoundFieldName, word& fieldName, fieldsDataBase::Functions& func ); - /** - * @brief Determines the input and output types for a given function. - * - * This function takes a `Functions` enum value and an input type as a string - * and determines the corresponding output type based on the function being applied. - * - * @param func The function for which to determine the input and output types. - * @param inputType The input type as a string. - * @param outputType A reference to a string where the determined output type will be stored. - * - * @return `true` if the input and output types were successfully determined, `false` otherwise. - */ static bool inputOutputType( fieldsDataBase::Functions func, const word& inputType, word& outputType); + +protected: + + // - protected member functions + + + virtual + bool checkTimeFolder(const word& fieldName) const = 0; + + virtual + const shape& getShape() const= 0; + + + /// @brief return the size of pointStructure + uint32 pointFieldSize() + { + auto s = updatePoints(); + return s.size(); + } + public: + // - Type info + + TypeInfo("fieldsDataBase"); + // - constructors - fieldsDataBase(const Time& time, bool inSimulation); + fieldsDataBase(systemControl& control, bool inSimulation); /// no copy constructor fieldsDataBase(const fieldsDataBase&) = delete; @@ -231,140 +180,70 @@ public: fieldsDataBase& operator=(fieldsDataBase&&) = delete; /// destructor - ~fieldsDataBase() = default; + virtual ~fieldsDataBase() = default; + + create_vCtor + ( + fieldsDataBase, + bool, + (systemControl& control, bool inSimulation), + (control, inSimulation) + ); + // - Public Access Functions /// returns the current time timeValue currentTime()const; - /// const ref to object Time - const Time& time()const + /// const ref to object Time + const Time& time()const { return time_; } - + + Time& time() + { + return time_; + } + // - Public Member Functions - /** - * @brief Retrieves the type of a point field based on its compound name. - * - * This function attempts to extract the type of a point field from its compound name. - * The compound name may include additional information such as a function or operation - * applied to the field, ie. mag(velcoty). If the type is successfully determined, it - * is stored in the provided `typeName` parameter. - * - * @param compoundName The compound name of the field, which may include additional - * information about operations or functions applied to the field. - * @param originalType A reference to a `word` where the original type name is obtained. - * This will be set to the type of the field before any function is applied. - * @param typeAfterFunction A reference to a `word` where the type name after applying - * the function is obtained. - * @param func the applied function to the field. - * - * @return `true` if the type was successfully determined and stored in `typeName`, - * `false` otherwise. - */ - bool getPointFieldType( + bool getFieldTypeNameFunction + ( const word& compoundName, - word& fieldName, + word& pointFieldName, word& originalType, word& typeAfterFunction, - Functions& func); - - /// overload for the function getPointFieldType without `func` argument - bool getPointFieldType( - const word& compoundName, - word& originalType, - word& typeAfterFunction); - - /// overload for function getPointFieldType without `originalType` argument - bool getPointFieldType( - const word& compoundName, - word& typeAfterFunction); + Functions& func + )const; - /** - * @brief Updates the points data and returns a span to the updated points. - * - * This function ensures that the points data is up-to-date by checking if an update - * is necessary. If the data is outdated or if a forced update is requested, it retrieves - * the latest points data and stores it in the internal fields database. The function - * then returns a span to the updated points data for further use. - * - * @param forceUpdate A boolean flag indicating whether to force an update of the points - * data regardless of its current state. Defaults to `false`. - * - * @return A span of `realx3` representing the updated points data. - */ + + bool getFieldType + ( + const word& compoundName, + word& originalType, + word& typeAfterFunction + ) const; + + bool getFieldType + ( + const word& compoundName, + word& typeAfterFunction + ) const; + + + /// update pointStructure if necessary span updatePoints(bool forceUpdate = false); - /** - * @brief Updates and retrieves a realx3 point field from the database. - * - * This function retrieves or updates a realx3 field based on its compound name. - * The compound name cannot include any function operation. - * If the field needs to be updated or if forceUpdate is true, the method will - * fetch the latest data from the database. - * - * @param compoundName The name of the field, possibly including a function operation - * @param forceUpdate If true, forces an update of the field regardless of its current state. - * Defaults to false. - * - * @return A span containing the updated realx3 field data - * - * @throws message If the field type is not compatible with realx3 or if the field - * cannot be found in the database - */ + /// update a field with realx3 type span updateFieldRealx3( const word& compoundName, bool forceUpdate = false); - /** - * @brief Updates and retrieves a realx4 point field from the database. - * - * This function retrieves or updates a realx4 field based on its compound name. - * The compound name cannot include any function operation. - * If the field needs to be updated or if forceUpdate is true, the method will - * fetch the latest data from the database. - * - * @param compoundName The name of the field, possibly including a function operation - * @param forceUpdate If true, forces an update of the field regardless of its current state. - * Defaults to false. - * - * @return A span containing the updated realx3 field data - * - * @throws message If the field type is not compatible with realx4 or if the field - * cannot be found in the database - */ span updateFieldRealx4( const word& compoundName, bool forceUpdate = false); - /** - * @brief Updates and retrieves a real point field from the database. - * - * This function retrieves or updates a real field based on its compound name. - * The compound name may include a function operation (e.g., abs, square, etc.). - * If the field needs to be updated or if forceUpdate is true, the method will - * fetch the latest data from the database and apply the specified function. - * - * Supported functions include: - * - None: Retrieves the field as is. - * - abs: Computes the absolute value of the field. - * - square: Computes the square of the field. - * - cube: Computes the cube of the field. - * - sqrt: Computes the square root of the field. - * - mag, magSquare, magCube, magSqrt: Compute magnitude-related operations for vector fields. - * - component(x, y, z): Extracts a specific component from a vector field. - * - * @param compoundName The name of the field, possibly including a function operation. - * @param forceUpdate If true, forces an update of the field regardless of its current state. - * Defaults to false. - * - * @return A span containing the updated real field data. - * - * @throws message If the field type is not compatible with real or if the field - * cannot be found in the database. - */ span updateFieldReal( const word& compoundName, bool forceUpdate = false); @@ -378,11 +257,20 @@ public: allPointFieldTypes updateFieldAll( const word& compoundName, bool forceUpdate = false); + + virtual + const pointStructure& pStruct()const = 0; - const pointStructure& pStruct()const; + virtual + void resetTimeFolder() = 0; + + static + uniquePtr create( + systemControl& control, + bool inSimulation); }; -} // nampespace pFlow +} // namespace pFlow #include "fieldsDataBaseTemplates.cpp" diff --git a/src/PostprocessData/fieldsDataBase/fieldsDataBaseDclr.hpp b/src/PostprocessData/fieldsDataBase/fieldsDataBaseDclr.hpp new file mode 100644 index 00000000..283b5e7b --- /dev/null +++ b/src/PostprocessData/fieldsDataBase/fieldsDataBaseDclr.hpp @@ -0,0 +1,45 @@ + +#ifndef __fieldsDataBaseDclr_hpp__ +#define __fieldsDataBaseDclr_hpp__ + +#include +#include +#include + +#include "types.hpp" +#include "span.hpp" + +namespace pFlow +{ + + +template +concept ValidFieldType = + std::same_as || + std::same_as || + std::same_as || + std::same_as; + +template +concept VectorType = + std::same_as || + std::same_as; + +template +concept ScalarType = + std::same_as; + + +template +concept ValidRegionFieldType = + std::same_as || + std::same_as || + std::same_as ; + + +using allPointFieldTypes = std::variant, span, span>; + + +} // namespace pFlow + +#endif //__fieldsDataBaseDclr_hpp__ \ No newline at end of file diff --git a/src/PostprocessData/fieldsDataBase/fieldsDataBaseTemplates.cpp b/src/PostprocessData/fieldsDataBase/fieldsDataBaseTemplates.cpp index 9466a8d6..a36eb95c 100644 --- a/src/PostprocessData/fieldsDataBase/fieldsDataBaseTemplates.cpp +++ b/src/PostprocessData/fieldsDataBase/fieldsDataBaseTemplates.cpp @@ -32,40 +32,25 @@ pFlow::span pFlow::fieldsDataBase::updateField(const word& name, bool forceUp if(shouldUpdate) { - if(name == "one") - { - allFields_.emplaceBackOrReplace> - ( - "one", - FieldTypeHost - ( - "one", - "value", - pointFieldSize(), - T{1} - ) - ); - } - else if( name == "position") + if(reservedFieldNames_.contains(name)) { - if constexpr( std::same_as) + return updateReservedField(name, true); + } + else + { + if( loadPointFieldToTime(name) ) { - return updatePoints(true); + const auto& pField = time_.lookupObject>(name); + allFields_.emplaceBackOrReplace>( + name, + pField.activeValuesHost()); } else { - fatalErrorInFunction<< "Error in getting the type name of field: "<< - name<<", with type name: "<< getTypeName() <(nullptr, 0); } - } - else - { - const auto& pField = time_.lookupObject>(name); - allFields_.emplaceBackOrReplace>( - name, - pField.activeValuesHost()); + } } @@ -77,4 +62,80 @@ pFlow::span pFlow::fieldsDataBase::updateField(const word& name, bool forceUp } + +template +inline +pFlow::span pFlow::fieldsDataBase::updateReservedField +( + const word& name, + bool forceUpdate +) +{ + if(name == "one") + { + if constexpr( std::same_as) + { + return createOrGetOne(forceUpdate); + } + else + { + fatalErrorInFunction + << "This type: " + << getTypeName() + <<" is not supported for field one."<) + { + return createOrGetVolume(forceUpdate); + } + else + { + fatalErrorInFunction + << "This type: " + << getTypeName() + <<" is not supported for field volume."<) + { + return createOrGetDensity(forceUpdate); + } + else + { + fatalErrorInFunction + << "This type: " + << getTypeName() + <<" is not supported for field density."<) + { + return updatePoints(forceUpdate); + } + else + { + fatalErrorInFunction + << "This type: " + << getTypeName() + <<" is not supported for field position."<(nullptr, 0); + +} + #endif //__fieldsDataBaseTemplates_hpp__ \ No newline at end of file diff --git a/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.cpp b/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.cpp new file mode 100644 index 00000000..312f8e51 --- /dev/null +++ b/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.cpp @@ -0,0 +1,62 @@ +#include "Time.hpp" +#include "simulationFieldsDataBase.hpp" +#include "dynamicPointStructure.hpp" +#include "vocabs.hpp" + +namespace pFlow +{ + bool pointFieldGetType(const word& TYPENAME, word& fieldType, word& fieldSpace); +} + +bool pFlow::simulationFieldsDataBase::pointFieldNameExists(const word &name) const +{ + return time().lookupObjectName(name); +} + +bool pFlow::simulationFieldsDataBase::loadPointFieldToTime(const word &name) +{ + return time().lookupObjectName(name); +} + +bool pFlow::simulationFieldsDataBase::loadPointStructureToTime() +{ + // it is already in the Time object + return time().lookupObjectName(pointStructureFile__); +} + +bool pFlow::simulationFieldsDataBase::checkTimeFolder(const word &fieldName) const +{ + return true; +} + +const pFlow::shape& pFlow::simulationFieldsDataBase::getShape() const +{ + return shape_; +} + +pFlow::simulationFieldsDataBase::simulationFieldsDataBase +( + systemControl &control, + bool inSimulation +) +: + fieldsDataBase(control, inSimulation), + shape_ + ( + dynamic_cast(*control.caseSetup().lookupObjectPtr(shapeFile__)) + ) +{ +} + +const pFlow::pointStructure &pFlow::simulationFieldsDataBase::pStruct() const +{ + return + static_cast + ( + time().lookupObject(pointStructureFile__) + ); +} + +void pFlow::simulationFieldsDataBase::resetTimeFolder() +{ +} diff --git a/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.hpp b/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.hpp new file mode 100644 index 00000000..d7ea7f50 --- /dev/null +++ b/src/PostprocessData/fieldsDataBase/simulationFieldsDataBase.hpp @@ -0,0 +1,79 @@ +/*------------------------------- 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 __simulationFieldsDataBase_hpp__ +#define __simulationFieldsDataBase_hpp__ + +#include "fieldsDataBase.hpp" + +namespace pFlow +{ + +class simulationFieldsDataBase +: + public fieldsDataBase +{ +private: + + const shape& shape_; + +protected: + + /// check if pointField name exists in Time or time folder + bool pointFieldNameExists(const word& name)const override; + + /// Loads a pointField with a given name to the Time object. + /// For simulation, it just checks if the name exists + bool loadPointFieldToTime(const word& name) override; + + /// Loads pointStructure to the Time object + /// For simulation, it just checks if the name exists + bool loadPointStructureToTime() override; + + bool checkTimeFolder(const word& fieldName) const override; + + const shape& getShape() const override; + +public: + + TypeInfo("fieldsDataBase"); + + simulationFieldsDataBase(systemControl& control, bool inSimulation); + + ~simulationFieldsDataBase() override = default; + + add_vCtor + ( + fieldsDataBase, + simulationFieldsDataBase, + bool + ); + + const pointStructure& pStruct()const override; + + void resetTimeFolder() override; + +}; + + +} + + +#endif //__simulationFieldsDataBase_hpp__ \ No newline at end of file diff --git a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAvMassVelocity.hpp b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAvMassVelocity.hpp index 16b029f1..5c0f164e 100644 --- a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAvMassVelocity.hpp +++ b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAvMassVelocity.hpp @@ -128,7 +128,7 @@ Licence: #include #include -#include "postprocessOperation.hpp" +#include "PostprocessOperationAverage.hpp" #include "regionField.hpp" #include "includeMask.hpp" @@ -138,7 +138,7 @@ namespace pFlow class PostprocessOperationAvMassVelocity : - public postprocessOperation + public PostprocessOperationAverage { public: diff --git a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp index a0de2384..3ffbd5b8 100644 --- a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp +++ b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.cpp @@ -1,7 +1,7 @@ #include "PostprocessOperationAverage.hpp" #include "dictionary.hpp" #include "fieldsDataBase.hpp" -#include "fieldFunctions.hpp" +#include "operationFunctions.hpp" /// Constructs average processor and initializes result field based on input field type pFlow::PostprocessOperationAverage::PostprocessOperationAverage @@ -80,7 +80,8 @@ pFlow::PostprocessOperationAverage::PostprocessOperationAverage /// Performs weighted average of field values within each region bool pFlow::PostprocessOperationAverage::execute ( - const std::vector>& weights + const std::vector>& weights, + const regionField& volFactor ) { auto allField = database().updateFieldAll(fieldName()); @@ -99,7 +100,7 @@ bool pFlow::PostprocessOperationAverage::execute return executeAverageOperation( procName, field, - regP, + volFactor, dbVol, weights, phi, @@ -124,6 +125,7 @@ bool pFlow::PostprocessOperationAverage::execute procName, field, std::get>(processedRegField), + volFactor, dbVol, weights, mask); diff --git a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp index 93181c1e..6620d588 100644 --- a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp +++ b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationAverage.hpp @@ -193,7 +193,9 @@ public: /// @brief Execute average operation on field values /// @param weights Weight factors for particles /// @return True if successful - bool execute(const std::vector>& weights) override; + bool execute( + const std::vector>& weights, + const regionField& volFactor) override; }; diff --git a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.cpp b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.cpp index 922bc1d4..c10315d7 100644 --- a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.cpp +++ b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.cpp @@ -1,7 +1,7 @@ #include "PostprocessOperationSum.hpp" #include "dictionary.hpp" #include "fieldsDataBase.hpp" -#include "fieldFunctions.hpp" +#include "operationFunctions.hpp" /// Constructs sum processor and initializes result field based on input field type pFlow::PostprocessOperationSum::PostprocessOperationSum @@ -41,7 +41,8 @@ pFlow::PostprocessOperationSum::PostprocessOperationSum /// Performs weighted sum of field values within each region bool pFlow::PostprocessOperationSum::execute ( - const std::vector>& weights + const std::vector>& weights, + const regionField& volFactor ) { auto allField = database().updateFieldAll(fieldName()); @@ -60,7 +61,7 @@ bool pFlow::PostprocessOperationSum::execute return executeSumOperation( procName, field, - regP, + volFactor, dbVol, weights, phi, diff --git a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.hpp b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.hpp index c8e910ff..b811e89b 100644 --- a/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.hpp +++ b/src/PostprocessData/operation/PostprocessOperation/PostprocessOperationSum.hpp @@ -175,7 +175,9 @@ public: /// @brief Execute sum operation on field values /// @param weights Weight factors for particles /// @return True if successful - bool execute(const std::vector>& weights) override; + bool execute( + const std::vector>& weights, + const regionField& volFactor) override; }; diff --git a/src/PostprocessData/operation/PostprocessOperation/fieldFunctions.hpp b/src/PostprocessData/operation/PostprocessOperation/operationFunctions.hpp similarity index 88% rename from src/PostprocessData/operation/PostprocessOperation/fieldFunctions.hpp rename to src/PostprocessData/operation/PostprocessOperation/operationFunctions.hpp index 3e278858..8dbe643b 100644 --- a/src/PostprocessData/operation/PostprocessOperation/fieldFunctions.hpp +++ b/src/PostprocessData/operation/PostprocessOperation/operationFunctions.hpp @@ -18,8 +18,8 @@ Licence: -----------------------------------------------------------------------------*/ -#ifndef __fieldFunctions_hpp__ -#define __fieldFunctions_hpp__ +#ifndef __operationFunctions_hpp__ +#define __operationFunctions_hpp__ #include @@ -36,13 +36,14 @@ regionField executeSumOperation ( const word& regFieldName, const span& field, - const regionPoints& regPoints, + const regionField& volFactor, const bool devideByVol, const std::vector>& weights, const span& phi, const includeMask::Mask& mask ) { + const auto& regPoints = volFactor.regPoints(); regionField processedField(regFieldName, regPoints, T{}); auto vols = regPoints.volumes(); @@ -63,7 +64,7 @@ regionField executeSumOperation } if(devideByVol) { - processedField[reg] = sum/vols[reg]; + processedField[reg] = sum/(volFactor[reg] * vols[reg]); } else { @@ -80,13 +81,15 @@ regionField executeAverageOperation ( const word& regFieldName, const span& field, - const regionPoints& regPoints, - const bool devideByVol, + const regionField& volFactor, + const bool devideByVol, const std::vector>& weights, const span& phi, const includeMask::Mask& mask ) { + + const auto& regPoints = volFactor.regPoints(); regionField processedField(regFieldName, regPoints, T{}); auto vols = regPoints.volumes(); @@ -113,7 +116,7 @@ regionField executeAverageOperation if(devideByVol) { - processedField[reg] = sumNum / max(sumDen, smallValue) / vols[reg]; + processedField[reg] = sumNum / max(sumDen, smallValue) / (volFactor[reg] * vols[reg]); } else { @@ -131,7 +134,8 @@ regionField executeFluctuation2Operation ( const word& regFieldName, const span& field, - const regionField& fieldAvg, + const regionField& fieldAvg, + const regionField& volFactor, const bool devideByVol, const std::vector>& weights, const includeMask::Mask& mask @@ -145,7 +149,7 @@ regionField executeFluctuation2Operation { auto partIndices = regPoints.indices(reg); auto w = weights[reg]; - auto vol = vols[reg]; + auto vol = volFactor[reg] * vols[reg]; T avField{}; if(devideByVol) { @@ -188,4 +192,4 @@ regionField executeFluctuation2Operation } // namespace pFlow -#endif //__fieldFunctions_hpp__ +#endif //__operationFunctions_hpp__ diff --git a/src/PostprocessData/operation/includeMask/IncludeMask.hpp b/src/PostprocessData/operation/includeMask/IncludeMask.hpp index 6a4a24f7..34ae4dfb 100644 --- a/src/PostprocessData/operation/includeMask/IncludeMask.hpp +++ b/src/PostprocessData/operation/includeMask/IncludeMask.hpp @@ -154,11 +154,34 @@ public: ).getVal("field")) {} + IncludeMask( + const word& type, + const dictionary& dict, + fieldsDataBase& feildsDB) + : + includeMask(type, dict, feildsDB), + operator_(dict.subDict(operatorName()+"Info")), + fieldName_( + dict.subDict + ( + operatorName()+"Info" + ).getVal("field")) + {} + /// Add virtual constructor pattern for creating instances - add_vCtor( + add_vCtor + ( includeMask, IncludeMask, - dictionary); + dictionary + ); + + add_vCtor + ( + includeMask, + IncludeMask, + word + ); /// Returns the mask for filtering elements (updates the mask if necessary) Mask getMask() override @@ -203,20 +226,40 @@ public: TypeInfoTemplate12("IncludeMask", T, allOp); - IncludeMask( - const dictionary& opDict, + IncludeMask( + const dictionary& opDict, fieldsDataBase& feildsDB) - : - includeMask(opDict, feildsDB) - { + : + includeMask(opDict, feildsDB) + { span s = database().updatePoints(); mask_.resize(s.size(), true); - } + } - add_vCtor( - includeMask, - IncludeMask, - dictionary); + IncludeMask( + const word& type, + const dictionary& opDict, + fieldsDataBase& feildsDB) + : + includeMask(type, opDict, feildsDB) + { + span s = database().updatePoints(); + mask_.resize(s.size(), true); + } + + add_vCtor + ( + includeMask, + IncludeMask, + dictionary + ); + + add_vCtor + ( + includeMask, + IncludeMask, + word + ); Mask getMask()override { diff --git a/src/PostprocessData/operation/includeMask/includeMask.cpp b/src/PostprocessData/operation/includeMask/includeMask.cpp index 95c85fb8..209391be 100644 --- a/src/PostprocessData/operation/includeMask/includeMask.cpp +++ b/src/PostprocessData/operation/includeMask/includeMask.cpp @@ -57,7 +57,7 @@ pFlow::uniquePtr pFlow::includeMask::create auto& maskDict = opDict.subDict(mask+"Info"); word maskField = maskDict.getVal("field"); - if( !fieldsDB.getPointFieldType(maskField, fieldType) ) + if( !fieldsDB.getFieldType(maskField, fieldType) ) { fatalErrorInFunction<<"Error in retriving the type of field" << maskField <<" from dictionary " @@ -111,7 +111,7 @@ pFlow::uniquePtr auto& maskDict = opDict.subDict(type+"Info"); word maskField = maskDict.getVal("field"); - if( !fieldsDB.getPointFieldType(maskField, fieldType) ) + if( !fieldsDB.getFieldType(maskField, fieldType) ) { fatalErrorInFunction<<"Error in retriving the type of field" << maskField <<" from dictionary " @@ -143,7 +143,7 @@ pFlow::uniquePtr method << " dose not exist. \n" <<"Avaiable ones are: \n\n" , - dictionaryvCtorSelector_ + wordvCtorSelector_ ); fatalExit; return nullptr; diff --git a/src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp b/src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp index 53473a09..e752f359 100644 --- a/src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp +++ b/src/PostprocessData/operation/postprocessOperation/postprocessOperation.cpp @@ -117,7 +117,7 @@ pFlow::postprocessOperation::postprocessOperation ), divideByVolume_ ( - opDict.getValOrSet("dividedByVolume", Logical(false)) + opDict.getValOrSet("divideByVolume", Logical(false)) ), regionPoints_ ( @@ -141,7 +141,7 @@ pFlow::postprocessOperation::postprocessOperation ) { - if(!fieldsDB.getPointFieldType(fieldName_, fieldType_)) + if(!fieldsDB.getFieldType(fieldName_, fieldType_)) { fatalErrorInFunction; fatalExit; @@ -159,7 +159,7 @@ bool pFlow::postprocessOperation::write(const fileSystem &parDir) const if(!osPtr_) { fileSystem path = parDir+( - processedFieldName() + ".Start_" + ti.prevTimeName()); + processedFieldName() + ".Start_" + ti.timeName()); osPtr_ = makeUnique(path); regPoints().write(osPtr_()); diff --git a/src/PostprocessData/operation/postprocessOperation/postprocessOperation.hpp b/src/PostprocessData/operation/postprocessOperation/postprocessOperation.hpp index 86e776d3..285a7b7e 100644 --- a/src/PostprocessData/operation/postprocessOperation/postprocessOperation.hpp +++ b/src/PostprocessData/operation/postprocessOperation/postprocessOperation.hpp @@ -246,7 +246,10 @@ public: /// execute the operation /// @param weights Vector of weights for the operation. - virtual bool execute(const std::vector>& weights) = 0; + /// @param volFactor a factor to be multiplied by the volume of the region + virtual bool execute( + const std::vector>& weights, + const regionField& volFactor) = 0; /// write the result to a file /// @param parDir Parent directory for the output file. diff --git a/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.cpp b/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.cpp index 759395f5..10590f7c 100644 --- a/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.cpp +++ b/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.cpp @@ -36,6 +36,12 @@ pFlow::PostprocessComponent::PostprocessComponent ( regionPointsPtr_().size() ), + volumeFactor_ + ( + "volumeFactor", + regionPointsPtr_(), + 1.0 + ), operationDicts_(readDictList("operations", dict)) { @@ -106,7 +112,7 @@ bool pFlow::PostprocessComponent::execute for(auto& op:operatios_) { - if( !op->execute(weights) ) + if( !op->execute(weights, volumeFactor_) ) { fatalErrorInFunction <<"error occured in executing operatoin defined in dict " diff --git a/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.hpp b/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.hpp index 51c46490..996467a1 100644 --- a/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.hpp +++ b/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponent.hpp @@ -51,6 +51,8 @@ private: /// Method for processing the selected particles data std::vector regionsProcessMethod_; + regionField volumeFactor_; + bool executed_{false}; dictionaryList operationDicts_; @@ -62,6 +64,16 @@ protected: return regionsProcessMethod_; } + regionField& volumeFactor() + { + return volumeFactor_; + } + + const regionField& volumeFactor()const + { + return volumeFactor_; + } + public: // type info diff --git a/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponentArithmetic.hpp b/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponentArithmetic.hpp index d801c9d4..7b9a37c3 100644 --- a/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponentArithmetic.hpp +++ b/src/PostprocessData/postprocessComponent/PostprocessComponent/PostprocessComponentArithmetic.hpp @@ -51,10 +51,12 @@ public: auto d = this->regPoints().eqDiameters(); auto c = this->regPoints().centers(); auto& regs = this->regionProecessMethod(); + auto& volFactor = this->volumeFactor(); const uint32 n = d.size(); for(uint32 i=0; iregPoints().eqDiameters(); auto c = this->regPoints().centers(); auto& regs = this->regionProecessMethod(); + auto& volFactor = this->volumeFactor(); + const uint32 n = d.size(); for(uint32 i=0; iregPoints().eqDiameters(); auto c = this->regPoints().centers(); auto& regs = this->regionProecessMethod(); + auto& volFactor = this->volumeFactor(); const uint32 n = d.size(); for(uint32 i=0; i; template class pFlow::PostprocessComponentUniform; template class pFlow::PostprocessComponentArithmetic; +template class pFlow::PostprocessComponentGaussian; +template class pFlow::PostprocessComponentUniform; +template class pFlow::PostprocessComponentArithmetic; + +template class pFlow::PostprocessComponentGaussian; +template class pFlow::PostprocessComponentUniform; +template class pFlow::PostprocessComponentArithmetic; + diff --git a/src/PostprocessData/postprocessComponent/particleProbePostprocessComponent/particleProbePostprocessComponent.cpp b/src/PostprocessData/postprocessComponent/particleProbePostprocessComponent/particleProbePostprocessComponent.cpp index f388c939..7588e602 100644 --- a/src/PostprocessData/postprocessComponent/particleProbePostprocessComponent/particleProbePostprocessComponent.cpp +++ b/src/PostprocessData/postprocessComponent/particleProbePostprocessComponent/particleProbePostprocessComponent.cpp @@ -135,7 +135,7 @@ bool pFlow::particleProbePostprocessComponent::write(const fileSystem& parDir)co if( !osPtr_) { // file is not open yet - fileSystem path = parDir + (name_+".Start_"+ti.prevTimeName()); + fileSystem path = parDir + (name_+".Start_"+ti.timeName()); osPtr_ = makeUnique(path); regionPointsPtr_().write(osPtr_()); } diff --git a/src/PostprocessData/postprocessData/postprocessData.cpp b/src/PostprocessData/postprocessData/postprocessData.cpp index 15a7709b..dc1dc479 100644 --- a/src/PostprocessData/postprocessData/postprocessData.cpp +++ b/src/PostprocessData/postprocessData/postprocessData.cpp @@ -30,7 +30,14 @@ pFlow::postprocessData::postprocessData(const systemControl &control) : auxFunctions(control), time_(control.time()), - fieldsDataBase_(control.time(), true), + fieldsDataBasePtr_ + ( + fieldsDataBase::create + ( + const_cast(control), + true + ) + ), dict_ ( objectFile @@ -73,6 +80,12 @@ pFlow::postprocessData::postprocessData(const systemControl &control) control.time().saveInterval(), "execution"); } + + shapeType_ = dict_.getValOrSet + ( + "shapeType", + word("sphere") + ); componentsDictsPtr_ = makeUnique(readDictList("components", dict_)); @@ -80,7 +93,7 @@ pFlow::postprocessData::postprocessData(const systemControl &control) { postprocesses_.push_back( postprocessComponent::create( compDict, - fieldsDataBase_, + fieldsDataBasePtr_(), defaultTimeControlPtr_() )); } diff --git a/src/PostprocessData/postprocessData/postprocessData.hpp b/src/PostprocessData/postprocessData/postprocessData.hpp index 4e5a95f2..e2223116 100644 --- a/src/PostprocessData/postprocessData/postprocessData.hpp +++ b/src/PostprocessData/postprocessData/postprocessData.hpp @@ -57,11 +57,14 @@ class postprocessData const Time& time_; /// Database for all the points fields on the host - fieldsDataBase fieldsDataBase_; + uniquePtr fieldsDataBasePtr_; /// file dictionary that is constructed from the file (postProcessDataDict) fileDictionary dict_; + /// name of the shape for use in the time of postprocess after simulation + word shapeType_; + /// list of dictionaries for postprocess components uniquePtr componentsDictsPtr_ = nullptr; diff --git a/src/PostprocessData/postprocessData/postprocessGlobals.hpp b/src/PostprocessData/postprocessData/postprocessGlobals.hpp index 99d04038..335bc267 100644 --- a/src/PostprocessData/postprocessData/postprocessGlobals.hpp +++ b/src/PostprocessData/postprocessData/postprocessGlobals.hpp @@ -27,7 +27,7 @@ namespace pFlow::postProcessGlobals { static fileSystem defaultDir__; -inline const word defaultRelDir__ = "VTK/postprocessData"; +inline const word defaultRelDir__ = "postprocessData"; } diff --git a/src/PostprocessData/processMethod/GaussianDistribution.hpp b/src/PostprocessData/processMethod/GaussianDistribution.hpp index 53889b76..6248bfa0 100644 --- a/src/PostprocessData/processMethod/GaussianDistribution.hpp +++ b/src/PostprocessData/processMethod/GaussianDistribution.hpp @@ -26,7 +26,7 @@ Licence: #include "typeInfo.hpp" #include "types.hpp" #include "span.hpp" - +#include "numericConstants.hpp" namespace pFlow { @@ -74,15 +74,15 @@ public: for(uint32 i=0; iselectedPoints(); ids_.resize(selectedPoints.size()); ids_.assign(selectedPoints.begin(), selectedPoints.end()); diff --git a/src/PostprocessData/region/regionPoints/lineRegionPoints/lineRegionPoints.cpp b/src/PostprocessData/region/regionPoints/lineRegionPoints/lineRegionPoints.cpp index 5e41ddf3..979a51a6 100644 --- a/src/PostprocessData/region/regionPoints/lineRegionPoints/lineRegionPoints.cpp +++ b/src/PostprocessData/region/regionPoints/lineRegionPoints/lineRegionPoints.cpp @@ -38,6 +38,7 @@ pFlow::lineRegionPoints::lineRegionPoints sphereRegions_.resize(nPoints, sphere(realx3(0,0,0),1)); centerPoints_.resize(nPoints); volumes_.resize(nPoints); + diameters_.resize(nPoints); selectedPoints_.resize(nPoints); real dt = 1.0/(nPoints-1); for(uint32 i = 0; i < nPoints; ++i) @@ -64,6 +65,21 @@ pFlow::span pFlow::lineRegionPoints::indices(uint32 elem) c selectedPoints_[elem].size()); } +pFlow::span pFlow::lineRegionPoints::indices(uint32 elem) +{ + if(elem >= size()) + { + fatalErrorInFunction + << "The element index is out of range. elem: " << elem + << " size: " << size() << endl; + fatalExit; + } + + return span( + selectedPoints_[elem].data(), + selectedPoints_[elem].size()); +} + bool pFlow::lineRegionPoints::update() { const auto points = database().updatePoints(); diff --git a/src/PostprocessData/region/regionPoints/lineRegionPoints/lineRegionPoints.hpp b/src/PostprocessData/region/regionPoints/lineRegionPoints/lineRegionPoints.hpp index bdffd094..58989aab 100644 --- a/src/PostprocessData/region/regionPoints/lineRegionPoints/lineRegionPoints.hpp +++ b/src/PostprocessData/region/regionPoints/lineRegionPoints/lineRegionPoints.hpp @@ -126,6 +126,8 @@ public: /// Return indices of points in the specified element/region span indices(uint32 elem)const override; + + span indices(uint32 elem) override; /// Update regions based on current particle positions bool update() override; diff --git a/src/PostprocessData/region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.cpp b/src/PostprocessData/region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.cpp index 8665f72e..e983c602 100644 --- a/src/PostprocessData/region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.cpp +++ b/src/PostprocessData/region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.cpp @@ -59,6 +59,20 @@ pFlow::span pFlow::multipleSpheresRegionPoints::indices(uin return span(selectedPoints_[elem].data(), selectedPoints_[elem].size()); } +pFlow::span pFlow::multipleSpheresRegionPoints::indices(uint32 elem) +{ + if (elem >= size()) + { + fatalErrorInFunction + << "The element index is out of range. elem: " << elem + << " size: " << size() << endl; + fatalExit; + } + + return span(selectedPoints_[elem].data(), selectedPoints_[elem].size()); +} + + bool pFlow::multipleSpheresRegionPoints::update() { const auto points = database().updatePoints(); diff --git a/src/PostprocessData/region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.hpp b/src/PostprocessData/region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.hpp index f250d216..e01da658 100644 --- a/src/PostprocessData/region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.hpp +++ b/src/PostprocessData/region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.hpp @@ -138,6 +138,11 @@ public: /// @return Span containing indices of particles within the specified region span indices(uint32 elem)const override; + /// Returns the indices of particles contained in a specific spherical region + /// @param elem Index of the spherical region to query + /// @return Span containing indices of particles within the specified region + span indices(uint32 elem) override; + /// Updates the selection of particles within each spherical region /// @return True if update was successful, false otherwise bool update() override; diff --git a/src/PostprocessData/sampleDictionary/postprocessDataDict b/src/PostprocessData/sampleDictionary/postprocessDataDict index 3cf582a1..92e7d8a5 100755 --- a/src/PostprocessData/sampleDictionary/postprocessDataDict +++ b/src/PostprocessData/sampleDictionary/postprocessDataDict @@ -50,7 +50,7 @@ components { function average; field velocity; - dividedByVolume no; //default + divideByVolume no; //default threshold 3; //default is 1; includeMask all; } @@ -61,7 +61,7 @@ components function average; field one; phi one; // default - dividedByVolume no; + divideByVolume no; includeMask lessThan; // diameter of par1 is 0.003, so these settings @@ -79,7 +79,7 @@ components function sum; field one; phi one; // default - dividedByVolume yes; + divideByVolume yes; } ); @@ -114,14 +114,14 @@ components { function sum; field one; - dividedByVolume yes; //default is no + divideByVolume yes; //default is no } volumeDensity { function sum; field cube(diameter); // d^3, although it differs by pi/6 - dividedByVolume yes; //default is no + divideByVolume yes; //default is no } ); } diff --git a/src/phasicFlow/repository/repository/repository.cpp b/src/phasicFlow/repository/repository/repository.cpp index 648b912f..2815956f 100644 --- a/src/phasicFlow/repository/repository/repository.cpp +++ b/src/phasicFlow/repository/repository/repository.cpp @@ -236,7 +236,42 @@ size_t pFlow::repository::numRepositories()const return repositories_.size(); } -pFlow::repository& pFlow::repository::lookupRepository(const word& name) +const pFlow::IOobject *pFlow::repository::lookupObjectPtr +( + const word &name +) const +{ + if( auto [iter, success] = objects_.findIf(name); success ) + { + return iter->second; + } + else + { + fatalErrorInFunction << + "Object with name " << name << " is not found in repository " << this->name()<second; + } + else + { + fatalErrorInFunction << + "Object with name " << name << " is not found in repository " << this->name()< T& lookupObject(const word& name); diff --git a/src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.cpp b/src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.cpp index 3a4a28f0..2e1591de 100644 --- a/src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.cpp +++ b/src/phasicFlow/structuredData/pointStructure/selectors/selectorRandomPoints/selectorRandomPoints.cpp @@ -93,9 +93,18 @@ pFlow::selectorRandomPoints::selectorRandomPoints( const dictionary& dict ) : pStructSelector(type, pStruct, dict), - begin_(dict.getVal("begin")), - end_(dict.getValOrSet("end", pStruct.size())), - number_(dict.getValOrSet("number", 1)) + begin_ + ( + dict.getValOrSet("begin",0u) + ), + end_ + ( + dict.getValOrSetMax("end", pStruct.size()) + ), + number_ + ( + dict.getValOrSetMax("number", 0u) + ) { begin_ = max(begin_, 1u); end_ = min(end_, static_cast(pStruct.size()));