⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmdsoutput.cc

📁 XMDS is a code generator that integrates equations. You write them down in human readable form in a
💻 CC
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 2000-2004 Code contributed by Greg Collecutt, Joseph Hope and Paul Cochrane This file is part of xmds.  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*//*  $Id: xmdsoutput.cc,v 1.26 2004/10/21 09:49:27 paultcochrane Exp $*//*! @file xmdsoutput.cc  @brief Output element parsing classes and methods  More detailed explanation...*/#include<xmlbasics.h>#include<dom3.h>#include<xmdsutils.h>#include<xmdsclasses.h>#include<vector>// ******************************************************************************// ******************************************************************************//                              xmdsOutput public// ******************************************************************************// ******************************************************************************extern bool debugFlag;extern vector<string> simHeaderText, simBodyText, simFooterText;long nxmdsOutputs=0;  //!< Number of xmds output objects// ******************************************************************************xmdsOutput::xmdsOutput(		       const xmdsSimulation *const yourSimulation,		       const bool& yourVerboseMode) :  xmdsElement(yourSimulation,yourVerboseMode) {  if(debugFlag) {    nxmdsOutputs++;    printf("xmdsOutput::xmdsOutput\n");    printf("nxmdsOutputs=%li\n",nxmdsOutputs);  }  myInFileSplitPoint = 0;};// ******************************************************************************xmdsOutput::~xmdsOutput() {  if(debugFlag) {    nxmdsOutputs--;    printf("xmdsOutput::~xmdsOutput\n");    printf("nxmdsOutputs=%li\n",nxmdsOutputs);  }};// ******************************************************************************void xmdsOutput::processElement(				const Element *const yourElement) {  if(debugFlag) {    printf("xmdsOutput::processElement\n");  }  if(verbose()) {    printf("Processing output element ...\n");  }  list<XMLString> myXMLStringList;  list<bool> myBoolList;  // ************************************  // find output file name  getAssignmentStrings(yourElement,"filename",0,1,myXMLStringList);  if(myXMLStringList.size()==1) {    myOutputFileName=*myXMLStringList.begin();    if(verbose()) {      printf("Output file is '%s'\n",myOutputFileName.c_str());    }  }  else {    // Create default output file name    myOutputFileName = simulation()->parameters()->simulationName;    myOutputFileName += ".xsil";    printf("Output file name defaulting to '%s'\n",myOutputFileName.c_str());  }  // ************************************  // find and process moment groups  // ************************************  const NodeList* candidateElements;  // find constants element and process if present  candidateElements = yourElement->getElementsByTagName("group",NOT_DEEP);  if(candidateElements->length()==0) {    throw xmdsException(yourElement,"No moment <group>s defined!");  }  for(unsigned long i=0; i<candidateElements->length(); i++) {    xmdsMomentGroup* newxmdsMomentGroup = createxmdsMomentGroup();    const Element* yourElement = dynamic_cast<const Element*> (candidateElements->item(i));    newxmdsMomentGroup->processElement(yourElement);  }  // ************************************  // find and process breakpoint  // ************************************  // find breakpoint element and process if present  candidateElements = yourElement->getElementsByTagName("breakpoint",NOT_DEEP);  if(candidateElements->length()>1) {    throw xmdsException(yourElement,"More than one <breakpoint> defined!");  }    if(candidateElements->length()==1) {    if (debugFlag) {      printf("xmdsOutput::processElement; found <breakpoint> tag\n");    }    bpEnabledFlag = true;  // by default, if the <breakpoint> tag is given, then breakpoints are enabled    getAttributeBools(yourElement, "breakpoint", "enabled", NOT_REQD, bpEnabledFlag);    if (debugFlag) {      printf("xmdsOutput::processElement : bpEnabledFlag = %d\n", bpEnabledFlag);    }    xmdsBreakPoint* newxmdsBreakPoint = createxmdsBreakPoint();    const Element* yourElement = dynamic_cast<const Element*> (candidateElements->item(0));    newxmdsBreakPoint->processElement(yourElement);  }};// ******************************************************************************void xmdsOutput::setInFileSplitPoint(				     const unsigned long& inFileSplitPoint) {  if(debugFlag) {    printf("xmdsOutput::setInFileSplitPoint\n");  }  myInFileSplitPoint = inFileSplitPoint;};// ******************************************************************************unsigned long xmdsOutput::nMomentGroups() const {  if(debugFlag) {    printf("xmdsOutput::nMomentGroups\n");  }  return myMomentGroupsList.size();};// ******************************************************************************XMLString xmdsOutput::getOutputFileName() const {  if (debugFlag) {    printf("xmdsOutput::getOutputFileName\n");  }  return myOutputFileName;};// ******************************************************************************const xmdsMomentGroup* xmdsOutput::momentGroup(					       const unsigned long& index) const {  if(debugFlag) {    printf("xmdsOutput::momentGroup\n");  }  if(index>=myMomentGroupsList.size()) {    throw xmdsException("Internal range error in xmdsOutput::momentGroup");  }  list<xmdsMomentGroup*>::const_iterator ppxmdsMomentGroup = myMomentGroupsList.begin();  for(unsigned long i=0; i<index; i++) {    ppxmdsMomentGroup++;  }  return *ppxmdsMomentGroup;};// ******************************************************************************void xmdsOutput::addSamples(			    const list<unsigned long>& samplesList) const {  if(debugFlag) {    printf("xmdsOutput::addSamples\n");  }  if(samplesList.size() != myMomentGroupsList.size()) {    throw xmdsException("Internal error in xmdsOutput::addSamples: wrong number of samples.");  }  list<unsigned long>::const_iterator pLong = samplesList.begin();  for(list<xmdsMomentGroup*>::const_iterator pxmdsMomentGroup = myMomentGroupsList.begin(); pxmdsMomentGroup != myMomentGroupsList.end(); pxmdsMomentGroup++) {    (*pxmdsMomentGroup)->addSamples(*pLong);    pLong++;  }};// ******************************************************************************void xmdsOutput::finaliseGeometry() {  if(debugFlag) {    printf("xmdsOutput::finaliseGeometry\n");  }  for(list<xmdsMomentGroup*>::const_iterator pxmdsMomentGroup = myMomentGroupsList.begin(); pxmdsMomentGroup != myMomentGroupsList.end(); pxmdsMomentGroup++) {    (*pxmdsMomentGroup)->finaliseGeometry();  }};// ******************************************************************************void xmdsOutput::assignActiveVectorPointers(					    FILE *const outfile,					    const char *const tempVectorName) const {  if(debugFlag) {    printf("xmdsOutput::assignActiveVectorPointers\n");  }  for(list<xmdsMomentGroup*>::const_iterator pxmdsMomentGroup = myMomentGroupsList.begin(); pxmdsMomentGroup != myMomentGroupsList.end(); pxmdsMomentGroup++) {    (*pxmdsMomentGroup)->assignActiveVectorPointers(outfile,tempVectorName);  }};// ******************************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -