Added: Input file option to output only primary solution variables to VTF/HDF5.

This commit is contained in:
Knut Morten Okstad
2016-01-21 18:43:29 +01:00
parent 5f5d792c00
commit 1641924b03
8 changed files with 45 additions and 38 deletions

View File

@@ -95,8 +95,7 @@ bool MultiStepSIM::saveModel (int& gBlock, int& rBlock, char* fileName)
}
bool MultiStepSIM::saveStep (int iStep, double time,
bool psolOnly, const char* vecName)
bool MultiStepSIM::saveStep (int iStep, double time, const char* vecName)
{
if (iStep <= lastSt) return true; // We have already saved this step
@@ -111,18 +110,18 @@ bool MultiStepSIM::saveStep (int iStep, double time,
lastSt = iStep;
// Write boundary tractions, if any
if (!psolOnly)
if (!opt.pSolOnly)
if (!model.writeGlvT(iStep,geoBlk,nBlock))
return false;
// Write residual force vector, but only when no extra visualization points
if (!psolOnly && opt.nViz[0] == 2 && opt.nViz[1] <= 2 && opt.nViz[2] <= 2)
if (!opt.pSolOnly && opt.nViz[0] == 2 && opt.nViz[1] <= 2 && opt.nViz[2] <= 2)
if (!model.writeGlvV(residual,"Residual forces",iStep,nBlock))
return false;
// Write solution fields
if (!solution.empty())
if (!model.writeGlvS(solution.front(),iStep,nBlock,time,psolOnly,vecName))
if (!model.writeGlvS(solution.front(),iStep,nBlock,time,vecName))
return false;
// Write any problem-specific data (rigid body transformations, etc.)
@@ -142,10 +141,10 @@ bool MultiStepSIM::saveStep (int iStep, double time,
*/
bool MultiStepSIM::saveStep (int iStep, int& rBlock, double time,
bool psolOnly, const char* vecName)
const char* vecName)
{
if (rBlock > nBlock) nBlock = rBlock;
bool s = this->saveStep(iStep,time,psolOnly,vecName);
bool s = this->saveStep(iStep,time,vecName);
rBlock = nBlock;
return s;
}

View File

@@ -58,7 +58,7 @@ public:
//! \param[in] withRF Whether nodal reaction forces should be computed or not
bool initEqSystem(bool withRF = true);
//! \brief Advances the time step one step forward.
//! \brief Advances the time/load step one step forward.
//! \param param Time stepping parameters
//! \param[in] updateTime If \e false, the time parameters are not incremented
virtual bool advanceStep(TimeStep& param, bool updateTime = true);
@@ -96,24 +96,21 @@ public:
//! \param[in] fileName File name used to construct the VTF-file name from
bool saveModel(int& gBlock, int& rBlock, char* fileName = nullptr);
//! \brief Saves the converged results to VTF file of a given time step.
//! \brief Saves the converged results to VTF file of a given time/load step.
//! \param[in] iStep Time/load step identifier
//! \param[in] time Current time/load parameter
//! \param[in] psolOnly If \e true, skip secondary solution field output
//! \param[in] vecName Optional name of primary solution vector field
bool saveStep(int iStep, double time,
bool psolOnly = false, const char* vecName = nullptr);
bool saveStep(int iStep, double time, const char* vecName = nullptr);
//! \brief Saves the converged results to VTF file of a given time step.
//! \brief Saves the converged results to VTF file of a given time/load step.
//! \param[in] iStep Time/load step identifier
//! \param rBlock Running result block counter
//! \param[in] time Current time/load parameter
//! \param[in] psolOnly If \e true, skip secondary solution field output
//! \param[in] vecName Optional name of primary solution vector field
bool saveStep(int iStep, int& rBlock, double time,
bool psolOnly = false, const char* vecName = nullptr);
const char* vecName = nullptr);
//! \brief Saves the converged solution to VTF file of a given time step.
//! \brief Saves the converged solution to VTF file of a given time/load step.
//! \param[in] iStep Time/load step identifier
//! \param rBlock Running result block counter
//! \param[in] vecName Name of primary solution vector field
@@ -138,9 +135,9 @@ public:
//! \brief Returns whether a points result file has been defined or not.
bool hasPointResultFile() const;
//! \brief Saves point solution to file for a given time step.
//! \param[in] time Load/time step parameter
//! \param[in] step Load/time step counter
//! \brief Saves point-wise solution to file for a given time/load step.
//! \param[in] time Time/load step parameter
//! \param[in] step Time/load step counter
bool savePoints(double time, int step) const;
//! \brief Returns a const reference to the solution vectors.

View File

@@ -74,7 +74,7 @@ public:
const Vector& getAcceleration() const { return solution[solution.size()-1]; }
//! \brief Dumps solution variables at user-defined points.
//! \param[in] time Current time/load parameter
//! \param[in] time Current time
//! \param[in] os The output stream to write the solution to
//! \param[in] precision Number of digits after the decimal point
//! \param[in] formatted If \e false, write all result points on a single line

View File

@@ -18,9 +18,9 @@
/*!
\brief Nonlinear solution driver for isogeometric FEM simulators.
\brief Nonlinear quasi-static solution driver for isogeometric FEM simulators.
\details This class contains data and methods for computing the nonlinear
solution to a FE problem based on splines/NURBS basis functions,
solution to a quasi-static FE problem based on splines/NURBS basis functions,
through Newton-Raphson iterations.
*/
@@ -52,7 +52,7 @@ public:
//! \param[in] initVal Initial values of the primary solution
void init(size_t nSol, const RealArray& initVal);
//! \brief Advances the time/load step one step forward.
//! \brief Advances the load step one step forward.
//! \param param Time stepping parameters
//! \param[in] updateTime If \e false, the time parameters are not incremented
virtual bool advanceStep(TimeStep& param, bool updateTime = true);
@@ -104,7 +104,7 @@ protected:
double divgLim; //!< Relative divergence limit
double eta; //!< Line search tolerance
double alpha; //!< Iteration acceleration parameter (for line search)
int maxit; //!< Maximum number of iterations in a time/load step
int maxit; //!< Maximum number of iterations in a load step
int nupdat; //!< Number of iterations with updated tangent
int prnSlow; //!< How many DOFs to print out on slow convergence

View File

@@ -46,6 +46,7 @@ SIMoptions::SIMoptions ()
format = -1;
saveInc = 1;
dtSave = 0.0;
pSolOnly = false;
enableController = false;
nGauss[0] = nGauss[1] = 4;
@@ -173,6 +174,9 @@ bool SIMoptions::parseOutputTag (const TiXmlElement* elem)
hdf5 = "(default)";
}
else if (!strcasecmp(elem->Value(),"primarySolOnly"))
pSolOnly = true;
else if (!strcasecmp(elem->Value(),"projection")) {
std::string type;
if (utl::getAttribute(elem,"type",type))
@@ -337,11 +341,16 @@ utl::LogStream& SIMoptions::print (utl::LogStream& os, bool addBlankLine) const
if (!hdf5.empty())
os <<"\nHDF5 result database: "<< hdf5 <<".hdf5";
else if (format < 0)
return os;
if (dtSave > 0.0)
os <<"\nTime between each result save: "<< dtSave;
if (saveInc > 1)
os <<"\nIncrements between each result save: "<< saveInc;
if (pSolOnly)
os <<"\nSecondary solution variables are not saved.";
return os;
}

View File

@@ -81,8 +81,9 @@ public:
// Output options
int format; //!< VTF-file format (-1=NONE, 0=ASCII, 1=BINARY)
int nViz[3]; //!< Number of visualization points over each knot-span
int saveInc; //!< Number of increments between each result output
int saveInc; //!< Number of load/time increments between each result output
double dtSave; //!< Time interval between each result output
bool pSolOnly; //!< If \e true, don't save secondary solution variables
std::string hdf5; //!< Prefix for HDF5-file
bool enableController; //!< Whether or not to enable external program control

View File

@@ -367,14 +367,14 @@ bool SIMoutput::writeGlvV (const Vector& vec, const char* fieldName,
bool SIMoutput::writeGlvS (const Vector& psol, int iStep, int& nBlock,
double time, bool psolOnly, const char* pvecName,
double time, const char* pvecName,
int idBlock, int psolComps)
{
idBlock = this->writeGlvS1(psol,iStep,nBlock,time,
pvecName,idBlock,psolComps);
if (idBlock < 0)
return false;
else if (idBlock == 0 || psolOnly)
else if (idBlock == 0 || opt.pSolOnly)
return true;
return this->writeGlvS2(psol,iStep,nBlock,time,idBlock,psolComps);
@@ -384,9 +384,9 @@ bool SIMoutput::writeGlvS (const Vector& psol, int iStep, int& nBlock,
/*!
This method writes only the primary solution field to the VTF-file.
The primary solution is written as a deformation plot (labelled "Solution")
if \a pvecName is nullptr. If the primary solution is a scalar field, the field
if \a pvecName is null. If the primary solution is a scalar field, the field
value is in that case interpreted as a deformation along the global Z-axis.
If the primary solution is a vector field and \a pvecName is not nullptr,
If the primary solution is a vector field and \a pvecName is not null,
it is written as a named vector field instead (no deformation plot).
If the primary solution is a vector field, each vector component is written
@@ -478,11 +478,12 @@ int SIMoutput::writeGlvS1 (const Vector& psol, int iStep, int& nBlock,
const VecFunc& pSol = *mySol->getVectorSol();
for (j = 1; cit != grid->end_XYZ() && haveXsol; j++, ++cit)
field.fillColumn(j,pSol(Vec4(*cit,time)).ptr());
if (mySol->getScalarSol()) {
if (mySol->getScalarSol())
{
cit = grid->begin_XYZ();
const RealFunc& sSol = *mySol->getScalarSol();
for (j = 1; cit != grid->end_XYZ() && haveXsol; j++, ++cit)
field(field.rows(), j) = sSol(Vec4(*cit,time));
field(field.rows(),j) = sSol(Vec4(*cit,time));
}
}
@@ -670,8 +671,9 @@ bool SIMoutput::writeGlvS2 (const Vector& psol, int iStep, int& nBlock,
if (!myVtf->writeVblk(vID[i],vname.c_str(),idBlock+i,iStep))
return false;
const char* prefix = haveAsol ? "FE" : nullptr;
for (i = j = 0; i < nf && j < sMAX && !sID[j].empty(); i++, j++)
if (!myVtf->writeSblk(sID[j],myProblem->getField2Name(i,haveAsol?"FE":nullptr).c_str(),
if (!myVtf->writeSblk(sID[j],myProblem->getField2Name(i,prefix).c_str(),
idBlock++,iStep)) return false;
if (doProject)

View File

@@ -77,7 +77,7 @@ public:
//! \brief Writes current model geometry to the VTF-file.
//! \param nBlock Running result block counter
//! \param[in] inpFile File name used to construct the VTF-file name from
//! \param[in] doClear If \e true, clear geometry block if \a inpFile is nullptr
//! \param[in] doClear If \e true, clear geometry block if \a inpFile is null
//!
//! \details The spline patches are tesselated into linear finite elements
//! with a fixed number of elements within each knot-span of non-zero length.
@@ -116,13 +116,12 @@ public:
//! \param[in] iStep Load/time step identifier
//! \param nBlock Running result block counter
//! \param[in] time Load/time step parameter
//! \param[in] psolOnly If \e true, skip secondary solution field evaluation
//! \param[in] pvecName Optional name of the primary vector field solution
//! \param[in] idBlock Starting value of result block numbering
//! \param[in] psolComps Optional number of primary solution components
bool writeGlvS(const Vector& psol, int iStep, int& nBlock, double time = 0.0,
bool psolOnly = false, const char* pvecName = nullptr,
int idBlock = 10, int psolComps = 0);
const char* pvecName = nullptr, int idBlock = 10,
int psolComps = 0);
//! \brief Writes primary solution for a given load/time step to the VTF-file.
//! \param[in] psol Primary solution vector
@@ -212,9 +211,9 @@ public:
bool writeGlvF(const RealFunc& f, const char* fname,
int iStep, int& nBlock, int idBlock = 50, double time = 0.0);
//! \brief Writes time/load step info to the VTF-file.
//! \brief Writes load/time step info to the VTF-file.
//! \param[in] iStep Load/time step identifier
//! \param[in] value Time or load parameter of the step
//! \param[in] value Load parameter or time of the step
//! \param[in] itype Type identifier of the step
bool writeGlvStep(int iStep, double value = 0.0, int itype = 0);