76MatlabExportModule :: MatlabExportModule(
int n,
EngngModel *e) :
ExportModule(n, e), internalVarsToExport(), primaryVarsToExport()
81 exportSpecials =
false;
82 exportReactionForces =
false;
83 reactionForcesDofManList.clear();
84 dataDofManList.clear();
85 exportIntegrationPointFields =
false;
87 reactionForcesNodeSet = 0;
94MatlabExportModule :: ~MatlabExportModule()
101 ExportModule :: initializeFrom(ir);
163 Area += elem->computeArea();
167 for (
size_t i = 0; i <
partVolume.size(); i++ ) {
176 v = e->computeCurrentVolume(tStep);
179 v = elem->computeVolume();
184 std :: string eName ( elem->giveClassName() );
189 for (
size_t k = 0; k <
partName.size(); k++ ) {
191 if ( eName.compare(
partName.at(k)) == 0 ) {
198 partName.push_back( elem->giveClassName() );
213MatlabExportModule :: doOutput(
TimeStep *tStep,
bool forcedOutput)
220 int nelem = this->
elList.giveSize();
222 this->
elList.enumerate(this->
emodel->giveDomain(1)->giveNumberOfElements());
231 fprintf( FID,
"%%%% OOFEM generated export file \n");
232 fprintf( FID,
"%% Output for time %f\n", tStep->
giveTargetTime() );
235 fprintf( FID,
"function [mesh area data specials ReactionForces IntegrationPointFields]=%s\n\n",
functionname.c_str() );
240 fprintf(FID,
"\tmesh=[];\n");
246 fprintf(FID,
"\tdata=[];\n");
251 fprintf(FID,
"\tarea.xmax=%f;\n",
smax.at(0));
252 fprintf(FID,
"\tarea.xmin=%f;\n",
smin.at(0));
253 fprintf(FID,
"\tarea.ymax=%f;\n",
smax.at(1));
254 fprintf(FID,
"\tarea.ymin=%f;\n",
smin.at(1));
256 fprintf(FID,
"\tarea.area=%f;\n",
Area);
257 fprintf(FID,
"\tvolume=[];\n");
259 fprintf(FID,
"\tarea.zmax=%f;\n",
smax.at(2));
260 fprintf(FID,
"\tarea.zmin=%f;\n",
smin.at(2));
261 fprintf(FID,
"\tarea.area=[];\n");
262 fprintf(FID,
"\tarea.volume=%f;\n",
Volume);
263 for (
size_t i=0; i<this->
partName.size(); i++) {
268 fprintf(FID,
"\tarea.area=[];\n");
269 fprintf(FID,
"\tarea.volume=[];\n");
279 fprintf(FID,
"\tspecials=[];\n");
286 fprintf(FID,
"\tReactionForces=[];\n");
293 fprintf(FID,
"\tIntegrationPointFields=[];\n");
301 fprintf(FID,
"\nend\n");
307MatlabExportModule :: doOutputMesh(
TimeStep *tStep, FILE *FID)
311 fprintf(FID,
"\tmesh.p=[");
314 double c = dman->giveCoordinate(j);
315 fprintf(FID,
"%f, ", c);
320 fprintf(FID,
"]';\n");
324 fprintf(FID,
"\tmesh.t=[");
326 if ( elem->giveNumberOfDofManagers() == numberOfDofMans ) {
327 for (
int j = 1; j <= elem->giveNumberOfDofManagers(); j++ ) {
328 fprintf( FID,
"%d,", elem->giveDofManagerNumber(j) );
334 fprintf(FID,
"]';\n");
339MatlabExportModule :: doOutputData(
TimeStep *tStep, FILE *FID)
342 std :: vector< int >DofIDList;
343 std :: vector< int > :: iterator it;
344 std :: vector< std :: vector< double > >valuesList;
352 for (
Dof *thisDof: *dman ) {
353 it = std :: find( DofIDList.begin(), DofIDList.end(), thisDof->giveDofID() );
355 double value = thisDof->giveUnknown(VM_Total, tStep);
356 if ( it == DofIDList.end() ) {
357 DofIDList.push_back( thisDof->giveDofID() );
358 valuesList.push_back({value});
360 std::size_t pos = it - DofIDList.begin();
361 valuesList[pos].push_back(value);
368 for (
Dof *thisDof: *dman ) {
369 it = std :: find( DofIDList.begin(), DofIDList.end(), thisDof->giveDofID() );
371 double value = thisDof->giveUnknown(VM_Total, tStep);
372 if ( it == DofIDList.end() ) {
373 DofIDList.push_back( thisDof->giveDofID() );
374 valuesList.push_back({value});
376 std::size_t pos = it - DofIDList.begin();
377 valuesList[pos].push_back(value);
385 fprintf(FID,
"\tdata.DofIDs=[");
386 for (
auto &dofid : DofIDList ) {
387 fprintf( FID,
"%d, ", dofid );
390 fprintf(FID,
"];\n");
392 for (
size_t i = 0; i < valuesList.size(); i++ ) {
393 fprintf(FID,
"\tdata.a{%lu}=[",
static_cast< long unsigned int >(i) + 1);
394 for (
double val: valuesList[i] ) {
395 fprintf( FID,
"%f,", val );
398 fprintf(FID,
"];\n");
405MatlabExportModule :: doOutputSpecials(
TimeStep *tStep, FILE *FID)
415 for ( auto &elem : domain->giveElements() ) {
418 if ( Tr21Stokes *Tr = dynamic_cast< Tr21Stokes * >( elem.get() ) ) {
419 Tr->giveIntegratedVelocity(v_hatTemp, tStep);
420 v_hat.add(v_hatTemp);
421 } else if ( Tet21Stokes *Tet = dynamic_cast< Tet21Stokes * >( elem.get() ) ) {
422 Tet->giveIntegratedVelocity(v_hatTemp, tStep);
423 v_hat.add(v_hatTemp);
430 // Compute intrinsic area/volume
431 double intrinsicSize = 1.0;
433 std :: vector <double> V;
435 for ( int i = 0; i < (int)smax.size(); i++ ) {
436 intrinsicSize *= ( smax.at(i) - smin.at(i) );
439 for ( double vh: v_hat ) {
443 fprintf(FID, "\tspecials.velocitymean=[");
445 for (int i=0; i<ndim; i++) {
446 fprintf(FID, "%e", V.at(i));
447 if (i!=(ndim-1)) fprintf (FID, ", ");
449 fprintf(FID, "];\n");
451 fprintf(FID, "]; %% No velocities\n");
457 unsigned int wpbccount = 1, sbsfcount = 1, mcount = 1, pdsdcount=1, pdsncount=1, trccount=1;
458 [[maybe_unused]]
unsigned int pdsmcount=1;
460 for (
auto &gbc : domain->
giveBcs() ) {
464 fprintf(FID,
"\tspecials.weakperiodic{%u}.descType=%u;\n", wpbccount, wpbc->
giveBasisType() );
465 fprintf(FID,
"\tspecials.weakperiodic{%u}.coefficients=[", wpbccount);
467 double X = dof->giveUnknown(VM_Total, tStep);
468 fprintf(FID,
"%e\t", X);
471 fprintf(FID,
"];\n");
477 fprintf(FID,
"\tspecials.solutionbasedsf{%u}.values=[", sbsfcount);
479 double X = dof->giveUnknown(VM_Total, tStep);
480 fprintf(FID,
"%e\t", X);
482 fprintf(FID,
"];\n");
487 fprintf(FID,
"\tspecials.prescribedmean{%u}.value=[", mcount);
489 double X = dof->giveUnknown(VM_Total, tStep);
490 fprintf(FID,
"%e\t", X);
492 fprintf(FID,
"];\n");
502 fprintf(FID,
"\tspecials.prescribeddispslipbcdirichletrc{%u}.stress=[", pdsdcount);
503 for (
auto i : stress ) {
504 fprintf(FID,
"%e\t", i);
506 fprintf(FID,
"];\n");
507 fprintf(FID,
"\tspecials.prescribeddispslipbcdirichletrc{%u}.transferstress=[", pdsdcount);
508 for (
auto i : bStress ) {
509 fprintf(FID,
"%e\t", i);
511 fprintf(FID,
"];\n");
512 fprintf(FID,
"\tspecials.prescribeddispslipbcdirichletrc{%u}.reinfstress=[", pdsdcount);
513 for (
auto i : rStress ) {
514 fprintf(FID,
"%e\t", i);
516 fprintf(FID,
"];\n");
525 fprintf(FID,
"\tspecials.prescribeddispslipbcneumannrc{%u}.stress=[", pdsncount);
526 for (
auto i : stress ) {
527 fprintf(FID,
"%e\t", i);
529 fprintf(FID,
"];\n");
530 fprintf(FID,
"\tspecials.prescribeddispslipbcneumannrc{%u}.transferstress=[", pdsncount);
531 for (
auto i : bStress ) {
532 fprintf(FID,
"%e\t", i);
534 fprintf(FID,
"];\n");
535 fprintf(FID,
"\tspecials.prescribeddispslipbcneumannrc{%u}.reinfstress=[", pdsncount);
536 for (
auto i : rStress ) {
537 fprintf(FID,
"%e\t", i);
539 fprintf(FID,
"];\n");
548 fprintf(FID,
"\tspecials.prescribeddispslipmultiple{%u}.stress=[", pdsncount);
549 for (
auto i : stress ) {
550 fprintf(FID,
"%e\t", i);
552 fprintf(FID,
"];\n");
553 fprintf(FID,
"\tspecials.prescribeddispslipmultiple{%u}.transferstress=[", pdsncount);
554 for (
auto i : bStress ) {
555 fprintf(FID,
"%e\t", i);
557 fprintf(FID,
"];\n");
558 fprintf(FID,
"\tspecials.prescribeddispslipmultiple{%u}.reinfstress=[", pdsncount);
559 for (
auto i : rStress ) {
560 fprintf(FID,
"%e\t", i);
562 fprintf(FID,
"];\n");
569 fprintf(FID,
"\tspecials.transversereinfconstraint{%u}.stress=[", trccount);
570 for (
auto i : lambda ) {
571 fprintf(FID,
"%e\t", i);
573 fprintf(FID,
"];\n");
582MatlabExportModule :: doOutputReactionForces(
TimeStep *tStep, FILE *FID)
589 IntArray dofManMap, dofidMap, eqnMap;
598 OOFEM_ERROR(
"Cannot export reaction forces - only implemented for structural problems.");
609 if ( numDofManToExport == 0 ) {
621 fprintf( FID,
"\n %%%% Export of reaction forces \n\n" );
624 fprintf( FID,
"\tReactionForces.DofManNumbers = [" );
625 for (
int i = 1; i <= numDofManToExport; i++ ) {
628 fprintf( FID,
"];\n" );
632 fprintf( FID,
"\tReactionForces.ReactionForces = cell(%i,1); \n", numDofManToExport );
633 fprintf( FID,
"\tReactionForces.DofIDs = cell(%i,1); \n", numDofManToExport );
638 for (
int i = 1; i <= numDofManToExport; i++ ) {
641 fprintf(FID,
"\tReactionForces.ReactionForces{%i} = [", i);
642 if ( dofManMap.
contains( dManNum ) ) {
647 for (
Dof *dof: *dofMan ) {
652 fprintf(FID,
"%e ", reactions.
at(pos));
654 fprintf( FID,
"%e ", 0.0 );
658 fprintf(FID,
"];\n");
662 fprintf( FID,
"\tReactionForces.DofIDs{%i} = [", i);
663 if ( dofManMap.
contains( dManNum ) ) {
664 for (
int id: dofIDs ) {
665 fprintf( FID,
"%i ",
id );
668 fprintf(FID,
"];\n");
673 fprintf( FID,
"\tReactionForces.LoadLevel = [" );
674 fprintf( FID,
"%.9e", loadLevel);
675 fprintf( FID,
"];\n" );
680MatlabExportModule :: doOutputIntegrationPointFields(
TimeStep *tStep, FILE *FID)
687 fprintf( FID,
"\n %%%% Export of internal variables in integration points \n\n" );
688 fprintf( FID,
"\n %% for interpretation of internal var. numbers see internalstatetype.h\n");
693 fprintf( FID,
"\tIntegrationPointFields.InternalVarsToExport = [" );
694 for (
int i = 1; i <= numVars; i++ ) {
697 fprintf( FID,
"];\n" );
710 int nelem = this->
elList.giveSize();
712 fprintf( FID,
"\tIntegrationPointFields.Elements = cell(%i,1); \n", nelem );
714 for (
int ielem = 1; ielem <= nelem; ielem++ ) {
716 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.elementNumber = %i; \n", ielem, el->
giveNumber());
719 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule = cell(%i,1); \n", ielem, numIntRules);
720 for (
int i = 1; i <= numIntRules; i++ ) {
723 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip = cell(%i,1); \n ",
729 double weight = ip->giveWeight();
731 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.ipWeight = %e; \n ",
732 ielem, i, ip->giveNumber(), weight);
736 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.coords = [",
737 ielem, i, ip->giveNumber());
741 for (
int ic = 1; ic <= coords.
giveSize(); ic++ ) {
742 fprintf( FID,
"%e ", coords.
at(ic) );
744 fprintf( FID,
"]; \n" );
747 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.volume = %e; \n ",
751 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.valArray = cell(%i,1); \n",
752 ielem, i, ip->giveNumber(), numVars);
754 for (
int iv = 1; iv <= numVars; iv++ ) {
755 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.valArray{%i} = [",
756 ielem, i, ip->giveNumber(), iv);
760 for (
int ic = 1; ic <= nv; ic++ ) {
761 fprintf( FID,
"%.6e ", valueArray.
at(ic) );
763 fprintf( FID,
"]; \n" );
774MatlabExportModule :: initialize()
776 ExportModule :: initialize();
781MatlabExportModule :: terminate()
786MatlabExportModule :: giveOutputStream(
TimeStep *tStep)
795 if ( this->
emodel->isParallel() && this->emodel->giveNumberOfProcesses() > 1 ) {
801 if ( this->
emodel->isParallel() && this->emodel->giveNumberOfProcesses() > 1 ) {
802 sprintf( fext,
"_%03d_m%d_%d",
emodel->giveRank(), this->number, tStep->
giveNumber() );
808 std :: string fileName;
810 fileName = this->
emodel->giveOutputBaseFileName();
813 foundDot = fileName.rfind(
".");
816 while (foundDot != std :: string :: npos) {
817 fileName.replace(foundDot, 1,
"_");
818 foundDot = fileName.rfind(
".");
826 size_t backslash = temp.rfind(
"/");
828 if (backslash != std :: string :: npos ) {
829 functionname = temp.substr(backslash+1, std :: string :: npos);
836 if ( ( answer = fopen(fileName.c_str(),
"w") ) == NULL ) {
837 OOFEM_ERROR(
"failed to open file %s", fileName.c_str() );
844MatlabExportModule :: doOutputHomogenizeDofIDs(
TimeStep *tStep, FILE *FID)
846 std :: vector <FloatArray> HomQuantities;
852 int nelem = this->
elList.giveSize();
853 for (
int i = 1; i<=nelem; i++) {
866 elementValues.
times(gp->giveWeight()*detJ);
867 if (HomQuantities[j].giveSize() == 0) {
868 HomQuantities[j].resize(elementValues.
giveSize());
870 HomQuantities[j].add(elementValues);
877 for ( std :: size_t i = 0; i < HomQuantities.size(); i ++) {
879 thisIS.
times(1.0/vol);
882 for (
int j = 0; j<thisIS.
giveSize(); j++) {
883 fprintf(FID,
"%e", thisIS.
at(j+1));
888 fprintf(FID,
"];\n");
#define REGISTER_ExportModule(class)
double giveCoordinate(int i) const
std ::vector< std ::unique_ptr< DofManager > > & giveDofManagers()
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
std ::vector< std ::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
DofManager * giveDofManager(int n)
Element * giveElement(int n)
int giveNumberOfSpatialDimensions()
Returns number of spatial dimensions.
EngngModel * giveEngngModel()
std ::vector< std ::unique_ptr< Element > > & giveElements()
virtual int computeGlobalCoordinates(FloatArray &answer, const FloatArray &lcoords)
virtual FEInterpolation * giveInterpolation() const
virtual double computeVolumeAreaOrLength()
Computes the volume, area or length of the element depending on its spatial dimension.
int giveNumberOfIntegrationRules()
virtual IntegrationRule * giveIntegrationRule(int i)
virtual int giveNumberOfDofManagers() const
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
virtual double computeVolumeAround(GaussPoint *gp)
virtual double giveLoadLevel()
Returns the current load level.
int number
Component number.
EngngModel * emodel
Problem pointer.
bool testTimeStepOutput(TimeStep *tStep)
virtual double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo) const
Index giveSize() const
Returns the size of receiver.
void followedBy(const IntArray &b, int allocChunk=0)
bool contains(int value) const
int findFirstIndexOf(int value) const
int giveNumberOfIntegrationPoints() const
FILE * giveOutputStream(TimeStep *)
std ::vector< double > smin
void computeArea(TimeStep *tStep)
void doOutputMesh(TimeStep *tStep, FILE *FID)
void doOutputHomogenizeDofIDs(TimeStep *tStep, FILE *FID)
int reactionForcesNodeSet
std ::vector< std ::string > partName
IntArray reactionForcesDofManList
void doOutputData(TimeStep *tStep, FILE *FID)
bool exportReactionForces
IntArray internalVarsToExport
list of InternalStateType values, identifying the selected vars for export
void doOutputSpecials(TimeStep *tStep, FILE *FID)
void doOutputReactionForces(TimeStep *tStep, FILE *FID)
std ::vector< double > smax
std ::vector< double > partVolume
void doOutputIntegrationPointFields(TimeStep *tStep, FILE *FID)
bool exportIntegrationPointFields
void computeStress(FloatArray &sigma, TimeStep *tStep) override
void computeReinfStress(FloatArray &rStress, TimeStep *tStep) override
void computeTransferStress(FloatArray &bStress, TimeStep *tStep) override
void computeStress(FloatArray &sigma, TimeStep *tStep) override
void computeReinfStress(FloatArray &rStress, TimeStep *tStep) override
void computeTransferStress(FloatArray &bStress, TimeStep *tStep) override
void computeTransferStress(FloatArray &bStress, TimeStep *tStep) override
void computeStress(FloatArray &stress, TimeStep *tStep) override
void computeReinfStress(FloatArray &rStress, TimeStep *tStep) override
DofManager * giveInternalDofManager(int i) override
Gives an internal dof manager from receiver.
const IntArray & giveElementList()
const IntArray & giveNodeList()
DofManager * giveInternalDofManager(int i) override
Gives an internal dof manager from receiver.
void buildReactionTable(IntArray &restrDofMans, IntArray &restrDofs, IntArray &eqn, TimeStep *tStep, int di)
void computeReaction(FloatArray &answer, TimeStep *tStep, int di)
double giveTargetTime()
Returns target time.
int giveNumber()
Returns receiver's number.
int giveSubStepNumber()
Returns receiver's substep number.
void computeField(FloatArray &lambda, TimeStep *tStep)
basisType giveBasisType()
DofManager * giveInternalDofManager(int i) override
Gives an internal dof manager from receiver.
int giveNumberOfInternalDofManagers() override
Gives the number of internal dof managers.
#define _IFT_MatlabExportModule_mesh
#define _IFT_MatlabExportModule_area
#define _IFT_MatlabExportModule_ReactionForces
#define _IFT_MatlabExportModule_IntegrationPoints
#define _IFT_MatlabExportModule_DataNodeSet
#define _IFT_MatlabExportModule_homogenizeInternalVars
#define _IFT_MatlabExportModule_ReactionForcesNodeSet
#define _IFT_MatlabExportModule_data
#define _IFT_MatlabExportModule_ElementList
#define _IFT_MatlabExportModule_internalVarsToExport
#define _IFT_MatlabExportModule_noScaledHomogenization
#define _IFT_MatlabExportModule_IPFieldsElSet
#define _IFT_MatlabExportModule_DofManList
#define _IFT_MatlabExportModule_specials
const char * __InternalStateTypeToString(InternalStateType _value)
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)