Skip to content
Snippets Groups Projects
MacroReader.h 3.77 KiB
Newer Older
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ==                                                                        ==
// ============================================================================
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.



/** \file MacroReader.h */

#ifndef AMDIS_MACROREADER_H
#define AMDIS_MACROREADER_H

#include <deque>
Thomas Witkowski's avatar
Thomas Witkowski committed
#include "AMDiS_fwd.h"
#include "Global.h"
#include "FixVec.h"
#include "Boundary.h"

namespace AMDiS {

  /** \defgroup Input Input module */

  /** \ingroup Input
   *  
   * \brief
   * Static class which reads a macro triangulation file and creates
   * the corresponding macro mesh.
   */
  class MacroReader
  {
    // Is used to read periodic macros
    class PeriodicMap
    {
    public:
      void setEntry(DegreeOfFreedom key, DegreeOfFreedom entry) 
      {
	// no trivial entries!
	if (key == entry) 
	  return;
	
	// if a key equal to entry exists ...
	if (getEntry(entry) >= 0) {
	  if (getEntry(entry) == key)
	    return;
	  
	  // ... let it be equal entries
	  setEntry(key, getEntry(entry));
	  return;
	}
	
	// replace entries equal to key
	for (map<DegreeOfFreedom, DegreeOfFreedom>::iterator it = 
	       periodicMap.begin(); it != periodicMap.end(); ++it)
	  if (it->second == key)
	    it->second = entry;
	
	// if key exists already, insert new entry with old entry as key
	if (getEntry(key) >= 0)
	  setEntry(getEntry(key), entry);
	
	// set entry
	periodicMap[key] = entry;
      }
            
      DegreeOfFreedom getEntry(DegreeOfFreedom key) 
      {
	map<DegreeOfFreedom, DegreeOfFreedom>::iterator it = periodicMap.find(key);
	if (it != periodicMap.end())
	  return it->second;
	return -1;
      }
    
    protected:
      map<DegreeOfFreedom, DegreeOfFreedom> periodicMap;
    };


    /// Creates a Mesh by reading the macro file with the given filename.
				int check);

  protected:
    static void computeNeighbours(Mesh *mesh);
    static void boundaryDOFs(Mesh *mesh);

    static void umb(int *ele, Mesh *mesh,
		    void (*umbvk)(Mesh *mesh, MacroElement*,int k, int *el));

    static int macrotest(Mesh *mesh);

    static void macroTest(Mesh *mesh, const char *nameneu);

    static bool newEdge(Mesh *mesh, MacroElement *mel,
			int mel_edge_no, int *n_neigh);

    static void fillMelBoundary(Mesh *, MacroElement *mel,
				FixVec<BoundaryType ,NEIGH>);

    static void fillMelNeigh(MacroElement *mel,
			     std::deque<MacroElement*>& macro_elements,
			     FixVec<int,NEIGH> ind);

    static void umbVkantMacro(Mesh *mesh,
			      MacroElement *,
			      int ka,
			      int *ele);

    static void recumb(Mesh *mesh, 
		       MacroElement *mel, MacroElement *macroalt,
		       int *test, double lg, int ka, int *ele, 
		       void (*umbvk)(Mesh *mesh, MacroElement*,int k, int *el));

    static void laengstekante(FixVec<WorldVector<double>,VERTEX> coord, 
			      double *l, int *v);

    static void checkMesh(Mesh *mesh);

    static int basicCheckFct(ElInfo* elInfo, Mesh *mesh);
    static void basicDOFCheckFct(ElInfo* elInfo, Mesh *mesh, int iadmin);
    static void basicNodeFct(ElInfo* elInfo, Mesh *mesh);