Skip to content

Commit

Permalink
replace GetInt with GetIntInput and GetDouble with GetDoubleInput
Browse files Browse the repository at this point in the history
  • Loading branch information
aschellenberg74 committed Oct 29, 2024
1 parent ff9c709 commit 29c682c
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 128 deletions.
254 changes: 127 additions & 127 deletions SRC/recorder/MPCORecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ while opensees is writing data. Warning: this is a new feature in hdf5 version 1
#include <stdint.h>

// for parallel
#ifdef _PARALLEL_PROCESSING
extern bool OPS_PARTITIONED;
#include <mpi.h>
#ifdef _PARALLEL_PROCESSING
extern bool OPS_PARTITIONED;
#include <mpi.h>
#endif // _PARALLEL_PROCESSING

/*************************************************************************************
Expand Down Expand Up @@ -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<Node*>& nodes, std::vector<double>& 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<Node*>& nodes, std::vector<double>& 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<Node*>& nodes, std::vector<double>& 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<Node*>& nodes, std::vector<double>& 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<Node*>& nodes, std::vector<double>& 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<Node*>& nodes, std::vector<double>& 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<Node*>& nodes, std::vector<double>& 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<Node*>& nodes, std::vector<double>& 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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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, &region_tag) != 0) {
if (OPS_GetIntInput(&one_item, &region_tag) != 0) {
opserr << "MPCORecorder error: option -R (region) requires an extra parameter (int) for the region tag. (cannot get int value)\n";
return 0;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion SRC/recorder/VTK_Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29c682c

Please sign in to comment.