80 int edges, trias, quads, tetras, pyrams, wedges, hexas;
81 IntArray edgeIdArray, triaIdArray, quadIdArray, tetraIdArray, pyramIdArray, wedgeIdArray, hexaIdArray;
82 bool tri_tetra =
false;
85 edges = trias = quads = tetras = pyrams = wedges = hexas = 0;
86 for (
int i = 1; i <= nelem; i++ ) {
121 edgeIdArray.
resize(edges);
122 triaIdArray.
resize(trias);
123 quadIdArray.
resize(quads);
124 tetraIdArray.
resize(tetras);
125 pyramIdArray.
resize(pyrams);
126 wedgeIdArray.
resize(wedges);
127 hexaIdArray.
resize(hexas);
129 edges = trias = quads = tetras = pyrams = wedges = hexas = 0;
130 for (
int i = 1; i <= nelem; i++ ) {
137 edgeIdArray.
at(++edges) = i;
141 triaIdArray.
at(++trias) = i;
145 quadIdArray.
at(++quads) = i;
149 tetraIdArray.
at(++tetras) = i;
153 wedgeIdArray.
at(++wedges) = i;
157 hexaIdArray.
at(++hexas) = i;
164 if ( quads + hexas + pyrams + wedges == 0 ) {
174 outputStrem = fopen(fileName,
"w");
175 if ( tri_tetra ==
true ) {
176 fprintf(outputStrem,
"3 1 -1\n");
177 fprintf(outputStrem,
"%d %d %d %d\n", nnodes, edges, trias, tetras);
179 fprintf(outputStrem,
"7 1 -1\n");
180 fprintf(outputStrem,
"%d %d %d %d %d %d %d %d\n", nnodes, edges, trias, quads, tetras, pyrams, wedges, hexas);
184 for (
int i = 1; i <= nnodes; i++ ) {
195 for (
int i = 1; i <= edges; i++ ) {
197 fprintf(outputStrem,
"%d", i);
198 for (
int j = 1; j <= 2; j++ ) {
202 fprintf(outputStrem,
"\n");
207 for (
int i = 1; i <= trias; i++ ) {
209 fprintf(outputStrem,
"%d", i);
210 for (
int j = 1; j <= 3; j++ ) {
214 fprintf(outputStrem,
"\n");
219 for (
int i = 1; i <= quads; i++ ) {
221 fprintf(outputStrem,
"%d", i);
222 for (
int j = 1; j <= 4; j++ ) {
226 fprintf(outputStrem,
"\n");
231 for (
int i = 1; i <= tetras; i++ ) {
233 fprintf(outputStrem,
"%d", i);
234 for (
int j = 1; j <= 4; j++ ) {
238 fprintf(outputStrem,
"\n");
243 for (
int i = 1; i <= pyrams; i++ ) {
245 fprintf(outputStrem,
"%d", i);
246 for (
int j = 1; j <= 5; j++ ) {
250 fprintf(outputStrem,
"\n");
255 for (
int i = 1; i <= wedges; i++ ) {
257 fprintf(outputStrem,
"%d", i);
258 for (
int j = 1; j <= 6; j++ ) {
262 fprintf(outputStrem,
"\n");
267 for (
int i = 1; i <= hexas; i++ ) {
269 fprintf(outputStrem,
"%d", i);
270 for (
int j = 1; j <= 8; j++ ) {
274 fprintf(outputStrem,
"\n");
289T3DInterface :: t3d_2_OOFEM(
const char *t3dOutFile,
Domain **dNew)
291 std::ifstream inputStream;
292 inputStream.open( t3dOutFile );
293 if ( !inputStream.is_open() ) {
294 OOFEM_ERROR(
"OOFEMTXTDataReader::OOFEMTXTDataReader: Can't open T3D input stream (%s)", t3dOutFile);
298 ( * dNew ) =
new Domain( 2, this->
domain->giveSerialNumber() + 1, this->domain->giveEngngModel() );
299 ( * dNew )->setDomainType( this->
domain->giveDomainType() );
306 std::getline(inputStream, line);
308 char *currentLine =
new char[line.size() + 1];
309 std::strcpy ( currentLine, line.c_str() );
311 char *token = std::strtok(currentLine,
" ");
314 while (token !=
nullptr) {
325 token = std::strtok(
nullptr,
" ");
330 int nnodes = 0, ntriangles = 0, ntetras = 0;
339 std::getline(inputStream, line);
341 currentLine =
new char[line.size() + 1];
342 std::strcpy ( currentLine, line.c_str() );
344 token = std::strtok(currentLine,
" ");
347 while (token !=
nullptr) {
349 nnodes = atoi(token);
353 ntriangles = atoi(token);
355 ntetras = atoi(token);
358 token = std::strtok(
nullptr,
" ");
362 (*dNew)->resizeDofManagers(nnodes);
365 std::getline(inputStream, line);
368 const IntArray dofIDArrayPtr =
domain->giveDefaultNodeDofIDArry();
369 int ndofs = dofIDArrayPtr.
giveSize();
371 for (
int inode = 1; inode <= nnodes; inode++ ) {
373 std::getline(inputStream, line);
375 currentLine =
new char[line.size() + 1];
376 std::strcpy ( currentLine, line.c_str() );
378 token = std::strtok(currentLine,
" ");
381 while (token !=
nullptr) {
385 coords.
at(1) = atof(token);
387 coords.
at(2) = atof(token);
389 coords.
at(3) = atof(token);
392 token = std::strtok(NULL,
" ");
396 auto node = std::make_unique<Node>(inode, * dNew);
398 node->setNumberOfDofs(ndofs);
399 node->setCoordinates( coords );
407 std::getline(inputStream, line);
412 for (
int itriangle = 1; itriangle <= ntriangles; itriangle++) {
415 std::getline(inputStream, line);
417 currentLine =
new char[line.size() + 1];
418 std::strcpy ( currentLine, line.c_str() );
420 token = std::strtok(currentLine,
" ");
423 while (token !=
nullptr) {
425 elemNumber = atoi(token);
426 else if (i >= 1 && i<=4)
427 dofManagers.
at(i) = atoi(token);
430 token = std::strtok(
nullptr,
" ");
434 elem->setDofManagers( dofManagers );
445 for (
int itetra = 1; itetra <= ntetras; itetra++) {
448 std::getline(inputStream, line);
450 currentLine =
new char[line.size() + 1];
451 std::strcpy ( currentLine, line.c_str() );
453 token = std::strtok(currentLine,
" ");
456 while (token !=
nullptr) {
458 elemNumber = atoi(token);
459 else if (i >= 1 && i<=4)
460 dofManagers.
at(i) = atoi(token);
463 token = std::strtok(
nullptr,
" ");
467 auto elem =
classFactory.createElement(
"LTRSpace", elemNumber, * dNew);
468 elem->setDofManagers( dofManagers );
471 (*dNew)->setElement(elemNumber, std::move(elem));
478 int ncrosssect =
domain->giveNumberOfCrossSectionModels();
479 ( * dNew )->resizeCrossSectionModels(ncrosssect);
480 for (
int i = 1; i <= ncrosssect; i++ ) {
482 domain->giveCrossSection(i)->giveInputRecord(ir);
485 auto crossSection =
classFactory.createCrossSection(name.c_str(), i, * dNew);
486 crossSection->initializeFrom(ir);
487 ( * dNew )->setCrossSection(i, std::move(crossSection));
491 int nmat =
domain->giveNumberOfMaterialModels();
492 ( * dNew )->resizeMaterials(nmat);
493 for (
int i = 1; i <= nmat; i++ ) {
495 domain->giveMaterial(i)->giveInputRecord(ir);
498 auto mat =
classFactory.createMaterial(name.c_str(), i, * dNew);
499 mat->initializeFrom(ir);
500 ( * dNew )->setMaterial(i, std::move(mat));
504 int nbarriers =
domain->giveNumberOfNonlocalBarriers();
505 ( * dNew )->resizeNonlocalBarriers(nbarriers);
506 for (
int i = 1; i <= nbarriers; i++ ) {
508 domain->giveNonlocalBarrier(i)->giveInputRecord(ir);
511 auto barrier =
classFactory.createNonlocalBarrier(name.c_str(), i, * dNew);
512 barrier->initializeFrom(ir);
513 ( * dNew )->setNonlocalBarrier(i, std::move(barrier));
517 int nbc =
domain->giveNumberOfBoundaryConditions();
518 ( * dNew )->resizeBoundaryConditions(nbc);
519 for (
int i = 1; i <= nbc; i++ ) {
521 domain->giveBc(i)->giveInputRecord(ir);
524 auto bc =
classFactory.createBoundaryCondition(name.c_str(), i, * dNew);
525 bc->initializeFrom(ir);
526 ( * dNew )->setBoundaryCondition(i, std::move(bc));
530 int nic =
domain->giveNumberOfInitialConditions();
531 ( * dNew )->resizeInitialConditions(nic);
532 for (
int i = 1; i <= nic; i++ ) {
534 domain->giveIc(i)->giveInputRecord(ir);
537 auto ic = std::make_unique<InitialCondition>(i, *dNew);
538 ic->initializeFrom(ir);
539 ( * dNew )->setInitialCondition(i, std::move(ic));
544 int nltf =
domain->giveNumberOfFunctions();
546 ( * dNew )->resizeFunctions(nltf);
547 for (
int i = 1; i <= nltf; i++ ) {
550 domain->giveFunction(i)->giveInputRecord(ir);
554 auto ltf =
classFactory.createFunction(name.c_str(), i, * dNew);
555 ltf->initializeFrom(ir);
557 ( * dNew )->setFunction(i, std::move(ltf));
561 ( * dNew )->giveOutputManager()->beCopyOf(
domain->giveOutputManager() );
603T3DInterface :: createVTKExportMesh(
const char *t3dOutFile,std::vector<FloatArray> &nodeCoords, std::vector<IntArray> &cellNodes,
IntArray &cellTypes )
606 std::ifstream inputStream;
607 inputStream.open( t3dOutFile );
608 if ( !inputStream.is_open() ) {
609 OOFEM_ERROR(
"OOFEMTXTDataReader::OOFEMTXTDataReader: Can't open T3D input stream (%s)", t3dOutFile);
614 std::getline(inputStream, line);
622 int nnodes = 0, ntriangles = 0;
623 std::getline(inputStream, line);
625 char *currentLine =
new char[line.size() + 1];
626 std::strcpy ( currentLine, line.c_str() );
628 char *token = std::strtok(currentLine,
" ");
631 while (token != NULL) {
633 nnodes = atoi(token);
637 ntriangles = atoi(token);
642 token = std::strtok(NULL,
" ");
645 delete [] currentLine;
647 std::getline(inputStream, line);
651 for (
int inode = 1; inode <= nnodes; inode++ ) {
654 std::getline(inputStream, line);
656 currentLine =
new char[line.size() + 1];
657 std::strcpy ( currentLine, line.c_str() );
659 token = std::strtok(currentLine,
" ");
662 while (token != NULL) {
666 coords.
at(1) = atof(token);
668 coords.
at(2) = atof(token);
670 coords.
at(3) = atof(token);
673 token = std::strtok(NULL,
" ");
677 nodeCoords.push_back(coords);
678 delete [] currentLine;
684 std::getline(inputStream, line);
685 cellTypes.
resize(ntriangles);
687 for (
int itriangle = 1; itriangle <= ntriangles; itriangle++) {
690 std::getline(inputStream, line);
692 currentLine =
new char[line.size() + 1];
693 std::strcpy ( currentLine, line.c_str() );
695 token = std::strtok(currentLine,
" ");
698 while (token != NULL) {
701 else if (i >= 1 && i<=3)
702 dofManagers.
at(i) = atoi(token) - 1;
705 token = std::strtok(NULL,
" ");
708 cellNodes.push_back(dofManagers);
710 cellTypes.
at(itriangle) = 5;
711 delete [] currentLine;
722T3DInterface :: createQCInterpolationMesh(
const char *t3dOutFile,std::vector<FloatArray> &nodeCoords, std::vector<IntArray> &cellNodes,
IntArray &cellTypes )
729 std::ifstream inputStream;
730 inputStream.open( t3dOutFile );
731 if ( !inputStream.is_open() ) {
732 OOFEM_ERROR(
"OOFEMTXTDataReader::OOFEMTXTDataReader: Can't open T3D input stream (%s)", t3dOutFile);
737 std::getline(inputStream, line);
745 int nnodes = 0, ntriangles = 0, ntetras = 0;
746 std::getline(inputStream, line);
748 char *currentLine =
new char[line.size() + 1];
749 std::strcpy ( currentLine, line.c_str() );
751 char *token = std::strtok(currentLine,
" ");
754 while (token != NULL) {
756 nnodes = atoi(token);
760 ntriangles = atoi(token);
762 ntetras = atoi(token);
765 token = std::strtok(NULL,
" ");
768 delete [] currentLine;
770 std::getline(inputStream, line);
773 if (ntriangles!=0 && ntetras!=0 ) {
774 OOFEM_ERROR(
"T3DInterface: 2D and 3D interpolation elements are not supported together");
775 }
else if (ntriangles!=0) {
776 cellTypes.
resize(ntriangles);
777 }
else if (ntetras!=0) {
778 cellTypes.
resize(ntetras);
780 OOFEM_ERROR(
"T3DInterface: No interpolation element found in %s", t3dOutFile);
784 for (
int inode = 1; inode <= nnodes; inode++ ) {
787 std::getline(inputStream, line);
789 currentLine =
new char[line.size() + 1];
790 std::strcpy ( currentLine, line.c_str() );
792 token = std::strtok(currentLine,
" ");
795 while (token != NULL) {
799 coords.
at(1) = atof(token);
801 coords.
at(2) = atof(token);
803 coords.
at(3) = atof(token);
806 token = std::strtok(NULL,
" ");
810 nodeCoords.push_back(coords);
811 delete [] currentLine;
815 std::getline(inputStream, line);
818 for (
int itriangle = 1; itriangle <= ntriangles; itriangle++) {
821 std::getline(inputStream, line);
823 currentLine =
new char[line.size() + 1];
824 std::strcpy ( currentLine, line.c_str() );
826 token = std::strtok(currentLine,
" ");
829 while (token != NULL) {
832 else if (i >= 1 && i<=3)
833 dofManagers.
at(i) = atoi(token);
836 token = std::strtok(NULL,
" ");
839 cellNodes.push_back(dofManagers);
841 cellTypes.
at(itriangle) = 5;
842 delete [] currentLine;
846 for (
int itetra = 1; itetra <= ntetras; itetra++) {
849 std::getline(inputStream, line);
851 currentLine =
new char[line.size() + 1];
852 std::strcpy ( currentLine, line.c_str() );
854 token = std::strtok(currentLine,
" ");
857 while (token != NULL) {
860 else if (i >= 1 && i<=4)
861 dofManagers.
at(i) = atoi(token);
864 token = std::strtok(NULL,
" ");
867 cellNodes.push_back(dofManagers);
869 cellTypes.
at(itetra) = 5;
870 delete [] currentLine;
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.