changed: factor the reading of patches into a function
will be useful when reading from the HDF5 file git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@1025 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
parent
48cf338752
commit
992208fc38
@ -69,27 +69,7 @@ bool SIM1D::parse (char* keyWord, std::istream& is)
|
||||
size_t i = 9; while (i < strlen(keyWord) && isspace(keyWord[i])) i++;
|
||||
std::cout <<"\nReading data file "<< keyWord+i << std::endl;
|
||||
std::ifstream isp(keyWord+i);
|
||||
|
||||
ASMbase* pch = 0;
|
||||
for (int patchNo = 1; isp.good(); patchNo++)
|
||||
{
|
||||
std::cout <<"Reading patch "<< patchNo << std::endl;
|
||||
switch (discretization) {
|
||||
case Lagrange:
|
||||
pch = new ASMs1DLag(isp,1,nf);
|
||||
break;
|
||||
case Spectral:
|
||||
pch = new ASMs1DSpec(isp,1,nf);
|
||||
break;
|
||||
default:
|
||||
pch = new ASMs1D(isp,1,nf);
|
||||
}
|
||||
if (pch->empty())
|
||||
delete pch;
|
||||
else
|
||||
myModel.push_back(pch);
|
||||
}
|
||||
|
||||
readPatches(isp);
|
||||
if (myModel.empty())
|
||||
{
|
||||
std::cerr <<" *** SIM1D::parse: No patches read"<< std::endl;
|
||||
@ -389,3 +369,27 @@ void SIM1D::setQuadratureRule (size_t ng)
|
||||
if (!myModel.empty())
|
||||
static_cast<ASMs1D*>(myModel[i])->setGauss(ng);
|
||||
}
|
||||
|
||||
|
||||
void SIM1D::readPatches(std::istream& isp)
|
||||
{
|
||||
ASMbase* pch = 0;
|
||||
for (int patchNo = 1; isp.good(); patchNo++)
|
||||
{
|
||||
std::cout <<"Reading patch "<< patchNo << std::endl;
|
||||
switch (discretization) {
|
||||
case Lagrange:
|
||||
pch = new ASMs1DLag(isp,1,nf);
|
||||
break;
|
||||
case Spectral:
|
||||
pch = new ASMs1DSpec(isp,1,nf);
|
||||
break;
|
||||
default:
|
||||
pch = new ASMs1D(isp,1,nf);
|
||||
}
|
||||
if (pch->empty())
|
||||
delete pch;
|
||||
else
|
||||
myModel.push_back(pch);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ public:
|
||||
//! \param[in] ng Number of Gauss points in each parameter direction
|
||||
virtual void setQuadratureRule(size_t ng);
|
||||
|
||||
//! \brief Read patches from given stream
|
||||
//! \param[in] isp The stream to read from
|
||||
void readPatches(std::istream& isp);
|
||||
|
||||
protected:
|
||||
//! \brief Parses a data section from an input stream.
|
||||
//! \param[in] keyWord Keyword of current data section to read
|
||||
|
@ -77,33 +77,7 @@ bool SIM2D::parse (char* keyWord, std::istream& is)
|
||||
size_t i = 9; while (i < strlen(keyWord) && isspace(keyWord[i])) i++;
|
||||
std::cout <<"\nReading data file "<< keyWord+i << std::endl;
|
||||
std::ifstream isp(keyWord+i);
|
||||
|
||||
ASMbase* pch = 0;
|
||||
for (int patchNo = 1; isp.good(); patchNo++)
|
||||
{
|
||||
std::cout <<"Reading patch "<< patchNo << std::endl;
|
||||
switch (discretization) {
|
||||
case Lagrange:
|
||||
if (nf[1] > 0)
|
||||
pch = new ASMs2DmxLag(isp,2,nf[0],nf[1]);
|
||||
else
|
||||
pch = new ASMs2DLag(isp,2,nf[0]);
|
||||
break;
|
||||
case Spectral:
|
||||
pch = new ASMs2DSpec(isp,2,nf[0]);
|
||||
break;
|
||||
default:
|
||||
if (nf[1] > 0)
|
||||
pch = new ASMs2Dmx(isp,2,nf[0],nf[1]);
|
||||
else
|
||||
pch = new ASMs2D(isp,2,nf[0]);
|
||||
}
|
||||
if (pch->empty() || this->getLocalPatchIndex(patchNo) < 1)
|
||||
delete pch;
|
||||
else
|
||||
myModel.push_back(pch);
|
||||
}
|
||||
|
||||
readPatches(isp);
|
||||
if (myModel.empty())
|
||||
{
|
||||
std::cerr <<" *** SIM2D::parse: No patches read"<< std::endl;
|
||||
@ -485,3 +459,33 @@ void SIM2D::setQuadratureRule (size_t ng)
|
||||
if (!myModel.empty())
|
||||
static_cast<ASMs2D*>(myModel[i])->setGauss(ng);
|
||||
}
|
||||
|
||||
|
||||
void SIM2D::readPatches(std::istream& isp)
|
||||
{
|
||||
ASMbase* pch = 0;
|
||||
for (int patchNo = 1; isp.good(); patchNo++)
|
||||
{
|
||||
std::cout <<"Reading patch "<< patchNo << std::endl;
|
||||
switch (discretization) {
|
||||
case Lagrange:
|
||||
if (nf[1] > 0)
|
||||
pch = new ASMs2DmxLag(isp,2,nf[0],nf[1]);
|
||||
else
|
||||
pch = new ASMs2DLag(isp,2,nf[0]);
|
||||
break;
|
||||
case Spectral:
|
||||
pch = new ASMs2DSpec(isp,2,nf[0]);
|
||||
break;
|
||||
default:
|
||||
if (nf[1] > 0)
|
||||
pch = new ASMs2Dmx(isp,2,nf[0],nf[1]);
|
||||
else
|
||||
pch = new ASMs2D(isp,2,nf[0]);
|
||||
}
|
||||
if (pch->empty() || this->getLocalPatchIndex(patchNo) < 1)
|
||||
delete pch;
|
||||
else
|
||||
myModel.push_back(pch);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,10 @@ public:
|
||||
//! \param[in] ng Number of Gauss points in each parameter direction
|
||||
virtual void setQuadratureRule(size_t ng);
|
||||
|
||||
//! \brief Read patches from given stream
|
||||
//! \param[in] isp The stream to read from
|
||||
void readPatches(std::istream& isp);
|
||||
|
||||
protected:
|
||||
//! \brief Parses a data section from an input stream.
|
||||
//! \param[in] keyWord Keyword of current data section to read
|
||||
|
@ -78,33 +78,7 @@ bool SIM3D::parse (char* keyWord, std::istream& is)
|
||||
size_t i = 9; while (i < strlen(keyWord) && isspace(keyWord[i])) i++;
|
||||
std::cout <<"\nReading data file "<< keyWord+i << std::endl;
|
||||
std::ifstream isp(keyWord+i);
|
||||
|
||||
ASMbase* pch = 0;
|
||||
for (int patchNo = 1; isp.good(); patchNo++)
|
||||
{
|
||||
std::cout <<"Reading patch "<< patchNo << std::endl;
|
||||
switch (discretization) {
|
||||
case Lagrange:
|
||||
if (nf[1] > 0)
|
||||
pch = new ASMs3DmxLag(isp,checkRHSys,nf[0],nf[1]);
|
||||
else
|
||||
pch = new ASMs3DLag(isp,checkRHSys,nf[0]);
|
||||
break;
|
||||
case Spectral:
|
||||
pch = new ASMs3DSpec(isp,checkRHSys,nf[0]);
|
||||
break;
|
||||
default:
|
||||
if (nf[1] > 0)
|
||||
pch = new ASMs3Dmx(isp,checkRHSys,nf[0],nf[1]);
|
||||
else
|
||||
pch = new ASMs3D(isp,checkRHSys,nf[0]);
|
||||
}
|
||||
if (pch->empty() || this->getLocalPatchIndex(patchNo) < 1)
|
||||
delete pch;
|
||||
else
|
||||
myModel.push_back(pch);
|
||||
}
|
||||
|
||||
readPatches(isp);
|
||||
if (myModel.empty())
|
||||
{
|
||||
std::cerr <<" *** SIM3D::parse: No patches read"<< std::endl;
|
||||
@ -597,3 +571,33 @@ void SIM3D::setQuadratureRule (size_t ng)
|
||||
if (!myModel.empty())
|
||||
static_cast<ASMs3D*>(myModel[i])->setGauss(ng);
|
||||
}
|
||||
|
||||
|
||||
void SIM3D::readPatches(std::istream& isp)
|
||||
{
|
||||
ASMbase* pch = 0;
|
||||
for (int patchNo = 1; isp.good(); patchNo++)
|
||||
{
|
||||
std::cout <<"Reading patch "<< patchNo << std::endl;
|
||||
switch (discretization) {
|
||||
case Lagrange:
|
||||
if (nf[1] > 0)
|
||||
pch = new ASMs3DmxLag(isp,checkRHSys,nf[0],nf[1]);
|
||||
else
|
||||
pch = new ASMs3DLag(isp,checkRHSys,nf[0]);
|
||||
break;
|
||||
case Spectral:
|
||||
pch = new ASMs3DSpec(isp,checkRHSys,nf[0]);
|
||||
break;
|
||||
default:
|
||||
if (nf[1] > 0)
|
||||
pch = new ASMs3Dmx(isp,checkRHSys,nf[0],nf[1]);
|
||||
else
|
||||
pch = new ASMs3D(isp,checkRHSys,nf[0]);
|
||||
}
|
||||
if (pch->empty() || this->getLocalPatchIndex(patchNo) < 1)
|
||||
delete pch;
|
||||
else
|
||||
myModel.push_back(pch);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ public:
|
||||
//! \param[in] ng Number of Gauss points in each parameter direction
|
||||
virtual void setQuadratureRule(size_t ng);
|
||||
|
||||
//! \brief Read patches from given stream
|
||||
//! \param[in] isp The stream to read from
|
||||
void readPatches(std::istream& isp);
|
||||
|
||||
protected:
|
||||
//! \brief Parses a data section from an input stream.
|
||||
//! \param[in] keyWord Keyword of current data section to read
|
||||
|
@ -96,6 +96,10 @@ public:
|
||||
bool preprocess(const std::vector<int>& ignoredPatches = std::vector<int>(),
|
||||
bool fixDup = false);
|
||||
|
||||
//! \brief Read patches from given stream
|
||||
//! \param[in] isp The stream to read from
|
||||
virtual void readPatches(std::istream& isp) {};
|
||||
|
||||
//! \brief Allocates the system matrices of the FE problem to be solved.
|
||||
//! \param[in] mType The matrix format to use
|
||||
//! \param[in] nMats Number of system matrices
|
||||
|
Loading…
Reference in New Issue
Block a user