LifeV
BCInterfaceData.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  * @file
29  * @brief File containing the BCInterfaceData class
30  *
31  * @date 17-07-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #include <lifev/bc_interface/core/bc/BCInterfaceData.hpp>
38 
39 namespace LifeV
40 {
41 
42 // ===================================================
43 // Constructors
44 // ===================================================
46  M_base (),
47  M_baseString (),
48  M_mapBase (),
49  M_boundaryID (),
50  M_parameters ()
51 {
52  //Set mapBase
53  M_mapBase["function"] = BCIFunctionParser;
54  M_mapBase["functionFile"] = BCIFunctionParserFile;
55  M_mapBase["functionSolver"] = BCIFunctionParserSolver;
56  M_mapBase["functionFileSolver"] = BCIFunctionParserFileSolver;
57  M_mapBase["functionUD"] = BCIFunctionUserDefined;
58  M_mapBase["functionSD"] = BCIFunctionSolverDefined;
59  M_mapBase["dataInterpolator"] = BCI3DDataInterpolator;
60 }
61 
63  M_base ( data.M_base ),
68 {
69 }
70 
71 // ===================================================
72 // Operators
73 // ===================================================
76 {
77  if ( this != &data )
78  {
79  M_base = data.M_base;
80  M_baseString = data.M_baseString;
81  M_mapBase = data.M_mapBase;
84  }
85 
86  return *this;
87 }
88 
89 // ===================================================
90 // Methods
91 // ===================================================
92 void
93 BCInterfaceData::readBC ( const std::string& fileName, const std::string& dataSection, const std::string& name )
94 {
95  GetPot dataFile ( fileName );
96 
97  // Read base
98  readBase ( dataFile, dataSection + name + "/", M_base, M_baseString );
99 
100  // Read parameters
101  readParameters ( dataFile, ( dataSection + name + "/parameters" ).c_str() );
102 }
103 
104 void
105 BCInterfaceData::showMe ( std::ostream& output ) const
106 {
107  output << "baseString = " << M_baseString << std::endl;
108  output << "base = " << M_base.second << std::endl;
109 
110  output << "boundary ID = " << M_boundaryID << std::endl;
111 
112  output << "Parameters = ";
113  for ( UInt i (0); i < static_cast<UInt> ( M_parameters.size() ); ++i )
114  {
115  output << M_parameters[i] << " ";
116  }
117  output << "\n";
118 }
119 
120 // ===================================================
121 // Set Methods
122 // ===================================================
123 void BCInterfaceData::setBaseString ( const std::string& baseString )
124 {
125  M_baseString = baseString;
126  std::string search = " ";
127  std::string replace = "";
128 
129  for( size_t pos = 0; ; pos += replace.length() ) {
130  pos = M_baseString.find( search, pos );
131  if( pos == std::string::npos ) break;
132  M_baseString.erase( pos, search.length() );
133  M_baseString.insert( pos, replace );
134  }
135 }
136 
137 // ===================================================
138 // Private Methods
139 // ===================================================
140 void
141 BCInterfaceData::readBase ( const GetPot& dataFile, const std::string& path, std::pair< std::string, baseList_Type >& base, std::string& baseString )
142 {
143  for ( std::map< std::string, baseList_Type >::iterator j = M_mapBase.begin(); j != M_mapBase.end(); ++j )
144  if ( isBase ( dataFile, ( path + j->first ).c_str(), baseString ) )
145  {
146  base.first = j->first;
147  base.second = M_mapBase[j->first];
148 
149  break;
150  }
151 }
152 
153 bool
154 BCInterfaceData::isBase ( const GetPot& dataFile, const char* base, std::string& baseString )
155 {
156  baseString = dataFile ( base, " " );
157 
158  return dataFile.checkVariable ( base );
159 }
160 
161 void
162 BCInterfaceData::readParameters ( const GetPot& dataFile, const char* parameters )
163 {
164  UInt parametersSize = dataFile.vector_variable_size ( parameters );
165 
166  M_parameters.resize ( parametersSize );
167  for ( UInt j ( 0 ); j < parametersSize; ++j )
168  {
169  M_parameters[j] = dataFile ( parameters, 0, j );
170  }
171 }
172 
173 } // Namespace LifeV
void setBaseString(const std::string &baseString)
Set the base string of the boundary condition.
BCInterfaceData - The BCInterface data container.
virtual void readBC(const std::string &fileName, const std::string &dataSection, const std::string &name)
Read parameters for all kind of BC.
bool isBase(const GetPot &dataFile, const char *base, std::string &baseString)
void updateInverseJacobian(const UInt &iQuadPt)
void readParameters(const GetPot &dataFile, const char *parameters)
void readBase(const GetPot &dataFile, const std::string &path, std::pair< std::string, baseList_Type > &base, std::string &baseString)
bool checkVariable(const char *VarName) const
Definition: GetPot.hpp:2276
BCInterfaceData(const BCInterfaceData &data)
Copy constructor.
BCInterfaceData & operator=(const BCInterfaceData &data)
Operator =.
virtual void showMe(std::ostream &output=std::cout) const
Display general information about the content of the class.
parametersContainer_Type M_parameters
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
BCInterfaceData()
Constructor.
unsigned vector_variable_size(const char *VarName) const
Definition: GetPot.hpp:2291