39 namespace Electromagnetism{
44 template <
typename TDomain>
49 : m_spDomain (domain),
53 UG_THROW (
"EMaterial: Invalid domain or subset handler.");
63 template <
typename TDomain>
74 UG_THROW (
"EMaterial: Attempt to get data from a unfinalized object.")
76 typename t_data_map::const_iterator iter = m_mUserDataBC.find (si);
77 if (iter == m_mUserDataBC.end () || (pSdD = iter->second) == NULL)
88 template <
typename TDomain>
99 " Attempt to add a subset data item to a finalized domain description.");
108 template <
typename TDomain>
111 std::vector<std::string> vssNames;
115 m_mUserDataBC.clear ();
118 if (m_vSdD.size () == 0)
119 UG_THROW (
"No data items specified.");
124 for (
size_t i = 0; i < m_vSdD.size (); i++)
128 for (
size_t k = 0; k < vssNames.size (); k++)
133 }
UG_CATCH_THROW (
"EMaterial::close: Failed to parse subset names.");
139 for (
int si = 0; si < ss_handler->num_subsets (); si++)
141 m_mUserDataBC [si] = 0;
144 for (
size_t i = 0; i < m_vSdD.size (); i++)
148 for (
size_t k = 0; k < ssg.
size (); k++)
150 typename t_data_map::iterator iter = m_mUserDataBC.find (ssg [k]);
151 if (iter == m_mUserDataBC.end ())
152 UG_THROW (
"EMaterial::close: Refered subset " << ssg.
name (k) <<
"has an illegal dimension.");
153 if (iter->second != NULL)
154 UG_THROW (
"EMaterial::close: Two data items refer to subset " << ssg.
name (k) <<
".");
160 for (
typename t_data_map::iterator iter = m_mUserDataBC.begin ();
161 iter != m_mUserDataBC.end (); ++iter)
162 if (iter->second == NULL)
163 UG_THROW (
"EMaterial::close: Subset "
164 << ss_handler->get_subset_name (iter->first)
165 <<
" not mentioned in the description.");
171 m_sSsNames = m_vSdD[0].ssNames;
172 for (
size_t i = 1; i < m_vSdD.size (); i++)
175 m_sSsNames += m_vSdD[i].ssNames;
182 UG_LOG (
"Materials specified. " << m_baseConductors.size () <<
" conductive parts found.\n");
194 template <
typename TDomain>
197 std::vector<int> & minCondInd
206 for (
size_t si = 0; si < isConductor.size (); si++)
208 typename t_data_map::iterator iter = m_mUserDataBC.find (si);
209 if (iter == m_mUserDataBC.end () || iter->second == NULL)
210 isConductor [si] =
false;
211 else if (iter->second->sigma == (
number) 0)
212 isConductor [si] =
false;
214 isConductor [si] =
true;
218 FindSubsetGroups<t_base_object> (minCondInd, isConductor, *
subset_handler().
get(),
226 for (
size_t si = 0; si < minCondInd.size (); si++)
227 if (minCondInd [si] == -1)
229 if (m_mUserDataBC.find (si) == m_mUserDataBC.end ())
230 minCondInd [si] = -2;
232 else if (minCondInd [si] < -1)
233 UG_THROW (
"EMaterial::connectivity: Low-dimensional conductor found (subset index " << si <<
").");
239 template <
typename TDomain>
243 connectivity (m_minCondSsI);
246 std::vector<bool> is_min_index (m_minCondSsI.size ());
247 for (
size_t i = 0; i < m_minCondSsI.size (); i++)
249 is_min_index [i] =
false;
250 if (m_minCondSsI[i] >= 0)
251 is_min_index [m_minCondSsI[i]] =
true;
253 m_baseConductors.clear ();
254 for (
size_t i = 0; i < is_min_index.size (); i++)
255 if (is_min_index [i])
256 m_baseConductors.push_back (i);
259 m_baseCondInd.resize (m_minCondSsI.size ());
260 for (
size_t i = 0; i < m_minCondSsI.size (); i++)
262 int min_cond_ssi = m_minCondSsI [i];
263 if (min_cond_ssi <= -2)
264 m_baseCondInd [i] = min_cond_ssi;
266 m_baseCondInd [i] = -1;
268 for (
size_t base_cond = 0; base_cond < m_baseConductors.size (); base_cond++)
270 int base_cond_si = m_baseConductors [base_cond];
271 for (
size_t i = 0; i < m_minCondSsI.size (); i++)
272 if (m_minCondSsI [i] == base_cond_si)
273 m_baseCondInd [i] = base_cond;
void add(const char *subsets, number mu, number sigma)
adds a generic subset data item
Definition: em_material_impl.h:90
void connectivity(std::vector< int > &minCondInd)
computes the connectivity of the conductions
Definition: em_material_impl.h:196
bool get_mu_sigma(int si, number &mu, number &sigma) const
reads the data for a subdomain from the data item
Definition: em_material_impl.h:65
void analyze_topology()
analyzes the conductor topology of the domain
Definition: em_material_impl.h:240
domain_type::subset_handler_type subset_handler_type
subset handler type
Definition: em_material.h:72
ConstSmartPtr< subset_handler_type > subset_handler() const
constant access to the subset handler
Definition: em_material.h:106
void close()
finalizes the object
Definition: em_material_impl.h:109
EMaterial(ConstSmartPtr< domain_type > domain)
Constructor.
Definition: em_material_impl.h:46
ConstSmartPtr< domain_type > domain() const
returns pointer to the domain
Definition: em_material.h:123
void add(const char *name)
const char * name(size_t i) const
SmartPtr< TSubsetHandler > subset_handler()
size_t num_subsets() const
vector< string > TokenizeString(const char *str, const char delimiter=',')
void RemoveWhitespaceFromString(std::string &string)
#define UG_CATCH_THROW(msg)
SM_edge_weight_map< typename T::value_type, ug::BidirectionalMatrix< T > > get(edge_weight_t, ug::BidirectionalMatrix< T > const &g)
int DimensionOfSubset(const ISubsetHandler &sh, int si)
data item type
Definition: em_material.h:215
number sigma
electric conductivity
Definition: em_material.h:220
number mu
magnetic permeability
Definition: em_material.h:219
SubsetGroup ssGrp
subset group
Definition: em_material.h:217
std::string ssNames
subset names
Definition: em_material.h:216