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

📄 xmdsintegrateex.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: xmdsintegrateex.cc,v 1.14 2004/07/13 05:29:38 paultcochrane Exp $*//*! @file xmdsintegrateex.cc  @brief Integrate element parsing classes and methods; explicit picture  More detailed explanation...*/#include<xmlbasics.h>#include<dom3.h>#include<xmdsutils.h>#include<xmdsclasses.h>// ******************************************************************************// ******************************************************************************//                              xmdsIntegrateEX public// ******************************************************************************// ******************************************************************************extern bool debugFlag;long nxmdsIntegrateEXs=0;  //!< Number of xmds integrate EX objects// ******************************************************************************xmdsIntegrateEX::xmdsIntegrateEX(				 const xmdsSimulation *const yourSimulation,				 const bool& yourVerboseMode) :  xmdsIntegrate(yourSimulation,yourVerboseMode) {  if(debugFlag) {    nxmdsIntegrateEXs++;    printf("xmdsIntegrateEX::xmdsIntegrateEX\n");    printf("nxmdsIntegrateEXs=%li\n",nxmdsIntegrateEXs);  }};// ******************************************************************************xmdsIntegrateEX::~xmdsIntegrateEX() {  if(debugFlag) {    nxmdsIntegrateEXs--;    printf("xmdsIntegrateEX::~xmdsIntegrateEX\n");    printf("nxmdsIntegrateEXs=%li\n",nxmdsIntegrateEXs);  }};// ******************************************************************************void xmdsIntegrateEX::processElement(				     const Element *const yourElement) {  if(debugFlag) {    printf("xmdsIntegrateEX::processElement\n");  }  // ************************************  // parse code for operators  const xmdsVector* mainVector;  if(!simulation()->field()->getVector("main",mainVector)) {    throw xmdsException("Internal error in xmdsIntegrateEX::processElement: cannot find 'main' vector");  }  XMLString* theCode = propagationCode();  XMLString nextOperatorName;  XMLString nextComponentName;  unsigned long start=0;  unsigned long end=0;  char s[256];  list<XMLString> coVectorComponentNamesList;  // first need to get all co pairs  while(end<theCode->length()) {    if(findNextcoPair(nextOperatorName,nextComponentName,start,end)) {      unsigned long nextComponentNumber;      if(!mainVector->getComponent(nextComponentName,nextComponentNumber)) {	sprintf(errorMessage(),"[%s] is not a component of the main vector",nextComponentName.c_str());	throw xmdsException(yourElement,errorMessage());      }      unsigned long nextOperatorNumber;      if(!getKOperator(nextOperatorName,nextOperatorNumber)) {	sprintf(errorMessage(),"'%s' was not defined in <k_operators>",nextOperatorName.c_str());	throw xmdsException(yourElement,errorMessage());      }      sprintf(s,"_segment%li_co_term_%s_%s",segmentNumber,nextOperatorName.c_str(),nextComponentName.c_str());      const XMLString nextVectorComponentName = s;      unsigned long coKey;      if(!getcoKey(nextComponentNumber,nextOperatorNumber,coKey)) {	if(verbose()) {	  printf("adding operator-component pair: %s[%s]\n",nextOperatorName.c_str(),nextComponentName.c_str());	}	coKey = addcoPair(nextComponentNumber,nextOperatorNumber);	coVectorComponentNamesList.push_back(nextVectorComponentName);      }      theCode->replaceData(start,end-start,nextVectorComponentName);      start = start+nextVectorComponentName.length();    }    else {      start = end;    }  }  if(coVectorComponentNamesList.size()>0) {    xmdsVector* coVector = simulation()->field()->createxmdsVector();    sprintf(s,"segment%li_co_terms",segmentNumber);    coVector->setName(s);    coVector->setVectorType(COMPLEX);    coVector->setComponents(coVectorComponentNamesList);    list<XMLString> tempVectorNamesList;    tempVectorNamesList.push_back("main");    tempVectorNamesList.push_back(s);    simulation()->field()->processVectors(tempVectorNamesList,simulation()->field()->geometry()->fullSpace());    vectorNamesList()->push_back(s);  }};// ******************************************************************************// ******************************************************************************//                              xmdsIntegrateEX protected// ******************************************************************************// ******************************************************************************// ******************************************************************************void xmdsIntegrateEX::writePrototypes(				      FILE *const outfile) const {  if(debugFlag) {    printf("xmdsIntegrateEX::writePrototypes\n");  }  if(usesKOperators()) {    fprintf(outfile,"// integrate (EX) prototypes\n");    fprintf(outfile,"\n");    if(constantK()) {      fprintf(outfile,"void _segment%li_calculate_k_operator_field();\n",segmentNumber);      fprintf(outfile,"\n");    }    fprintf(outfile,"void _segment%li_calculate_co_terms();\n",segmentNumber);  }};// ******************************************************************************void xmdsIntegrateEX::writeRoutines(				    FILE *const outfile) const {  if(debugFlag) {    printf("xmdsIntegrateEX::writeRoutines\n");  }  if(usesKOperators()) {    if(constantK()) {      writeCalculatekOperatorFieldRoutine(outfile);      writeCalculateCOTermsConstantKRoutine(outfile);    }    else      writeCalculateCOTermsTimeDepKRoutine(outfile);  }};// ******************************************************************************// ******************************************************************************//                              xmdsIntegrateEX private// ******************************************************************************// ******************************************************************************// ******************************************************************************void xmdsIntegrateEX::writeCalculatekOperatorFieldRoutine(							  FILE *const outfile) const {  if(debugFlag) {    printf("xmdsIntegrateEX::writeCalculatekOperatorFieldRoutine\n");  }

⌨️ 快捷键说明

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