/*
* Copyright (C) 2013 Thorsten Liebig (Thorsten.Liebig@gmx.de)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "tinyxml.h"
#include "CSPropDebyeMaterial.h"
CSPropDebyeMaterial::CSPropDebyeMaterial(ParameterSet* paraSet) : CSPropDispersiveMaterial(paraSet) {Type=(CSProperties::PropertyType)(DEBYEMATERIAL | DISPERSIVEMATERIAL | MATERIAL);Init();}
CSPropDebyeMaterial::CSPropDebyeMaterial(CSProperties* prop) : CSPropDispersiveMaterial(prop) {Type=(CSProperties::PropertyType)(DEBYEMATERIAL | DISPERSIVEMATERIAL | MATERIAL);Init();}
CSPropDebyeMaterial::CSPropDebyeMaterial(unsigned int ID, ParameterSet* paraSet) : CSPropDispersiveMaterial(ID,paraSet) {Type=(CSProperties::PropertyType)(DEBYEMATERIAL | DISPERSIVEMATERIAL | MATERIAL);Init();}
CSPropDebyeMaterial::~CSPropDebyeMaterial()
{
DeleteValues();
m_Order = 0;
}
void CSPropDebyeMaterial::Init()
{
m_Order = 0;
EpsDelta=NULL;
WeightEpsDelta=NULL;
EpsRelaxTime=NULL;
WeightEpsRelaxTime=NULL;
InitValues();
CSPropDispersiveMaterial::Init();
}
void CSPropDebyeMaterial::DeleteValues()
{
for (int o=0;oappend(stream.str());
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightEpsDelta[o][n].Evaluate();
if (EC!=ParameterScalar::NO_ERROR) bOK=false;
if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Debye Material-Property epsilon Delta frequency weighting function (ID: " << uiID << "): ";
ErrStr->append(stream.str());
PSErrorCode2Msg(EC,ErrStr);
}
EC=EpsRelaxTime[o][n].Evaluate();
if (EC!=ParameterScalar::NO_ERROR) bOK=false;
if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Debye Material-Property epsilon relaxation time value (ID: " << uiID << "): ";
ErrStr->append(stream.str());
PSErrorCode2Msg(EC,ErrStr);
}
EC=WeightEpsRelaxTime[o][n].Evaluate();
if (EC!=ParameterScalar::NO_ERROR) bOK=false;
if ((EC!=ParameterScalar::NO_ERROR) && (ErrStr!=NULL))
{
std::stringstream stream;
stream << std::endl << "Error in Debye Material-Property epsilon relaxation time weighting function (ID: " << uiID << "): ";
ErrStr->append(stream.str());
PSErrorCode2Msg(EC,ErrStr);
}
}
}
return bOK & CSPropDispersiveMaterial::Update(ErrStr);
}
bool CSPropDebyeMaterial::Write2XML(TiXmlNode& root, bool parameterised, bool sparse)
{
if (CSPropDispersiveMaterial::Write2XML(root,parameterised,sparse) == false) return false;
TiXmlElement* prop=root.ToElement();
if (prop==NULL) return false;
std::string suffix;
for (int o=0;oFirstChildElement("Property");
if (value==NULL)
return false;
WriteVectorTerm(EpsDelta[o],*value,"EpsilonDelta_"+suffix,parameterised);
WriteVectorTerm(EpsRelaxTime[o],*value,"EpsilonRelaxTime_"+suffix,parameterised);
TiXmlElement* weight=prop->FirstChildElement("Weight");
if (weight==NULL)
return false;
WriteVectorTerm(WeightEpsDelta[o],*weight,"EpsilonDelta_"+suffix,parameterised);
WriteVectorTerm(WeightEpsRelaxTime[o],*weight,"EpsilonRelaxTime_"+suffix,parameterised);
}
return true;
}
bool CSPropDebyeMaterial::ReadFromXML(TiXmlNode &root)
{
if (CSPropDispersiveMaterial::ReadFromXML(root)==false) return false;
TiXmlElement* prop=root.ToElement();
if (prop==NULL) return false;
// count m_Order
TiXmlElement* matProp=prop->FirstChildElement("Property");
if (matProp!=NULL)
{
m_Order=1;
while (1)
{
if (matProp->Attribute("EpsilonDelta_"+ConvertInt(m_Order+1)))
++m_Order;
else if (matProp->Attribute("MueDelta_"+ConvertInt(m_Order+1)))
++m_Order;
else
break;
}
}
else
return false;
InitValues();
if (ReadVectorTerm(EpsDelta[0],*matProp,"EpsilonDelta_1",0.0)==false)
ReadVectorTerm(EpsDelta[0],*matProp,"EpsilonDelta",0.0);
if (ReadVectorTerm(EpsRelaxTime[0],*matProp,"EpsilonRelaxTime_1",0.0)==false)
ReadVectorTerm(EpsRelaxTime[0],*matProp,"EpsilonRelaxTime",0.0);
TiXmlElement* weightProp=prop->FirstChildElement("Weight");
if (weightProp)
{
if (ReadVectorTerm(WeightEpsDelta[0],*weightProp,"EpsilonDelta_1",1.0)==false)
ReadVectorTerm(WeightEpsDelta[0],*weightProp,"EpsilonDelta",1.0);
if (ReadVectorTerm(WeightEpsRelaxTime[0],*weightProp,"EpsilonRelaxTime_1",1.0)==false)
ReadVectorTerm(WeightEpsRelaxTime[0],*weightProp,"EpsilonRelaxTime",1.0);
}
for (int o=1;o