Skip to content
Snippets Groups Projects
Commit f1a2e74f authored by Martin Nolte's avatar Martin Nolte
Browse files

put last (real) .cc file in 2d into lib

parent b2c6350b
No related branches found
No related tags found
No related merge requests found
#include <config.h>
#include <fstream>
#include "grid.h" #include "grid.h"
#include "handle.h" #include "handle.h"
#include "triang.h" #include "triang.h"
...@@ -47,19 +51,19 @@ template < int N, int NV > ...@@ -47,19 +51,19 @@ template < int N, int NV >
void Hmesh<N,NV>::setup_grid(const std::string &filename) void Hmesh<N,NV>::setup_grid(const std::string &filename)
{ {
#ifndef NDEBUG #ifndef NDEBUG
cerr << "\n Hmesh_basic::asciireadtriang(?) opens: " ; std::cerr << "\n Hmesh_basic::asciireadtriang(?) opens: ";
cerr << filename << "\n" << endl ; std::cerr << filename << "\n" << std::endl;
#endif #endif
ifstream in; std::ifstream in;
in.open(filename.c_str(), ios::in); in.open( filename.c_str() );
if( ! in.good() ) if( ! in.good() )
{ {
in.clear(); in.clear();
string macro = filename + ".macro"; std::string macro = filename + ".macro";
cerr << "Warning: file \"" << filename << "\" not found, trying \"" << macro std::cerr << "Warning: file \"" << filename << "\" not found, trying \"" << macro
<< "\"." << endl; << "\"." << std::endl;
in.open(macro.c_str(), ios::in); in.open( macro.c_str() );
} }
assert(in); assert(in);
...@@ -71,9 +75,7 @@ void Hmesh<N,NV>::setup_grid(const std::string &filename) ...@@ -71,9 +75,7 @@ void Hmesh<N,NV>::setup_grid(const std::string &filename)
// if restart we have to read the hierarchy // if restart we have to read the hierarchy
if( restart ) if( restart )
{
recoverGrid( in ); recoverGrid( in );
}
} }
template < int N, int NV > template < int N, int NV >
...@@ -132,7 +134,7 @@ Hmesh<N,NV>::~Hmesh() { ...@@ -132,7 +134,7 @@ Hmesh<N,NV>::~Hmesh() {
delete _pro_el; delete _pro_el;
delete _rest_el; delete _rest_el;
delete adp ; delete adp;
assert(ncv==0); assert(ncv==0);
...@@ -141,23 +143,23 @@ Hmesh<N,NV>::~Hmesh() { ...@@ -141,23 +143,23 @@ Hmesh<N,NV>::~Hmesh() {
template < int N, int NV > template < int N, int NV >
void Hmesh<N,NV>::refresh() { void Hmesh<N,NV>::refresh() {
Listwalk_impl < macroelement_t > walk (mel) ; Listwalk_impl < macroelement_t > walk (mel);
adp->refresh(walk) ; adp->refresh(walk);
} }
template < int N, int NV > template < int N, int NV >
bool Hmesh<N,NV>::checkConf() bool Hmesh<N,NV>::checkConf()
{ {
bool elem_marked = false ; bool elem_marked = false;
Listwalkptr< helement_t > walk(*this); // Leafwalk Listwalkptr< helement_t > walk(*this); // Leafwalk
for( walk->first() ; !walk->done() ; walk->next() ) { for( walk->first(); !walk->done(); walk->next() ) {
triang_t *item = (triang_t *)&walk->getitem() ; triang_t *item = (triang_t *)&walk->getitem();
if (item->confLevelExceeded(_nconfDeg)) if (item->confLevelExceeded(_nconfDeg))
item->mark(refinement_rule) ; item->mark(refinement_rule);
if (item->is(Refco::quart) || item->is(Refco::ref_1) || item->is(Refco::ref_2) ) if (item->is(Refco::quart) || item->is(Refco::ref_1) || item->is(Refco::ref_2) )
elem_marked = true ; elem_marked = true;
} }
return elem_marked; return elem_marked;
} }
...@@ -205,7 +207,7 @@ bool Hmesh<N,NV>::duneAdapt(AdaptRestrictProlong2dType & arp) { ...@@ -205,7 +207,7 @@ bool Hmesh<N,NV>::duneAdapt(AdaptRestrictProlong2dType & arp) {
_pro_el=&produne; _pro_el=&produne;
_rest_el=&restdune; _rest_el=&restdune;
this->refine (); this->refine ();
this->coarse () ; this->coarse ();
_pro_el=pro_el_old; _pro_el=pro_el_old;
_rest_el=rest_el_old; _rest_el=rest_el_old;
return true; return true;
...@@ -214,67 +216,67 @@ bool Hmesh<N,NV>::duneAdapt(AdaptRestrictProlong2dType & arp) { ...@@ -214,67 +216,67 @@ bool Hmesh<N,NV>::duneAdapt(AdaptRestrictProlong2dType & arp) {
template < int N, int NV > template < int N, int NV >
void Hmesh<N,NV>::refine() { void Hmesh<N,NV>::refine() {
assert( ! mel.busy()) ; assert( ! mel.busy());
assert( ! mbl.busy()) ; assert( ! mbl.busy());
assert( ! vl.busy()) ; assert( ! vl.busy());
//Listwalk_impl <macroelement_t> walk(mel); //Listwalk_impl <macroelement_t> walk(mel);
//for( walk.first() ; !walk.done() ; walk.next() ) //for( walk.first(); !walk.done(); walk.next() )
// walk.getitem()->clearAllWas(); // walk.getitem()->clearAllWas();
do { do {
Listwalk_impl <macroelement_t> walk(mel); Listwalk_impl <macroelement_t> walk(mel);
for (walk.first() ; !walk.done() ; walk.next()) for (walk.first(); !walk.done(); walk.next())
walk.getitem()->refine(&vl, adp,ncv,_nconfDeg,refinement_rule,_pro_el) ; walk.getitem()->refine(&vl, adp,ncv,_nconfDeg,refinement_rule,_pro_el);
#if 0 #if 0
for (walk.first() ; !walk.done() ; walk.next()) for (walk.first(); !walk.done(); walk.next())
walk.getitem()->refine(&vl, adp,ncv,_nconfDeg,refinement_rule,_pro_el) ; walk.getitem()->refine(&vl, adp,ncv,_nconfDeg,refinement_rule,_pro_el);
#endif #endif
} while( checkConf() ) ; } while( checkConf() );
// renumber vertices // renumber vertices
vl.renumber() ; vl.renumber();
} }
template < int N, int NV > template < int N, int NV >
void Hmesh<N,NV>::coarse() { void Hmesh<N,NV>::coarse() {
assert(!mel.busy()) ; assert(!mel.busy());
assert(!mbl.busy()) ; assert(!mbl.busy());
assert(!vl.busy()) ; assert(!vl.busy());
// walk over all macro elements and call hierarchic coarseining procedure // walk over all macro elements and call hierarchic coarseining procedure
{ {
Listwalk_impl < macroelement_t > walk(mel) ; Listwalk_impl < macroelement_t > walk(mel);
for(walk.first() ; !walk.done() ; walk.next()) { for(walk.first(); !walk.done(); walk.next()) {
walk.getitem()->coarse(ncv,_nconfDeg,_rest_el) ; walk.getitem()->coarse(ncv,_nconfDeg,_rest_el);
} }
} }
// remove all unused vertices // remove all unused vertices
{ {
Listwalk_impl < vertex_t > walk (vl) ; Listwalk_impl < vertex_t > walk (vl);
for(walk.first() ; !walk.done() ; ) { for(walk.first(); !walk.done(); ) {
vertex_t * v = & walk.getitem() ; vertex_t * v = & walk.getitem();
walk.next() ; walk.next();
if (v->Basic::isfree()) { if (v->Basic::isfree()) {
vl.detach(v) ; vl.detach(v);
delete v ; delete v;
} }
} }
} }
// renumber vertices // renumber vertices
vl.renumber() ; vl.renumber();
} }
template < int N, int NV > template < int N, int NV >
void Hmesh<N,NV>::setdata(void (*f)(element_t &)) void Hmesh<N,NV>::setdata(void (*f)(element_t &))
{ {
Leafwalk < element_t > walk(mel) ; Leafwalk < element_t > walk(mel);
for (walk.first();walk.done();walk.next()) for (walk.first();walk.done();walk.next())
f(walk.getitem()); f(walk.getitem());
} }
......
...@@ -2,6 +2,7 @@ lib_LTLIBRARIES = libalugrid_2d.la libalugrid_serial.la libalugrid_parallel.la l ...@@ -2,6 +2,7 @@ lib_LTLIBRARIES = libalugrid_2d.la libalugrid_serial.la libalugrid_parallel.la l
libalugrid_2d_la_SOURCES = \ libalugrid_2d_la_SOURCES = \
$(top_srcdir)/dune/alugrid/src/2d/grid.cc \ $(top_srcdir)/dune/alugrid/src/2d/grid.cc \
$(top_srcdir)/dune/alugrid/src/2d/handle.cc \
$(top_srcdir)/dune/alugrid/src/2d/hdlrw.cc \ $(top_srcdir)/dune/alugrid/src/2d/hdlrw.cc \
$(top_srcdir)/dune/alugrid/src/2d/mknbrs.cc \ $(top_srcdir)/dune/alugrid/src/2d/mknbrs.cc \
$(top_srcdir)/dune/alugrid/src/2d/triang.cc \ $(top_srcdir)/dune/alugrid/src/2d/triang.cc \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment