From 29c682cfbe4d1e483ba05498d3e3e62a150173ed Mon Sep 17 00:00:00 2001 From: aschellenberg74 Date: Mon, 28 Oct 2024 17:27:32 -0700 Subject: [PATCH] replace GetInt with GetIntInput and GetDouble with GetDoubleInput --- SRC/recorder/MPCORecorder.cpp | 254 +++++++++++++++++----------------- SRC/recorder/VTK_Recorder.cpp | 2 +- 2 files changed, 128 insertions(+), 128 deletions(-) diff --git a/SRC/recorder/MPCORecorder.cpp b/SRC/recorder/MPCORecorder.cpp index ad851e2754..d23414083f 100755 --- a/SRC/recorder/MPCORecorder.cpp +++ b/SRC/recorder/MPCORecorder.cpp @@ -117,9 +117,9 @@ while opensees is writing data. Warning: this is a new feature in hdf5 version 1 #include // for parallel -#ifdef _PARALLEL_PROCESSING -extern bool OPS_PARTITIONED; -#include +#ifdef _PARALLEL_PROCESSING +extern bool OPS_PARTITIONED; +#include #endif // _PARALLEL_PROCESSING /************************************************************************************* @@ -1813,111 +1813,111 @@ namespace mpco { virtual int getReactionFlag()const { return 2; } }; - class ResultRecorderUnbalancedForce : public ResultRecorder - { - public: - ResultRecorderUnbalancedForce(const mpco::ProcessInfo& info) - : ResultRecorder(info) - { - std::stringstream ss_buffer; - ss_buffer << "MODEL_STAGE[" << info.current_model_stage_id << "]/RESULTS/ON_NODES/UNBALANCED_FORCE"; - m_result_name = ss_buffer.str(); - m_result_display_name = "Unbalanced Force"; - m_num_components = 0; - if (m_ndim == 1) { - m_components_name = "Fx"; - m_num_components = 1; - m_result_data_type = mpco::ResultDataType::Scalar; - } - else if (m_ndim == 2) { - m_components_name = "Fx,Fy"; - m_num_components = 2; - m_result_data_type = mpco::ResultDataType::Vectorial; - } - else if (m_ndim == 3) { - m_components_name = "Fx,Fy,Fz"; - m_num_components = 3; - m_result_data_type = mpco::ResultDataType::Vectorial; - } - m_dimension = "F"; - m_description = "Nodal unbalanced force field"; - m_result_type = mpco::ResultType::Generic; - } - protected: - virtual void bufferResponse(mpco::ProcessInfo& info, std::vector& nodes, std::vector& buffer)const { - for (size_t i = 0; i < nodes.size(); i++) - utils::misc::bufferNodeResponseVec3u(i, m_ndim, nodes[i]->getUnbalancedLoad(), buffer); - } - }; - - class ResultRecorderUnbalancedMoment : public ResultRecorder - { - public: - ResultRecorderUnbalancedMoment(const mpco::ProcessInfo& info) - : ResultRecorder(info) - { - std::stringstream ss_buffer; - ss_buffer << "MODEL_STAGE[" << info.current_model_stage_id << "]/RESULTS/ON_NODES/UNBALANCED_MOMENT"; - m_result_name = ss_buffer.str(); - m_result_display_name = "Unbalanced Moment"; - m_num_components = 0; - if (m_ndim == 2) { - m_components_name = "Mz"; - m_num_components = 1; - m_result_data_type = mpco::ResultDataType::Scalar; - } - else { - m_components_name = "Mx,My,Mz"; - m_num_components = 3; - m_result_data_type = mpco::ResultDataType::Vectorial; - } - m_dimension = "F*L"; - m_description = "Nodal unbalanced moment field"; - m_result_type = mpco::ResultType::Generic; - } - protected: - virtual void bufferResponse(mpco::ProcessInfo& info, std::vector& nodes, std::vector& buffer)const { - for (size_t i = 0; i < nodes.size(); i++) - utils::misc::bufferNodeResponseVec3r(i, m_ndim, nodes[i]->getUnbalancedLoad(), buffer); - } - }; - - class ResultRecorderUnbalancedForceIncIntertia : public ResultRecorderUnbalancedForce - { - public: - ResultRecorderUnbalancedForceIncIntertia(const mpco::ProcessInfo& info) - : ResultRecorderUnbalancedForce(info) - { - std::stringstream ss_buffer; - ss_buffer << "MODEL_STAGE[" << info.current_model_stage_id << "]/RESULTS/ON_NODES/UNBALANCED_FORCE_INCLUDING_INERTIA"; - m_result_name = ss_buffer.str(); - m_result_display_name = "Unbalanced Force Including Inertia"; - m_description = "Nodal unbalanced force field including inertia"; - } - protected: - virtual void bufferResponse(mpco::ProcessInfo& info, std::vector& nodes, std::vector& buffer)const { - for (size_t i = 0; i < nodes.size(); i++) - utils::misc::bufferNodeResponseVec3u(i, m_ndim, nodes[i]->getUnbalancedLoadIncInertia(), buffer); - } - }; - - class ResultRecorderUnbalancedMomentIncIntertia : public ResultRecorderUnbalancedMoment - { - public: - ResultRecorderUnbalancedMomentIncIntertia(const mpco::ProcessInfo& info) - : ResultRecorderUnbalancedMoment(info) - { - std::stringstream ss_buffer; - ss_buffer << "MODEL_STAGE[" << info.current_model_stage_id << "]/RESULTS/ON_NODES/UNBALANCED_MOMENT_INCLUDING_INERTIA"; - m_result_name = ss_buffer.str(); - m_result_display_name = "Unbalanced Moment Including Inertia"; - m_description = "Nodal unbalanced moment field including inertia"; - } - protected: - virtual void bufferResponse(mpco::ProcessInfo& info, std::vector& nodes, std::vector& buffer)const { - for (size_t i = 0; i < nodes.size(); i++) - utils::misc::bufferNodeResponseVec3r(i, m_ndim, nodes[i]->getUnbalancedLoadIncInertia(), buffer); - } + class ResultRecorderUnbalancedForce : public ResultRecorder + { + public: + ResultRecorderUnbalancedForce(const mpco::ProcessInfo& info) + : ResultRecorder(info) + { + std::stringstream ss_buffer; + ss_buffer << "MODEL_STAGE[" << info.current_model_stage_id << "]/RESULTS/ON_NODES/UNBALANCED_FORCE"; + m_result_name = ss_buffer.str(); + m_result_display_name = "Unbalanced Force"; + m_num_components = 0; + if (m_ndim == 1) { + m_components_name = "Fx"; + m_num_components = 1; + m_result_data_type = mpco::ResultDataType::Scalar; + } + else if (m_ndim == 2) { + m_components_name = "Fx,Fy"; + m_num_components = 2; + m_result_data_type = mpco::ResultDataType::Vectorial; + } + else if (m_ndim == 3) { + m_components_name = "Fx,Fy,Fz"; + m_num_components = 3; + m_result_data_type = mpco::ResultDataType::Vectorial; + } + m_dimension = "F"; + m_description = "Nodal unbalanced force field"; + m_result_type = mpco::ResultType::Generic; + } + protected: + virtual void bufferResponse(mpco::ProcessInfo& info, std::vector& nodes, std::vector& buffer)const { + for (size_t i = 0; i < nodes.size(); i++) + utils::misc::bufferNodeResponseVec3u(i, m_ndim, nodes[i]->getUnbalancedLoad(), buffer); + } + }; + + class ResultRecorderUnbalancedMoment : public ResultRecorder + { + public: + ResultRecorderUnbalancedMoment(const mpco::ProcessInfo& info) + : ResultRecorder(info) + { + std::stringstream ss_buffer; + ss_buffer << "MODEL_STAGE[" << info.current_model_stage_id << "]/RESULTS/ON_NODES/UNBALANCED_MOMENT"; + m_result_name = ss_buffer.str(); + m_result_display_name = "Unbalanced Moment"; + m_num_components = 0; + if (m_ndim == 2) { + m_components_name = "Mz"; + m_num_components = 1; + m_result_data_type = mpco::ResultDataType::Scalar; + } + else { + m_components_name = "Mx,My,Mz"; + m_num_components = 3; + m_result_data_type = mpco::ResultDataType::Vectorial; + } + m_dimension = "F*L"; + m_description = "Nodal unbalanced moment field"; + m_result_type = mpco::ResultType::Generic; + } + protected: + virtual void bufferResponse(mpco::ProcessInfo& info, std::vector& nodes, std::vector& buffer)const { + for (size_t i = 0; i < nodes.size(); i++) + utils::misc::bufferNodeResponseVec3r(i, m_ndim, nodes[i]->getUnbalancedLoad(), buffer); + } + }; + + class ResultRecorderUnbalancedForceIncIntertia : public ResultRecorderUnbalancedForce + { + public: + ResultRecorderUnbalancedForceIncIntertia(const mpco::ProcessInfo& info) + : ResultRecorderUnbalancedForce(info) + { + std::stringstream ss_buffer; + ss_buffer << "MODEL_STAGE[" << info.current_model_stage_id << "]/RESULTS/ON_NODES/UNBALANCED_FORCE_INCLUDING_INERTIA"; + m_result_name = ss_buffer.str(); + m_result_display_name = "Unbalanced Force Including Inertia"; + m_description = "Nodal unbalanced force field including inertia"; + } + protected: + virtual void bufferResponse(mpco::ProcessInfo& info, std::vector& nodes, std::vector& buffer)const { + for (size_t i = 0; i < nodes.size(); i++) + utils::misc::bufferNodeResponseVec3u(i, m_ndim, nodes[i]->getUnbalancedLoadIncInertia(), buffer); + } + }; + + class ResultRecorderUnbalancedMomentIncIntertia : public ResultRecorderUnbalancedMoment + { + public: + ResultRecorderUnbalancedMomentIncIntertia(const mpco::ProcessInfo& info) + : ResultRecorderUnbalancedMoment(info) + { + std::stringstream ss_buffer; + ss_buffer << "MODEL_STAGE[" << info.current_model_stage_id << "]/RESULTS/ON_NODES/UNBALANCED_MOMENT_INCLUDING_INERTIA"; + m_result_name = ss_buffer.str(); + m_result_display_name = "Unbalanced Moment Including Inertia"; + m_description = "Nodal unbalanced moment field including inertia"; + } + protected: + virtual void bufferResponse(mpco::ProcessInfo& info, std::vector& nodes, std::vector& buffer)const { + for (size_t i = 0; i < nodes.size(); i++) + utils::misc::bufferNodeResponseVec3r(i, m_ndim, nodes[i]->getUnbalancedLoadIncInertia(), buffer); + } }; class ResultRecorderVelocity : public ResultRecorder @@ -4570,28 +4570,28 @@ int MPCORecorder::record(int commitTag, double timeStamp) */ auto lambdaHasDomainChanged = [this]() -> int { int new_stamp = m_data->info.domain->hasDomainChanged(); -#if defined(_PARALLEL_PROCESSING) +#if defined(_PARALLEL_PROCESSING) int pid = 0; int np = 1; MPI_Comm_rank(MPI_COMM_WORLD, &pid); - MPI_Comm_size(MPI_COMM_WORLD, &np); - // quick return for 1 process - if (np == 1) { - return new_stamp; - } - // if the model has not been partitioned, the recorder is only on P0! - // return otherwise the MPI_Allreduce will hang... - if (pid == 0 && !OPS_PARTITIONED) { - return new_stamp; - } - // get the maximum domain change stamp from all processes + MPI_Comm_size(MPI_COMM_WORLD, &np); + // quick return for 1 process + if (np == 1) { + return new_stamp; + } + // if the model has not been partitioned, the recorder is only on P0! + // return otherwise the MPI_Allreduce will hang... + if (pid == 0 && !OPS_PARTITIONED) { + return new_stamp; + } + // get the maximum domain change stamp from all processes int new_stamp_max = 0; if (MPI_Allreduce(&new_stamp, &new_stamp_max, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD) != MPI_SUCCESS) { opserr << "MPCORecorder::lambdaHasDomainChanged() Warning: MPI_Reduce failed to get max domain changed stamp\n"; return new_stamp; - } - new_stamp = new_stamp_max; -#endif // defined(_PARALLEL_PROCESSING) + } + new_stamp = new_stamp_max; +#endif // defined(_PARALLEL_PROCESSING) return new_stamp; }; bool rebuild_model = false; @@ -6720,7 +6720,7 @@ void* OPS_MPCORecorder() curr_opt = utils::parsing::opt_region; if (numdata > 0) { int region_tag = 0; - if (OPS_GetInt(&one_item, ®ion_tag) != 0) { + if (OPS_GetIntInput(&one_item, ®ion_tag) != 0) { opserr << "MPCORecorder error: option -R (region) requires an extra parameter (int) for the region tag. (cannot get int value)\n"; return 0; } @@ -6812,7 +6812,7 @@ void* OPS_MPCORecorder() } if (numdata > 0) { int grad_index; - if (OPS_GetInt(&one_item, &grad_index) != 0) { + if (OPS_GetIntInput(&one_item, &grad_index) != 0) { opserr << "MPCORecorder error: option -NS requires an extra parameter (int) for the sensitivity parameter index. (cannot get int value)\n"; return 0; } @@ -6837,7 +6837,7 @@ void* OPS_MPCORecorder() output_freq.type = mpco::OutputFrequency::DeltaTime; output_freq.nsteps = 1; if (numdata > 0) { - if (OPS_GetDouble(&one_item, &output_freq.dt) != 0) { + if (OPS_GetDoubleInput(&one_item, &output_freq.dt) != 0) { opserr << "MPCORecorder error: invalid double argument for the delta time\n"; return 0; } @@ -6853,7 +6853,7 @@ void* OPS_MPCORecorder() output_freq.type = mpco::OutputFrequency::NumberOfSteps; output_freq.dt = 0.0; if (numdata > 0) { - if (OPS_GetInt(&one_item, &output_freq.nsteps) != 0) { + if (OPS_GetIntInput(&one_item, &output_freq.nsteps) != 0) { opserr << "MPCORecorder error: invalid int argument for the number of steps\n"; return 0; } diff --git a/SRC/recorder/VTK_Recorder.cpp b/SRC/recorder/VTK_Recorder.cpp index 533d458035..715d1efa8e 100644 --- a/SRC/recorder/VTK_Recorder.cpp +++ b/SRC/recorder/VTK_Recorder.cpp @@ -908,7 +908,7 @@ VTK_Recorder::sendSelf(int commitTag, Channel &theChannel) static ID idData(2+14+1); int fileNameLength = 0; if (name != 0) - fileNameLength = strlen(name); + fileNameLength = (int)strlen(name); idData(0) = fileNameLength; idData(1) = -sendSelfCount; // -sendSelfCount indicates a process other than P0