Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

CompositeFEMMethods.cc 3.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "BasisFunction.h"
#include "DOFAdmin.h"
#include "Element.h"
#include "ElInfo.h"
#include "FiniteElemSpace.h"
#include "Global.h"
#include "Mesh.h"
#include "Parameters.h"
#include "Traverse.h"

#include "CompositeFEMMethods.h"


14 15 16
void CompositeFEMMethods::setPosLsToVal(DOFVector<double> *dof,
					const double &val,
					const DOFVector<double> *lsFct_dof)
17 18 19 20 21 22 23 24 25 26
{
  DOFVector<double>::Iterator it_dof(dof, USED_DOFS);
  DOFVector<double>::Iterator it_lsFct_dof(
                     const_cast<DOFVector<double> *>(lsFct_dof), 
		     USED_DOFS);
  for (it_dof.reset(), it_lsFct_dof.reset();
       !it_dof.end();
       ++it_dof, ++it_lsFct_dof) {

    // Is vertex in domain with positive level set function values ?
27
    if (*it_lsFct_dof > 0)
28 29 30 31
      *it_dof = val;
  }
}

32 33 34
void CompositeFEMMethods::setPosLsToFct(DOFVector<double> *dof,
					const AbstractFunction<double, WorldVector<double> > *fct,
					const DOFVector<double> *lsFct_dof)
35
{
36 37 38
  const BasisFunction *basisFcts = dof->getFeSpace()->getBasisFcts();
  const DOFAdmin *admin = dof->getFeSpace()->getAdmin();
  const int dim = dof->getFeSpace()->getMesh()->getDim();
39 40
  const DegreeOfFreedom *locInd;

41 42 43
  TraverseStack stack;
  ElInfo *elInfo = stack.traverseFirst(dof->getFeSpace()->getMesh(), -1, 
				       Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS);
44 45
  ElementVector locVec(basisFcts->getNumber());

46
  while (elInfo) {
47
    const Element *el = elInfo->getElement();
48 49
    
    // Get level set function values for all vertices of element.
50
    lsFct_dof->getLocalVector(el, locVec);
51 52 53 54

    // Get dof indices of vertices.
    locInd = basisFcts->getLocalIndices(el, admin, NULL);

55
    for (int i = 0; i <= dim; i++) {
56
      // Is vertex in domain with positive level set function values ?
57
      if (locVec[i] > 0)
58 59 60 61 62 63 64
	(*dof)[locInd[i]] = (*fct)(elInfo->getCoord(i));
    }

    elInfo = stack.traverseNext(elInfo);
  }
}

65 66 67
void CompositeFEMMethods::printBoundaryElements(const std::string fn_str,
						ElementLevelSet *elLS,
						FiniteElemSpace *feSpace)
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
{
  FUNCNAME("CompositeFEMMethods::printBoundaryElements()");

  int dim = feSpace->getMesh()->getDim();
  std::string fn_main;
  std::string fn;
  GET_PARAMETER(0, fn_str + "->filename", &fn_main);
  fn = fn_main + "boundary_elements";
  int elStatus;

  ofstream boundaryOut(fn.c_str());

  // ===== Traverse mesh and print boundary elements. =====
  TraverseStack stack;
  int boundEl_cntr = 0;
  WorldVector<double> coord;

  const int nBasFcts = feSpace->getBasisFcts()->getNumber();
86
  DegreeOfFreedom *locInd = new DegreeOfFreedom[nBasFcts];
87 88 89 90 91 92

  ElInfo *loc_elInfo = stack.traverseFirst(feSpace->getMesh(),
					   -1, 
					   Mesh::CALL_LEAF_EL | 
					   Mesh::FILL_BOUND |
					   Mesh::FILL_COORDS);
93
  while (loc_elInfo) {
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130

    // Get local indices of vertices.
    feSpace->getBasisFcts()->getLocalIndices(
	  const_cast<Element *>(loc_elInfo->getElement()),
	  const_cast<DOFAdmin *>(feSpace->getAdmin()),
	  locInd); 

    // Get element status.
    elStatus = elLS->createElementLevelSet(loc_elInfo);

    // Is element cut by the interface ?
    if (elStatus == ElementLevelSet::LEVEL_SET_BOUNDARY) {
      ++boundEl_cntr;

      boundaryOut << loc_elInfo->getElement()->getIndex() << ": \t";

      for (int i=0; i<=dim; ++i) {

	coord = loc_elInfo->getCoord(i);

	if (i > 0) {
	  boundaryOut << "\n\t";
	}

	boundaryOut << "\t" << coord[0];
	for (int j=1; j<dim; ++j) {
	  boundaryOut << "; " << coord[j] ;
	}
	boundaryOut << " (" << locInd[i] << ")";
      }
      boundaryOut << "\n";
    }

    loc_elInfo = stack.traverseNext(loc_elInfo);

  }  // end of: mesh traverse

131
  delete [] locInd;
132 133 134 135 136

  boundaryOut << "\nNumber of boundary elements: \t" << boundEl_cntr << "\n";

  boundaryOut.close();
}