void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
- //
+ if(!arr || !arr->isAllocated())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
_field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
*/
void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
+ if(!field)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
+ if(!arrOfVals || !arrOfVals->isAllocated())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
TypeOfField type=field->getTypeOfField();
- int start=copyTinyInfoFrom(field,arrOfVals);
std::vector<DataArrayInt *> idsInPflPerType;
std::vector<DataArrayInt *> idsPerType;
std::vector<int> code,code2;
if(type!=ON_NODES)
{
m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
+ std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
+ // start of check
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
+ if(type==ON_GAUSS_NE)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
+ field2->setMesh(mPart);
+ }
+ int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
+ if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ // end of check
+ int start=copyTinyInfoFrom(field,arrOfVals);
code2=m->getDistributionOfTypes();
//
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
- for(std::size_t i=0;i<idsInPflPerType.size();i++)
- idsInPflPerType2[i]=idsInPflPerType[i];
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
- for(std::size_t i=0;i<idsPerType.size();i++)
- idsPerType2[i]=idsPerType[i];
- //
int pos=addNewEntryIfNecessary(m);
_field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
}
else
{
+ if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
+ std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
+ std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
+ int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
+ if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int start=copyTinyInfoFrom(field,arrOfVals);
int pos=addNewEntryIfNecessary(m);
_field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
}
}
/*!
- * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
- * of a given mesh are used as the support of the given field (a real support is not used).
- * Elements of the given mesh must be sorted suitable for writing to MED file.
- * Order of underlying mesh entities of the given field specified by \a profile parameter
- * is not prescribed; this method permutes field values to have them sorted by element
- * type as required for writing to MED file. A new profile is added only if no equal
- * profile is missing.
+ * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
+ * can be an aggregation of several MEDCouplingFieldDouble instances.
+ * The mesh support of input parameter \a field is ignored here, it can be NULL.
+ * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
+ * and \a profile.
+ *
+ * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
+ * A new profile is added only if no equal profile is missing.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] field - the field to add to \a this.
+ * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
* \param [in] mesh - the supporting mesh of \a field.
- * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
+ * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
* \param [in] profile - ids of mesh entities on which corresponding field values lie.
* \throw If either \a field or \a mesh or \a profile has an empty name.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
}
/*!
- * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
- * of a given mesh are used as the support of the given field (a real support is not used).
- * Elements of the given mesh must be sorted suitable for writing to MED file.
- * Order of underlying mesh entities of the given field specified by \a profile parameter
- * is not prescribed; this method permutes field values to have them sorted by element
- * type as required for writing to MED file. A new profile is added only if no equal
- * profile is missing.
+ * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
+ * can be an aggregation of several MEDCouplingFieldDouble instances.
+ * The mesh support of input parameter \a field is ignored here, it can be NULL.
+ * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
+ * and \a profile.
+ *
+ * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
+ * A new profile is added only if no equal profile is missing.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] field - the field to add to \a this. The field double values are ignored.
+ * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
* \param [in] arrOfVals - the values of the field \a field used.
* \param [in] mesh - the supporting mesh of \a field.
- * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
+ * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
* \param [in] profile - ids of mesh entities on which corresponding field values lie.
* \throw If either \a field or \a mesh or \a profile has an empty name.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
}
/*!
- * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
- * a given dimension of a given mesh are used as the support of the given field.
- * Elements of the given mesh must be sorted suitable for writing to MED file.
- * Order of underlying mesh entities of the given field specified by \a profile parameter
- * is not prescribed; this method permutes field values to have them sorted by element
- * type as required for writing to MED file.
+ * Adds a MEDCouplingFieldDouble to \a this as another time step.
+ * The mesh support of input parameter \a field is ignored here, it can be NULL.
+ * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
+ * and \a profile.
+ *
+ * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
+ * A new profile is added only if no equal profile is missing.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] field - the field to add to \a this.
+ * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
* \param [in] mesh - the supporting mesh of \a field.
- * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
+ * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
* \param [in] profile - ids of mesh entities on which corresponding field values lie.
* \throw If either \a field or \a mesh or \a profile has an empty name.
- * \throw If existing time steps have different name or number of components than \a field.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
* \throw If the data array of \a field is not set.
+ * \throw If the data array of \a this is already allocated but has different number of
+ * components than \a field.
* \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
+ * \sa setFieldNoProfileSBT()
*/
void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
- * a given dimension of a given mesh are used as the support of the given field.
- * Elements of the given mesh must be sorted suitable for writing to MED file.
- * Order of underlying mesh entities of the given field specified by \a profile parameter
- * is not prescribed; this method permutes field values to have them sorted by element
- * type as required for writing to MED file.
+ * Adds a MEDCouplingFieldDouble to \a this as another time step.
+ * The mesh support of input parameter \a field is ignored here, it can be NULL.
+ * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
+ * and \a profile.
+ *
+ * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
+ * A new profile is added only if no equal profile is missing.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] field - the field to add to \a this.
+ * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
+ * \param [in] arrOfVals - the values of the field \a field used.
* \param [in] mesh - the supporting mesh of \a field.
- * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
+ * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
* \param [in] profile - ids of mesh entities on which corresponding field values lie.
* \throw If either \a field or \a mesh or \a profile has an empty name.
- * \throw If existing time steps have different name or number of components than \a field.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
* \throw If the data array of \a field is not set.
+ * \throw If the data array of \a this is already allocated but has different number of
+ * components than \a field.
* \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
+ * \sa setFieldNoProfileSBT()
*/
void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
{