24 #ifndef MEDTFIELDINFO_H 25 #define MEDTFIELDINFO_H 27 #include "MEDFieldInfo.h" 28 #include "xc_basic/src/med_xc/MEDMEM_ArrayInterface.hxx" 29 #include "xc_basic/src/med_xc/MEDMEM_Field.hxx" 30 #include "MEDGaussModel.h" 31 #include "preprocessor/set_mgmt/Set.h" 32 #include "domain/mesh/element/Element.h" 45 typedef typename MEDMEM::MEDMEM_ArrayInterface<T,MEDMEM::FullInterlace,MEDMEM::Gauss>::Array ArrayGauss;
46 typedef typename MEDMEM::FIELD<T> TipoCampo;
49 bool has_gauss_points;
51 void alloc(
void)
const;
64 void setValueIJK(
int i,
int j,
int k,
int t,
const T &valor);
66 void write(
const std::string &)
const;
97 const int nc= getXCFieldInfo().getNumberOfComponents();
100 MEDMEM::GROUP *grupo= getGrupoMED();
102 campo=
new MEDMEM::FIELD<T>(grupo,nc);
105 std::cerr <<
"El campo: '" << getXCFieldInfo().GetNombre()
106 <<
"' tiene 0 componentes; se ignora." << std::endl;
113 ArrayGauss *retval=
nullptr;
114 const int numberOfComponents= getXCFieldInfo().getNumberOfComponents();
117 std::vector<int> numberOfElementsOfTypeC(numberOfTypes+1,0);
118 std::vector<int> numberOfGaussPoint(numberOfTypes+1,1);
119 numberOfElementsOfTypeC[0]= 1;
120 numberOfGaussPoint[0]= 1;
122 for(MEDMapNumCeldasPorTipo::const_iterator i= cell_types.begin();i!=cell_types.end();i++,conta++)
124 const MED_EN::medGeometryElement tipo= i->first;
125 numberOfElementsOfTypeC[conta]= i->second+numberOfElementsOfTypeC[conta-1];
126 numberOfGaussPoint[conta]=
campo->getGaussLocalization(tipo).getNbGauss();
128 retval=
new ArrayGauss(numberOfComponents,numberOfElementsOfTypeC[numberOfTypes]-1,numberOfTypes, &numberOfElementsOfTypeC[0], &numberOfGaussPoint[0]);
136 if(valor.size()!=dim)
137 std::cerr <<
"The property: '" << nmb_prop
138 <<
"' returns a vector with dimension: " 139 << valor.size() <<
"; a vector of dimension " 140 << dim <<
" was expected" << std::endl;
148 const MEDGaussModel::med_gauss_model *model= gm.getGaussModelMED();
151 has_gauss_points=
true;
158 const DqPtrsElem &elements=
set.getElements();
159 std::set<std::string> nombres;
160 for(DqPtrsElem::const_iterator j= elements.begin();j!=elements.end();j++)
164 if(nombres.find(nmb)==nombres.end())
178 const int nc= getXCFieldInfo().getNumberOfComponents();
180 std::cerr <<
"j index: " << j
181 <<
" out of range (1," << nc
182 <<
").\n" << std::endl;
185 std::cerr <<
"i index: " << i
186 <<
" out of range (1," << ne
187 <<
").\n" << std::endl;
189 campo->setValueIJ(i,j,valor);
196 const int nc= getXCFieldInfo().getNumberOfComponents();
198 std::cerr <<
"j index: " << j
199 <<
" out of range (1," << nc
200 <<
").\n" << std::endl;
203 std::cerr <<
"i index: " << i
204 <<
" out of range (1," << ne
205 <<
").\n" << std::endl;
207 const int num_ptos_gauss=
campo->getNumberOfGaussPoints(t);
209 std::cerr <<
"k index: " << k
210 <<
" out of range (1," << num_ptos_gauss
211 <<
").\n" << std::endl;
212 campo->setValueIJK(i,j,k,valor);
220 campo->setName(getXCFieldInfo().GetNombre());
222 campo->setComponentsNames(getComponentNamesPtr());
223 campo->setComponentsDescriptions(getComponentDescriptionsPtr());
224 campo->setMEDComponentsUnits(getComponentUnitsPtr());
226 campo->setIterationNumber(getXCFieldInfo().getIterationNumber());
227 campo->setOrderNumber(getXCFieldInfo().getOrderNumber());
228 campo->setTime(getXCFieldInfo().getTime());
236 campo->write(MEDMEM::MED_DRIVER,filename.c_str());
238 std::cerr <<
"the pointer al campo es nulo." << std::endl;
TipoCampo * campo
Field definition in MEDMEM.
Definition: MEDTFieldInfo.h:48
Information about a field defined over a set.
Definition: FieldInfo.h:39
void to_med(void) const
Dumps the field definition into MEDMEM.
Definition: MEDTFieldInfo.h:217
Information about node and element sets.
Definition: MEDGroupInfo.h:36
void setValueIJ(int i, int j, const T &valor)
Value of the field at indexes i,j.
Definition: MEDTFieldInfo.h:176
void libera(void) const
Frees memory (and erases the field definition).
Definition: MEDTFieldInfo.h:83
~MEDTFieldInfo(void)
Destructor.
Definition: MEDTFieldInfo.h:78
Information about Gauss model.
Definition: MEDGaussModel.h:38
void alloc(void) const
Creates MEDMEM field definition.
Definition: MEDTFieldInfo.h:94
const std::string & getNombre(void) const
Returns the nombre del model.
Definition: MEDGaussModel.cc:70
const MEDGroupInfo & getGrupo(void) const
Returns the group over which the field is defined.
Definition: MEDFieldInfo.cc:38
ArrayGauss * getArrayGauss(void) const
Crea la matriz para los valores del campo en los puntos de Gauss.
Definition: MEDTFieldInfo.h:111
Number of cells de cada tipo.
Definition: MEDMapNumCeldasPorTipo.h:36
void write(const std::string &) const
Escribe el campo en el archivo cuyo nombre being passed as parameter.
Definition: MEDTFieldInfo.h:233
Pointer to element container.
Definition: DqPtrsElem.h:45
void defineGaussModels(const Set &)
Sets the Gauss integration model for the elements in the set.
Definition: MEDTFieldInfo.h:156
static void checkVectorDimension(const std::string &, const std::vector< T > &, const size_t &)
Checks vector dimension.
Definition: MEDTFieldInfo.h:134
const MED_EN::medGeometryElement & getTipo(void) const
Returns the element type the model.
Definition: MEDGaussModel.cc:74
Iformation about a field defined over a mesh subset.
Definition: MEDTFieldInfo.h:42
Information about a field defined over a mesh subset.
Definition: MEDFieldInfo.h:38
Object set.
Definition: Set.h:63
size_t getNumberOfElements(void) const
Returns the number of elements.
Definition: MEDCellBaseInfo.cc:28
size_t getNumberOfTypes(void) const
Returns the number of cell types.
Definition: MEDMapNumCeldasPorTipo.cc:42
================================================================================
Definition: ContinuaReprComponent.h:34
void setValueIJK(int i, int j, int k, int t, const T &valor)
Value of the field at indexes i,j y k (punto de Gauss).
Definition: MEDTFieldInfo.h:194