本文整理汇总了C++中ArrayT::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayT::Length方法的具体用法?C++ ArrayT::Length怎么用?C++ ArrayT::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayT
的用法示例。
在下文中一共展示了ArrayT::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WaitReceive
/* return the index the next receive */
void CommunicatorT::WaitReceive(const ArrayT<MPI_Request>& requests, int& index, int& source) const
{
const char caller[] = "CommunicatorT::WaitReceive";
Log(kModerate, caller, "waiting for 1 of %d", requests.Length());
index = source = -1;
#ifdef __TAHOE_MPI__
/* grab completed receive */
MPI_Status status;
int ret = MPI_Waitany(requests.Length(), (MPI_Request*) requests.Pointer(), &index, &status);
#ifdef CHECK_MPI_RETURN
if (ret != MPI_SUCCESS) Log(kFail, caller, "MPI_Waitany failed");
#endif
#ifdef CHECK_MPI_STATUS
if (status.MPI_ERROR != MPI_SUCCESS) Log(kFail, caller, "bad status: %d", status.MPI_ERROR);
#endif
source = status.MPI_SOURCE;
#endif
Log(kModerate, caller, "received request at index %d from %d", index, source);
}
示例2: FreeRequests
/* free any uncompleted requests */
void CommunicatorT::FreeRequests(ArrayT<MPI_Request>& requests) const
{
#ifdef __TAHOE_MPI__
const char caller[] = "CommunicatorT::FreeRequests";
/* free any uncompleted receive requests */
for (int i = 0; i < requests.Length(); i++)
if (requests[i] != MPI_REQUEST_NULL)
{
Log(kLow, "caller", "cancelling request %d/%d", i+1, requests.Length());
/* cancel request */
MPI_Cancel(&requests[i]);
MPI_Status status;
MPI_Wait(&requests[i], &status);
int flag;
MPI_Test_cancelled(&status, &flag);
if (flag )
Log(kLow, "caller", "cancelling request %d/%d: DONE", i+1, requests.Length());
else
Log(kLow, "caller", "cancelling request %d/%d: FAIL", i+1, requests.Length());
}
#else
#pragma unused(requests)
#endif
}
示例3: WaitSends
/* block until all sends posted with CommunicatorT::PostSend have completed */
void CommunicatorT::WaitSends(const ArrayT<MPI_Request>& requests)
{
const char caller[] = "CommunicatorT::WaitSends";
Log(kModerate, caller, "waiting for 1 of %d", requests.Length());
/* complete all sends */
for (int i = 0; i < requests.Length(); i++)
{
int index = -1;
#ifdef __TAHOE_MPI__
/* grab completed receive */
MPI_Status status;
int ret = MPI_Waitany(requests.Length(), (MPI_Request*) requests.Pointer(), &index, &status);
#ifdef CHECK_MPI_RETURN
if (ret != MPI_SUCCESS) Log(kFail, caller, "MPI_Waitany failed");
#endif
#ifdef CHECK_MPI_STATUS
if (status.MPI_ERROR != MPI_SUCCESS) {
WriteStatus(Log(), caller, status);
Log(kFail, caller, "bad status: %d", status.MPI_ERROR);
}
#endif
#endif
Log(kLow, caller, "completing send at index %d", index);
}
}
示例4: SetActiveElementGroupMask
/* change the number of active element groups */
void ElementListT::SetActiveElementGroupMask(const ArrayT<bool>& mask)
{
/* first time */
if (fAllElementGroups.Length() == 0)
{
/* cache all pointers */
fAllElementGroups.Dimension(Length());
for (int i = 0; i < fAllElementGroups.Length(); i++)
{
ElementBaseT* element = (*this)[i];
fAllElementGroups[i] = element;
}
}
/* check */
if (mask.Length() != fAllElementGroups.Length())
ExceptionT::SizeMismatch("ElementListT::SetActiveElementGroupMask",
"expecting mask length %d not %d", fAllElementGroups.Length(), mask.Length());
/* reset active element groups */
int num_active = 0;
for (int i = 0; i < mask.Length(); i++)
if (mask[i])
num_active++;
/* cast this to an ArrayT */
ArrayT<ElementBaseT*>& element_list = *this;
element_list.Dimension(num_active);
num_active = 0;
for (int i = 0; i < mask.Length(); i++)
if (mask[i])
element_list[num_active++] = fAllElementGroups[i];
}
示例5: if
void Quad2Tri::BackSlashSideSets (ArrayT<iArray2DT>& sidesets)
{
fSideSetData.Allocate (sidesets.Length());
for (int s=0; s < sidesets.Length(); s++)
{
fSideSetData[s].Allocate (sidesets[s].MajorDim(), 2);
fSideSetData[s] = 0;
int *e = sidesets[s].Pointer();
int *f = sidesets[s].Pointer(1);
int *enew = fSideSetData[s].Pointer();
int *fnew = fSideSetData[s].Pointer(1);
for (int i=0; i < sidesets[s].MajorDim(); i++)
{
*enew = *e * 2;
if (*f == 1 || *f == 2)
{
*enew += 1;
*fnew = *f - 1;
}
else if (*f == 0) *fnew = 1;
else *fnew = 0;
e += 2;
f += 2;
enew += 2;
fnew += 2;
}
}
}
示例6: NumStateVariables
/* initialize the state variable array */
void MR_RP2DT::InitStateVariables(ArrayT<double>& state)
{
int num_state = NumStateVariables();
if (state.Length() != num_state) {
#ifndef _SIERRA_TEST_
cout << "\n SurfacePotentialT::InitStateVariables: expecting state variable array\n"
<< " length " << num_state << ", found length " << state.Length() << endl;
#endif
throw ExceptionT::kSizeMismatch;
}
/* clear */
if (num_state > 0) state = 0.0;
/* Initializing internal state variables */
double enp = state[14];
double esp = state[15];
double fchi = fchi_r + (fchi_p - fchi_r)*exp(-falpha_chi*enp);
double fc = fc_r + (fc_p - fc_r)*exp(-falpha_c*esp);
double ftan_phi = tan(fphi_r) + (tan(fphi_p) - tan(fphi_r))*exp(-falpha_phi*esp);
double ftan_psi = (tan(fpsi_p))*exp(-falpha_psi*esp);
state[6] = fchi;
state[7] = fc ;
state[8] = ftan_phi;
state[9] = ftan_psi;
state[13] = 0.;
state[nTiedFlag] = kTiedNode;
}
示例7: DefineElements
/* echo element connectivity data */
void SCNIMFT::DefineElements(const ArrayT<StringT>& block_ID, const ArrayT<int>& mat_index)
{
const char caller[] = "SCNIMFT::DefineElements";
//TEMP
if (block_ID.Length() > 1)
ExceptionT::GeneralFail(caller, "mutliple block ID's not supported %d",
block_ID.Length());
/* access to the model database */
ModelManagerT& model = ElementSupport().ModelManager();
fElementConnectivities.Dimension(1);
// NB THIS IS SPECIALIZED TO ONLY ONE ELEMENT BLOCK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
model.ReadConnectivity(block_ID[0]);
/* set pointer to connectivity list */
fElementConnectivities[0] = model.ElementGroupPointer(block_ID[0]);
// Get nodal coordinates
int nsd = NumSD();
fNodalCoordinates.Dimension(fNodes.Length(), nsd);
fNodalCoordinates.RowCollect(fNodes, model.Coordinates());
/* set up element cards for state variable storage */
fElementCards.Dimension(fNodes.Length()); /* one card per node */
for (int i = 0; i < fElementCards.Length(); i++)
fElementCards[i].SetMaterialNumber(mat_index[0]);
fCellGeometry->DefineElements(block_ID, mat_index);
}
示例8: AddNodeSet
void NodeManagerPrimitive::AddNodeSet (const StringT& setID, const ArrayT<int>& nodes, CSEConstants::NodeMapMethodT transfermethod)
{
int dex;
fNodeSetID.HasValue (setID, dex);
if (dex > -1)
{
int num = nodes.Length();
int length = fNodeSetData[dex].Length();
fNodeSetData[dex].Resize (length + num, CSEConstants::kNotSet);
fNodeSetData[dex].CopyPart (length, nodes, 0, num);
RemoveRepeats (fNodeSetData[dex]);
out << " Added to Node Set. . . . . . . . . . = "
<< setID << '\n' << endl;
}
else
{
int length = fNodeSetID.Length();
fNodeSetData.Resize (length + 1);
fNodeSetID.Resize (length + 1, "");
fNodeSetData[length].Allocate (nodes.Length());
fNodeSetData[length].CopyPart (0, nodes, 0, nodes.Length());
fNodeSetID[length] = setID;
int ml = fTransMethods.Length();
fTransMethods.Resize (ml + 1, transfermethod);
out << " Added Node Set . . . . . . . . . . . = "
<< setID << '\n' << endl;
}
}
示例9: ElementSupport
void MFPenaltyContact2DT::ComputeStrikerCoordinates(const ArrayT<int>& strikers)
{
/* dimension */
fStrikerCoords_man.SetMajorDimension(strikers.Length(), false);
/* current striker coords */
if (strikers.Length() > 0) {
/* reconstruct displacement field */
if (fSCNI) {
fSCNI_tmp = strikers;
if (!fSCNI->GlobalToLocalNumbering(fSCNI_tmp))
ExceptionT::GeneralFail("MFPenaltyContact2DT::ComputeStrikerCoordinates",
"SCNI global->local failed");
fSCNI->InterpolatedFieldAtNodes(fSCNI_tmp, fStrikerCoords);
}
else {
iArrayT tmp;
tmp.Alias(strikers);
fElementGroup->NodalDOFs(tmp, fStrikerCoords);
}
/* compute current coordinates */
const dArray2DT& init_coords = ElementSupport().InitialCoordinates();
for (int i = 0; i < strikers.Length(); i++)
fStrikerCoords.AddToRowScaled(i, 1.0, init_coords(strikers[i]));
}
}
示例10: ElementGroupNames
void TextInputT::ElementGroupNames (ArrayT<StringT>& groupnames) const
{
if (groupnames.Length() != fBlockID.Length()) throw ExceptionT::kSizeMismatch;
for (int i=0; i < groupnames.Length(); i++)
{
groupnames[i] = fBlockID[i];
}
}
示例11: Assemble
/* assemble the element contribution */
void PSPASESMatrixT::Assemble(const ElementMatrixT& elMat, const ArrayT<int>& eqnos)
{
const char caller[] = "PSPASESMatrixT::Assemble";
/* element matrix format */
ElementMatrixT::FormatT format = elMat.Format();
/* two cases: element matrix is diagonal, or it's not. */
int end_update = fStartEQ + fLocNumEQ - 1;
if (format == ElementMatrixT::kDiagonal)
{
/* diagonal entries only */
const double *pelMat = elMat.Pointer();
int inc = elMat.Rows() + 1; /* offset between diag entries are */
int nee = eqnos.Length();
for (int i = 0; i < nee; ++i) {
int eq = eqnos[i];
if (eq >= fStartEQ && eq <= end_update) /* active eqn */ {
eq--;
double* a = (*this)(eq,eq);
if (a)
*a += *pelMat;
else
ExceptionT::OutOfRange(caller);
}
pelMat += inc;
}
}
else if (format == ElementMatrixT::kNonSymmetric ||
format == ElementMatrixT::kSymmetric ||
format == ElementMatrixT::kSymmetricUpper )
{
/* fill matrix */
if (format != ElementMatrixT::kNonSymmetric)
elMat.CopySymmetric();
int nee = eqnos.Length(); // number of equations for element
for (int col = 0; col < nee; ++col)
{
int ceqno = eqnos[col] - 1;
if (ceqno > -1) /* active eqn */ {
for (int row = 0; row < nee; ++row) {
int reqno = eqnos[row];
if (reqno >= fStartEQ && reqno <= end_update) /* active eqn */ {
reqno--;
double* a = (*this)(reqno,ceqno);
if (a)
*a += 0.5*(elMat(row,col) + elMat(col,row));
else
ExceptionT::OutOfRange(caller);
}
}
}
}
}
else
ExceptionT::GeneralFail(caller, "unsupported element matrix format %d", format);
}
示例12: Collect
/* collect subset */
void LocalArrayT::Collect(const ArrayT<int>& nodes, const LocalArrayT& source)
{
#if __option(extended_errorcheck)
if (nodes.Length() != fNumNodes || source.fMinorDim != fMinorDim)
ExceptionT::SizeMismatch("LocalArrayT::Collect");
#endif
for (int j = 0; j < fMinorDim; j++)
for (int i = 0; i < nodes.Length(); i++)
(*this)(i,j) = source(nodes[i],j);
}
示例13: Same
/* return true if all values are the same */
bool MessageT::Same(const ArrayT<int>& a) const
{
if (a.Length() == 0)
return true;
else
{
int i = a[0];
for (int j = 1; j < a.Length(); j++)
if (a[j] != i)
return false;
return true;
}
}
示例14: Assemble
void DiagonalMatrixT::Assemble(const ElementMatrixT& elMat, const ArrayT<int>& row_eqnos,
const ArrayT<int>& col_eqnos)
{
/* pick out diagonal values */
for (int row = 0; row < row_eqnos.Length(); row++)
for (int col = 0; col < col_eqnos.Length(); col++)
if (row_eqnos[row] == col_eqnos[col])
{
int eqno = row_eqnos[row] - 1;
if (eqno > -1)
fMatrix[eqno] += elMat(row, col);
}
}
示例15: RegisterOutput
int ElementSupportT::RegisterOutput(ArrayT<StringT>& n_labels,
ArrayT<StringT>& e_labels)
{
/* copy labels */
fNodeOutputLabels.Dimension(n_labels.Length());
for (int i = 0; i < fNodeOutputLabels.Length(); i++)
fNodeOutputLabels[i] = n_labels[i];
fElemOutputLabels.Dimension(e_labels.Length());
for (int i = 0; i < fElemOutputLabels.Length(); i++)
fElemOutputLabels[i] = e_labels[i];
return 0;
}