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");
292 std::ifstream inputStream;
293 inputStream.open( t3dOutFile );
294 if ( !inputStream.is_open() ) {
295 OOFEM_ERROR(
"OOFEMTXTDataReader::OOFEMTXTDataReader: Can't open T3D input stream (%s)", t3dOutFile);
307 std::getline(inputStream, line);
309 char *currentLine =
new char[line.size() + 1];
310 std::strcpy ( currentLine, line.c_str() );
312 char *token = std::strtok(currentLine,
" ");
315 while (token != NULL) {
326 token = std::strtok(NULL,
" ");
331 int nnodes,ntriangles,ntetras;
340 std::getline(inputStream, line);
342 currentLine =
new char[line.size() + 1];
343 std::strcpy ( currentLine, line.c_str() );
345 token = std::strtok(currentLine,
" ");
348 while (token != NULL) {
350 nnodes = atoi(token);
354 ntriangles = atoi(token);
356 ntetras = atoi(token);
359 token = std::strtok(NULL,
" ");
363 (*dNew)->resizeDofManagers(nnodes);
367 std::getline(inputStream, line);
372 int ndofs = dofIDArrayPtr.
giveSize();
374 for (
int inode = 1; inode <= nnodes; inode++ ) {
376 std::getline(inputStream, line);
378 currentLine =
new char[line.size() + 1];
379 std::strcpy ( currentLine, line.c_str() );
381 token = std::strtok(currentLine,
" ");
384 while (token != NULL) {
388 coords.
at(1) = atof(token);
390 coords.
at(2) = atof(token);
392 coords.
at(3) = atof(token);
395 token = std::strtok(NULL,
" ");
399 node =
new Node(inode, * dNew);
410 std::getline(inputStream, line);
414 Element *parentElementPtr, *elem;
417 for (
int itriangle = 1; itriangle <= ntriangles; itriangle++) {
420 std::getline(inputStream, line);
422 currentLine =
new char[line.size() + 1];
423 std::strcpy ( currentLine, line.c_str() );
425 token = std::strtok(currentLine,
" ");
428 while (token != NULL) {
430 elemNumber = atoi(token);
431 else if (i >= 1 && i<=4)
432 dofManagers.
at(i) = atof(token);
435 token = std::strtok(NULL,
" ");
450 for (
int itetra = 1; itetra <= ntetras; itetra++) {
453 std::getline(inputStream, line);
455 currentLine =
new char[line.size() + 1];
456 std::strcpy ( currentLine, line.c_str() );
458 token = std::strtok(currentLine,
" ");
461 while (token != NULL) {
463 elemNumber = atoi(token);
464 else if (i >= 1 && i<=4)
465 dofManagers.
at(i) = atof(token);
468 token = std::strtok(NULL,
" ");
476 (*dNew)->setElement(elemNumber, elem);
492 ( * dNew )->resizeCrossSectionModels(ncrosssect);
493 for (
int i = 1; i <= ncrosssect; i++ ) {
500 ( * dNew )->setCrossSection(i, crossSection);
505 ( * dNew )->resizeMaterials(nmat);
506 for (
int i = 1; i <= nmat; i++ ) {
513 ( * dNew )->setMaterial(i, mat);
518 ( * dNew )->resizeNonlocalBarriers(nbarriers);
519 for (
int i = 1; i <= nbarriers; i++ ) {
526 ( * dNew )->setNonlocalBarrier(i, barrier);
531 ( * dNew )->resizeBoundaryConditions(nbc);
532 for (
int i = 1; i <= nbc; i++ ) {
539 ( * dNew )->setBoundaryCondition(i, bc);
544 ( * dNew )->resizeInitialConditions(nic);
545 for (
int i = 1; i <= nic; i++ ) {
552 ( * dNew )->setInitialCondition(i, ic);
559 ( * dNew )->resizeFunctions(nltf);
560 for (
int i = 1; i <= nltf; i++ ) {
570 ( * dNew )->setFunction(i, ltf);
585 inputStrem = fopen(t3dInFile,
"w");
589 for (
int i = 1; i <= nnodes; i++ ) {
594 for (
int i = 1; i<=nnodes; i++) {
596 fprintf(inputStrem,
"curve %d order 2 vertex %d %d\n", i, i, i+1);
598 fprintf(inputStrem,
"curve %d order 2 vertex %d %d\n", i, i, 1);
600 fprintf(inputStrem,
"patch 1 normal 0 0 1 boundary curve");
601 for (
int i = 1; i<=nnodes; i++) {
602 fprintf(inputStrem,
" %d", i);
620 std::ifstream inputStream;
621 inputStream.open( t3dOutFile );
622 if ( !inputStream.is_open() ) {
623 OOFEM_ERROR(
"OOFEMTXTDataReader::OOFEMTXTDataReader: Can't open T3D input stream (%s)", t3dOutFile);
628 std::getline(inputStream, line);
636 int nnodes,ntriangles;
637 std::getline(inputStream, line);
639 char *currentLine =
new char[line.size() + 1];
640 std::strcpy ( currentLine, line.c_str() );
642 char *token = std::strtok(currentLine,
" ");
645 while (token != NULL) {
647 nnodes = atoi(token);
651 ntriangles = atoi(token);
656 token = std::strtok(NULL,
" ");
659 delete [] currentLine;
661 std::getline(inputStream, line);
665 for (
int inode = 1; inode <= nnodes; inode++ ) {
668 std::getline(inputStream, line);
670 currentLine =
new char[line.size() + 1];
671 std::strcpy ( currentLine, line.c_str() );
673 token = std::strtok(currentLine,
" ");
676 while (token != NULL) {
680 coords.
at(1) = atof(token);
682 coords.
at(2) = atof(token);
684 coords.
at(3) = atof(token);
687 token = std::strtok(NULL,
" ");
691 nodeCoords.push_back(coords);
692 delete [] currentLine;
698 std::getline(inputStream, line);
699 cellTypes.
resize(ntriangles);
701 for (
int itriangle = 1; itriangle <= ntriangles; itriangle++) {
704 std::getline(inputStream, line);
706 currentLine =
new char[line.size() + 1];
707 std::strcpy ( currentLine, line.c_str() );
709 token = std::strtok(currentLine,
" ");
712 while (token != NULL) {
715 else if (i >= 1 && i<=3)
716 dofManagers.
at(i) = atof(token) - 1;
719 token = std::strtok(NULL,
" ");
722 cellNodes.push_back(dofManagers);
724 cellTypes.
at(itriangle) = 5;
725 delete [] currentLine;
743 std::ifstream inputStream;
744 inputStream.open( t3dOutFile );
745 if ( !inputStream.is_open() ) {
746 OOFEM_ERROR(
"OOFEMTXTDataReader::OOFEMTXTDataReader: Can't open T3D input stream (%s)", t3dOutFile);
751 std::getline(inputStream, line);
759 int nnodes,ntriangles,ntetras;
760 std::getline(inputStream, line);
762 char *currentLine =
new char[line.size() + 1];
763 std::strcpy ( currentLine, line.c_str() );
765 char *token = std::strtok(currentLine,
" ");
768 while (token != NULL) {
770 nnodes = atoi(token);
774 ntriangles = atoi(token);
776 ntetras = atoi(token);
779 token = std::strtok(NULL,
" ");
782 delete [] currentLine;
784 std::getline(inputStream, line);
787 if (ntriangles!=0 && ntetras!=0 ) {
788 OOFEM_ERROR(
"T3DInterface: 2D and 3D interpolation elements are not supported together");
789 }
else if (ntriangles!=0) {
790 cellTypes.
resize(ntriangles);
791 }
else if (ntetras!=0) {
792 cellTypes.
resize(ntetras);
794 OOFEM_ERROR(
"T3DInterface: No interpolation element found in %s", t3dOutFile);
798 for (
int inode = 1; inode <= nnodes; inode++ ) {
801 std::getline(inputStream, line);
803 currentLine =
new char[line.size() + 1];
804 std::strcpy ( currentLine, line.c_str() );
806 token = std::strtok(currentLine,
" ");
809 while (token != NULL) {
813 coords.
at(1) = atof(token);
815 coords.
at(2) = atof(token);
817 coords.
at(3) = atof(token);
820 token = std::strtok(NULL,
" ");
824 nodeCoords.push_back(coords);
825 delete [] currentLine;
829 std::getline(inputStream, line);
832 for (
int itriangle = 1; itriangle <= ntriangles; itriangle++) {
835 std::getline(inputStream, line);
837 currentLine =
new char[line.size() + 1];
838 std::strcpy ( currentLine, line.c_str() );
840 token = std::strtok(currentLine,
" ");
843 while (token != NULL) {
846 else if (i >= 1 && i<=3)
847 dofManagers.
at(i) = atof(token);
850 token = std::strtok(NULL,
" ");
853 cellNodes.push_back(dofManagers);
855 cellTypes.
at(itriangle) = 5;
856 delete [] currentLine;
860 for (
int itetra = 1; itetra <= ntetras; itetra++) {
863 std::getline(inputStream, line);
865 currentLine =
new char[line.size() + 1];
866 std::strcpy ( currentLine, line.c_str() );
868 token = std::strtok(currentLine,
" ");
871 while (token != NULL) {
874 else if (i >= 1 && i<=4)
875 dofManagers.
at(i) = atof(token);
878 token = std::strtok(NULL,
" ");
881 cellNodes.push_back(dofManagers);
883 cellTypes.
at(itetra) = 5;
884 delete [] currentLine;
CrossSection * giveCrossSection()
Material * createMaterial(const char *name, int num, Domain *domain)
Creates new instance of material corresponding to given keyword.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
int createVTKExportMesh(const char *t3dOutFile, std::vector< FloatArray > &nodeCoords, std::vector< IntArray > &cellNodes, IntArray &cellTypes)
Function * createFunction(const char *name, int num, Domain *domain)
Creates new instance of load time function corresponding to given keyword.
Abstract base class for all nonlocal barriers.
Class implementing general initial condition.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
InitialCondition * giveIc(int n)
Service for accessing particular domain ic.
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
REGISTER_Mesher(FreemInterface, MPT_FREEM)
int giveNumberOfBoundaryConditions() const
Returns number of boundary conditions in domain.
NonlocalBarrier * giveNonlocalBarrier(int n)
Service for accessing particular domain nonlocal barrier representation.
double & at(int i)
Coefficient access function.
NonlocalBarrier * createNonlocalBarrier(const char *name, int num, Domain *domain)
Creates new instance of nonlocal barrier corresponding to given keyword.
int giveNumberOfInitialConditions() const
Returns number of initial conditions in domain.
EngngModel * giveEngngModel()
Returns engineering model to which receiver is associated.
const IntArray & giveDefaultNodeDofIDArry()
Returns default DofID array which defines physical meaning of particular DOFs.
bool isParallel() const
Returns true if receiver in parallel mode.
Abstract base class for all finite elements.
CrossSection * createCrossSection(const char *name, int num, Domain *domain)
Creates new instance of cross section corresponding to given keyword.
int giveNumberOfElements() const
Returns number of elements in domain.
GeneralBoundaryCondition * createBoundaryCondition(const char *name, int num, Domain *domain)
Creates new instance of boundary condition corresponding to given keyword.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
virtual double giveCoordinate(int i)
domainType giveDomainType()
Returns domain type.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
virtual double giveRequiredDofManDensity(int num, TimeStep *tStep, int relative=0)=0
Returns the required mesh size n given dof manager.
virtual int giveNumberOfDofManagers() const
GeneralBoundaryCondition * giveBc(int n)
Service for accessing particular domain bc.
Base abstract class representing cross section in finite element mesh.
ErrorEstimator * giveErrorEstimator()
Returns Error Estimator associated to receiver.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
CrossSection * giveCrossSection(int n)
Service for accessing particular domain cross section model.
virtual returnCode createMesh(TimeStep *tStep, int domainNumber, int domainSerNum, Domain **dNew)
Runs the mesh generation, mesh will be written to corresponding domain din file.
#define OOFEM_LOG_INFO(...)
Material * giveMaterial(int n)
Service for accessing particular domain material model.
Element * giveElement(int n)
Service for accessing particular domain fe element.
void setDomainType(domainType _dType)
Sets domain type.
int giveNumberOfCrossSectionModels() const
Returns number of cross section models in domain.
int giveNumberOfMaterialModels() const
Returns number of material models in domain.
virtual void setCrossSection(int csIndx)
Sets the cross section model of receiver.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Abstract base class for all boundary conditions of problem.
virtual RemeshingCriteria * giveRemeshingCrit()=0
Returns reference to associated remeshing criteria.
Abstract base class for all material models.
void resize(int n)
Checks size of receiver towards requested bounds.
void setDofManagers(const IntArray &dmans)
Sets receiver dofManagers.
virtual const char * giveClassName() const
Function * giveFunction(int n)
Service for accessing particular domain load time function.
Class representing vector of real numbers.
void setNumberOfDofs(int _ndofs)
Sets number of dofs of the receiver; Deallocates existing DOFs; Resizes the dofArray accordingly...
int giveSerialNumber()
Returns domain serial (version) number.
Abstract base class representing a function with vector input and output.
void setCoordinates(FloatArray coords)
Sets node coordinates to given array.
int giveNumberOfFunctions() const
Returns number of load time functions in domain.
const char * __Element_Geometry_TypeToString(Element_Geometry_Type _value)
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
void setMaterial(int matIndx)
Sets the material of receiver.
int giveNumberOfNonlocalBarriers() const
Returns number of nonlocal integration barriers.
ClassFactory & classFactory
OutputManager * giveOutputManager()
Returns domain output manager.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
int t3d_2_OOFEM(const char *t3dOutFile, Domain **dNew)
virtual Element_Geometry_Type giveGeometryType() const
Returns the element geometry type.
Node * giveNode(int n)
Service for accessing particular domain node.
the oofem namespace is to define a context or scope in which all oofem names are defined.
Class implementing node in finite element mesh.
Element * createElement(const char *name, int num, Domain *domain)
Creates new instance of element corresponding to given keyword.
Node * giveNode(int i) const
Returns reference to the i-th node of element.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Class representing solution step.
int createInput(Element *e, char *t3dInFile)
virtual Material * giveMaterial()
int createQCInterpolationMesh(const char *t3dOutFile, std::vector< FloatArray > &nodeCoords, std::vector< IntArray > &cellNodes, IntArray &cellTypes)