57 #include "../fm/tr21stokes.h" 58 #include "../fm/tet21stokes.h" 59 #include "../fm/stokesflow.h" 63 #include "../sm/Elements/nlstructuralelement.h" 64 #include "../sm/EngineeringModels/structengngmodel.h" 77 exportSpecials =
false;
78 exportReactionForces =
false;
79 reactionForcesDofManList.clear();
80 dataDofManList.clear();
81 exportIntegrationPointFields =
false;
83 reactionForcesNodeSet = 0;
162 Area += elem->computeArea();
166 for (
size_t i = 0; i <
partVolume.size(); i++ ) {
175 v = e->computeCurrentVolume(tStep);
178 v = elem->computeVolume();
183 std :: string eName ( elem->giveClassName() );
188 for (
size_t k = 0; k <
partName.size(); k++ ) {
190 if ( eName.compare(
partName.at(k)) == 0 ) {
197 partName.push_back( elem->giveClassName() );
230 fprintf( FID,
"%%%% OOFEM generated export file \n");
231 fprintf( FID,
"%% Output for time %f\n", tStep->
giveTargetTime() );
234 fprintf( FID,
"function [mesh area data specials ReactionForces IntegrationPointFields]=%s\n\n",
functionname.c_str() );
239 fprintf(FID,
"\tmesh=[];\n");
245 fprintf(FID,
"\tdata=[];\n");
250 fprintf(FID,
"\tarea.xmax=%f;\n",
smax.at(0));
251 fprintf(FID,
"\tarea.xmin=%f;\n",
smin.at(0));
252 fprintf(FID,
"\tarea.ymax=%f;\n",
smax.at(1));
253 fprintf(FID,
"\tarea.ymin=%f;\n",
smin.at(1));
255 fprintf(FID,
"\tarea.area=%f;\n",
Area);
256 fprintf(FID,
"\tvolume=[];\n");
258 fprintf(FID,
"\tarea.zmax=%f;\n",
smax.at(2));
259 fprintf(FID,
"\tarea.zmin=%f;\n",
smin.at(2));
260 fprintf(FID,
"\tarea.area=[];\n");
261 fprintf(FID,
"\tarea.volume=%f;\n",
Volume);
262 for (
size_t i=0; i<this->
partName.size(); i++) {
267 fprintf(FID,
"\tarea.area=[];\n");
268 fprintf(FID,
"\tarea.volume=[];\n");
278 fprintf(FID,
"\tspecials=[];\n");
285 fprintf(FID,
"\tReactionForces=[];\n");
292 fprintf(FID,
"\tIntegrationPointFields=[];\n");
300 fprintf(FID,
"\nend\n");
310 fprintf(FID,
"\tmesh.p=[");
313 double c = dman->giveCoordinate(j);
314 fprintf(FID,
"%f, ", c);
319 fprintf(FID,
"]';\n");
323 fprintf(FID,
"\tmesh.t=[");
325 if ( elem->giveNumberOfDofManagers() == numberOfDofMans ) {
326 for (
int j = 1; j <= elem->giveNumberOfDofManagers(); j++ ) {
327 fprintf( FID,
"%d,", elem->giveDofManagerNumber(j) );
333 fprintf(FID,
"]';\n");
341 std :: vector< int >DofIDList;
342 std :: vector< int > :: iterator it;
343 std :: vector< std :: vector< double > >valuesList;
351 for (
Dof *thisDof: *dman ) {
352 it = std :: find( DofIDList.begin(), DofIDList.end(), thisDof->giveDofID() );
354 double value = thisDof->giveUnknown(VM_Total, tStep);
355 if ( it == DofIDList.end() ) {
356 DofIDList.push_back( thisDof->giveDofID() );
357 valuesList.push_back({value});
359 std::size_t pos = it - DofIDList.
begin();
360 valuesList[pos].push_back(value);
367 for (
Dof *thisDof: *dman ) {
368 it = std :: find( DofIDList.begin(), DofIDList.end(), thisDof->giveDofID() );
370 double value = thisDof->giveUnknown(VM_Total, tStep);
371 if ( it == DofIDList.end() ) {
372 DofIDList.push_back( thisDof->giveDofID() );
373 valuesList.push_back({value});
375 std::size_t pos = it - DofIDList.begin();
376 valuesList[pos].push_back(value);
384 fprintf(FID,
"\tdata.DofIDs=[");
385 for (
auto &dofid : DofIDList ) {
386 fprintf( FID,
"%d, ", dofid );
389 fprintf(FID,
"];\n");
391 for (
size_t i = 0; i < valuesList.size(); i++ ) {
392 fprintf(FID,
"\tdata.a{%lu}=[", static_cast< long unsigned int >(i) + 1);
393 for (
double val: valuesList[i] ) {
394 fprintf( FID,
"%f,", val );
397 fprintf(FID,
"];\n");
456 unsigned int wpbccount = 1, sbsfcount = 1, mcount = 1;
458 for (
auto &gbc : domain->
giveBcs() ) {
462 fprintf(FID,
"\tspecials.weakperiodic{%u}.descType=%u;\n", wpbccount, wpbc->
giveBasisType() );
463 fprintf(FID,
"\tspecials.weakperiodic{%u}.coefficients=[", wpbccount);
465 double X = dof->giveUnknown(VM_Total, tStep);
466 fprintf(FID,
"%e\t", X);
469 fprintf(FID,
"];\n");
475 fprintf(FID,
"\tspecials.solutionbasedsf{%u}.values=[", sbsfcount);
477 double X = dof->giveUnknown(VM_Total, tStep);
478 fprintf(FID,
"%e\t", X);
480 fprintf(FID,
"];\n");
485 fprintf(FID,
"\tspecials.prescribedmean{%u}.value=[", mcount);
487 double X = dof->giveUnknown(VM_Total, tStep);
488 fprintf(FID,
"%e\t", X);
490 fprintf(FID,
"];\n");
505 IntArray dofManMap, dofidMap, eqnMap;
514 OOFEM_ERROR(
"Cannot export reaction forces - only implemented for structural problems.");
525 if ( numDofManToExport == 0 ) {
537 fprintf( FID,
"\n %%%% Export of reaction forces \n\n" );
540 fprintf( FID,
"\tReactionForces.DofManNumbers = [" );
541 for (
int i = 1; i <= numDofManToExport; i++ ) {
544 fprintf( FID,
"];\n" );
548 fprintf( FID,
"\tReactionForces.ReactionForces = cell(%i,1); \n", numDofManToExport );
549 fprintf( FID,
"\tReactionForces.DofIDs = cell(%i,1); \n", numDofManToExport );
554 for (
int i = 1; i <= numDofManToExport; i++ ) {
557 fprintf(FID,
"\tReactionForces.ReactionForces{%i} = [", i);
558 if ( dofManMap.
contains( dManNum ) ) {
563 for (
Dof *dof: *dofMan ) {
568 fprintf(FID,
"%e ", reactions.
at(pos));
570 fprintf( FID,
"%e ", 0.0 );
574 fprintf(FID,
"];\n");
578 fprintf( FID,
"\tReactionForces.DofIDs{%i} = [", i);
579 if ( dofManMap.
contains( dManNum ) ) {
580 for (
int id: dofIDs ) {
581 fprintf( FID,
"%i ",
id );
584 fprintf(FID,
"];\n");
597 fprintf( FID,
"\n %%%% Export of internal variables in integration points \n\n" );
598 fprintf( FID,
"\n %% for interpretation of internal var. numbers see internalstatetype.h\n");
603 fprintf( FID,
"\tIntegrationPointFields.InternalVarsToExport = [" );
604 for (
int i = 1; i <= numVars; i++ ) {
607 fprintf( FID,
"];\n" );
614 elList =
set->giveElementList();
622 fprintf( FID,
"\tIntegrationPointFields.Elements = cell(%i,1); \n", nelem );
624 for (
int ielem = 1; ielem <= nelem; ielem++ ) {
626 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.elementNumber = %i; \n", ielem, el->
giveNumber());
629 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule = cell(%i,1); \n", ielem, numIntRules);
630 for (
int i = 1; i <= numIntRules; i++ ) {
633 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip = cell(%i,1); \n ",
639 double weight = ip->giveWeight();
641 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.ipWeight = %e; \n ",
642 ielem, i, ip->giveNumber(), weight);
646 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.coords = [",
647 ielem, i, ip->giveNumber());
651 for (
int ic = 1; ic <= coords.giveSize(); ic++ ) {
652 fprintf( FID,
"%e ", coords.at(ic) );
654 fprintf( FID,
"]; \n" );
657 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.valArray = cell(%i,1); \n",
658 ielem, i, ip->giveNumber(), numVars);
660 for (
int iv = 1; iv <= numVars; iv++ ) {
661 fprintf( FID,
"\tIntegrationPointFields.Elements{%i}.integrationRule{%i}.ip{%i}.valArray{%i} = [",
662 ielem, i, ip->giveNumber(), iv);
666 for (
int ic = 1; ic <= nv; ic++ ) {
667 fprintf( FID,
"%.6e ", valueArray.
at(ic) );
669 fprintf( FID,
"]; \n" );
714 std :: string fileName;
719 foundDot = fileName.rfind(
".");
722 while (foundDot != std :: string :: npos) {
723 fileName.replace(foundDot, 1,
"_");
724 foundDot = fileName.rfind(
".");
732 size_t backslash = temp.rfind(
"/");
734 if (backslash != std :: string :: npos ) {
735 functionname = temp.substr(backslash+1, std :: string :: npos);
742 if ( ( answer = fopen(fileName.c_str(),
"w") ) == NULL ) {
743 OOFEM_ERROR(
"failed to open file %s", fileName.c_str() );
753 std :: vector <FloatArray*> HomQuantities;
764 for (
int i = 1; i<=nelem; i++) {
777 elementValues.
times(gp->giveWeight()*detJ);
778 if (HomQuantities.at(j)->giveSize() == 0) {
779 HomQuantities.at(j)->resize(elementValues.
giveSize());
780 HomQuantities.at(j)->zero();
782 HomQuantities.at(j)->add(elementValues);
790 for ( std :: size_t i = 0; i < HomQuantities.size(); i ++) {
792 thisIS = HomQuantities.
at(i);
793 thisIS->
times(1.0/Vol);
796 for (
int j = 0; j<thisIS->
giveSize(); j++) {
797 fprintf(FID,
"%e", thisIS->
at(j+1));
802 fprintf(FID,
"];\n");
803 delete HomQuantities.at(i);
bool contains(int value) const
#define _IFT_MatlabExportModule_DataNodeSet
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
bool exportIntegrationPointFields
void enumerate(int maxVal)
Resizes receiver and enumerates from 1 to the maximum value given.
bool testTimeStepOutput(TimeStep *tStep)
Tests if given time step output is required.
virtual DofManager * giveInternalDofManager(int i)
Gives an internal dof manager from receiver.
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in full form.
std::string giveOutputBaseFileName()
Returns base output file name to which extensions, like .out .vtu .osf should be added.
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Access method for default integration rule.
virtual IntegrationRule * giveIntegrationRule(int i)
virtual double giveTransformationJacobian(const FloatArray &lcoords, const FEICellGeometry &cellgeo)
Evaluates the determinant of the transformation.
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Abstract base class for "structural" finite elements with geometrical nonlinearities.
bool exportReactionForces
double & at(int i)
Coefficient access function.
int max(int i, int j)
Returns bigger value form two given decimals.
#define _IFT_MatlabExportModule_area
std::vector< double > partVolume
virtual void initialize()
double giveTargetTime()
Returns target time.
bool isParallel() const
Returns true if receiver in parallel mode.
Abstract base class for all finite elements.
Base class for dof managers.
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
std::vector< std::unique_ptr< DofManager > > & giveDofManagers()
int giveNumberOfElements() const
Returns number of elements in domain.
void computeArea(TimeStep *tStep)
int giveNumberOfSpatialDimensions()
Returns number of spatial dimensions.
Represents export output module - a base class for all output modules.
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
#define _IFT_MatlabExportModule_ReactionForces
virtual int giveNumberOfDofManagers() const
virtual FEInterpolation * giveInterpolation() const
Abstract base class representing integration rule.
virtual double computeVolumeAreaOrLength()
Computes the volume, area or length of the element depending on its spatial dimension.
int giveNumberOfIntegrationRules()
#define _IFT_MatlabExportModule_noScaledHomogenization
virtual ~MatlabExportModule()
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
basisType giveBasisType()
Class representing a general abstraction for finite element interpolation class.
#define _IFT_MatlabExportModule_data
int giveSubStepNumber()
Returns receiver's substep number.
void buildReactionTable(IntArray &restrDofMans, IntArray &restrDofs, IntArray &eqn, TimeStep *tStep, int di)
Builds the reaction force table.
#define _IFT_MatlabExportModule_specials
void doOutputMesh(TimeStep *tStep, FILE *FID)
std::vector< std::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
virtual void terminate()
Terminates the receiver.
int giveNumber()
Returns receiver's number.
Element * giveElement(int n)
Service for accessing particular domain fe element.
bool testSubStepOutput()
Initializes receiver.
void clear()
Clears the array (zero size).
EngngModel * emodel
Problem pointer.
#define _IFT_MatlabExportModule_DofManList
Set of elements, boundaries, edges and/or nodes.
Wrapper around element definition to provide FEICellGeometry interface.
Set * giveSet(int n)
Service for accessing particular domain set.
#define _IFT_MatlabExportModule_homogenizeInternalVars
std::vector< double > smin
void resize(int n)
Checks size of receiver towards requested bounds.
virtual void doOutput(TimeStep *tStep, bool forcedOutput=false)
Writes the output.
void doOutputReactionForces(TimeStep *tStep, FILE *FID)
void doOutputData(TimeStep *tStep, FILE *FID)
int reactionForcesNodeSet
Class representing vector of real numbers.
virtual DofManager * giveInternalDofManager(int i)
Gives an internal dof manager from receiver.
#define _IFT_MatlabExportModule_IPFieldsElSet
void doOutputSpecials(TimeStep *tStep, FILE *FID)
#define _IFT_MatlabExportModule_mesh
IRResultType
Type defining the return values of InputRecord reading operations.
#define _IFT_MatlabExportModule_ElementList
IntArray reactionForcesDofManList
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
The representation of EngngModel default prescribed unknown numbering.
std::vector< Dof * >::iterator begin()
int number
Component number.
void followedBy(const IntArray &b, int allocChunk=0)
Appends array b at the end of receiver.
int giveNumberOfIntegrationPoints() const
Returns number of integration points of receiver.
#define _IFT_MatlabExportModule_ReactionForcesNodeSet
void doOutputIntegrationPointFields(TimeStep *tStep, FILE *FID)
std::vector< std::string > partName
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
#define _IFT_MatlabExportModule_IntegrationPoints
FILE * giveOutputStream(TimeStep *)
void times(double s)
Multiplies receiver with scalar.
void doOutputHomogenizeDofIDs(TimeStep *tStep, FILE *FID)
virtual int giveNumberOfInternalDofManagers()
Gives the number of internal dof managers.
This class implements extension of EngngModel for structural models.
int min(int i, int j)
Returns smaller value from two given decimals.
std::vector< std::unique_ptr< Element > > & giveElements()
void computeReaction(FloatArray &answer, TimeStep *tStep, int di)
Computes reaction forces.
virtual DofManager * giveInternalDofManager(int i)
Gives an internal dof manager from receiver.
(Under development) The Matlab export module enables oofem to export the results to a textfile contai...
const char * __InternalStateTypeToString(InternalStateType _value)
Abstract base class representing the "problem" under consideration.
IntArray internalVarsToExport
list of InternalStateType values, identifying the selected vars for export
int giveSize() const
Returns the size of receiver.
virtual double giveCoordinate(int i)
the oofem namespace is to define a context or scope in which all oofem names are defined.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Abstract class Dof represents Degree Of Freedom in finite element mesh.
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
virtual void initialize()
#define _IFT_MatlabExportModule_internalVarsToExport
Imposes weak periodicity on the doftype of choice.
std::vector< double > smax
Class representing integration point in finite element program.
Class representing solution step.
virtual int computeGlobalCoordinates(FloatArray &answer, const FloatArray &lcoords)
Computes the global coordinates from given element's local coordinates.
REGISTER_ExportModule(ErrorCheckingExportModule)
int findFirstIndexOf(int value) const
Finds index of first occurrence of given value in array.